com.saxonica.bytecode.util
Class LoopBodyGenerator

java.lang.Object
  extended by com.saxonica.bytecode.util.LoopBodyGenerator

public abstract class LoopBodyGenerator
extends Object

LoopBodyGenerator is code to generate the body of a loop, for example of a ForExpression. When the ForExpression is compiled as a loop, this callback specifies how to generate code for the loop body. For example, if the caller is the compiler for the sum() function, the callback will increment the local variable holding the total so far.


Constructor Summary
LoopBodyGenerator()
           
 
Method Summary
abstract  void generateLoopBody(CompilerService compiler)
          Generate the code to process each item delivered by the looping expression.
 Class getExpectedItemClass()
          Say in what form the loop body generator expects the items to be delivered.
 boolean isSmallAmountOfCode()
          Say whether the amount of code generated is sufficiently small that we don't mind it being generated more than once.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoopBodyGenerator

public LoopBodyGenerator()
Method Detail

generateLoopBody

public abstract void generateLoopBody(CompilerService compiler)
                               throws CannotCompileException
Generate the code to process each item delivered by the looping expression. On entry to this code, the relevant item will be on the top of the bytecode stack. On exit the stack will be empty (that is, this item will have been removed)

Parameters:
compiler - the compiler service
Throws:
CannotCompileException - if the expression cannot be compiled

getExpectedItemClass

public Class getExpectedItemClass()
Say in what form the loop body generator expects the items to be delivered. This method returns a class which gives the expected type of the item on the top of stack at the point where the loop body code takes over. The default is that the item is on the stack as an instance of Item. The alternative is to ask for it to be placed as a primitive value, for example of type Double.TYPE or Boolean.TYPE, or as a Java String or BigDecimal object

Returns:
the class of objects to be delivered

isSmallAmountOfCode

public boolean isSmallAmountOfCode()
Say whether the amount of code generated is sufficiently small that we don't mind it being generated more than once.

Returns:
true if the amount of code to be generated is small


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.