class Riml::DefNode
Method definition.
Constants
- DEFAULT_PARAMS
- SPLAT
Attributes
original_name[W]
private_function[RW]
private_function?[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/riml/nodes.rb, line 611 def initialize(*args) super # max number of arguments in viml if parameters.reject(&DEFAULT_PARAMS).size > 20 error_msg = "can't have more than 20 parameters for function #{full_name}" error = Riml::UserArgumentError.new(error_msg, self) raise error end expressions.nodes.select { |node| DefNode === node}.each do |nested_func| nested_func.nested_within.unshift(self) end end
Public Instance Methods
argument_variable_names()
click to toggle source
[“arg1”, “arg2”}
# File lib/riml/nodes.rb, line 633 def argument_variable_names parameters.reject(&SPLAT) end
autoload?()
click to toggle source
# File lib/riml/nodes.rb, line 670 def autoload? name.include?('#') end
children()
click to toggle source
# File lib/riml/nodes.rb, line 698 def children children = if sid? [sid, expressions] else [expressions] end children.concat(default_param_nodes) end
default_param_nodes()
click to toggle source
# File lib/riml/nodes.rb, line 688 def default_param_nodes parameters.select(&DEFAULT_PARAMS) end
defined_on_dictionary?()
click to toggle source
# File lib/riml/nodes.rb, line 666 def defined_on_dictionary? keywords.include?('dict') end
is_splat_arg?(node)
click to toggle source
# File lib/riml/nodes.rb, line 692 def is_splat_arg?(node) splat = splat() return false unless splat GetVariableNode === node && node.scope_modifier.nil? && node.name == splat[1..-1] end
keywords()
click to toggle source
Calls superclass method
# File lib/riml/nodes.rb, line 658 def keywords if name.include?('.') (super.to_a + ['dict']) else super.to_a end.uniq end
nested_function?()
click to toggle source
# File lib/riml/nodes.rb, line 649 def nested_function? not nested_within.empty? end
nested_within()
click to toggle source
# File lib/riml/nodes.rb, line 645 def nested_within @nested_within ||= [] end
original_name()
click to toggle source
# File lib/riml/nodes.rb, line 627 def original_name @original_name ||= name end
shadowed_argument?(var_name)
click to toggle source
# File lib/riml/nodes.rb, line 637 def shadowed_argument?(var_name) shadowed_argument_variable_names.include?(var_name) end
shadowed_argument_variable_names()
click to toggle source
# File lib/riml/nodes.rb, line 641 def shadowed_argument_variable_names @shadowed_argument_variable_names ||= Set.new end
splat()
click to toggle source
returns the splat argument or nil
# File lib/riml/nodes.rb, line 654 def splat parameters.detect(&SPLAT) end
super_node()
click to toggle source
FIXME: only detects top-level super nodes
# File lib/riml/nodes.rb, line 677 def super_node expressions.nodes.detect {|n| SuperNode === n} end
to_scope()
click to toggle source
# File lib/riml/nodes.rb, line 681 def to_scope ScopeNode.new.tap do |scope| scope.argument_variable_names += argument_variable_names scope.function = self end end