IPState.mesa
Last edited by:
Doug Wyatt, April 27, 1983 5:19 pm
DIRECTORY
IO USING [STREAM],
IPBasic USING [Any, Index, Marker, nullMarker, Vec],
IPEncoding USING [Reader],
IPImager USING [Imager];
IPState: CEDAR DEFINITIONS
= BEGIN OPEN IPBasic;
State: TYPE = REF StateRep; -- access to all the state of an Interpress interpreter
StateRep: TYPE = RECORD[
master: IPEncoding.Reader, -- a reader for the encoded master
skeleton: Skeleton, -- where to find instructions, preamble, and page bodies
pc: Index, -- program counter: index of the next token to be read
stack: Stack, -- the stack
topFrame: Vec, -- the result of executing the preamble
context: Context, -- current context
lastMark: Marker, -- last mark value used
imager: IPImager.Imager, -- imager state
log: IO.STREAM -- for logging errors
];
Page: TYPE = RECORD[instructions, body: Index];
Skeleton: TYPE = REF SkeletonRep;
SkeletonRep: TYPE = RECORD[SEQUENCE size: NAT OF Page]; -- page 0 is the preamble
Stack: TYPE = REF StackRep;
StackRep: TYPE = RECORD[
mark: MarkItem, -- list of marks on the stack
bot: NAT, -- index of the element at the (virtual) bottom of the stack
top: NAT, -- index of the vacant element above the top of the stack
elements: SEQUENCE max: NAT OF Any -- array of stack elements
];
MarkItem: TYPE = REF MarkItemRep;
MarkItemRep: TYPE = RECORD[next: MarkItem, marker: Marker, bot: NAT];
Context: TYPE = REF ContextRep;
ContextRep: TYPE = RECORD[
caller: Context, -- return link to calling context
mark: Marker, -- unique mark value for this context
initialFrame: Vec, -- initial value of frame (may be shared)
frame: Vec -- current value of frame, if different from initial frame (never shared)
];
nullContextRep: ContextRep = [caller: NIL, mark: nullMarker, initialFrame: NIL, frame: NIL];
END.