Class: CodeTools::AST::DefineSingleton

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/code/ast/definitions.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, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, receiver, name, block) ⇒ DefineSingleton

Returns a new instance of DefineSingleton.



295
296
297
298
299
# File 'lib/rubinius/code/ast/definitions.rb', line 295

def initialize(line, receiver, name, block)
  @line = line
  @receiver = receiver
  @body = DefineSingletonScope.new line, name, block
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



293
294
295
# File 'lib/rubinius/code/ast/definitions.rb', line 293

def body
  @body
end

#receiverObject

Returns the value of attribute receiver.



293
294
295
# File 'lib/rubinius/code/ast/definitions.rb', line 293

def receiver
  @receiver
end

Instance Method Details

#bytecode(g) ⇒ Object



301
302
303
304
305
# File 'lib/rubinius/code/ast/definitions.rb', line 301

def bytecode(g)
  pos(g)

  @body.bytecode(g, @receiver)
end

#to_sexpObject



307
308
309
310
# File 'lib/rubinius/code/ast/definitions.rb', line 307

def to_sexp
  [:defs, @receiver.to_sexp, @body.name,
    @body.arguments.to_sexp, [:scope, @body.body.to_sexp]]
end