Class: CodeTools::AST::EndData

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/code/ast/data.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, 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(offset, body) ⇒ EndData

Returns a new instance of EndData.



8
9
10
11
# File 'lib/rubinius/code/ast/data.rb', line 8

def initialize(offset, body)
  @offset = offset
  @body = body || NilLiteral.new(1)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/rubinius/code/ast/data.rb', line 6

def data
  @data
end

Instance Method Details

#bytecode(g) ⇒ Object

When a script includes __END__, Ruby makes the data after it available as an IO instance via the DATA constant. Since code in the toplevel can access this constant, we have to set it up before any other code runs. This AST node wraps the top node returned by the file parser.



18
19
20
21
22
23
24
25
26
27
# File 'lib/rubinius/code/ast/data.rb', line 18

def bytecode(g)
  g.push_rubinius
  g.push_scope
  g.send :data_path, 0
  g.push_int @offset
  g.send :set_data, 2
  g.pop

  @body.bytecode(g)
end