Module: Duby::Compiler::JavaSource::Redoable

Included in:
ComplexWhileLoop
Defined in:
lib/duby/jvm/source_generator/loops.rb

Instance Method Summary collapse

Instance Method Details

#breakObject



71
72
73
# File 'lib/duby/jvm/source_generator/loops.rb', line 71

def break
  compiler.method.puts "break #{@outer};"
end

#compile_with_redo(block) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/duby/jvm/source_generator/loops.rb', line 61

def compile_with_redo(block)
  @redo = compiler.method.tmp(JVMTypes::Boolean)
  compiler.method.puts "#{@inner}:"
  compiler.method.block "do" do
    compiler.method.puts "#{@redo} = false;"
    block.compile(compiler, false)
  end
  compiler.method.puts "while (#{@redo});"
end

#nextObject



75
76
77
# File 'lib/duby/jvm/source_generator/loops.rb', line 75

def next
  compiler.method.puts "break #{@inner};"
end

#redoObject



79
80
81
82
# File 'lib/duby/jvm/source_generator/loops.rb', line 79

def redo
  compiler.method.puts "#{@redo} = true;"
  compiler.method.puts "continue #{@inner};"
end