class CodeTools::AST::Yield

Attributes

flags[RW]

Public Class Methods

new(line, arguments, unwrap) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 1051
def initialize(line, arguments, unwrap)
  @line = line

  if arguments.kind_of? ArrayLiteral and not unwrap
    arguments = ArrayLiteral.new line, [arguments]
  end

  @arguments = Arguments.new line, arguments
  @argument_count = @arguments.size
  @yield_splat = false

  if @arguments.splat?
    splat = @arguments.splat.value
    if (splat.kind_of? ArrayLiteral or splat.kind_of? EmptyArray) and not unwrap
      @argument_count += 1
    else
      @yield_splat = true
    end
  end
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 1072
def bytecode(g)
  pos(g)

  @arguments.bytecode(g)

  if @yield_splat
    g.yield_splat @argument_count
  else
    g.yield_stack @argument_count
  end
end
defined(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 1084
def defined(g)
  t = g.new_label
  f = g.new_label

  g.push_block
  g.goto_if_true t
  g.push_tagged_nil 0
  g.goto f

  t.set!
  g.push_literal "yield"

  f.set!
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 1099
def to_sexp
  args = @arguments.to_sexp
  args << @block.to_sexp if @block
  if @argument_count == 1 and !@yield_splat and @arguments.splat.nil? and
     @arguments.array.first.kind_of? SplatValue
    [:yield, [:array] + args]
  else
    [:yield] + args
  end
end