class CodeTools::AST::While
Attributes
body[RW]
check_first[RW]
condition[RW]
Public Class Methods
new(line, condition, body, check_first)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 350 def initialize(line, condition, body, check_first) @line = line @condition = condition @body = body || NilLiteral.new(line) @check_first = check_first end
Public Instance Methods
body_bytecode(g, lbl)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 366 def body_bytecode(g, lbl) g.state.push_loop @body.bytecode(g) g.state.pop_loop # This is a loop epilogue. Nothing that changes # computation should be put here. lbl.set! g.pop end
bytecode(g, use_gif=true)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 377 def bytecode(g, use_gif=true) pos(g) g.push_modifiers top = g.new_label post = g.next = g.new_label bottom = g.new_label g.break = g.new_label if @check_first g.redo = g.new_label top.set! condition_bytecode(g, bottom, use_gif) g.redo.set! body_bytecode(g, post) else g.redo = top top.set! body_bytecode(g, post) condition_bytecode(g, bottom, use_gif) end g.goto_past top # See other set_line(0) comments g.set_line 0 bottom.set! g.push_tagged_nil 0 g.break.set! g.pop_modifiers end
condition_bytecode(g, bottom, use_gif)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 357 def condition_bytecode(g, bottom, use_gif) @condition.bytecode(g) if use_gif g.goto_if_false bottom else g.goto_if_true bottom end end
defined(g)
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 417 def defined(g) g.push_literal "expression" end
sexp_name()
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 421 def sexp_name :while end
to_sexp()
click to toggle source
# File lib/rubinius/code/ast/control_flow.rb, line 425 def to_sexp [sexp_name, @condition.to_sexp, @body.to_sexp, @check_first] end