class CodeTools::AST::Next

Public Class Methods

new(line, value) click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 591
def initialize(line, value)
  @line = line
  @value = value
end

Public Instance Methods

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

  g.pop if g.state.top_level_ensure?

  # From "The Ruby Programming Lanuage"
  #  "When next is used in a loop, any values following the next
  #   are ignored"
  #
  # By ignored, it must mean evaluated and the value of the expression
  # is thrown away, because 1.8 evaluates them even though it doesn't
  # use them.
  if @value
    @value.bytecode(g)
  else
    g.push_tagged_nil 0
  end

  if g.state.loop?
    g.goto_past g.next
  elsif g.state.block?
    if g.next
      g.goto_past g.next
    else
      g.ret
    end
  else
    g.pop

    jump_error g, :next
  end

  g.push_tagged_nil 0 if g.state.top_level_ensure?
end
sexp_name() click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 631
def sexp_name
  :next
end