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?, #block_parameter?, #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

Returns a new instance of For.



861
862
863
864
865
866
867
# File 'lib/rubinius/code/ast/sends.rb', line 861

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



886
887
888
889
890
891
892
# File 'lib/rubinius/code/ast/sends.rb', line 886

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



894
895
896
# File 'lib/rubinius/code/ast/sends.rb', line 894

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

#nest_scope(scope) ⇒ Object



869
870
871
# File 'lib/rubinius/code/ast/sends.rb', line 869

def nest_scope(scope)
  scope.parent = self
end

#new_nested_local(name) ⇒ Object



880
881
882
883
884
# File 'lib/rubinius/code/ast/sends.rb', line 880

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

#search_local(name) ⇒ Object



873
874
875
876
877
878
# File 'lib/rubinius/code/ast/sends.rb', line 873

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

#sexp_nameObject



898
899
900
# File 'lib/rubinius/code/ast/sends.rb', line 898

def sexp_name
  :for
end