Class: CodeTools::AST::Container

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



1088
1089
1090
1091
# File 'lib/rubinius/code/ast/definitions.rb', line 1088

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

Instance Attribute Details

#fileObject

Returns the value of attribute file.



1086
1087
1088
# File 'lib/rubinius/code/ast/definitions.rb', line 1086

def file
  @file
end

#nameObject

Returns the value of attribute name.



1086
1087
1088
# File 'lib/rubinius/code/ast/definitions.rb', line 1086

def name
  @name
end

#pre_exeObject

Returns the value of attribute pre_exe.



1086
1087
1088
# File 'lib/rubinius/code/ast/definitions.rb', line 1086

def pre_exe
  @pre_exe
end

#variable_scopeObject

Returns the value of attribute variable_scope.



1086
1087
1088
# File 'lib/rubinius/code/ast/definitions.rb', line 1086

def variable_scope
  @variable_scope
end

Instance Method Details

#container_bytecode(g) ⇒ Object



1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'lib/rubinius/code/ast/definitions.rb', line 1101

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



1097
1098
1099
# File 'lib/rubinius/code/ast/definitions.rb', line 1097

def pop_state(g)
  g.pop_state
end

#push_state(g) ⇒ Object



1093
1094
1095
# File 'lib/rubinius/code/ast/definitions.rb', line 1093

def push_state(g)
  g.push_state self
end

#to_sexpObject



1115
1116
1117
1118
1119
1120
# File 'lib/rubinius/code/ast/definitions.rb', line 1115

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