Misp.Mesa
Last Edited by: Spreitzer, July 30, 1985 2:06:42 pm PDT
Pavel, June 20, 1985 1:21:41 pm PDT
DIRECTORY BasicTime, Complex, Interpreter, IO, List, Rope;
Misp: CEDAR DEFINITIONS =
BEGIN
LORA: TYPE = LIST OF REF ANY;
ROPE: TYPE = Rope.ROPE;
COMPLEX: TYPE = Complex.VEC;
Int: TYPE = REF INT;
Real: TYPE = REF REAL;
Comp: TYPE = REF COMPLEX;
RefTime: TYPE = REF TimeRec; TimeRec: TYPE = RECORD [t: BasicTime.GMT];
AbortClosure: TYPE = Interpreter.AbortClosure;
Error: ERROR [env: Environment, stack: Stack, msg: ROPE];
Stop: ERROR [env: Environment, stack: Stack, stop: AbortClosure];
Throw: ERROR [env: Environment, stack: Stack, atom: ATOM, value: REF ANY];
Closure: TYPE = REF ClosureRep;
ClosureRep: TYPE = RECORD [
name: ROPE,
eval: EvalProc,
evalArgs: BOOLEANTRUE,
data: REF ANYNIL];
Environment: TYPE = REF EnvironmentRep;
EnvironmentRep: TYPE = RECORD [
name: ROPE,
in, out: IO.STREAMNIL,
stop: AbortClosure,
parent: Environment,
rep: REF ANY,
class: EnvironmentClass];
EnvironmentClass: TYPE = REF EnvironmentClassRep;
EnvironmentClassRep: TYPE = RECORD [
Responsible for only the local bindings:
Init: PROC [env: Environment, sizeGuess: NAT, initData: REF ANY],
GetBinding: PROC [env: Environment, key: ATOM] RETURNS [found: BOOL, binding: REF ANY],
SetBinding: PROC [env: Environment, key: ATOM, binding: REF ANY, overwriteOld: BOOL],
Enumerate: PROC [env: Environment, consume: PROC [key: ATOM, binding: REF ANY]],
Size: PROC [env: Environment] RETURNS [NAT]
];
Stack: TYPE = LORA;
defaultEnvironmentClass: EnvironmentClass;
EvalProc: TYPE = PROC [args: LORA, environment: Environment, data: REF ANYNIL, stack: Stack] RETURNS [cooked: REF ANY];
Eval: PROC [raw: REF ANY, environment: Environment, stack: Stack] RETURNS [cooked: REF ANY];
ApplyFn: PROC [fn: Closure, args: LORA, env: Environment, parentStack: Stack] RETURNS [ans: REF ANY];
NewEnvironment: PROC [name: ROPE, parent: Environment ← NIL, in, out: IO.STREAMNIL, sizeGuess: NAT ← 10, stop: AbortClosure ← Interpreter.nilAbortClosure, class: EnvironmentClass ← defaultEnvironmentClass, initData: REF ANYNIL] RETURNS [Environment];
EnvName: PROC [environment: Environment, long: BOOLEANTRUE] RETURNS [ROPE];
EnvStop: PROC [environment: Environment] RETURNS [stop: AbortClosure];
Bind: PROC [pattern, value: REF ANY, env: Environment, introduce: BOOL, stack: Stack ← NIL];
BindAtom: PROC [pattern: ATOM, value: REF ANY, env: Environment, introduce: BOOL, stack: Stack ← NIL];
Defun: PROC [env: Environment, name: ATOM, eval: EvalProc, evalArgs: BOOLEANTRUE, data: REF ANYNIL, stack: Stack ← NIL];
Load: PUBLIC PROC [fileName: ROPE, env: Environment, stack: Stack];
DefinePrimitives: PROC [env: Environment];
RegisterPrimitiveDefiner: PROC [ep: EnvironmentProc, end: End ← back];
End: TYPE = {front, back};
EnvironmentProc: TYPE = PROC [environment: Environment];
ToBool: PROC [REF ANY, Environment, Stack] RETURNS [BOOL];
ToInt: PROC [REF ANY, Environment, Stack] RETURNS [INT];
ToReal: PROC [REF ANY, Environment, Stack] RETURNS [REAL];
ToComplex: PROC [REF ANY, Environment, Stack] RETURNS [COMPLEX];
true, false: REF ANY;
Sample Boolean values; possibly NOT REF BOOLs.
BoolDecode: PROC [REF ANY] RETURNS [isBool, value: BOOL];
IsEnvironment: PROC [REF ANY] RETURNS [BOOL];
NarrowToEnvironment: PROC [REF ANY] RETURNS [Environment];
Re: PROC [c: COMPLEX] RETURNS [re: REAL];
Im: PROC [c: COMPLEX] RETURNS [im: REAL];
GetIn: PROC [env: Environment] RETURNS [in: IO.STREAM];
GetOut: PROC [env: Environment] RETURNS [out: IO.STREAM];
PrintVal: PROC [out: IO.STREAM, val: REF ANY, quoteRopes: BOOLTRUE];
PrintValRope: PROC [val: REF ANY, quoteRopes: BOOLTRUE] RETURNS [rope: ROPE];
END.