RuleTriggerMethodAdapter
public class RuleGeneratorAdapter extends RuleMethodAdapter
newLocal(org.objectweb.asm.Type)
, popLocal(int)
,
loadLocal(int)
and storeLocal(int)
.
Another reason to transplant code to this class is because it inherits functionality from
RuleMethodAdapter which is used by RuleCheckAdapter and RuleTriggerAdapter to identify
and classify local variables but provides functionality to modify bytecode which is only
needed by RuleTriggerAdapter. So, the original class would have needed reparenting anyway.RuleMethodAdapter.LocalVar
Modifier and Type | Field | Description |
---|---|---|
static int |
ADD |
Constant for the
math method. |
static int |
AND |
Constant for the
math method. |
static int |
DIV |
Constant for the
math method. |
static int |
EQ |
Constant for the
ifCmp method. |
static int |
GE |
Constant for the
ifCmp method. |
static int |
GT |
Constant for the
ifCmp method. |
static int |
LE |
Constant for the
ifCmp method. |
static int |
LT |
Constant for the
ifCmp method. |
static int |
MUL |
Constant for the
math method. |
static int |
NE |
Constant for the
ifCmp method. |
static int |
NEG |
Constant for the
math method. |
static int |
OR |
Constant for the
math method. |
static int |
REM |
Constant for the
math method. |
static int |
SHL |
Constant for the
math method. |
static int |
SHR |
Constant for the
math method. |
static int |
SUB |
Constant for the
math method. |
static int |
USHR |
Constant for the
math method. |
static int |
XOR |
Constant for the
math method. |
access, descriptor, name, rule, transformContext
Constructor | Description |
---|---|
RuleGeneratorAdapter(org.objectweb.asm.MethodVisitor mv,
TransformContext transformContext,
int access,
String name,
String desc,
Rule rule) |
Creates a new
RuleGeneratorAdapter . |
Modifier and Type | Method | Description |
---|---|---|
void |
arrayLength() |
Generates the instruction to compute the length of an array.
|
void |
arrayLoad(org.objectweb.asm.Type type) |
Generates the instruction to load an element from an array.
|
void |
arrayStore(org.objectweb.asm.Type type) |
Generates the instruction to store an element in an array.
|
void |
box(org.objectweb.asm.Type type) |
Generates the instructions to box the top stack value.
|
void |
cast(org.objectweb.asm.Type from,
org.objectweb.asm.Type to) |
Generates the instructions to cast a numerical value from one type to
another.
|
void |
catchException(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Type exception) |
Marks the start of an exception handler.
|
void |
checkCast(org.objectweb.asm.Type type) |
Generates the instruction to check that the top stack value is of the
given type.
|
void |
dup() |
Generates a DUP instruction.
|
void |
dup2() |
Generates a DUP2 instruction.
|
void |
dup2X1() |
Generates a DUP2_X1 instruction.
|
void |
dup2X2() |
Generates a DUP2_X2 instruction.
|
void |
dupX1() |
Generates a DUP_X1 instruction.
|
void |
dupX2() |
Generates a DUP_X2 instruction.
|
void |
endMethod() |
Marks the end of the visited method.
|
void |
getField(org.objectweb.asm.Type owner,
String name,
org.objectweb.asm.Type type) |
Generates the instruction to push the value of a non static field on the
stack.
|
org.objectweb.asm.Type |
getLocalType(int local) |
|
void |
getStatic(org.objectweb.asm.Type owner,
String name,
org.objectweb.asm.Type type) |
Generates the instruction to push the value of a static field on the
stack.
|
void |
goTo(org.objectweb.asm.Label label) |
Generates the instruction to jump to the given label.
|
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 |
ifICmp(int mode,
org.objectweb.asm.Label label) |
Generates the instructions to jump to a label based on the comparison of
the top two integer stack values.
|
void |
ifNonNull(org.objectweb.asm.Label label) |
Generates the instruction to jump to the given label if the top stack
value is not null.
|
void |
ifNull(org.objectweb.asm.Label label) |
Generates the instruction to jump to the given label if the top stack
value is null.
|
void |
ifZCmp(int mode,
org.objectweb.asm.Label label) |
Generates the instructions to jump to a label based on the comparison of
the top integer stack value with zero.
|
void |
iinc(int local,
int amount) |
Generates the instruction to increment the given local variable.
|
void |
instanceOf(org.objectweb.asm.Type type) |
Generates the instruction to test if the top stack value is of the given
type.
|
void |
invokeConstructor(org.objectweb.asm.Type type,
org.objectweb.asm.commons.Method method) |
Generates the instruction to invoke a constructor.
|
void |
invokeDynamic(String name,
String desc,
org.objectweb.asm.Handle bsm,
Object... bsmArgs) |
Generates an invokedynamic instruction.
|
void |
invokeInterface(org.objectweb.asm.Type owner,
org.objectweb.asm.commons.Method method) |
Generates the instruction to invoke an interface method.
|
void |
invokeStatic(org.objectweb.asm.Type owner,
org.objectweb.asm.commons.Method method) |
Generates the instruction to invoke a static method.
|
void |
invokeVirtual(org.objectweb.asm.Type owner,
org.objectweb.asm.commons.Method method) |
Generates the instruction to invoke a normal method.
|
void |
loadArg(int arg) |
Generates the instruction to load the given method argument on the stack.
|
void |
loadArgArray() |
Generates the instructions to load all the method arguments on the stack,
as a single object array.
|
void |
loadArgs() |
Generates the instructions to load all the method arguments on the stack.
|
void |
loadArgs(int arg,
int count) |
Generates the instructions to load the given method arguments on the
stack.
|
void |
loadLocal(int local) |
load a value onto the stack from a local var slot which can obtained from a call to newLocal or
from a lcoal variable table entry.
|
void |
loadThis() |
Generates the instruction to load 'this' on the stack.
|
org.objectweb.asm.Label |
mark() |
Marks the current code position with a new label.
|
void |
mark(org.objectweb.asm.Label label) |
Marks the current code position with the given label.
|
void |
math(int op,
org.objectweb.asm.Type type) |
Generates the instruction to do the specified mathematical or logical
operation.
|
void |
monitorEnter() |
Generates the instruction to get the monitor of the top stack value.
|
void |
monitorExit() |
Generates the instruction to release the monitor of the top stack value.
|
void |
newArray(org.objectweb.asm.Type type) |
Generates the instruction to create a new array.
|
void |
newInstance(org.objectweb.asm.Type type) |
Generates the instruction to create a new object.
|
org.objectweb.asm.Label |
newLabel() |
Creates a new
Label . |
int |
newLocal(org.objectweb.asm.Type valueType) |
return a new local slot index for a local var not currently in use.
|
void |
not() |
Generates the instructions to compute the bitwise negation of the top
stack value.
|
void |
pop() |
Generates a POP instruction.
|
void |
pop2() |
Generates a POP2 instruction.
|
void |
popLocal(int local) |
free a previously allocated local slot
|
void |
push(boolean value) |
Generates the instruction to push the given value on the stack.
|
void |
push(double value) |
Generates the instruction to push the given value on the stack.
|
void |
push(float value) |
Generates the instruction to push the given value on the stack.
|
void |
push(int value) |
Generates the instruction to push the given value on the stack.
|
void |
push(long value) |
Generates the instruction to push the given value on the stack.
|
void |
push(String value) |
Generates the instruction to push the given value on the stack.
|
void |
push(org.objectweb.asm.Handle handle) |
Generates the instruction to push a handle on the stack.
|
void |
push(org.objectweb.asm.Type value) |
Generates the instruction to push the given value on the stack.
|
void |
putField(org.objectweb.asm.Type owner,
String name,
org.objectweb.asm.Type type) |
Generates the instruction to store the top stack value in a non static
field.
|
void |
putStatic(org.objectweb.asm.Type owner,
String name,
org.objectweb.asm.Type type) |
Generates the instruction to store the top stack value in a static field.
|
void |
ret(int local) |
Generates a RET instruction.
|
void |
returnValue() |
Generates the instruction to return the top stack value to the caller.
|
void |
storeArg(int arg) |
Generates the instruction to store the top stack value in the given
method argument.
|
void |
storeLocal(int local) |
save a value on the stack to a local var slot
|
void |
swap() |
Generates a SWAP instruction.
|
void |
swap(org.objectweb.asm.Type prev,
org.objectweb.asm.Type type) |
Generates the instructions to swap the top two stack values.
|
void |
tableSwitch(int[] keys,
org.objectweb.asm.commons.TableSwitchGenerator generator) |
Generates the instructions for a switch statement.
|
void |
tableSwitch(int[] keys,
org.objectweb.asm.commons.TableSwitchGenerator generator,
boolean useTable) |
Generates the instructions for a switch statement.
|
void |
throwException() |
Generates the instruction to throw an exception.
|
void |
throwException(org.objectweb.asm.Type type,
String msg) |
Generates the instructions to create and throw an exception.
|
void |
unbox(org.objectweb.asm.Type type) |
Generates the instructions to unbox the top stack value.
|
void |
visitFrame(int type,
int nLocal,
Object[] local,
int nStack,
Object[] stack) |
|
void |
visitMaxs(int maxStack,
int maxLocals) |
ensure we allow enough room for any extra locals on the stack
|
void |
visitVarInsn(int opcode,
int var) |
override this so we can see track which local var slots are in use and avoid overwriting them
|
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitIincInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTriggerClassName, lookup, visitLocalVariable
public static final int ADD
math
method.public static final int SUB
math
method.public static final int MUL
math
method.public static final int DIV
math
method.public static final int REM
math
method.public static final int NEG
math
method.public static final int SHL
math
method.public static final int SHR
math
method.public static final int USHR
math
method.public static final int AND
math
method.public static final int OR
math
method.public static final int XOR
math
method.public static final int EQ
ifCmp
method.public static final int NE
ifCmp
method.public static final int LT
ifCmp
method.public static final int GE
ifCmp
method.public static final int GT
ifCmp
method.public static final int LE
ifCmp
method.public RuleGeneratorAdapter(org.objectweb.asm.MethodVisitor mv, TransformContext transformContext, int access, String name, String desc, Rule rule)
RuleGeneratorAdapter
.mv
- the method visitor to which this adapter delegates calls.access
- the method's access flags (see Opcodes
).name
- the method's name.desc
- the method's descriptor (see Type
).transformContext
- the current transform contextrule
- the rule currently being injectedpublic void push(boolean value)
value
- the value to be pushed on the stack.public void push(int value)
value
- the value to be pushed on the stack.public void push(long value)
value
- the value to be pushed on the stack.public void push(float value)
value
- the value to be pushed on the stack.public void push(double value)
value
- the value to be pushed on the stack.public void push(String value)
value
- the value to be pushed on the stack. May be null.public void push(org.objectweb.asm.Type value)
value
- the value to be pushed on the stack.public void push(org.objectweb.asm.Handle handle)
handle
- the handle to be pushed on the stack.public void loadThis()
public void loadArg(int arg)
arg
- the index of a method argument.public void loadArgs(int arg, int count)
arg
- the index of the first method argument to be loaded.count
- the number of method arguments to be loaded.public void loadArgs()
public void loadArgArray()
public void storeArg(int arg)
arg
- the index of a method argument.public void arrayLoad(org.objectweb.asm.Type type)
type
- the type of the array element to be loaded.public void arrayStore(org.objectweb.asm.Type type)
type
- the type of the array element to be stored.public void pop()
public void pop2()
public void dup()
public void dup2()
public void dupX1()
public void dupX2()
public void dup2X1()
public void dup2X2()
public void swap()
public void swap(org.objectweb.asm.Type prev, org.objectweb.asm.Type type)
prev
- type of the top - 1 stack value.type
- type of the top stack value.public void math(int op, org.objectweb.asm.Type type)
op
- a mathematical or logical operation. Must be one of ADD, SUB,
MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR.type
- the type of the operand(s) for this operation.public void not()
public void iinc(int local, int amount)
local
- the local variable to be incremented.amount
- the amount by which the local variable must be incremented.public void cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
from
- the type of the top stack valueto
- the type into which this value must be cast.public void box(org.objectweb.asm.Type type)
type
- the type of the top stack value.public void unbox(org.objectweb.asm.Type type)
type
- the type of the top stack value.public org.objectweb.asm.Label newLabel()
Label
.Label
.public void mark(org.objectweb.asm.Label label)
label
- a label.public org.objectweb.asm.Label mark()
public void ifCmp(org.objectweb.asm.Type type, int mode, org.objectweb.asm.Label label)
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.public void ifICmp(int mode, org.objectweb.asm.Label label)
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.public void ifZCmp(int mode, org.objectweb.asm.Label label)
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.public void ifNull(org.objectweb.asm.Label label)
label
- where to jump if the condition is true.public void ifNonNull(org.objectweb.asm.Label label)
label
- where to jump if the condition is true.public void goTo(org.objectweb.asm.Label label)
label
- where to jump if the condition is true.public void ret(int local)
local
- a local variable identifier, as returned by
newLocal()
.public void tableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator)
keys
- the switch case keys.generator
- a generator to generate the code for the switch cases.public void tableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator, boolean useTable)
keys
- the switch case keys.generator
- a generator to generate the code for the switch cases.useTable
- true to use a TABLESWITCH instruction, or
false to use a LOOKUPSWITCH instruction.public void returnValue()
public void getStatic(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type type)
owner
- the class in which the field is defined.name
- the name of the field.type
- the type of the field.public void putStatic(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type type)
owner
- the class in which the field is defined.name
- the name of the field.type
- the type of the field.public void getField(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type type)
owner
- the class in which the field is defined.name
- the name of the field.type
- the type of the field.public void putField(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type type)
owner
- the class in which the field is defined.name
- the name of the field.type
- the type of the field.public void invokeVirtual(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)
owner
- the class in which the method is defined.method
- the method to be invoked.public void invokeConstructor(org.objectweb.asm.Type type, org.objectweb.asm.commons.Method method)
type
- the class in which the constructor is defined.method
- the constructor to be invoked.public void invokeStatic(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)
owner
- the class in which the method is defined.method
- the method to be invoked.public void invokeInterface(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)
owner
- the class in which the method is defined.method
- the method to be invoked.public void invokeDynamic(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs)
name
- the method's name.desc
- the method's descriptor (see Type
).bsm
- the bootstrap method.bsmArgs
- the bootstrap method constant arguments. Each argument must be
an Integer
, Float
, Long
,
Double
, String
, Type
or Handle
value. This method is allowed to modify the content of the
array so a caller should expect that this array may change.public void newInstance(org.objectweb.asm.Type type)
type
- the class of the object to be created.public void newArray(org.objectweb.asm.Type type)
type
- the type of the array elements.public void arrayLength()
public void throwException()
public void throwException(org.objectweb.asm.Type type, String msg)
type
- the class of the exception to be thrown.msg
- the detailed message of the exception.public void checkCast(org.objectweb.asm.Type type)
type
- a class or interface type.public void instanceOf(org.objectweb.asm.Type type)
type
- a class or interface type.public void monitorEnter()
public void monitorExit()
public void endMethod()
public void catchException(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Type exception)
start
- beginning of the exception handler's scope (inclusive).end
- end of the exception handler's scope (exclusive).exception
- internal name of the type of exceptions handled by the
handler.public void visitVarInsn(int opcode, int var)
visitVarInsn
in class org.objectweb.asm.MethodVisitor
opcode
- the bytecode operationvar
- local variable indexpublic int newLocal(org.objectweb.asm.Type valueType)
valueType
- the type of the value to be stored in the local slotpublic void popLocal(int local)
local
- the slot to be releasedpublic void loadLocal(int local)
local
- the slot to load frompublic void storeLocal(int local)
local
- the slot to save topublic org.objectweb.asm.Type getLocalType(int local)
public void visitMaxs(int maxStack, int maxLocals)
visitMaxs
in class org.objectweb.asm.MethodVisitor
maxStack
- the maximum stack depthmaxLocals
- the maximum local countCopyright © 2018. All rights reserved.