Class: CodeTools::AST::ForParameters

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/ast/sends.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, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, assignments) ⇒ ForParameters

Returns a new instance of ForParameters.



835
836
837
838
839
840
841
842
843
# File 'lib/rubinius/ast/sends.rb', line 835

def initialize(line, assignments)
  @line = line
  @assignments = assignments
  @splat_index = assignments.kind_of?(MultipleAssignment) ? 0 : nil
  @required_args = @splat_index ? 0 : 1
  @post_args = 0
  @keywords = nil
  @block_index = nil
end

Instance Attribute Details

#assignmentsObject

Returns the value of attribute assignments.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def assignments
  @assignments
end

#block_indexObject

Returns the value of attribute block_index.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def block_index
  @block_index
end

#keywordsObject

Returns the value of attribute keywords.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def keywords
  @keywords
end

#post_argsObject

Returns the value of attribute post_args.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def post_args
  @post_args
end

#required_argsObject Also known as: total_args, arity

Returns the value of attribute required_args.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def required_args
  @required_args
end

#splat_indexObject

Returns the value of attribute splat_index.



832
833
834
# File 'lib/rubinius/ast/sends.rb', line 832

def splat_index
  @splat_index
end

Instance Method Details

#bytecode(g) ⇒ Object



855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/rubinius/ast/sends.rb', line 855

def bytecode(g)
  map_arguments(g.state.scope)

  if @splat_index
    g.push_rubinius
    g.find_const :Runtime
    g.push_local 0
    g.send :unwrap_block_arg, 1
  else
    g.push_local 0
  end

  g.state.push_masgn
  @assignments.bytecode(g)
  g.state.pop_masgn
end

#map_arguments(scope) ⇒ Object



848
849
850
851
852
853
# File 'lib/rubinius/ast/sends.rb', line 848

def map_arguments(scope)
  case @assignments
  when LocalVariable
    scope.assign_local_reference @assignments
  end
end