Class: CodeTools::AST::DefaultArguments

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/code/ast/definitions.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, block) ⇒ DefaultArguments

Returns a new instance of DefaultArguments.



601
602
603
604
605
606
# File 'lib/rubinius/code/ast/definitions.rb', line 601

def initialize(line, block)
  @line = line
  array = block.array
  @names = array.map { |a| a.name }
  @arguments = array
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



599
600
601
# File 'lib/rubinius/code/ast/definitions.rb', line 599

def arguments
  @arguments
end

#namesObject

Returns the value of attribute names.



599
600
601
# File 'lib/rubinius/code/ast/definitions.rb', line 599

def names
  @names
end

Instance Method Details

#bytecode(g) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/rubinius/code/ast/definitions.rb', line 612

def bytecode(g)
  @arguments.each do |arg|
    done = g.new_label

    arg.variable.get_bytecode(g)
    g.goto_if_not_undefined done
    arg.bytecode(g)
    g.pop

    done.set!
  end
end

#map_arguments(scope) ⇒ Object



608
609
610
# File 'lib/rubinius/code/ast/definitions.rb', line 608

def map_arguments(scope)
  @arguments.each { |var| scope.assign_local_reference var }
end

#to_sexpObject



625
626
627
# File 'lib/rubinius/code/ast/definitions.rb', line 625

def to_sexp
  @arguments.map { |x| x.to_sexp }
end