|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.saxonica.bytecode.util.CompilerService
public class CompilerService
Controlling/service class for compilation of expressions to Java bytecode
Nested Class Summary | |
---|---|
static class |
CompilerService.GeneratedClassInfo
|
class |
CompilerService.GeneratedExpression
sub-class GeneratedExpression - used to keep track of ExpressionCompiler classes that need to generate a method |
static class |
CompilerService.StaticSubClasses
|
static class |
CompilerService.StaticVariableInfo
|
Field Summary | |
---|---|
HashMap<com.saxonica.bytecode.util.CompilerService.ObjectIdentityWrapper,CompilerService.StaticSubClasses> |
cClassMap
|
static int |
tracePoint
|
Constructor Summary | |
---|---|
CompilerService(Configuration config)
|
Method Summary | |
---|---|
void |
addNewMethod(ExpressionCompiler ec,
Expression e)
The methods adds the |
CompilerService.StaticVariableInfo |
allocateStaticVariableInfo(Object value)
Create a StaticVariableInfo containing the information needed to allow a static reference to a given object to be added as a static field in the currently-being-compiled class |
boolean |
canCompileToLoop(Expression expr)
Ask if an expression can be compiled using the compileToLoop() method |
void |
compileToBoolean(Expression expr)
Generate bytecode to evaluate an expression leaving a boolean on the stack. |
CompiledExpression |
compileToByteCode(Expression expr,
String objectName,
int evaluationModes)
Compile a top-level expression to bytecode, and return the resulting expression |
void |
compileToItem(Expression expr)
Generate bytecode to evaluate an expression leaving either an Item or null on the stack (null indicating that the expression evaluated to an empty sequence). |
void |
compileToIterator(Expression expr)
Generate bytecode to evaluate an expression leaving a SequenceIterator on the stack |
void |
compileToLoop(Expression expr,
LoopBodyGenerator bodyGen)
|
void |
compileToPrimitive(Expression expr,
Class requiredClass,
OnEmpty onEmpty)
Compile an expression that returns a singleton (or empty) result of type xs:double, xs:float, xs:string, xs:untypedAtomic. |
void |
compileToPush(Expression expr)
Generate bytecode to evaluate an expression by writing events to the current SequenceReceiver (leaving nothing on the stack at execution time) |
void |
compileToValueRepresentation(Expression expression)
Compile code to evaluate a variable reference, or any other expresssion, leaving a ValueRepresentation on the stack |
void |
generateGetContext()
Generate code to load the current XPathContext, leaving it on the top of the stack |
void |
generateGetReceiver()
Generate code to load the current Receiver, leaving it on the top of the stack |
Class |
getCompiledClass(Object expr)
|
Configuration |
getConfiguration()
Get the Configuration used by this CompilerService |
CompilerService.GeneratedClassInfo |
getCurrentClass()
|
Generator |
getCurrentGenerator()
|
GeneratedMethodInfo |
getCurrentMethod()
|
Stack<GeneratedMethodInfo> |
getCurrentMethods()
|
int |
getFlags()
Get the flag options used by the ClassWriter |
int |
getUniqueNumber()
Get a unique number which is different from any other number allocated by a call on this method, for the same CompilerService instance |
void |
initNewMethod(Generator ga,
boolean holdReceiverAsLocal)
Initialize context information for a new method. |
boolean |
isDisplayByteCode()
|
boolean |
isInRangeForInt(Expression exp)
|
boolean |
isInRangeForLong(Expression exp)
|
static boolean |
isLanguagePrimitiveType(AtomicType targetType)
|
Class |
makeClass(org.objectweb.asm.ClassWriter writer,
String className)
Having written the bytecode for all the methods for a class, create the Class itself so it can be used |
String |
makeValidJavaName(String name)
Given a candidate Java name, make it into a valid Java name |
void |
popCurrentMethodInfo()
|
void |
popReceiverInfo()
Generate code to reinstate the previous current receiver by popping it from the receiver stack. |
void |
pushNewClassInfo(String className,
Class superclass,
org.objectweb.asm.ClassWriter cw)
|
void |
pushNewMethodInfo(Generator ga,
boolean contextIsArgument,
int contextVariablePosition)
|
void |
pushNewReceiverInfo(Generator ga)
Generate code to set a new current receiver on the top of the receiver stack. |
void |
setCompiledClass(Object expr,
Class clss)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int tracePoint
public HashMap<com.saxonica.bytecode.util.CompilerService.ObjectIdentityWrapper,CompilerService.StaticSubClasses> cClassMap
Constructor Detail |
---|
public CompilerService(Configuration config)
Method Detail |
---|
public static boolean isLanguagePrimitiveType(AtomicType targetType)
public boolean isDisplayByteCode()
public void addNewMethod(ExpressionCompiler ec, Expression e)
ec
- - The ExpressionCompiler that needs to generate a methode
- - The expression represented by the Expressioncompilerpublic void compileToValueRepresentation(Expression expression) throws CannotCompileException
expression
- the expression to be compiled
CannotCompileException
- if the expression cannot be compiledpublic Class getCompiledClass(Object expr)
public void setCompiledClass(Object expr, Class clss)
public int getUniqueNumber()
public void pushNewReceiverInfo(Generator ga)
Runtime precondition: the new receiver is on the top of the bytecode stack
Runtime postcondition: the new receiver is now the current receiver; the previous current receiver has been added to the receiver stack. The top entry from the bytecode stack has been consumed.
ga
- the code generatorpublic void popReceiverInfo()
Runtime precondition: there is a non-empty receiver stack
Runtime postcondition: the top entry in the receiver stack has been removed from the receiver stack and is now the current receiver.
public void pushNewMethodInfo(Generator ga, boolean contextIsArgument, int contextVariablePosition)
public void initNewMethod(Generator ga, boolean holdReceiverAsLocal)
ga
- the code generatorholdReceiverAsLocal
- true if a local variable on the bytecode stack is to be
allocated to hold the current receiver; if false, the receiver is obtained via the context when requiredpublic void pushNewClassInfo(String className, Class superclass, org.objectweb.asm.ClassWriter cw)
public Stack<GeneratedMethodInfo> getCurrentMethods()
public GeneratedMethodInfo getCurrentMethod()
public CompilerService.GeneratedClassInfo getCurrentClass()
public Configuration getConfiguration()
public int getFlags()
public CompiledExpression compileToByteCode(Expression expr, String objectName, int evaluationModes)
expr
- The expression to be compiledobjectName
- The name of the object (e.g. function) being compiledevaluationModes
- The evaluation modes for which code is generated. Currently a subset of
Expression.PROCESS_METHOD
,
Expression.ITERATE_METHOD
,
Expression.EVALUATE_METHOD
. If no code is generated for
a given evaluation method, the fallback implementation from the superclass is used.
public void compileToIterator(Expression expr) throws CannotCompileException
expr
- the expression to be evaluated
CannotCompileException
- if the expression cannot be compiledpublic void compileToPush(Expression expr) throws CannotCompileException
expr
- the expression to be evaluated
CannotCompileException
- if the expression cannot be compiledpublic void compileToItem(Expression expr) throws CannotCompileException
expr
- the expression to be evaluated
CannotCompileException
- if the expression cannot be compiledpublic void compileToBoolean(Expression expr) throws CannotCompileException
expr
- the expression to be evaluated
CannotCompileException
- if the expression cannot be compiledpublic boolean isInRangeForInt(Expression exp)
public boolean isInRangeForLong(Expression exp)
public void compileToPrimitive(Expression expr, Class requiredClass, OnEmpty onEmpty) throws CannotCompileException
expr
- the expression to be compiledrequiredClass
- the required class. For an expression with static type xs:double, this will be
Double.TYPE; for xs:float it will be Float.TYPE; for xs:string and xs:untypedAtomic it may be either
String.class or CharSequence.class. The expression compiler MUST generate code that leaves this class
of value on the top of the bytecode stack.
For an expression whose static type is xs:integer, the requiredClass may be Integer.TYPE or Long.TYPE,
provided that either (a) the expression is known always to deliver a value in the range of an int or long
respectively, or (b) that any other value would exceed system limits in the context where it is used (for
example, if it is used as an index into a sequence then it cannot exceed a 32-bit integer). All expressions
that have a static type of xs:integer must therefore implement this method.onEmpty
- action to be taken when the expression returns an empty result.
CannotCompileException
- if the expression cannot be compiledpublic boolean canCompileToLoop(Expression expr)
expr
- the expression in question
public void compileToLoop(Expression expr, LoopBodyGenerator bodyGen) throws CannotCompileException
CannotCompileException
public Generator getCurrentGenerator()
public void popCurrentMethodInfo()
public void generateGetContext()
public void generateGetReceiver()
public Class makeClass(org.objectweb.asm.ClassWriter writer, String className)
writer
- the writer that was used to create the classclassName
- the name of the class
public CompilerService.StaticVariableInfo allocateStaticVariableInfo(Object value)
value
- the object to be referenced
public String makeValidJavaName(String name)
name
- a candidate Java name
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |