-- JaMOtherDefs.mesa
-- Last changed by Bill Paxton, March 24, 1981 3:29 PM

JaMOtherDefs: DEFINITIONS =
BEGIN

Name: TYPE = RECORD [local: BOOLEAN, index: [0..77777B]];

Text: TYPE = LONG POINTER TO TEXT;

CreateName: PROCEDURE[Text] RETURNS [Name];

TextForName: PROC [Text, Name];
-- fills the text with the characters used to create the name
-- generates signal TextOverflow if text too short

TextOverflow: SIGNAL [Text] RETURNS [Text];

RegisterCommand: PROCEDURE[text: Text, proc: PROCEDURE];

PushText
: PROCEDURE[Text];
PopText: PROCEDURE[Text];

CreateNameFromString: PROCEDURE[str: STRING] RETURNS [Name];

StringForName: PROC [STRING, Name];
-- fills the string with the text used to create the name

PushName: PROC [Name];
-- turns the name into an object and pushes it on the operand stack

PopName: PROC RETURNS [Name];
-- pops a name object from operand stack and returns the name

TryToPopName: PROC RETURNS [Name, BOOLEAN];
-- if top of stack is a name, pops it and returns [name, TRUE]
-- else returns [-, FALSE]

PopNameOrReal: PROC RETURNS
[nameflag: BOOLEAN, name: Name, value: REAL];
-- pops either name or real from operand stack
-- nameflag true if top was a name, false if was a real
-- converts integer or long integer into real if necessary

ExecuteName
: PROC [Name] RETURNS [known: BOOLEAN];
-- tries to load the value for name with current dictstk
-- if name is known, value goes on execstk and is executed
-- (actually calls Execute in JaMExec)
-- otherwise, just returns false

Obj
: TYPE [3]; -- objects are 3 words
PushObj: PROCEDURE[Obj];
PopObj: PROCEDURE RETURNS[Obj];

Command
: TYPE [1]; -- command has a 1 word representation
TryToGetCommand: PROC [Name] RETURNS [Command, BOOLEAN];
-- looks up name in current context
-- BOOLEAN is false if name not known or value not a command
ExecuteCommand: PROC [Command]; -- calls the command procedure
PushCommand: PROC [Command]; -- pushes command on exec stk
PushCommandName: PROC [Name]; -- does cvx and pushes on exec stk

Go: PROC; -- start the JaM machine. (i.e., call Execute)

END.