TJaMFnsDefsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Original version by John Warnock
Last changed by Bill Paxton, March 24, 1981 3:29 PM
Last changed by Doug Wyatt, 1-Oct-81 15:12:07
Last Edited by: Maxwell, January 18, 1983 11:04 am
Russ Atkinson, July 25, 1983 1:34 pm
Michael Plass, February 14, 1985 1:09:30 pm PST
DIRECTORY
Basics USING [LowHalf],
TJaMBasic USING [Object],
TJaMFnsDefs USING [],
TJaMInternal USING [Frame],
TJaMOps USING [defaultFrame, Error, GetAbort, GetStream, MakeStream, MakeString,
Pop, PopBoolean, PopInteger, PopReal, PopStream, PopString, Push, PushBoolean,
PushInteger, PushReal, rangechk, RegisterImplicit, SetAbort, StartTJaM, StringText],
TJaMStreamDefs USING [StreamHandle];
TJaMFnsDefsImpl: PROGRAM
IMPORTS Basics, TJaMOps
EXPORTS TJaMFnsDefs = {
StreamHandle: TYPE = TJaMStreamDefs.StreamHandle;
Register: PUBLIC PROC[string: LONG STRING, proc: PROC] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.RegisterImplicit[frame,string,proc];
};
TJaMExec: PUBLIC PROC[string: LONG STRING] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
ob: string TJaMBasic.Object ← TJaMOps.MakeString[string];
ob.tag ← X; TJaMOps.Push[frame.execstk, ob];
};
PushInteger: PUBLIC PROC[i: INTEGER] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.PushInteger[frame.opstk,i];
};
PopInteger: PUBLIC PROC RETURNS[INTEGER] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
i: INT ← TJaMOps.PopInteger[frame.opstk];
IF i IN[FIRST[INTEGER]..LAST[INTEGER]] THEN RETURN[Basics.LowHalf[i]]
ELSE ERROR TJaMOps.Error[TJaMOps.rangechk];
};
PushLongInteger: PUBLIC PROC[i: INT] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.PushInteger[frame.opstk,i];
};
PopLongInteger,GetLongInteger: PUBLIC PROC RETURNS[INT] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
RETURN[TJaMOps.PopInteger[frame.opstk]];
};
PushReal: PUBLIC PROC[r: REAL] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.PushReal[frame.opstk,r];
};
PopReal,GetReal: PUBLIC PROC RETURNS[REAL] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
RETURN[TJaMOps.PopReal[frame.opstk]];
};
PushBoolean: PUBLIC PROC[b: BOOL] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.PushBoolean[frame.opstk,b];
};
PopBoolean: PUBLIC PROC RETURNS[BOOL] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
RETURN[TJaMOps.PopBoolean[frame.opstk]];
};
PushString: PUBLIC PROC[s: LONG STRING] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
ob: string TJaMBasic.Object ← TJaMOps.MakeString[s];
TJaMOps.Push[frame.opstk,ob];
};
PopString: PUBLIC PROC[s: LONG STRING] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
ob: string TJaMBasic.Object ← TJaMOps.PopString[frame.opstk];
WHILE s.maxlength<ob.length DO s ← SIGNAL StringOverflow[s] ENDLOOP;
TJaMOps.StringText[ob,s];
};
StringOverflow: PUBLIC SIGNAL[s: LONG STRING] RETURNS[ns: LONG STRING] = CODE;
PushStream: PUBLIC PROC[s: StreamHandle] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
ob: stream TJaMBasic.Object ← TJaMOps.MakeStream[s];
TJaMOps.Push[frame.opstk,ob];
};
PopStream: PUBLIC PROC RETURNS[StreamHandle] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
ob: stream TJaMBasic.Object ← TJaMOps.PopStream[frame.opstk];
RETURN[TJaMOps.GetStream[ob]];
};
Pop: PUBLIC PROC = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
[] ← TJaMOps.Pop[frame.opstk];
};
GetTJaMBreak: PUBLIC PROC RETURNS[BOOL] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
RETURN[TJaMOps.GetAbort[frame]];
};
SetTJaMBreak: PUBLIC PROC[flag: BOOLTRUE] = {
frame: TJaMInternal.Frame ← TJaMOps.defaultFrame;
TJaMOps.SetAbort[frame,flag];
};
TJaMOps.StartTJaM[];
}.