public StackState updateMerged(int pos, StackEntry frame) { List<StackEntry> newContents = new ArrayList<StackEntry>(contents); newContents.remove(pos); newContents.add(pos, frame); return new StackState(newContents, constPool); }
/** * marks the value in potition initializedValueStackPosition as initialized. This also pops this value and everything above * it */ public StackFrame constructorCall(int initializedValueStackPosition) { StackEntry entry = stackState.getContents().get(stackState.getContents().size() - 1 - initializedValueStackPosition); StackState ns = stackState.constructorCall(initializedValueStackPosition, entry); LocalVariableState locals = localVariableState.constructorCall(entry); return new StackFrame(ns, locals, StackFrameType.FULL_FRAME); }
public StackFrame dup() { StackState ns = stackState.dup(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public void assertNotWideOnStack(int position, String message) { if (getStack().size() <= position) { throw new InvalidBytecodeException(message + " Stack State: " + getStack().toString()); } int index = getStack().getContents().size() - 1 - position; StackEntryType stype = getStack().getContents().get(index).getType(); if (stype == StackEntryType.TOP) { throw new InvalidBytecodeException(message + " Stack State: " + getStack().toString()); } }
/** * determins the type of stack frame this is when no local variables have changed */ private StackFrameType typeNoLocalChange(StackState ns) { int size = ns.getContents().size(); if (size == 0) { return StackFrameType.SAME_FRAME; } else if (size == 1) { return StackFrameType.SAME_LOCALS_1_STACK; } return StackFrameType.FULL_FRAME; }
/** * pop a non-wide type from the top of the stack */ public StackState pop(int no) { if (no == 0) { return this; } if (contents.size() < no) { throw new InvalidBytecodeException("cannot pop" + no + ", only " + contents.size() + " on stack " + toString()); } StackEntry type = contents.get(contents.size() - no); if (type.getType() == StackEntryType.TOP) { throw new InvalidBytecodeException("Pop" + no + " would split wide type " + toString()); } return new StackState(contents.subList(0, contents.size() - no), constPool); }
/** * pushes a null type onto the stack * * @return */ public StackFrame aconstNull() { StackState ns = stackState.aconstNull(); return new StackFrame(ns, localVariableState, typeNoLocalChange(ns)); }
public StackFrame dup2X1() { StackState ns = stackState.dup2X1(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dup2X2() { StackState ns = stackState.dup2X2(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dupX1() { StackState ns = stackState.dupX1(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dup2() { StackState ns = stackState.dup2(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dupX2() { StackState ns = stackState.dupX2(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public void assertNotWideOnStack(int position, String message) { if (getStack().size() <= position) { throw new InvalidBytecodeException(message + " Stack State: " + getStack().toString()); } int index = getStack().getContents().size() - 1 - position; StackEntryType stype = getStack().getContents().get(index).getType(); if (stype == StackEntryType.TOP) { throw new InvalidBytecodeException(message + " Stack State: " + getStack().toString()); } }
/** * determins the type of stack frame this is when no local variables have changed */ private StackFrameType typeNoLocalChange(StackState ns) { int size = ns.getContents().size(); if (size == 0) { return StackFrameType.SAME_FRAME; } else if (size == 1) { return StackFrameType.SAME_LOCALS_1_STACK; } return StackFrameType.FULL_FRAME; }
/** * pop a non-wide type from the top of the stack */ public StackState pop(int no) { if (no == 0) { return this; } if (contents.size() < no) { throw new InvalidBytecodeException("cannot pop" + no + ", only " + contents.size() + " on stack " + toString()); } StackEntry type = contents.get(contents.size() - no); if (type.getType() == StackEntryType.TOP) { throw new InvalidBytecodeException("Pop" + no + " would split wide type " + toString()); } return new StackState(contents.subList(0, contents.size() - no), constPool); }
/** * pushes a null type onto the stack * * @return */ public StackFrame aconstNull() { StackState ns = stackState.aconstNull(); return new StackFrame(ns, localVariableState, typeNoLocalChange(ns)); }
public StackFrame dup2X1() { StackState ns = stackState.dup2X1(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dup2X2() { StackState ns = stackState.dup2X2(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dupX1() { StackState ns = stackState.dupX1(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }
public StackFrame dup2() { StackState ns = stackState.dup2(); return new StackFrame(ns, localVariableState, StackFrameType.FULL_FRAME); }