IPStack.mesa
Last edited by:
Doug Wyatt, March 23, 1983 1:04 pm
DIRECTORY
IPBasic USING [Any, Identifier, Integer, Marker, Number, Operator, State, Vector];
IPStack: CEDAR DEFINITIONS
= BEGIN OPEN IPBasic;
Init: PROC[self: State, max: Integer];
Initialize a stack with the capacity to hold up to max items.
PushAny: PROC[self: State, x: Any];
Push an element onto the stack.
! MasterError[StackOverflow] if the stack is full
PopAny: PROC[self: State] RETURNS[Any];
Pop an element from the stack.
! MasterError[StackUnderflow] if the stack is empty
PushBool: PROC[State, BOOL];
PushInteger: PROC[State, Integer];
PushReal: PROC[State, REAL];
PushNumber: PROC[State, Number];
PushIdentifier: PROC[State, Identifier];
PushVector: PROC[State, Vector];
PushOperator: PROC[State, Operator];
PopBool: PROC[State] RETURNS[BOOL];
PopInteger: PROC[State] RETURNS[Integer];
PopReal: PROC[State] RETURNS[REAL];
PopNumber: PROC[State] RETURNS[Number];
PopIdentifier: PROC[State] RETURNS[Identifier];
PopVector: PROC[State] RETURNS[Vector];
PopOperator: PROC[State] RETURNS[Operator];
Copy: PROC[self: State, n: Integer];
Copy the top n elements on the stack.
! MasterError[StackUnderflow] if there are fewer than n elements on the stack
! MasterError[StackOverflow] if there is not enough room to push n more elements
Roll: PROC[self: State, depth, moveFirst: Integer];
Treat the top depth elements as a circular queue; roll moveFirst elements to the bottom.
! MasterError[InvalidArgs] if moveFirst > depth
! MasterError[StackUnderflow] if there are fewer than depth elements on the stack
Mark: PROC[self: State, n: Integer];
Place a mark n elements down in the stack.
! MasterError[StackUnderflow] if there are fewer than n elements on the stack
Unmark: PROC[self: State, n: Integer];
Remove a mark n elements down in the stack.
The given marker must match the one pushed by the corresponding Mark.
! MasterError[StackUnderflow] if there are fewer than n elements on the stack
! MasterError[WrongType] if there is not a mark at depth n
! MasterError[MarkMismatch] if the mark was not pushed by the current context
Count: PROC[self: State] RETURNS[Integer];
Count the stack elements above the top mark.
! MasterError[MarkMismatch] if the mark was not pushed by the current context
PopToMark: PROC[self: State] RETURNS[Marker];
Pop the stack until a mark is on top. Used for error recovery.
PopMark: PROC[self: State];
Pop the mark on top of the stack. Used for error recovery.
! Bug if there is not a mark on top of the stack
END.