|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.asm.MethodAdapter org.objectweb.fractal.julia.asm.InterceptorCodeAdapter
public abstract class InterceptorCodeAdapter
An abstract code adapter to ease the implementation of CodeGenerator
.
This code adapter can replace the return instructions it
visits with goto or jsr instructions, in order to add a post code block after
the original code of a method. This code adapter can also insert new local
variables before the original local variables (which are therefore shifted),
but after the actual parameters. This can be useful to use private local
variables in the interception code.
Field Summary | |
---|---|
static int |
EMPTY
Describes an empty post block. |
static int |
FINALLY
Describes a finally post block. |
protected Method |
m
The method for which this code adapter is used. |
protected int |
nbFormals
Size of the formal parameters of the method for which this code adapter is used. |
static int |
NORMAL
Describes a normal post code block. |
protected Label |
postBlockLabel
Beginning of the post code block added to the original code. |
protected int |
returnLocal
The inserted local variable used to store the result value. |
Fields inherited from class org.objectweb.asm.MethodAdapter |
---|
mv |
Constructor Summary | |
---|---|
InterceptorCodeAdapter(MethodVisitor cv,
Method m,
int newLocals,
int postBlockType)
Constructs a new InterceptorCodeAdapter . |
Method Summary | |
---|---|
protected void |
generateReturnCode()
Generates the code to return the result value stored in the returnLocal local variable. |
void |
visitIincInsn(int var,
int increment)
Shifts the original local variables to make room for the inserted ones. |
void |
visitInsn(int opcode)
Replaces returns with instructions to jump to the beginning of the post code block. |
void |
visitVarInsn(int opcode,
int var)
Shifts the original local variables to make room for the inserted ones. |
Methods inherited from class org.objectweb.asm.MethodAdapter |
---|
visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EMPTY
public static final int NORMAL
public static final int FINALLY
protected Method m
protected int nbFormals
protected int returnLocal
protected Label postBlockLabel
Constructor Detail |
---|
public InterceptorCodeAdapter(MethodVisitor cv, Method m, int newLocals, int postBlockType)
InterceptorCodeAdapter
.
cv
- the code visitor to which this adapter must delegate calls.m
- the method for which this code adapter is used.newLocals
- the number of new local variables that must be inserted
in the original method code. This number does not include the local
variable used to store the result value, which is automatically
inserted. The inserted local variables are those between the nbFormals
index, inclusive, and the nbFormals
+ newLocals index, exclusive.postBlockType
- the type of the post code block that will be added
after the original code, i.e., either EMPTY
, NORMAL
or FINALLY
.Method Detail |
---|
public void visitInsn(int opcode)
xSTORE returnLocal GOTO postCodeLabelIf the post code block is a finally block, they are replaced by sequences of the following form:
xSTORE returnLocal JSR postCodeLabel xLOAD returnLocal xRETURN
visitInsn
in interface MethodVisitor
visitInsn
in class MethodAdapter
opcode
- the opcode of the visited instruction.public void visitVarInsn(int opcode, int var)
visitVarInsn
in interface MethodVisitor
visitVarInsn
in class MethodAdapter
opcode
- the opcode of the visited instruction.var
- a local variable index.public void visitIincInsn(int var, int increment)
visitIincInsn
in interface MethodVisitor
visitIincInsn
in class MethodAdapter
var
- a local variable index.increment
- an increment value.protected void generateReturnCode()
returnLocal
local variable. More precisely, generates
a sequence of the following form:
xLOAD returnLocal xRETURN
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |