public class Generator
extends org.objectweb.asm.commons.GeneratorAdapter
Constructor and Description |
---|
Generator(int access,
org.objectweb.asm.commons.Method method,
boolean throwsXPathException,
org.objectweb.asm.ClassVisitor cv)
Create a code generator for a particular method
|
Modifier and Type | Method and Description |
---|---|
void |
addComment(CompilerService compiler,
java.lang.String message)
Add a comment (in the form of an unused label) to the code listing
|
void |
checkClass(java.lang.Class theClass)
Generate a "checking" cast instruction, given a Class to check against.
|
void |
concatenateStrings(int n)
Generate code to concatenate a sequence of string objects.
|
void |
getInstanceField(java.lang.Class theClass,
java.lang.String fieldName)
Helper method to get an instance-level field of an object
|
org.objectweb.asm.Type |
getLocalType(int local)
Returns the type of the given local variable.
|
void |
getStaticField(java.lang.Class theClass,
java.lang.String fieldName,
java.lang.Class fieldClass)
Helper method to generate code that gets a static field
|
void |
goTo(LabelInfo labelInfo)
Generate code to go to a LabelInfo
|
void |
ifFalse(LabelInfo label)
Generate code to test whether the object on top of stack is NOT an instance of a given class
|
void |
ifInstance(java.lang.Class theClass,
LabelInfo label)
Generate code to test whether the object on top of stack is an instance of a given class
|
void |
ifNotInstance(java.lang.Class theClass,
LabelInfo label)
Generate code to test whether the object on top of stack is NOT an instance of a given class
|
void |
ifNotSameObject(LabelInfo label)
Generate code to test whether the two object references on top of stack refer to different objects
|
void |
ifSameObject(LabelInfo label)
Generate code to test whether the two object references on top of stack refer to the same object
|
void |
ifTrue(LabelInfo label)
Generate code to test whether the object on top of stack is the boolean true
|
void |
invokeConstructor(java.lang.Class<?> theClass,
java.lang.Class<?>... argTypes)
Helper method to generate code that invokes a constructor.
|
void |
invokeDefaultConstructor(java.lang.Class<?> theClass)
Helper method for a zero-argument constructor.
|
void |
invokeInstanceMethod(java.lang.Class<?> theClass,
java.lang.String methodName,
java.lang.Class... argTypes)
Helper method to generate code that invokes an instance method
|
void |
invokeStaticMethod(java.lang.Class<?> theClass,
java.lang.String methodName,
java.lang.Class... argTypes)
Helper method to generate code that invokes a static method
|
void |
loadArgOrLocal(int slot)
Load a local variable or method argument
|
void |
loadLocal(int local)
Generates the instruction to load the given local variable on the stack.
|
void |
newInstance(java.lang.Class theClass)
Helper method to generate code that creates a new instance of a class
|
int |
newLocal(java.lang.Class<?> theClass)
Helper method to generate a local bytecode variable
|
void |
pushNull()
Push "null" onto the stack
|
void |
showIntVariable(CompilerService compiler,
java.lang.String name,
int slot)
Generate code to output the value of a run-time variable (which must hold an int)
|
void |
showLongVariable(CompilerService compiler,
java.lang.String name,
int slot)
Generate code to output the value of a run-time variable (which must hold a long)
|
void |
showMessage(CompilerService compiler,
java.lang.String message)
Generate code to output a simple diagnostic message at run-time
|
void |
showObject(CompilerService compiler,
java.lang.String label)
Generate code to output the value of of the object on the top of the bytecode stack
|
void |
showObjectVariable(CompilerService compiler,
java.lang.String name,
int slot)
Generate code to output the value of a run-time bytecode variable (which must hold an object)
|
void |
storeArgOrLocal(int slot)
Generate code to store the value from top of stack into a local variable or method argument slot
|
void |
storeLocal(int local)
Generates the instruction to store the top stack value in the given local
variable.
|
void |
visitTryCatchBlock(LabelInfo start,
LabelInfo end,
LabelInfo handler,
java.lang.String type)
Process a try/catch block
|
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getField, getStatic, goTo, ifCmp, ifICmp, ifNonNull, ifNull, ifZCmp, iinc, instanceOf, invokeConstructor, invokeDynamic, invokeInterface, invokeStatic, invokeVirtual, loadArg, loadArgArray, loadArgs, loadArgs, loadLocal, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, not, pop, pop2, push, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOf
newLocal, newLocalMapping, updateNewLocals, visitFrame, visitIincInsn, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs, visitVarInsn
visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn
public Generator(int access, org.objectweb.asm.commons.Method method, boolean throwsXPathException, org.objectweb.asm.ClassVisitor cv)
access
- the visibility of the method, typically PUBLICmethod
- the Method object containing details of the argument and return typesthrowsXPathException
- true if the method throws XPathException on errorcv
- the class visitor for the containing classpublic void ifInstance(java.lang.Class theClass, LabelInfo label)
theClass
- the class to be testedlabel
- the label to jump to if the current object is an instance of the class. If it
is not an instance, control passes to the next instructionpublic void ifNotInstance(java.lang.Class theClass, LabelInfo label)
theClass
- the class to be testedlabel
- the label to jump to if the current object is an instance of the class. If it
is not an instance, control passes to the next instructionpublic void goTo(LabelInfo labelInfo)
labelInfo
- the label to jump topublic void pushNull()
public void ifTrue(LabelInfo label)
label
- the label to jump to if the value on top of stack is true (non-zero)public void ifFalse(LabelInfo label)
label
- the label to jump to if the current object is false (zero)public void ifSameObject(LabelInfo label)
label
- the label to jump to if the two object references are equalpublic void ifNotSameObject(LabelInfo label)
label
- the label to jump to if the two object references are differentpublic void checkClass(java.lang.Class theClass)
theClass
- the class to be testedpublic void addComment(CompilerService compiler, java.lang.String message)
compiler
- the compiler servicemessage
- the comment to be added to the codepublic void showMessage(CompilerService compiler, java.lang.String message)
compiler
- the compiler servicemessage
- the message to be output at run-timepublic void showObject(CompilerService compiler, java.lang.String label)
compiler
- the compiler servicelabel
- a label used to prefix the message to be output at run-timepublic void showObjectVariable(CompilerService compiler, java.lang.String name, int slot)
compiler
- the compiler servicename
- a label used to prefix the message to be output at run-time, typically the variable nameslot
- the slot number on the bytecode stack whose value is to be displayedpublic void showLongVariable(CompilerService compiler, java.lang.String name, int slot)
compiler
- the compiler servicename
- a label used to prefix the message to be output at run-time, typically the variable nameslot
- the slot number on the bytecode stack whose value is to be displayedpublic void showIntVariable(CompilerService compiler, java.lang.String name, int slot)
compiler
- the compiler servicename
- a label used to prefix the message to be output at run-time, typically the variable nameslot
- the slot number on the bytecode stack whose value is to be displayedpublic void getStaticField(java.lang.Class theClass, java.lang.String fieldName, java.lang.Class fieldClass)
theClass
- the class on which the field is definedfieldName
- the name of the field to be fetchedfieldClass
- the class of the field to be fetchedpublic void invokeStaticMethod(java.lang.Class<?> theClass, java.lang.String methodName, java.lang.Class... argTypes)
theClass
- the class on which the method is definedmethodName
- the name of the method to be invokedargTypes
- the classes of the arguments to the methodjava.lang.AssertionError
- if no suitable method is defined on this classpublic void invokeInstanceMethod(java.lang.Class<?> theClass, java.lang.String methodName, java.lang.Class... argTypes)
theClass
- the instance class on which the method is definedmethodName
- the name of the method to be invokedargTypes
- the classes of the arguments to the methodjava.lang.AssertionError
- if no suitable method is defined on this interfacepublic void getInstanceField(java.lang.Class theClass, java.lang.String fieldName)
theClass
- the instance class on which the method is definedfieldName
- the name of the field to be obtainedjava.lang.AssertionError
- if no suitable method is defined on this interfacepublic void invokeDefaultConstructor(java.lang.Class<?> theClass)
theClass
- the class of object to be constructedpublic void newInstance(java.lang.Class theClass)
theClass
- the class to be instantiatedpublic void invokeConstructor(java.lang.Class<?> theClass, java.lang.Class<?>... argTypes)
theClass
- the class on which the method is definedargTypes
- the classes of the arguments to the constructorjava.lang.AssertionError
- if no suitable constructor is defined on this classpublic int newLocal(java.lang.Class<?> theClass)
theClass
- the class of the variablepublic void loadLocal(int local)
loadLocal
in class org.objectweb.asm.commons.GeneratorAdapter
local
- a local variable identifier, as returned by
newLocal()
.public void loadArgOrLocal(int slot)
slot
- the slot number to be loaded, which may represent either a method argument or a local variablepublic void storeLocal(int local)
storeLocal
in class org.objectweb.asm.commons.GeneratorAdapter
local
- a local variable identifier, as returned by
newLocal()
.public void storeArgOrLocal(int slot)
slot
- the slot number to be used, which may represent either a method argument or a local variablepublic org.objectweb.asm.Type getLocalType(int local)
getLocalType
in class org.objectweb.asm.commons.GeneratorAdapter
local
- a local variable identifier, as returned by
newLocal()
.public void visitTryCatchBlock(LabelInfo start, LabelInfo end, LabelInfo handler, java.lang.String type)
start
- the label for the start of the try blockend
- the label for the end of the try blockhandler
- the label for the catch blocktype
- the typepublic void concatenateStrings(int n)
n
- the number of strings to be concatenatedCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.