class CodeTools::AST::Block

Is it weird that Block has the :arguments attribute? Yes. Is it weird that MRI parse tree puts arguments and block_arg in Block? Yes. So we make do and pull them out here rather than having something else reach inside of Block.

Attributes

array[RW]
locals[RW]

Public Class Methods

new(line, array) click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 72
def initialize(line, array)
  @line = line
  @array = array

  # These are any local variable that are declared as explicit
  # locals for this scope. This is only used by the |a;b| syntax.
  @locals = nil
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 91
def bytecode(g)
  count = @array.size - 1
  @array.each_with_index do |x, i|
    start_ip = g.ip
    x.bytecode(g)
    g.pop unless start_ip == g.ip or i == count
  end
end
extract_parameters() click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 81
def extract_parameters
  if @array.first.kind_of? Parameters
    node = @array.shift
    if @array.first.kind_of? BlockArgument
      node.block_arg = @array.shift
    end
    return node
  end
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 100
def to_sexp
  @array.inject([:block]) { |s, x| s << x.to_sexp }
end