Package com.saxonica.ee.bytecode
Class SimpleNodeConstructorCompiler
- java.lang.Object
-
- com.saxonica.ee.bytecode.ExpressionCompiler
-
- com.saxonica.ee.bytecode.ToIteratorCompiler
-
- com.saxonica.ee.bytecode.ToPushCompiler
-
- com.saxonica.ee.bytecode.SimpleNodeConstructorCompiler
-
- Direct Known Subclasses:
CommentCompiler,NamespaceConstructorCompiler,ProcessingInstructionCompiler,ValueOfCompiler
public abstract class SimpleNodeConstructorCompiler extends ToPushCompiler
-
-
Constructor Summary
Constructors Constructor Description SimpleNodeConstructorCompiler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckContent(CompilerService compiler, Expression expression)Compile code to check the content of the node, and adjust it if necessary On entry the proposed content is on the stack as a CharSequence; on exit the revised content must be on the stack as a CharSequence.protected voidcompileNodeName(CompilerService compiler, Expression expression)Compile code to generate the node name (if any) and leave it on the top of the stack.voidcompileToItem(CompilerService compiler, Expression expression)Generate bytecode to evaluate the expression as an Item Precondition: none.voidcompileToPush(CompilerService compiler, Expression expression)Generate bytecode to evaluate the expression in push mode Precondition: none.protected booleanisNamedNodeKind()Ask whether this instruction generates a kind of node that is namedprotected booleanisNoNodeIfEmpty(Expression expr)Overridable method to ask whether no node should be produced in the case that the content is emptyprotected abstract voidpushNode(CompilerService compiler, Expression expression)Generate code to write the node to the current receiver.-
Methods inherited from class com.saxonica.ee.bytecode.ToPushCompiler
compilePushToSequenceCollector, compileToIterator
-
Methods inherited from class com.saxonica.ee.bytecode.ToIteratorCompiler
compileToBoolean
-
Methods inherited from class com.saxonica.ee.bytecode.ExpressionCompiler
allocateStatic, compileItemFromInt, compileToPrimitive, generateMethod, handleEmptyStringResult, printStackTop, verify, visitAnnotation, visitLineNumber
-
-
-
-
Method Detail
-
compileToPush
public void compileToPush(CompilerService compiler, Expression expression) throws CannotCompileException
Description copied from class:ExpressionCompilerGenerate 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- Overrides:
compileToPushin classToIteratorCompiler- Parameters:
compiler- the compiler serviceexpression- the expression to be compiled- Throws:
CannotCompileException- if the expression cannot be compiled to bytecode
-
isNoNodeIfEmpty
protected boolean isNoNodeIfEmpty(Expression expr)
Overridable method to ask whether no node should be produced in the case that the content is empty- Returns:
- true if the rules for this instruction are that when the content is empty, no node is generated
-
checkContent
protected void checkContent(CompilerService compiler, Expression expression)
Compile code to check the content of the node, and adjust it if necessary On entry the proposed content is on the stack as a CharSequence; on exit the revised content must be on the stack as a CharSequence.- Parameters:
compiler- the compiler serviceexpression- the expression to be compiled
-
compileNodeName
protected void compileNodeName(CompilerService compiler, Expression expression) throws CannotCompileException
Compile code to generate the node name (if any) and leave it on the top of the stack. For node kinds that are always unnamed (such as comments), the stack is not changed. For node kinds that may be named or unnamed (namespace nodes), an entry is always added to the stack, which will be "" if the particular node has no name.- Parameters:
compiler- the compiler serviceexpression- the expression to be compiled- Throws:
CannotCompileException- if the expression cannot be compiled to bytecode
-
pushNode
protected abstract void pushNode(CompilerService compiler, Expression expression)
Generate code to write the node to the current receiver. On entry the stack holds the current receiver, the node name (for named node kinds only) and the content (for all nodes), in general as instances of CharSequence- Parameters:
compiler- the compiler serviceexpression- the expression to be compiled
-
isNamedNodeKind
protected boolean isNamedNodeKind()
Ask whether this instruction generates a kind of node that is named- Returns:
- true if the instruction generates a kind of node that is named
-
compileToItem
public void compileToItem(CompilerService compiler, Expression expression) throws CannotCompileException
Description copied from class:ExpressionCompilerGenerate bytecode to evaluate the expression as an Item Precondition: none. Postcondition: at execution time, the stack contains either an item (the result of the expression), or null (representing an empty sequence).- Overrides:
compileToItemin classToPushCompiler- Parameters:
compiler- the compiler serviceexpression- the expression to be compiled- Throws:
CannotCompileException- if the expression cannot be compiled to bytecode
-
-