From c47bb9a9fe62bbce641888b8fb4d853c72e81a20 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 11 Jun 2018 10:52:38 +1000 Subject: [PATCH] Allow setting stack values in analysis frames Adds a method `setStack` to analysis.Frame which allows setting the dataflow value of a stack slot. Could be 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. --- .../org/objectweb/asm/tree/analysis/Frame.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Frame.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Frame.java index a3dd6c86..63987e4b 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Frame.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Frame.java @@ -179,6 +179,20 @@ public V getStack(final int index) { return values[nLocals + index]; } + /** + * Sets the value of the given stack slot. + * + * @param i + * the index of an operand stack slot. + * @param value + * the new value of the stack slot. + * @throws IndexOutOfBoundsException + * if the stack slot does not exist. + */ + public void setStack(final int i, final V value) throws IndexOutOfBoundsException { + values[i + nLocals] = value; + } + /** Clears the operand stack of this frame. */ public void clearStack() { nStack = 0;