/** * Get a the location in the frame of a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public int getStackLocation(int loc) throws DataflowAnalysisException { int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } return slotList.size() - (loc + 1); }
/** * Get the values on the top of the Java operand stack. The top stack item * is placed at the end of the array, so that to restore the values to the * stack, you would push them in the order they appear in the array. */ public void getTopStackWords(ValueType[] valueList) throws DataflowAnalysisException { int stackDepth = getStackDepth(); if (valueList.length > stackDepth) { throw new DataflowAnalysisException("not enough values on stack"); } int numSlots = slotList.size(); for (int i = numSlots - valueList.length, j = 0; i < numSlots; ++i, ++j) { valueList[j] = slotList.get(i); } }
if (frame.getStackDepth() < numWordsConsumed) { try { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain in " + frame + " while processing " + ins); } catch (Exception e) { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain while processing " + ins);
/** * Get a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public ValueType getStackValue(int loc) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing TOP or BOTTOM frame!"); } int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } if (loc < 0) { throw new DataflowAnalysisException("can't get position " + loc + " of stack"); } int pos = slotList.size() - (loc + 1); return slotList.get(pos); }
/** * Get the slot the object instance referred to by given instruction is * located in. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the method * @return stack slot the object instance is in * @throws DataflowAnalysisException */ public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing invalid frame at " + ins); } int numConsumed = ins.consumeStack(cpg); if (numConsumed == Const.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } if (numConsumed > getStackDepth()) { throw new DataflowAnalysisException("Stack underflow " + ins); } return getNumSlots() - numConsumed; }
/** * Get a the location in the frame of a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public int getStackLocation(int loc) throws DataflowAnalysisException { int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } return slotList.size() - (loc + 1); }
/** * Get the values on the top of the Java operand stack. The top stack item * is placed at the end of the array, so that to restore the values to the * stack, you would push them in the order they appear in the array. */ public void getTopStackWords(ValueType[] valueList) throws DataflowAnalysisException { int stackDepth = getStackDepth(); if (valueList.length > stackDepth) { throw new DataflowAnalysisException("not enough values on stack"); } int numSlots = slotList.size(); for (int i = numSlots - valueList.length, j = 0; i < numSlots; ++i, ++j) { valueList[j] = slotList.get(i); } }
if (frame.getStackDepth() < numWordsConsumed) { try { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain in " + frame + " while processing " + ins); } catch (Exception e) { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain while processing " + ins);
/** * Get a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public ValueType getStackValue(int loc) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing TOP or BOTTOM frame!"); } int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } if (loc < 0) { throw new DataflowAnalysisException("can't get position " + loc + " of stack"); } int pos = slotList.size() - (loc + 1); return slotList.get(pos); }
/** * Get the slot the object instance referred to by given instruction is * located in. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the method * @return stack slot the object instance is in * @throws DataflowAnalysisException */ public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing invalid frame at " + ins); } int numConsumed = ins.consumeStack(cpg); if (numConsumed == Constants.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } if (numConsumed > getStackDepth()) { throw new DataflowAnalysisException("Stack underflow " + ins); } return getNumSlots() - numConsumed; }