Package com.saxonica.ee.bytecode
Class ToItemCompiler
- java.lang.Object
-
- com.saxonica.ee.bytecode.ExpressionCompiler
-
- com.saxonica.ee.bytecode.ToItemCompiler
-
- Direct Known Subclasses:
AccessorFnCompiler
,ArithmeticCompiler
,AttributeGetterCompiler
,BaseURICompiler
,CastExpressionCompiler
,ContextItemCompiler
,CountCompiler
,DateTimeConstructorCompiler
,FirstItemExpressionCompiler
,FunctionLiteralCompiler
,IdentityComparisonCompiler
,LastCompiler
,LastItemExpressionCompiler
,NamespaceUriFnCompiler
,NegateExpressionCompiler
,NodeNameFnCompiler
,NumberFnCompiler
,PartialApplyCompiler
,PositionCompiler
,QNameFnCompiler
,RootExpressionCompiler
,RootFunctionCompiler
,RoundingCompiler
,SingletonAtomizerCompiler
,SquareArrayConstructorCompiler
,StringLengthCompiler
,SubscriptExpressionCompiler
,SubstringCompiler
,SumCompiler
,ToStringCompiler
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
Constructors Constructor Description ToItemCompiler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 aSequenceIterator
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.ee.bytecode.ExpressionCompiler
allocateStatic, compileItemFromInt, compileToItem, compileToPrimitive, generateMethod, handleEmptyStringResult, printStackTop, verify, visitAnnotation, visitLineNumber
-
-
-
-
Method Detail
-
compileToIterator
public void compileToIterator(CompilerService compiler, Expression expression) throws CannotCompileException
Description copied from class:ExpressionCompiler
Generate bytecode to evaluate the expression as aSequenceIterator
Precondition: none. Postcondition: at execution time, the stack contains a SequenceIterator representing the result of the expression- Specified by:
compileToIterator
in classExpressionCompiler
- Parameters:
compiler
- the compiler serviceexpression
- the expression to be compiled- Throws:
CannotCompileException
- if the expression cannot be compiled to bytecode
-
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 classExpressionCompiler
- Parameters:
compiler
- the compiler serviceexpression
- the expression to be compiled- Throws:
CannotCompileException
- if the expression cannot be compiled to bytecode
-
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 classExpressionCompiler
- Parameters:
compiler
- the compiler serviceexpression
- the expression to be compiled- Throws:
CannotCompileException
- if the expression cannot be compiled to bytecode
-
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 argumentga
- the GeneratormethodInfo
- the method informationreturnLabel
- the label to jump to on completionextraPops
- items (other than the string being tested) that need to be popped of the stack if jumping to the return label
-
-