cn.wensiqun.asmsupport.asm
类 InstructionHelper

java.lang.Object
  继承者 cn.wensiqun.asmsupport.asm.InstructionHelper
直接已知子类:
CommonInstructionHelper

public abstract class InstructionHelper
extends Object

字节码操作的帮助类。 这里只需要操作栈。而本地变量的操作已经由LcoalVariables和ScopeLogicVariable封装完成了。

作者:
温斯群(Joe Wen)

字段摘要
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.
protected  LocalVariables locals
           
static int LT
          Constant for the ifCmp method.
static int NE
          Constant for the ifCmp method.
 
构造方法摘要
InstructionHelper(org.objectweb.asm.MethodVisitor mv, Method method)
           
 
方法摘要
 void add(org.objectweb.asm.Type type)
          generated the instruction to add top two stack value
 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 bitAnd(org.objectweb.asm.Type type)
           
 void bitOr(org.objectweb.asm.Type type)
           
 void bitXor(org.objectweb.asm.Type type)
           
 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 checkCast(org.objectweb.asm.Type type)
          Generates the instruction to check that the top stack value is of the given type.
 void declarationVariable(String name, String desc, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)
           
 void div(org.objectweb.asm.Type type)
          generated the instruction to mul top two stack value
 void dup()
          Generates a DUP instruction.
 void dupX1()
          Generates a DUP_X1 instruction.
 void dupX2()
          Generates a DUP_X2 instruction.
 void endMethod()
           
static org.objectweb.asm.Type getBoxedType(org.objectweb.asm.Type type)
           
 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.
 Method getMethod()
           
 StackLocalMethodVisitor getMv()
           
 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.
static org.objectweb.asm.Type getUnBoxedType(org.objectweb.asm.Type type)
           
 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 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 inverts(org.objectweb.asm.Type type)
           
 void invokeConstructor(org.objectweb.asm.Type ownerType, org.objectweb.asm.Type[] argTypes)
          Generates the instruction to invoke a constructor.
 void invokeInterface(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type returnType, org.objectweb.asm.Type[] arguTypes)
          Generates the instruction to invoke an interface method.
 void invokeStatic(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type returnType, org.objectweb.asm.Type[] arguTypes)
          Generates the instruction to invoke a static method.
 void invokeSuperMethod(org.objectweb.asm.Type ownerType, String name, org.objectweb.asm.Type returnType, org.objectweb.asm.Type[] argTypes)
          调用父类方法
 void invokeVirtual(org.objectweb.asm.Type owner, String name, org.objectweb.asm.Type returnType, org.objectweb.asm.Type[] arguTypes)
          Generates the instruction to invoke a normal method.
 void leftShift(org.objectweb.asm.Type type)
           
 void loadInsn(org.objectweb.asm.Type type, int index)
          Generates the instruction to push a local variable on the stack.
 void loadThis()
          Generates the instruction to load 'this' on the stack.
 void mark(org.objectweb.asm.Label label)
          Marks the current code position with the given label.
 void maxs(int stack, int locals)
           
 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 mul(org.objectweb.asm.Type type)
          generated the instruction to mul top two stack value
 void multiANewArrayInsn(org.objectweb.asm.Type type, int dims)
           
 void neg(org.objectweb.asm.Type type)
           
 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.
 void nop()
          don't do any thing
 void pop()
           
 void pop(int time)
           
 void push(boolean value)
          Generates the instruction to push the given value on the stack.
 void push(byte value)
          Generates the instruction to push the given value on the stack.
 void push(char 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(short 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.Type type)
          push null
 void pushClass(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 rem(org.objectweb.asm.Type type)
          generated the instruction to rem top two stack value
 void returnInsn()
           
 void returnInsn(org.objectweb.asm.Type type)
           
 void rightShift(org.objectweb.asm.Type type)
           
 void setMv(StackLocalMethodVisitor mv)
           
 void storeInsn(LocalVariable var)
          Generates the instruction to store the top stack value in a local variable.
 void sub(org.objectweb.asm.Type type)
          generated the instruction to sub top two stack value
 void swap()
          Generates a SWAP instruction.
 void throwException()
          Generates the instruction to throw an exception.
 void tryCatchBlock(org.objectweb.asm.Label tryStart, org.objectweb.asm.Label tryEnd, org.objectweb.asm.Label catchStart, org.objectweb.asm.Type exceptionType)
           
 void unbox(org.objectweb.asm.Type type)
          Generates the instructions to unbox the top stack value.
 void unsignedRightShift(org.objectweb.asm.Type type)
           
 void valueOf(org.objectweb.asm.Type type)
          Generates the instructions to box the top stack value using Java 5's valueOf() method.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

locals

protected LocalVariables locals

EQ

public static final int EQ
Constant for the ifCmp method.

另请参见:
常量字段值

NE

public static final int NE
Constant for the ifCmp method.

另请参见:
常量字段值

LT

public static final int LT
Constant for the ifCmp method.

另请参见:
常量字段值

GE

public static final int GE
Constant for the ifCmp method.

另请参见:
常量字段值

GT

public static final int GT
Constant for the ifCmp method.

另请参见:
常量字段值

LE

public static final int LE
Constant for the ifCmp method.

另请参见:
常量字段值
构造方法详细信息

InstructionHelper

public InstructionHelper(org.objectweb.asm.MethodVisitor mv,
                         Method method)
方法详细信息

getMethod

public Method getMethod()

getMv

public StackLocalMethodVisitor getMv()

setMv

public void setMv(StackLocalMethodVisitor mv)

push

public void push(boolean value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

push

public void push(int value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

push

public void push(byte value)
Generates the instruction to push the given value on the stack.

参数:
b -

push

public void push(short value)
Generates the instruction to push the given value on the stack.

参数:
b -

push

public void push(char value)
Generates the instruction to push the given value on the stack.

参数:
b -

push

public void push(long value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

push

public void push(float value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

push

public void push(double value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

push

public void push(String value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack. May be null.

push

public void push(org.objectweb.asm.Type type)
push null


pushClass

public void pushClass(org.objectweb.asm.Type value)
Generates the instruction to push the given value on the stack.

参数:
value - the value to be pushed on the stack.

cast

public 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.

参数:
from - the type of the top stack value
to - the type into which this value must be cast.

checkCast

public void checkCast(org.objectweb.asm.Type type)
Generates the instruction to check that the top stack value is of the given type.

参数:
type - a class or interface type.

getBoxedType

public static org.objectweb.asm.Type getBoxedType(org.objectweb.asm.Type type)

getUnBoxedType

public static org.objectweb.asm.Type getUnBoxedType(org.objectweb.asm.Type type)

box

public void box(org.objectweb.asm.Type type)
Generates the instructions to box the top stack value. This value is replaced by its boxed equivalent on top of the stack.

参数:
type - the type of the top stack value.

valueOf

public void valueOf(org.objectweb.asm.Type type)
Generates the instructions to box the top stack value using Java 5's valueOf() method. This value is replaced by its boxed equivalent on top of the stack.

参数:
type - the type of the top stack value.

unbox

public void unbox(org.objectweb.asm.Type type)
Generates the instructions to unbox the top stack value. This value is replaced by its unboxed equivalent on top of the stack.

参数:
type - the type of the top stack value.

mark

public void mark(org.objectweb.asm.Label label)
Marks the current code position with the given label.

参数:
label - a label.

nop

public void nop()
don't do any thing


loadInsn

public void loadInsn(org.objectweb.asm.Type type,
                     int index)
Generates the instruction to push a local variable on the stack.

参数:
type - the type of the local variable to be loaded.
index - an index in the frame's local variables array.

loadThis

public void loadThis()
Generates the instruction to load 'this' on the stack.


storeInsn

public void storeInsn(LocalVariable var)
Generates the instruction to store the top stack value in a local variable.

参数:
type - the type of the local variable to be stored.
index - an index in the frame's local variables array.

swap

public void swap()
Generates a SWAP instruction.


dup

public void dup()
Generates a DUP instruction.


dupX1

public void dupX1()
Generates a DUP_X1 instruction.


dupX2

public void dupX2()
Generates a DUP_X2 instruction.


newInstance

public void newInstance(org.objectweb.asm.Type type)
Generates the instruction to create a new object.

参数:
type - the class of the object to be created.

invokeVirtual

public void invokeVirtual(org.objectweb.asm.Type owner,
                          String name,
                          org.objectweb.asm.Type returnType,
                          org.objectweb.asm.Type[] arguTypes)
Generates the instruction to invoke a normal method.

参数:
owner -
name -
returnType -
arguTypes -

invokeConstructor

public void invokeConstructor(org.objectweb.asm.Type ownerType,
                              org.objectweb.asm.Type[] argTypes)
Generates the instruction to invoke a constructor.

参数:
ownerType - the class in which the constructor is defined.
method - the constructor to be invoked.

invokeSuperMethod

public void invokeSuperMethod(org.objectweb.asm.Type ownerType,
                              String name,
                              org.objectweb.asm.Type returnType,
                              org.objectweb.asm.Type[] argTypes)
调用父类方法

参数:
ownerType -
name -
returnType -
argTypes -

invokeStatic

public void invokeStatic(org.objectweb.asm.Type owner,
                         String name,
                         org.objectweb.asm.Type returnType,
                         org.objectweb.asm.Type[] arguTypes)
Generates the instruction to invoke a static method.

参数:
owner -
name -
returnType -
arguTypes -

invokeInterface

public void invokeInterface(org.objectweb.asm.Type owner,
                            String name,
                            org.objectweb.asm.Type returnType,
                            org.objectweb.asm.Type[] arguTypes)
Generates the instruction to invoke an interface method.

参数:
owner -
name -
returnType -
arguTypes -

getStatic

public 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.

参数:
owner - the class in which the field is defined.
name - the name of the field.
type - the type of the field.

putStatic

public 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.

参数:
owner - the class in which the field is defined.
name - the name of the field.
type - the type of the field.

getField

public 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.

参数:
owner - the class in which the field is defined.
name - the name of the field.
type - the type of the field.

putField

public 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.

参数:
owner - the class in which the field is defined.
name - the name of the field.
type - the type of the field.

add

public void add(org.objectweb.asm.Type type)
generated the instruction to add top two stack value

参数:
type - which add type

sub

public void sub(org.objectweb.asm.Type type)
generated the instruction to sub top two stack value

参数:
type - which add type

mul

public void mul(org.objectweb.asm.Type type)
generated the instruction to mul top two stack value

参数:
type - which add type

div

public void div(org.objectweb.asm.Type type)
generated the instruction to mul top two stack value

参数:
type - which add type

rem

public void rem(org.objectweb.asm.Type type)
generated the instruction to rem top two stack value

参数:
type -

neg

public void neg(org.objectweb.asm.Type type)
参数:
type -

iinc

public void iinc(int local,
                 int amount)
Generates the instruction to increment the given local variable.

参数:
local - the local variable to be incremented.
amount - the amount by which the local variable must be incremented.

inverts

public void inverts(org.objectweb.asm.Type type)
参数:
type -

bitAnd

public void bitAnd(org.objectweb.asm.Type type)

bitOr

public void bitOr(org.objectweb.asm.Type type)

bitXor

public void bitXor(org.objectweb.asm.Type type)

leftShift

public void leftShift(org.objectweb.asm.Type type)

rightShift

public void rightShift(org.objectweb.asm.Type type)

unsignedRightShift

public void unsignedRightShift(org.objectweb.asm.Type type)

newArray

public void newArray(org.objectweb.asm.Type type)
Generates the instruction to create a new array.

参数:
type - the type of the array elements.

multiANewArrayInsn

public void multiANewArrayInsn(org.objectweb.asm.Type type,
                               int dims)
参数:
type -
dims -

arrayLoad

public void arrayLoad(org.objectweb.asm.Type type)
Generates the instruction to load an element from an array.

参数:
type - the type of the array element to be loaded.

arrayStore

public void arrayStore(org.objectweb.asm.Type type)
Generates the instruction to store an element in an array.

参数:
type - the type of the array element to be stored.

arrayLength

public void arrayLength()
Generates the instruction to compute the length of an array.


ifCmp

public 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.

参数:
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.

ifZCmp

public 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.

参数:
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.

ifNull

public void ifNull(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label if the top stack value is null.

参数:
label - where to jump if the condition is true.

ifNonNull

public void ifNonNull(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label if the top stack value is not null.

参数:
label - where to jump if the condition is true.

goTo

public void goTo(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label.

参数:
label - where to jump if the condition is true.

instanceOf

public void instanceOf(org.objectweb.asm.Type type)
Generates the instruction to test if the top stack value is of the given type.

参数:
type - a class or interface type.

tryCatchBlock

public void tryCatchBlock(org.objectweb.asm.Label tryStart,
                          org.objectweb.asm.Label tryEnd,
                          org.objectweb.asm.Label catchStart,
                          org.objectweb.asm.Type exceptionType)

throwException

public void throwException()
Generates the instruction to throw an exception.


monitorEnter

public void monitorEnter()
Generates the instruction to get the monitor of the top stack value.


monitorExit

public void monitorExit()
Generates the instruction to release the monitor of the top stack value.


pop

public void pop()

pop

public void pop(int time)

returnInsn

public void returnInsn()

returnInsn

public void returnInsn(org.objectweb.asm.Type type)

declarationVariable

public void declarationVariable(String name,
                                String desc,
                                String signature,
                                org.objectweb.asm.Label start,
                                org.objectweb.asm.Label end,
                                int index)

maxs

public void maxs(int stack,
                 int locals)

endMethod

public void endMethod()


Copyright © 2013. All Rights Reserved.