com.saxonica.bytecode
Class ToItemCompiler

java.lang.Object
  extended by com.saxonica.bytecode.ExpressionCompiler
      extended by com.saxonica.bytecode.ToItemCompiler
Direct Known Subclasses:
ArithmeticCompiler, BaseURICompiler, CastExpressionCompiler, CastToUnionCompiler, ComponentCompiler, ContextItemCompiler, CountCompiler, DateTimeConstructorCompiler, DocCompiler, FirstItemExpressionCompiler, FunctionItemExpressionCompiler, IdentityComparisonCompiler, ItemAtCompiler, LastCompiler, LastItemExpressionCompiler, MinimaxCompiler, NamespaceUriFnCompiler, NegateExpressionCompiler, NodeNameFnCompiler, NumberFnCompiler, PartialApplyCompiler, PositionCompiler, QNameFnCompiler, RootExpressionCompiler, RootFunctionCompiler, RoundingCompiler, SingletonAtomizerCompiler, StringLengthCompiler, SumCompiler, ToStringCompiler, TupleExpressionCompiler

public abstract class ToItemCompiler
extends ExpressionCompiler

Abstract superclass for expression compilers that handle expressions returning a single item (or nothing). The compilers for such expressions must implement the compileToItem() method; they may optionally implement other methods such as compileToIterator().


Constructor Summary
ToItemCompiler()
           
 
Method Summary
 void compileToBoolean(CompilerService compiler, Expression expression)
          Generate bytecode to evaluate the expression as a boolean Precondition: none.
 void compileToIterator(CompilerService compiler, Expression expression)
          Generate bytecode to evaluate the expression as a SequenceIterator Precondition: none.
 void compileToPush(CompilerService compiler, Expression expression)
          Generate bytecode to evaluate the expression in push mode Precondition: none.
protected  void returnZeroLengthStringIfNull(Expression arg, Generator ga, GeneratedMethodInfo methodInfo, LabelInfo returnLabel, int extraPops)
          Utility method for use by subclasses to generate code that causes an empty string to be returned if the first argument is an empty sequence.
 
Methods inherited from class com.saxonica.bytecode.ExpressionCompiler
allocateStatic, compileItemFromInt, compileItemFromString, compileToItem, compileToLoop, compileToPrimitive, generateMethod, getConfiguration, handleEmptyStringResult, setConfiguration, throwXPathException, throwXPathException, unboxItem, verify, visitAnnotation, visitLineNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToItemCompiler

public ToItemCompiler()
Method Detail

compileToIterator

public void compileToIterator(CompilerService compiler,
                              Expression expression)
                       throws CannotCompileException
Description copied from class: ExpressionCompiler
Generate bytecode to evaluate the expression as a SequenceIterator Precondition: none. Postcondition: at execution time, the stack contains a SequenceIterator 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

compileToBoolean

public void compileToBoolean(CompilerService compiler,
                             Expression expression)
                      throws CannotCompileException
Description copied from class: ExpressionCompiler
Generate bytecode to evaluate the expression as a boolean Precondition: none. Postcondition: at execution time, the stack contains an integer (0=false, 1=true) representing the result of the expression

Specified by:
compileToBoolean in class ExpressionCompiler
Parameters:
compiler - the compiler service
expression - the expression to be compiled
Throws:
CannotCompileException

compileToPush

public void compileToPush(CompilerService compiler,
                          Expression expression)
                   throws CannotCompileException
Description copied from class: ExpressionCompiler
Generate bytecode to evaluate the expression in push mode Precondition: none. Postcondition: at execution time, the stack is unchanged, and the value of the expression has been written to the current receiver

Specified by:
compileToPush in class ExpressionCompiler
Parameters:
compiler - the compiler service
expression - the expression to be compiled
Throws:
CannotCompileException

returnZeroLengthStringIfNull

protected void returnZeroLengthStringIfNull(Expression arg,
                                            Generator ga,
                                            GeneratedMethodInfo methodInfo,
                                            LabelInfo returnLabel,
                                            int extraPops)
Utility method for use by subclasses to generate code that causes an empty string to be returned if the first argument is an empty sequence. Precondition: the value of the first argument is on the stack, either as a string or as an item Postcondition: either the control has jumped to the return label with a zero-length string on the stack, or control drops through with the value of the first argument still on the stack (as supplied).

Parameters:
arg - the first argument
ga - the Generator
methodInfo - the method information
returnLabel - the label to jump to on completion
extraPops - items (other than the string being tested) that need to be popped of the stack if jumping to the return label


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