Class: Rubinius::ToolSet.current::TS::AST::Container

Inherits:
ClosedScope show all
Defined in:
lib/rubinius/ast/definitions.rb

Direct Known Subclasses

EvalExpression, Script, Snippet

Instance Attribute Summary collapse

Attributes inherited from ClosedScope

#body

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from ClosedScope

#assign_local_reference, #attach_and_call, #module?, #nest_scope, #new_local, #new_nested_local, #search_local

Methods inherited from Node

#ascii_graph, #attributes, #bytecode, #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(body) ⇒ Container

Returns a new instance of Container.



990
991
992
993
# File 'lib/rubinius/ast/definitions.rb', line 990

def initialize(body)
  @body = body || NilLiteral.new(1)
  @pre_exe = []
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



988
989
990
# File 'lib/rubinius/ast/definitions.rb', line 988

def file
  @file
end

#nameObject

Returns the value of attribute name.



988
989
990
# File 'lib/rubinius/ast/definitions.rb', line 988

def name
  @name
end

#pre_exeObject

Returns the value of attribute pre_exe.



988
989
990
# File 'lib/rubinius/ast/definitions.rb', line 988

def pre_exe
  @pre_exe
end

#variable_scopeObject

Returns the value of attribute variable_scope.



988
989
990
# File 'lib/rubinius/ast/definitions.rb', line 988

def variable_scope
  @variable_scope
end

Instance Method Details

#container_bytecode(g) ⇒ Object



1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
# File 'lib/rubinius/ast/definitions.rb', line 1003

def container_bytecode(g)
  g.name = @name
  g.file = @file.to_sym

  push_state(g)
  @pre_exe.each { |pe| pe.pre_bytecode(g) }

  yield if block_given?
  pop_state(g)

  g.local_count = local_count
  g.local_names = local_names
end

#pop_state(g) ⇒ Object



999
1000
1001
# File 'lib/rubinius/ast/definitions.rb', line 999

def pop_state(g)
  g.pop_state
end

#push_state(g) ⇒ Object



995
996
997
# File 'lib/rubinius/ast/definitions.rb', line 995

def push_state(g)
  g.push_state self
end

#to_sexpObject



1017
1018
1019
1020
1021
1022
# File 'lib/rubinius/ast/definitions.rb', line 1017

def to_sexp
  sexp = [sexp_name]
  @pre_exe.each { |pe| sexp << pe.pre_sexp }
  sexp << @body.to_sexp
  sexp
end