IPPoolImpl.mesa
Last edited by:
Doug Wyatt, April 29, 1983 2:17 pm
DIRECTORY
IPBasic USING [Any, Integer, maxInteger, nullAny, State, Vec, VecRep, Vector, VectorShape],
IPConvert USING [AnyToInteger],
IPErrors USING [MasterError],
IPOps USING [EqN],
IPStack USING [PopAny, PushAny],
IPVector USING [],
IPStorage USING [pzone];
IPPoolImpl: CEDAR PROGRAM
IMPORTS IPConvert, IPErrors, IPOps, IPStack, IPStorage
EXPORTS IPVector
= BEGIN OPEN IPBasic;
PoolRef: TYPE = REF PoolRep;
PoolRep: TYPE = RECORD[
persistent: BOOL,
level: NAT,
link: PoolRef,
vec: Vec
];
Narrowing:
VectorToVec: PROC[Vector] RETURNS[Vec];
OperatorToPool: PROC[Operator] RETURNS[PoolRef];
Widening:
VecToVector: PROC[Vec] RETURNS[Vector];
PoolToOperator: PROC[PoolRef] RETURNS[Operator];
VGet: PROC[v: Vec, n: Integer] RETURNS[Any] = {
shape: VectorShape = v.shape;
IF n IN[shape.l..shape.l+shape.n) THEN RETURN[v[n-shape.l]]
ELSE ERROR IPErrors.MasterError[BoundsFault];
};
VSet: PROC[v: Vec, x: Any, n: Integer] = {
shape: VectorShape = v.shape;
IF n IN[shape.l..shape.l+shape.n) THEN v[n-shape.l] ← x
ELSE ERROR IPErrors.MasterError[BoundsFault];
};
VCopy: PROC[v: Vec] RETURNS[Vec] = {
};
Frame: PROC[self: State] RETURNS[Vec] = {
context: Context = self.context;
f: Vec = context.frame;
RETURN[IF f=NIL THEN context.initialFrame ELSE VCopy[f]]
};
FGet: PUBLIC PROC[self: State, n: Integer] RETURNS[Any] = {
context: Context = self.context;
f: Vec ← context.frame;
IF f=NIL THEN f ← context.initialFrame;
RETURN[VGet[f, n]];
};
FSet: PUBLIC PROC[self: State, x: Any, n: Integer] = {
context: Context = self.context;
f: Vec ← context.frame;
IF f=NIL THEN f ← context.frame ← VCopy[context.initialFrame];
VSet[f, x, n];
};
MakePool: PROC[self: State, v: Vector, persistent: BOOL] RETURNS[Operator] = {
};
NoPool: PROC[self: State] RETURNS[Operator] = {
};
MakeCO: PUBLIC PROC[self: State, po: Operator, f: Vector] RETURNS[Operator] = {
frame: Vec = IPVector.VectorToVec[f];
index: Index = SkipBody[self];
RETURN[IPStorage.qzone.NEW[OperatorRep[composed] ←
[composed[start: index, initialFrame: frame]]]];
};
DoPoolOp: PROC[pool: PoolRef] RETURNS[Vector] = {
RETURN[VecToVector[CopyVec[pool.vec]]];
};
PoolOp: PROC[self: State] RETURNS[Operator] = {
RETURN[PoolRefToOperator[self.context.pool]];
};
Pool: PROC[self: State] RETURNS[Vector] = {
RETURN[DoPoolOp[self.context.pool]];
};
PGet: PROC[self: State, n: Integer] RETURNS[Any] = {
pool: PoolRef = self.context.pool;
RETURN[VGet[pool.vec, n]];
};
PSet: PROC[self: State, n: Integer] RETURNS[Any] = {
pool: PoolRef = self.context.pool;
RETURN[VGet[pool.vec, n]];
};
END.