public class Generator
extends org.objectweb.asm.commons.GeneratorAdapter
Constructor and Description |
---|
Generator(int access,
org.objectweb.asm.commons.Method method,
org.objectweb.asm.Type[] exceptions,
org.objectweb.asm.ClassVisitor cv) |
Modifier and Type | Method and Description |
---|---|
void |
addComment(CompilerService compiler,
String message)
Add a comment (in the form of an unused label) to the code listing
|
void |
checkClass(Class theClass)
Generate a "checking" cast instruction, given a Class the check against.
|
void |
concatenateStrings(int n)
Generate code to concatenate a sequence of string objects.
|
void |
getInstanceField(Class theClass,
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(Class theClass,
String fieldName,
Class fieldClass)
Helper method to generate code that gets a static field
|
void |
goTo(LabelInfo labelInfo)
Generate code to go to a LabelInfo
|
void |
ifCmp(org.objectweb.asm.Type type,
int mode,
org.objectweb.asm.Label label)
Generates the instructions to jump to a label based on the comparison of
the top two stack values.
|
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(Class theClass,
LabelInfo label)
Generate code to test whether the object on top of stack is an instance of a given class
|
void |
ifNotInstance(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(Class theClass,
Class... argTypes)
Helper method to generate code that invokes a constructor.
|
void |
invokeDefaultConstructor(Class theClass)
Helper method for a zero-argument constructor.
|
void |
invokeInstanceMethod(Class theClass,
String methodName,
Class... argTypes)
Helper method to generate code that invokes an instance method
|
void |
invokeStaticMethod(Class theClass,
String methodName,
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(Class theClass)
Helper method to generate code that creates a new instance of a class
|
int |
newLocal(Class theClass)
Helper method to generate a local bytecode variable
|
void |
pushNull()
Push "null" onto the stack
|
void |
showIntVariable(CompilerService compiler,
String name,
int slot)
Generate code to output the value of a run-time variable (which must hold an int)
|
void |
showLongVariable(CompilerService compiler,
String name,
int slot)
Generate code to output the value of a run-time variable (which must hold a long)
|
void |
showMessage(CompilerService compiler,
String message)
Generate code to output a simple diagnostic message at run-time
|
void |
showObject(CompilerService compiler,
String label)
Generate code to output the value of of the object on the top of the bytecode stack
|
void |
showObjectVariable(CompilerService compiler,
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,
String type)
Process a try/catch block
|
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getField, getStatic, goTo, 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, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOf
newLocal, newLocalMapping, visitFrame, visitIincInsn, visitLocalVariable, visitMaxs, visitVarInsn
visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLookupSwitchInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn
public Generator(int access, org.objectweb.asm.commons.Method method, org.objectweb.asm.Type[] exceptions, org.objectweb.asm.ClassVisitor cv)
public void ifInstance(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(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(Class theClass)
theClass
- the class to be testedpublic void addComment(CompilerService compiler, String message)
compiler
- the compiler servicemessage
- the comment to be added to the codepublic void showMessage(CompilerService compiler, String message)
compiler
- the compiler servicemessage
- the message to be output at run-timepublic void showObject(CompilerService compiler, String label)
compiler
- the compiler servicelabel
- a label used to prefix the message to be output at run-timepublic void showObjectVariable(CompilerService compiler, 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, 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, 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(Class theClass, String fieldName, 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(Class theClass, String methodName, 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 methodAssertionError
- if no suitable method is defined on this classpublic void invokeInstanceMethod(Class theClass, String methodName, 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 methodAssertionError
- if no suitable method is defined on this interfacepublic void getInstanceField(Class theClass, String fieldName)
theClass
- the instance class on which the method is definedfieldName
- the name of the field to be obtainedAssertionError
- if no suitable method is defined on this interfacepublic void invokeDefaultConstructor(Class theClass)
theClass
- the class of object to be constructedpublic void newInstance(Class theClass)
theClass
- the class to be instantiatedpublic void invokeConstructor(Class theClass, Class... argTypes)
theClass
- the class on which the method is definedargTypes
- the classes of the arguments to the constructorAssertionError
- if no suitable constructor is defined on this classpublic int newLocal(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, 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 concatenatedpublic void ifCmp(org.objectweb.asm.Type type, int mode, org.objectweb.asm.Label label)
ifCmp
in class org.objectweb.asm.commons.GeneratorAdapter
type
- the type of the top two stack values.mode
- how these values must be compared. One of EQ, NE, LT, GE, GT,
LE.label
- where to jump if the comparison result is true.Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.