Class: CodeTools::AST::For

Inherits:
Iter show all
Defined in:
lib/rubinius/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

Returns a new instance of For.



789
790
791
792
793
794
795
# File 'lib/rubinius/ast/sends.rb', line 789

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



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

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



822
823
824
# File 'lib/rubinius/ast/sends.rb', line 822

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

#nest_scope(scope) ⇒ Object



797
798
799
# File 'lib/rubinius/ast/sends.rb', line 797

def nest_scope(scope)
  scope.parent = self
end

#new_nested_local(name) ⇒ Object



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

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

#search_local(name) ⇒ Object



801
802
803
804
805
806
# File 'lib/rubinius/ast/sends.rb', line 801

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

#sexp_nameObject



826
827
828
# File 'lib/rubinius/ast/sends.rb', line 826

def sexp_name
  :for
end