org.foray.ps
Class PsOperandStack

java.lang.Object
  extended by org.foray.ps.PsStack<PsObject>
      extended by org.foray.ps.PsOperandStack

public class PsOperandStack
extends PsStack<PsObject>

A PostScript Operand stack.


Field Summary
 
Fields inherited from class org.foray.ps.PsStack
DEFAULT_STACK_SIZE
 
Method Summary
protected  PsObject filterPush(PsObject objectToPush)
          A hook for subclasses to filter the content of items being pushed onto the stack.
 int getMinimumStackSize()
          Returns the minumum size that this stack can be.
 PsError getUnderflowError()
          Returns the appropriate PS error that should be used for an underflow condition in this stack.
protected  void roll(int n, int j, PsOperator operatorCode)
          Rolls the stack n elements deep, j positions.
 
Methods inherited from class org.foray.ps.PsStack
getInterpreter, getList, peek, peek, pop, pop, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMinimumStackSize

public int getMinimumStackSize()
Description copied from class: PsStack
Returns the minumum size that this stack can be. Attempts to pop an item off the stack that would violate this constraint will result in an underflow error.

Specified by:
getMinimumStackSize in class PsStack<PsObject>
Returns:
The minimum size that this stack can be.

getUnderflowError

public PsError getUnderflowError()
Description copied from class: PsStack
Returns the appropriate PS error that should be used for an underflow condition in this stack.

Specified by:
getUnderflowError in class PsStack<PsObject>
Returns:
The PS underflow error for this stack.

roll

protected void roll(int n,
                    int j,
                    PsOperator operatorCode)
             throws PsInterpreterException4a
Rolls the stack n elements deep, j positions. This is not a full implementation of the roll() operator. Clients must pop n and j off of the operand stack before running this.

Parameters:
n - The depth, or number of stack items to be rolled.
j - The distance and direction that the roll should occur, positive indicating elements should be rolled up toward the top of the stack, negetive indicating elements should be rolled down toward the bottom of the stack.
operatorCode - The PS operator code requesting the roll. This is used in user messages.
Throws:
PsInterpreterException4a - For PS stackunderflow errors.

filterPush

protected PsObject filterPush(PsObject objectToPush)
Description copied from class: PsStack
A hook for subclasses to filter the content of items being pushed onto the stack.

Specified by:
filterPush in class PsStack<PsObject>
Parameters:
objectToPush - The nominal object being pushed onto the stack.
Returns:
The object that should actually be pushed onto the stack. This can be the same as objectToPush, but is not required to be so.


Copyright © 2017. All rights reserved.