public class BlockCompiler extends ToIteratorCompiler
Constructor and Description |
---|
BlockCompiler() |
Modifier and Type | Method and Description |
---|---|
void |
compileToIterator(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the BlockExpression as an iterator
Precondition: none.
|
void |
compileToLoop(CompilerService compiler,
Expression expression,
LoopBodyGenerator loopBody)
The compileToLoop method compiles this expression in such a way that the code generated by the supplied
loopBody argument will be executed once for each item in the result of this expression.
|
void |
compileToPush(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the BlockExpression in push mode
Precondition: none.
|
compileToBoolean, compileToItem
allocateStatic, compileItemFromInt, compileItemFromString, compileToPrimitive, generateMethod, handleEmptyStringResult, throwXPathException, throwXPathException, unboxItem, verify, visitAnnotation, visitLineNumber
public void compileToPush(CompilerService compiler, Expression expression) throws CannotCompileException
compileToPush
in class ToIteratorCompiler
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
public void compileToLoop(CompilerService compiler, Expression expression, LoopBodyGenerator loopBody) throws CannotCompileException
ExpressionCompiler
Note that the compileToLoop() method must not be used where there is a need to maintain the value of position() or size(), or equivalents such as updating range variables. It is therefore generally used only for compiling aggregate functions such as count() and sum().
This has proved something of an obstacle. Attempts to compile path expressions as nested loops have failed in the case where there is a dependency on position() or last(): the current dependency mechanism doesn't always allow these cases to be detected (it only tells us when an expression uses position() or last(), not when it needs to maintain position() and last()). Hence this mode of compilation is not widely implemented (other than by the default implementation) and is currently used only when compiling sum() and count().
compileToLoop
in class ExpressionCompiler
compiler
- the compiler serviceexpression
- the expression to be compiledloopBody
- a generator which produces code to be executed once for every item in the result of this
expression, with that item being on the top of the bytecode stack.CannotCompileException
public void compileToIterator(CompilerService compiler, Expression expression) throws CannotCompileException
compileToIterator
in class ExpressionCompiler
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.