V
- type of the Value used for the analysis.public class Frame<V extends Value> extends Object
Constructor and Description |
---|
Frame(Frame<? extends V> frame)
Constructs a copy of the given Frame.
|
Frame(int numLocals,
int numStack)
Constructs a new frame with the given size.
|
Modifier and Type | Method and Description |
---|---|
void |
clearStack()
Clears the operand stack of this frame.
|
void |
execute(AbstractInsnNode insn,
Interpreter<V> interpreter)
Simulates the execution of the given instruction on this execution stack frame.
|
V |
getLocal(int index)
Returns the value of the given local variable.
|
int |
getLocals()
Returns the maximum number of local variables of this frame.
|
int |
getMaxStackSize()
Returns the maximum stack size of this frame.
|
V |
getStack(int index)
Returns the value of the given operand stack slot.
|
int |
getStackSize()
Returns the number of values in the operand stack of this frame.
|
Frame<V> |
init(Frame<? extends V> frame)
Copies the state of the given frame into this frame.
|
void |
initJumpTarget(int opcode,
LabelNode target)
Initializes a frame corresponding to the target or to the successor of a jump instruction.
|
boolean |
merge(Frame<? extends V> frame,
boolean[] localsUsed)
Merges the given frame into this frame (case of a subroutine).
|
boolean |
merge(Frame<? extends V> frame,
Interpreter<V> interpreter)
Merges the given frame into this frame.
|
V |
pop()
Pops a value from the operand stack of this frame.
|
void |
push(V value)
Pushes a value into the operand stack of this frame.
|
void |
setLocal(int index,
V value)
Sets the value of the given local variable.
|
void |
setReturn(V v)
Sets the expected return type of the analyzed method.
|
void |
setStack(int index,
V value)
Sets the value of the given stack slot.
|
String |
toString()
Returns a string representation of this frame.
|
public Frame(int numLocals, int numStack)
numLocals
- the maximum number of local variables of the frame.numStack
- the maximum stack size of the frame.public Frame<V> init(Frame<? extends V> frame)
frame
- a frame.public void initJumpTarget(int opcode, LabelNode target)
Analyzer.analyze(String, org.objectweb.asm.tree.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).public void setReturn(V v)
v
- the expected return type of the analyzed method, or null if the method
returns void.public int getLocals()
public int getMaxStackSize()
public V getLocal(int index)
index
- a local variable index.IndexOutOfBoundsException
- if the variable does not exist.public void setLocal(int index, V value)
index
- a local variable index.value
- the new value of this local variable.IndexOutOfBoundsException
- if the variable does not exist.public int getStackSize()
public V getStack(int index)
index
- the index of an operand stack slot.IndexOutOfBoundsException
- if the operand stack slot does not exist.public void setStack(int index, V value) throws IndexOutOfBoundsException
index
- the index of an operand stack slot.value
- the new value of the stack slot.IndexOutOfBoundsException
- if the stack slot does not exist.public void clearStack()
public V pop()
IndexOutOfBoundsException
- if the operand stack is empty.public void push(V value)
value
- the value that must be pushed into the stack.IndexOutOfBoundsException
- if the operand stack is full.public void execute(AbstractInsnNode insn, Interpreter<V> interpreter) throws AnalyzerException
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).public boolean merge(Frame<? extends V> frame, Interpreter<V> interpreter) throws AnalyzerException
frame
- a frame. This frame is left unchanged by this method.interpreter
- the interpreter used to merge values.AnalyzerException
- if the frames have incompatible sizes.public boolean merge(Frame<? extends V> frame, boolean[] localsUsed)
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.Copyright © 2024. All rights reserved.