Class: Duby::Compiler::JavaSource::SimpleForLoop

Inherits:
SimpleWhileLoop show all
Defined in:
lib/duby/jvm/source_generator/loops.rb

Direct Known Subclasses

RedoableForLoop

Instance Attribute Summary

Attributes inherited from SimpleWhileLoop

#compiler, #loop

Instance Method Summary collapse

Methods inherited from SimpleWhileLoop

#break, #compile, #compile_body, #initialize, #next, #redo

Constructor Details

This class inherits a constructor from Duby::Compiler::JavaSource::SimpleWhileLoop

Instance Method Details

#prepareObject



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/duby/jvm/source_generator/loops.rb', line 105

def prepare
  iter = loop.iter.precompile(compiler)
  iter_type = loop.iter.inferred_type
  type = iter_type.component_type.to_source
  name = loop.name
  @start = lambda do
    compiler.method.print "for (#{type} #{name} : "
    iter.compile(compiler, true)
    compiler.method.print ')'
  end
end