Class ForExpressionCompiler


  • public class ForExpressionCompiler
    extends ToIteratorCompiler
    Generate bytecode for a call to the ForExpression()
    • Constructor Detail

      • ForExpressionCompiler

        public ForExpressionCompiler()
    • Method Detail

      • compileToIterator

        public void compileToIterator​(CompilerService compiler,
                                      Expression expression)
                               throws CannotCompileException
        Generate bytecode to evaluate the ForExpression as an iterator Precondition: none. Postcondition: the stack contains an iterator representing the result of the expression
        Specified by:
        compileToIterator in class ExpressionCompiler
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode
      • generateSequenceMappingAction

        public static java.lang.Class generateSequenceMappingAction​(CompilerService compiler,
                                                                    ForExpression expression,
                                                                    Expression action,
                                                                    int slotNumber)
                                                             throws CannotCompileException
        Generate a mapping function with a map() method that returns an iterator over the results of one iteration of the loop
        Parameters:
        compiler - the CompilerService
        expression - the "for" expression itself
        action - the body of the "for" loop, which represents the expression to be compiled
        slotNumber - the slot number
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode