Skip to content

Commit eb6050e

Browse files
lrytzretronym
authored andcommitted
[asm-cherry-pick] Allow setting stack values in analysis frames
Adds a method `setStack` to analysis.Frame which allows setting the dataflow value of a stack slot. Used in nullness analysis. After, for example, an instance call, aliases of the receiver can be set to NotNull, both in locals and on the stack.
1 parent 6dfab19 commit eb6050e

File tree

1 file changed

+15
-1
lines changed
  • src/main/java/scala/tools/asm/tree/analysis

1 file changed

+15
-1
lines changed

Diff for: src/main/java/scala/tools/asm/tree/analysis/Frame.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,21 @@ public V getStack(final int index) {
179179
return values[nLocals + index];
180180
}
181181

182-
/** Clears the operand stack of this frame. */
182+
/**
183+
* Sets the value of the given stack slot.
184+
*
185+
* @param i
186+
* the index of an operand stack slot.
187+
* @param value
188+
* the new value of the stack slot.
189+
* @throws IndexOutOfBoundsException
190+
* if the stack slot does not exist.
191+
*/
192+
public void setStack(final int i, final V value) throws IndexOutOfBoundsException {
193+
values[i + nLocals] = value;
194+
}
195+
196+
/** Clears the operand stack of this frame. */
183197
public void clearStack() {
184198
nStack = 0;
185199
}

0 commit comments

Comments
 (0)