PSPrivateImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Doug Wyatt, April 1, 1987 5:33:02 pm PST
DIRECTORY
Imager USING [ConstantColor, VEC],
IO USING [STREAM],
Random USING [RandomStream],
RefTab USING [Ref],
Rope USING [ROPE];
PSPrivateImpl: CEDAR PROGRAM
EXPORTS PS
~ BEGIN
Any: TYPE ~ REF AnyRep;
AnyRep: PUBLIC TYPE ~ PSPrivate.AnyRep;
ArrayBase: TYPE ~ REF ArrayBaseRep;
ArrayBaseRep: TYPE ~ PUBLIC TYPE ~ PSPrivate.ArrayBaseRep;
ArrayGet: PUBLIC PROC [array: Array, index: INT] RETURNS [Any] ~ {
base: ArrayBase ~ array.base;
IF index NOT IN[0..array.length) THEN ERROR Error[rangecheck];
RETURN [base[array.start+index]];
};
StringBase: TYPE ~ REF StringBaseRep;
StringBaseRep: TYPE ~ PUBLIC TYPE ~ PSPrivate.StringBaseRep;
FileBase: TYPE ~ REF FileBaseRep;
FileBaseRep: TYPE ~ PUBLIC TYPE ~ PSPrivate.FileBaseRep;
DictBase: TYPE ~ REF DictBaseRep;
DictBaseRep: TYPE ~ PUBLIC TYPE ~ PSPrivate.DictBaseRep;
PushAny: PROC [stack: Stack, x: Any] ~ {
count: ArrayIndex ~ stack.count;
IF count<stack.size THEN { stack.base[count] ← x; stack.count ← count+1 }
ELSE ERROR Error[stackoverflow];
};
PopAny: PROC [stack: Stack] RETURNS [x: Any] ~ {
count: ArrayIndex ~ stack.count;
IF count>0 THEN RETURN [stack.base[stack.count ← count-1]]
ELSE ERROR Error[stackunderflow];
};
TopType: PROC [stack: Stack] RETURNS [TypeCode] ~ {
count: ArrayIndex ~ stack.count;
IF count>0 THEN RETURN [stack.base[count-1].type]
ELSE ERROR Error[stackunderflow];
};
END.