CirioEval.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Philip James, July 2, 1991 3:58 pm PDT
Laurie Horton, February 8, 1993 12:02 pm PST
DIRECTORY
Commander USING [CommandProc, Handle, Register],
CommanderOps USING [ArgN, NumArgs],
IO USING [PutF, rope],
LocalCirio USING [Connection, DoUnderMonitorLock, GetConnection, GetDummyStack, ReleaseConnection],
Rope USING [Length, ROPE, Substr],
StackCirio USING [InterpretTextLine, Stack];
CirioEval:
CEDAR
MONITOR
IMPORTS Commander, CommanderOps,
IO, LocalCirio, Rope, StackCirio ~ {
ch: Commander.Handle ← NIL;
DontCallMe:
PUBLIC
PROCEDURE [key:
CARD32] = {
IF ch # NIL THEN IO.PutF[ch.out, "If you get this message, then scream and holler, because it should never appear.\n"]; };
CirioEvalCmd: Commander.CommandProc ~ {
connection: LocalCirio.Connection;
numArgs:CARD ← CommanderOps.NumArgs[cmd];
stack: StackCirio.Stack ← NIL;
reslt, line: Rope.ROPE ← NIL;
interpret: PROC = {reslt ← StackCirio.InterpretTextLine[stack, line, cmd.out]};
ch ← cmd;
IF numArgs > 1
THEN {
connection ← LocalCirio.GetConnection[["CirioEval", "DontCallMe"], cmd.out];
IF connection #
NIL
THEN {
stack ← LocalCirio.GetDummyStack[connection, cmd.out];
line ← Rope.Substr[cmd.commandLine, CommanderOps.ArgN[cmd, 0].Length];
LocalCirio.DoUnderMonitorLock[connection, interpret];
IO.PutF[cmd.out, "%g\n", IO.rope[reslt]];
LocalCirio.ReleaseConnection[connection, cmd.out];
}
}
};
Commander.Register["←", CirioEvalCmd, "Evaluate an expression in the local world."];
Commander.Register["¬", CirioEvalCmd, "Evaluate an expression in the local world."];
}.