Class: CodeTools::AST::DefineFunction

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

Direct Known Subclasses

DefineFunctionMulti

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(line, name, block) ⇒ DefineFunction

Returns a new instance of DefineFunction.



191
192
193
194
195
196
197
# File 'lib/rubinius/code/ast/definitions.rb', line 191

def initialize(line, name, block)
  @line = line
  @name = name
  @arguments = block.extract_parameters
  block.array << NilLiteral.new(line) if block.array.empty?
  @body = block
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



189
190
191
# File 'lib/rubinius/code/ast/definitions.rb', line 189

def arguments
  @arguments
end

#nameObject

Returns the value of attribute name.



189
190
191
# File 'lib/rubinius/code/ast/definitions.rb', line 189

def name
  @name
end

Instance Method Details

#bytecode(g) ⇒ Object



199
200
201
202
203
204
205
206
207
208
# File 'lib/rubinius/code/ast/definitions.rb', line 199

def bytecode(g)
  pos(g)

  g.push_const :Kernel
  g.push_literal sexp_name.to_s
  g.push_literal " "
  g.push_literal @name.to_s
  g.string_build 3
  g.send :puts, 1
end

#sexp_nameObject



210
211
212
# File 'lib/rubinius/code/ast/definitions.rb', line 210

def sexp_name
  :fun
end