IPContextImpl.mesa
Copyright © 1984 Xerox Corporation. All rights reserved.
Doug Wyatt, August 16, 1984 2:16:25 pm PDT
DIRECTORY
IP;
IPContextImpl: CEDAR PROGRAM
IMPORTS IP
EXPORTS IP
~ BEGIN OPEN IP;
NewMarker: PROC[self: State] RETURNS[Marker] ~ {
last: Marker ~ self.lastMarker;
IF last<Marker.LAST THEN RETURN[self.lastMarker ← last+1]
ELSE ERROR Bug["Ran out of Marker values!"];
};
Call: PUBLIC PROC[self: State, action: PROC, frame: Vector, pool: Pool, env: Vector] ~ {
caller: Context ~ self.context;
marker: Marker ~ NewMarker[self]; -- generate a unique mark
context: Context ~ NEW[ContextRep ← [ -- create a new context
caller: caller, marker: marker,
frame: NIL, initialFrame: frame, pool: pool, env: env
]];
self.context ← context;
action[! UNWIND => self.context ← caller];
self.context ← caller;
};
Frame: PUBLIC PROC[self: State] RETURNS[Vector] ~ {
context: Context ~ self.context;
IF context.frame=NIL THEN RETURN[context.initialFrame]
ELSE RETURN[VectorFromArray[ACopy[context.frame]]];
};
FGet: PUBLIC PROC[self: State, j: Integer] RETURNS[Any] ~ {
context: Context ~ self.context;
IF context.frame=NIL THEN RETURN[Get[context.initialFrame, j]]
ELSE RETURN[AGet[context.frame, j]]
};
FSet: PUBLIC PROC[self: State, x: Any, j: Integer] ~ {
context: Context ~ self.context;
IF context.frame=NIL THEN context.frame ← ArrayFromVector[context.initialFrame];
ASet[context.frame, x, j];
};
PoolOp: PUBLIC PROC[self: State] RETURNS[Pool] ~ { RETURN[self.context.pool] };
PGet: PUBLIC PROC[self: State, j: Integer] RETURNS[Any] ~ {
pool: Pool ~ self.context.pool;
RETURN[AGet[pool.array, j]];
};
PSet: PUBLIC PROC[self: State, x: Any, j: Integer] ~ {
pool: Pool ~ self.context.pool;
-- SavePool[self, pool, ...]; --
ASet[pool.array, x, j];
};
Env: PUBLIC PROC[self: State] RETURNS[Vector] ~ {
RETURN[self.context.env];
};
END.