/** * Makes and returns a mutable copy of this instance. * * @return {@code non-null;} the copy */ public ExecutionStack copy() { ExecutionStack result = new ExecutionStack(stack.length); System.arraycopy(stack, 0, result.stack, 0, stack.length); result.stackPtr = stackPtr; return result; }
/** * Annotates (adds context to) the given exception with information * about this frame. * * @param ex {@code non-null;} the exception to annotate */ public void annotate(ExceptionWithContext ex) { locals.annotate(ex); stack.annotate(ex); } }
/** * Makes a new frame for an exception handler block invoked from this * frame. * * @param exceptionClass exception that the handler block will handle * @return new frame */ public Frame makeExceptionHandlerStartFrame(CstType exceptionClass) { ExecutionStack newStack = getStack().copy(); newStack.clear(); newStack.push(exceptionClass); return new Frame(getLocals(), newStack, subroutines); }
/** * Pops the top element off of the stack. * * @return {@code non-null;} the type formerly on the top of the stack * @throws SimException thrown if the stack is empty */ public TypeBearer pop() { throwIfImmutable(); TypeBearer result = peek(0); stack[stackPtr - 1] = null; local[stackPtr - 1] = false; stackPtr -= result.getType().getCategory(); return result; }
int sz = stack1.size(); ExecutionStack result = null; if (stack2.size() != sz) { throw new SimException("mismatched stack depths"); TypeBearer tb1 = stack1.peek(i); TypeBearer tb2 = stack2.peek(i); TypeBearer resultType = mergeType(tb1, tb2); if (resultType != tb1) { result = stack1.copy(); tb2); } else { result.change(i, resultType); result.setImmutable(); return result;
checkType = frame.getStack().peekType(0); Type peekType = frame.getStack().peekType(0); if (peekType.isCategory2()) { throw illegalTos(); Type arrayType = frame.getStack().peekType(0); if (!arrayType.isArrayOrKnownNull()) { fail("type mismatch: expected array type but encountered " + Type foundArrayType = frame.getStack().peekType(1); Type requiredArrayType = requiredArrayTypeFor(type, foundArrayType); Type foundArrayType = stack.peekType(peekDepth); boolean foundArrayLocal = stack.peekLocal(peekDepth); if (stack.peekType(0).isCategory2()) { } else if (stack.peekType(1).isCategory1()) { Type peekType = frame.getStack().peekType(0); if (!(stack.peekType(0).isCategory1() && stack.peekType(1).isCategory1())) { throw illegalTos(); if (stack.peekType(0).isCategory2()) { throw illegalTos();
/** * Merges two frames. If the merged result is the same as this frame, * then this instance is returned. * * @param other {@code non-null;} another frame * @return {@code non-null;} the result of merging the two frames */ public Frame mergeWith(Frame other) { LocalsArray resultLocals; ExecutionStack resultStack; IntList resultSubroutines; resultLocals = getLocals().merge(other.getLocals()); resultStack = getStack().merge(other.getStack()); resultSubroutines = mergeSubroutineLists(other.subroutines); resultLocals = adjustLocalsForSubroutines( resultLocals, resultSubroutines); if ((resultLocals == getLocals()) && (resultStack == getStack()) && subroutines == resultSubroutines) { return this; } return new Frame(resultLocals, resultStack, resultSubroutines); }
/** * Makes and returns a mutable copy of this instance. The copy * contains copies of the locals and stack (that is, it doesn't * share them with the original). * * @return {@code non-null;} the copy */ public Frame copy() { return new Frame(locals.copy(), stack.copy(), subroutines); }
/** * Replaces all the occurrences of the given uninitialized type in * this frame with its initialized equivalent. * * @param type {@code non-null;} type to replace */ public void makeInitialized(Type type) { locals.makeInitialized(type); stack.makeInitialized(type); }
/** * Peeks at the {@code n}th element down from the top of the * stack, returning the type per se, as opposed to the * <i>type-bearer</i>. This method is just a convenient shorthand * for {@code peek(n).getType()}. * * @see #peek */ public Type peekType(int n) { return peek(n).getType(); }
/** {@inheritDoc} */ public final void popArgs(Frame frame, int count) { ExecutionStack stack = frame.getStack(); clearArgs(); if (count > args.length) { // Grow args, and add a little extra room to grow even more. args = new TypeBearer[count + 10]; } for (int i = count - 1; i >= 0; i--) { args[i] = stack.pop(); } argCount = count; }
checkType = frame.getStack().peekType(0); Type peekType = frame.getStack().peekType(0); if (peekType.isCategory2()) { throw illegalTos(); Type arrayType = frame.getStack().peekType(0); if (!arrayType.isArrayOrKnownNull()) { throw new SimException("type mismatch: expected " + Type foundArrayType = frame.getStack().peekType(1); Type requireArrayType; frame.getStack().peekType(type.isCategory1() ? 2 : 3); Type requireArrayType; if (stack.peekType(0).isCategory2()) { } else if (stack.peekType(1).isCategory1()) { Type peekType = frame.getStack().peekType(0); if (! (stack.peekType(0).isCategory1() && stack.peekType(1).isCategory1())) { throw illegalTos(); if (stack.peekType(0).isCategory2()) { throw illegalTos();
int sz = stack1.size(); ExecutionStack result = null; if (stack2.size() != sz) { throw new SimException("mismatched stack depths"); TypeBearer tb1 = stack1.peek(i); TypeBearer tb2 = stack2.peek(i); TypeBearer resultType = mergeType(tb1, tb2); if (resultType != tb1) { result = stack1.copy(); tb2); } else { result.change(i, resultType); result.setImmutable(); return result;
/** * Pops the top element off of the stack. * * @return {@code non-null;} the type formerly on the top of the stack * @throws SimException thrown if the stack is empty */ public TypeBearer pop() { throwIfImmutable(); TypeBearer result = peek(0); stack[stackPtr - 1] = null; stackPtr -= result.getType().getCategory(); return result; }
checkType = frame.getStack().peekType(0); Type peekType = frame.getStack().peekType(0); if (peekType.isCategory2()) { throw illegalTos(); Type arrayType = frame.getStack().peekType(0); if (!arrayType.isArrayOrKnownNull()) { throw new SimException("type mismatch: expected " + Type foundArrayType = frame.getStack().peekType(1); Type requiredArrayType = requiredArrayTypeFor(type, foundArrayType); Type foundArrayType = stack.peekType(peekDepth); boolean foundArrayLocal = stack.peekLocal(peekDepth); if (stack.peekType(0).isCategory2()) { } else if (stack.peekType(1).isCategory1()) { Type peekType = frame.getStack().peekType(0); if (!(stack.peekType(0).isCategory1() && stack.peekType(1).isCategory1())) { throw illegalTos(); if (stack.peekType(0).isCategory2()) { throw illegalTos();
/** * Merges two frames. If the merged result is the same as this frame, * then this instance is returned. * * @param other {@code non-null;} another frame * @return {@code non-null;} the result of merging the two frames */ public Frame mergeWith(Frame other) { LocalsArray resultLocals; ExecutionStack resultStack; IntList resultSubroutines; resultLocals = getLocals().merge(other.getLocals()); resultStack = getStack().merge(other.getStack()); resultSubroutines = mergeSubroutineLists(other.subroutines); resultLocals = adjustLocalsForSubroutines( resultLocals, resultSubroutines); if ((resultLocals == getLocals()) && (resultStack == getStack()) && subroutines == resultSubroutines) { return this; } return new Frame(resultLocals, resultStack, resultSubroutines); }
/** * Makes and returns a mutable copy of this instance. The copy * contains copies of the locals and stack (that is, it doesn't * share them with the original). * * @return {@code non-null;} the copy */ public Frame copy() { return new Frame(locals.copy(), stack.copy(), subroutines); }
/** * Replaces all the occurrences of the given uninitialized type in * this frame with its initialized equivalent. * * @param type {@code non-null;} type to replace */ public void makeInitialized(Type type) { locals.makeInitialized(type); stack.makeInitialized(type); }
/** * Peeks at the {@code n}th element down from the top of the * stack, returning the type per se, as opposed to the * <i>type-bearer</i>. This method is just a convenient shorthand * for {@code peek(n).getType()}. * * @see #peek */ public Type peekType(int n) { return peek(n).getType(); }
/** {@inheritDoc} */ public final void popArgs(Frame frame, int count) { ExecutionStack stack = frame.getStack(); clearArgs(); if (count > args.length) { // Grow args, and add a little extra room to grow even more. args = new TypeBearer[count + 10]; } for (int i = count - 1; i >= 0; i--) { args[i] = stack.pop(); } argCount = count; }