类 Frame<V extends Value>
java.lang.Object
cn.taketoday.bytecode.tree.analysis.Frame<V>
- 类型参数:
V- type of the Value used for the analysis.
A symbolic execution stack frame. A stack frame contains a set of local variable slots, and an
operand stack. Warning: long and double values are represented with two slots in local
variables, and with one slot in the operand stack.
- 作者:
- Eric Bruneton
-
字段概要
字段修饰符和类型字段说明private static final intThe maximum size of the operand stack of any method.private intThe maximum number of elements in the operand stack.private intThe number of local variables of this frame.private intThe number of elements in the operand stack.private VThe expected return type of the analyzed method, or null if the method returns void.private V[]The local variables and the operand stack of this frame. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidClears the operand stack of this frame.voidexecute(AbstractInsnNode insn, Interpreter<V> interpreter) Simulates the execution of the given instruction on this execution stack frame.private booleanexecuteDupX2(AbstractInsnNode insn, V value1, Interpreter<V> interpreter) private voidexecuteInvokeInsn(AbstractInsnNode insn, String methodDescriptor, Interpreter<V> interpreter) getLocal(int index) Returns the value of the given local variable.intReturns the maximum number of local variables of this frame.intReturns the maximum number of elements in the operand stack of this frame.getStack(int index) Returns the value of the given operand stack slot.intReturns the number of elements in the operand stack of this frame.Copies the state of the given frame into this frame.voidinitJumpTarget(int opcode, LabelNode target) Initializes a frame corresponding to the target or to the successor of a jump instruction.booleanMerges the given frame into this frame (case of a subroutine).booleanmerge(Frame<? extends V> frame, Interpreter<V> interpreter) Merges the given frame into this frame.pop()Pops a value from the operand stack of this frame.voidPushes a value into the operand stack of this frame.voidSets the value of the given local variable.voidSets the expected return type of the analyzed method.voidSets the value of the given stack slot.toString()Returns a string representation of this frame.
-
字段详细资料
-
MAX_STACK_SIZE
private static final int MAX_STACK_SIZEThe maximum size of the operand stack of any method.- 另请参阅:
-
returnValue
The expected return type of the analyzed method, or null if the method returns void. -
values
The local variables and the operand stack of this frame. The firstnumLocalselements correspond to the local variables. The followingnumStackelements correspond to the operand stack. Long and double values are represented with two elements in the local variables section, and with one element in the operand stack section. -
numLocals
private int numLocalsThe number of local variables of this frame. Long and double values are represented with two elements. -
numStack
private int numStackThe number of elements in the operand stack. Long and double values are represented with a single element. -
maxStack
private int maxStackThe maximum number of elements in the operand stack. Long and double values are represented with a single element.
-
-
构造器详细资料
-
Frame
public Frame(int numLocals, int maxStack) Constructs a new frame with the given size.- 参数:
numLocals- the number of local variables of the frame. Long and double values are represented with two elements.maxStack- the maximum number of elements in the operand stack, or -1 if there is no maximum value. Long and double values are represented with a single element.
-
Frame
Constructs a copy of the given Frame.- 参数:
frame- a frame.
-
-
方法详细资料
-
init
Copies the state of the given frame into this frame.- 参数:
frame- a frame.- 返回:
- this frame.
-
initJumpTarget
Initializes a frame corresponding to the target or to the successor of a jump instruction. This method is called byAnalyzer.analyze(String, MethodNode)while interpreting jump instructions. It is called once for each possible target of the jump instruction, and once for its successor instruction (except for GOTO and JSR), before the frame is merged with the existing frame at this location. The default implementation of this method does nothing.Overriding this method and changing the frame values allows implementing branch-sensitive analyses.
- 参数:
opcode- the opcode of the jump instruction. Can be IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL, IFNONNULL, TABLESWITCH or LOOKUPSWITCH.target- a target of the jump instruction this frame corresponds to, or null if this frame corresponds to the successor of the jump instruction (i.e. the next instruction in the instructions sequence).
-
setReturn
Sets the expected return type of the analyzed method.- 参数:
v- the expected return type of the analyzed method, or null if the method returns void.
-
getLocals
public int getLocals()Returns the maximum number of local variables of this frame. Long and double values are represented with two variables.- 返回:
- the maximum number of local variables of this frame.
-
getMaxStackSize
public int getMaxStackSize()Returns the maximum number of elements in the operand stack of this frame. Long and double values are represented with a single element.- 返回:
- the maximum number of elements in the operand stack of this frame.
-
getLocal
Returns the value of the given local variable. Long and double values are represented with two variables.- 参数:
index- a local variable index.- 返回:
- the value of the given local variable.
- 抛出:
IndexOutOfBoundsException- if the variable does not exist.
-
setLocal
Sets the value of the given local variable. Long and double values are represented with two variables.- 参数:
index- a local variable index.value- the new value of this local variable.- 抛出:
IndexOutOfBoundsException- if the variable does not exist.
-
getStackSize
public int getStackSize()Returns the number of elements in the operand stack of this frame. Long and double values are represented with a single element.- 返回:
- the number of elements in the operand stack of this frame.
-
getStack
Returns the value of the given operand stack slot.- 参数:
index- the index of an operand stack slot.- 返回:
- the value of the given operand stack slot.
- 抛出:
IndexOutOfBoundsException- if the operand stack slot does not exist.
-
setStack
Sets the value of the given stack slot.- 参数:
index- the index of an operand stack slot.value- the new value of the stack slot.- 抛出:
IndexOutOfBoundsException- if the stack slot does not exist.
-
clearStack
public void clearStack()Clears the operand stack of this frame. -
pop
Pops a value from the operand stack of this frame.- 返回:
- the value that has been popped from the stack.
- 抛出:
IndexOutOfBoundsException- if the operand stack is empty.
-
push
Pushes a value into the operand stack of this frame.- 参数:
value- the value that must be pushed into the stack.- 抛出:
IndexOutOfBoundsException- if the operand stack is full.
-
execute
Simulates the execution of the given instruction on this execution stack frame.- 参数:
insn- the instruction to execute.interpreter- the interpreter to use to compute values from other values.- 抛出:
AnalyzerException- if the instruction cannot be executed on this execution frame (e.g. a POP on an empty operand stack).
-
executeDupX2
private boolean executeDupX2(AbstractInsnNode insn, V value1, Interpreter<V> interpreter) throws AnalyzerException -
executeInvokeInsn
private void executeInvokeInsn(AbstractInsnNode insn, String methodDescriptor, Interpreter<V> interpreter) throws AnalyzerException -
merge
Merges the given frame into this frame.- 参数:
frame- a frame. This frame is left unchanged by this method.interpreter- the interpreter used to merge values.- 返回:
- true if this frame has been changed as a result of the merge operation, or false otherwise.
- 抛出:
AnalyzerException- if the frames have incompatible sizes.
-
merge
Merges the given frame into this frame (case of a subroutine). The operand stacks are not merged, and only the local variables that have not been used by the subroutine are merged.- 参数:
frame- a frame. This frame is left unchanged by this method.localsUsed- the local variables that are read or written by the subroutine. The i-th element is true if and only if the local variable at index i is read or written by the subroutine.- 返回:
- true if this frame has been changed as a result of the merge operation, or false otherwise.
-
toString
Returns a string representation of this frame.
-