public abstract class ExpressionCompiler
extends java.lang.Object
CompilerService
working its way down the expression tree in a top
down fashion: there is a one-to-one correspondence between the classes implementing the
expression on the expression tree and the compiler object used to generate Java code fragments.
Various methods are supplied to compile expressions; exactly one of them is called, depending
on the context in which the expression appears.Constructor and Description |
---|
ExpressionCompiler() |
Modifier and Type | Method and Description |
---|---|
static void |
allocateStatic(CompilerService compiler,
java.lang.Object value)
Generate code to allocate static field in widget and to push field on stack
|
protected void |
compileItemFromInt(CompilerService compiler,
Expression expression)
Helper method to implement compileFromItem when the class implements compileToPrimitive returning an integer
|
abstract void |
compileToBoolean(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the expression as a boolean
Precondition: none.
|
abstract void |
compileToItem(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the expression as an Item
Precondition: none.
|
abstract void |
compileToIterator(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the expression as a
SequenceIterator
Precondition: none. |
void |
compileToPrimitive(CompilerService compiler,
Expression expression,
java.lang.Class requiredClass,
OnEmpty onEmpty)
Generate bytecode to evaluate the expression leaving a plain Java value on the stack.
|
abstract void |
compileToPush(CompilerService compiler,
Expression expression)
Generate bytecode to evaluate the expression in push mode
Precondition: none.
|
void |
generateMethod(CompilerService compiler,
Expression expression,
org.objectweb.asm.ClassVisitor cv) |
static void |
handleEmptyStringResult(OnEmpty onEmpty,
Generator ga,
GeneratedMethodInfo methodInfo,
LabelInfo exit) |
static void |
printStackTop(CompilerService compiler)
Print the top entry on the bytecode value stack, for diagnostic purposes
|
static void |
verify(org.objectweb.asm.ClassWriter cw,
java.lang.String objectName,
boolean debug)
Verify the generated bytecode, for diagnostic purposes
|
static void |
visitAnnotation(CompilerService compiler,
java.lang.String message)
Generate annotations in the bytecode, for diagnostic purposes
|
static void |
visitLineNumber(CompilerService compiler,
Generator ga,
Expression expr)
Generate line number of expression in byte-code
|
public abstract void compileToItem(CompilerService compiler, Expression expression) throws CannotCompileException
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
- if the expression cannot be compiled to bytecodepublic abstract void compileToIterator(CompilerService compiler, Expression expression) throws CannotCompileException
SequenceIterator
Precondition: none.
Postcondition: at execution time, the stack contains a SequenceIterator representing the result of the expressioncompiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
- if the expression cannot be compiled to bytecodepublic abstract void compileToBoolean(CompilerService compiler, Expression expression) throws CannotCompileException
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
- if the expression cannot be compiled to bytecodepublic void compileToPrimitive(CompilerService compiler, Expression expression, java.lang.Class requiredClass, OnEmpty onEmpty) throws CannotCompileException
compiler
- the compiler serviceexpression
- the expression to be compiledrequiredClass
- the class of the Java value that is to be left on the stack if the generated code
exits normally. This must be one of Integer.TYPE, Double.TYPE, Float.TYPE, BigDecimal.class, CharSequence.class.onEmpty
- defines the action to be taken if the expression evaluates to the empty sequence.
May be null if the expression is known statically not to evaluate to an empty sequence. If the return
class is a primitive type (double, float, etc) this must be an instance of OnEmpty.UnwindAndJump
CannotCompileException
- if the expression cannot be compiled to bytecodepublic static void handleEmptyStringResult(OnEmpty onEmpty, Generator ga, GeneratedMethodInfo methodInfo, LabelInfo exit)
public abstract void compileToPush(CompilerService compiler, Expression expression) throws CannotCompileException
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
- if the expression cannot be compiled to bytecodeprotected final void compileItemFromInt(CompilerService compiler, Expression expression) throws CannotCompileException
compiler
- the compiler serviceexpression
- the expression to be compiledCannotCompileException
- if the expression cannot be compiled to bytecodepublic static void visitAnnotation(CompilerService compiler, java.lang.String message)
compiler
- the compiler servicemessage
- the message to be inserted in the bytecodeCannotCompileException
- if the expression cannot be compiled to bytecodepublic static void printStackTop(CompilerService compiler)
compiler
- the bytecode compiler service to usepublic static void allocateStatic(CompilerService compiler, java.lang.Object value)
compiler
- the compiler servicevalue
- the Object of the fieldpublic static void verify(org.objectweb.asm.ClassWriter cw, java.lang.String objectName, boolean debug)
cw
- the ClassWriterobjectName
- debug
- true if bytecode tracing is requiredpublic static void visitLineNumber(CompilerService compiler, Generator ga, Expression expr)
compiler
- the compiler servicega
- the generator adapterexpr
- Expressionpublic void generateMethod(CompilerService compiler, Expression expression, org.objectweb.asm.ClassVisitor cv)
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.