INTERFACEAStackTbl ; IMPORT Atom; TYPE T <: Public; Public = OBJECT next_index: CARDINAL; next_formal: INTEGER METHODS init(): T; END;
StackTbl.T is a pair of integers (the next_index and next_formal)
together with a list of marks and atom-integer pairs.
A newly allocated StackTbl.T must be initialized before use, and can be
initialized again for re-use. A newly intialized StackTbl.T has a
next_index of 1, a next_formal of -1, and an empty list.
PROCEDURE Mark(t: T);
Add a mark to the front of t's list. PROCEDURE PopToMark(t: T);
Remove all entries fromt's list up to and including the first mark. This call should ``balance'' with a previous call toMark. More precisely, it is a checked run-time error to call this procedure ift's stack does not contain any marks.
PROCEDURE Push(t: T; nm: Atom.T);
Add the pair (nm,t.next_index) to the front oft's list, and incrementt.next_index.
PROCEDURE PushFormal(t: T; nm: Atom.T);
Add the pair (nm,t.next_formal) to the front oft's list, and decrementt.next_formal.
PROCEDURE Lookup(t: T; nm: Atom.T): INTEGER;
Return the integer paired with the first occurrence ofnmint's list, or return 0 if there are no such occurrences.
END StackTbl.