MoreInterpreterCommands.Mesa
Last Edited by: Spreitzer, November 16, 1984 4:41:00 pm PST
DIRECTORY AMMiniModel, AMModel, Commander, Interpreter, InterpreterOps, IO, List, ProcessProps, Rope, SymTab, WorldVM;
MoreInterpreterCommands: CEDAR PROGRAM
IMPORTS AMMiniModel, AMModel, Commander, InterpreterOps, IO, List, ProcessProps, SymTab, WorldVM =
BEGIN
SetGlobalFrame: PROC [cmd: Commander.Handle] RETURNS [result: REFNIL, msg: Rope.ROPENIL] --Commander.CommandProc-- =
BEGIN
cmdStream: IO.STREAMIO.RIS[cmd.commandLine];
moduleName: Rope.ROPENIL;
localWorld: WorldVM.World;
rootContext, moduleContext: AMModel.Context;
ppl: List.AList;
head: InterpreterOps.EvalHead;
TRUSTED {localWorld ← WorldVM.LocalWorld[];
rootContext ← AMModel.RootContext[localWorld]};
moduleName ← cmdStream.GetTokenRope[IO.IDProc !IO.EndOfStream => CONTINUE].token;
IF moduleName # NIL THEN {
TRUSTED {moduleContext ← AMModel.MostRecentNamedContext[moduleName, rootContext]};
IF moduleContext = NIL THEN moduleContext ← AMMiniModel.GetInterfaceRecord[moduleName, localWorld];
IF moduleContext = NIL THEN {result ← $Failure; msg ← IO.PutFR["No such program or interface as %g\n", IO.rope[moduleName]]};
}
ELSE moduleContext ← NIL;
ppl ← ProcessProps.GetPropList[];
head ← NARROW[List.Assoc[$EvalHead, ppl]];
IF head = NIL THEN {
IF ppl = NIL THEN ERROR;
head ← InterpreterOps.NewEvalHead[context: rootContext, specials: SymTab.Create[]];
[] ← List.PutAssoc[key: $EvalHead, val: head, aList: ppl];
};
IF moduleContext # NIL
THEN {contextName: Rope.ROPE;
TRUSTED {contextName ← AMModel.ContextName[moduleContext]};
head.context ← moduleContext;
cmd.out.PutF["Evaluation context set to %g\n", IO.rope[contextName]];
}
ELSE {
head.context ← rootContext;
cmd.out.PutRope["Evaluation context set to local world\n"];
};
END;
Commander.Register[key: "SetGlobalFrame", proc: SetGlobalFrame, doc: "set evaluation context to be a program"];
Commander.Register[key: "SGF", proc: SetGlobalFrame, doc: "set evaluation context to be a program"];
END.