Class: CodeTools::AST::For

Inherits:
Iter show all
Defined in:
lib/rubinius/code/ast/sends.rb

Instance Attribute Summary

Attributes inherited from Iter

#arguments, #body, #parent

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Iter

#block_local?, #bytecode, #module?, #new_local, #to_sexp

Methods inherited from Node

#ascii_graph, #attributes, #bytecode, #children, 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, arguments, body) ⇒ For



797
798
799
800
801
802
803
# File 'lib/rubinius/code/ast/sends.rb', line 797

def initialize(line, arguments, body)
  @line = line
  @arguments = ForParameters.new line, arguments
  @body = body || NilLiteral.new(line)

  new_local :"$for_args"
end

Instance Method Details

#assign_local_reference(var) ⇒ Object



822
823
824
825
826
827
828
# File 'lib/rubinius/code/ast/sends.rb', line 822

def assign_local_reference(var)
  unless reference = search_local(var.name)
    reference = new_nested_local var.name
  end

  var.variable = reference
end

#defined(g) ⇒ Object



830
831
832
# File 'lib/rubinius/code/ast/sends.rb', line 830

def defined(g)
  g.push_literal "expression"
end

#nest_scope(scope) ⇒ Object



805
806
807
# File 'lib/rubinius/code/ast/sends.rb', line 805

def nest_scope(scope)
  scope.parent = self
end

#new_nested_local(name) ⇒ Object



816
817
818
819
820
# File 'lib/rubinius/code/ast/sends.rb', line 816

def new_nested_local(name)
  reference = @parent.new_nested_local name
  reference.depth += 1
  reference
end

#search_local(name) ⇒ Object



809
810
811
812
813
814
# File 'lib/rubinius/code/ast/sends.rb', line 809

def search_local(name)
  if reference = @parent.search_local(name)
    reference.depth += 1
    reference
  end
end

#sexp_nameObject



834
835
836
# File 'lib/rubinius/code/ast/sends.rb', line 834

def sexp_name
  :for
end