/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Peeks at the {@code n}th element down from the top of the stack. * {@code n == 0} means to peek at the top of the stack. Note that * this will return {@code null} if the indicated element is the * deeper half of a category-2 value. * * @param n {@code >= 0;} which element to peek at * @return {@code null-ok;} the type of value stored at that element * @throws SimException thrown if {@code n >= size()} */ public TypeBearer peek(int n) { if (n < 0) { throw new IllegalArgumentException("n < 0"); } if (n >= stackPtr) { return throwSimException("underflow"); } return stack[stackPtr - n - 1]; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Pushes a value of the given type onto the stack. * * @param type {@code non-null;} type of the value * @throws SimException thrown if there is insufficient room on the * stack for the value */ public void push(TypeBearer type) { throwIfImmutable(); int category; try { type = type.getFrameType(); category = type.getType().getCategory(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } if ((stackPtr + category) > stack.length) { throwSimException("overflow"); return; } if (category == 2) { stack[stackPtr] = null; stackPtr++; } stack[stackPtr] = type; stackPtr++; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }
/** * Changes an element already on a stack. This method is useful in limited * contexts, particularly when merging two instances. As such, it places * the following restriction on its behavior: You may only replace * values with other values of the same category. * * @param n {@code >= 0;} which element to change, where {@code 0} is * the top element of the stack * @param type {@code non-null;} type of the new value * @throws SimException thrown if {@code n >= size()} or * the action is otherwise prohibited */ public void change(int n, TypeBearer type) { throwIfImmutable(); try { type = type.getFrameType(); } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("type == null"); } int idx = stackPtr - n - 1; TypeBearer orig = stack[idx]; if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) { throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type)); } stack[idx] = type; }