ArbiterSchematicImpl.mesa
Copyright c 1986 by Xerox Corporation. All rights reserved.
McCreight May 13, 1987 3:37:08 pm PDT
Last Edited by: McCreight October 24, 1987 5:42:58 pm PDT
ArbiterSchematicImpl:
CEDAR
MONITOR
IMPORTS Atom, CDViewer, CedarProcess, Commander, CommandTool, CoreIO, IO, FS, PW, Rope, Sisyph, TerminalIO
EXPORTS Arbiter
= BEGIN OPEN Arbiter;
useSavedCoreFile: BOOL ← FALSE;
writeSavedCoreFile: BOOL ← FALSE;
sctProp: ATOM = $SchematicCT;
SchematicCT:
PUBLIC
PROC [ cellName, designName: CoreCreate.
ROPE ]
RETURNS [ ct: CoreCreate.CellType ] = {
atom: ATOM = Atom.MakeAtom[cellName];
ref: REF ANY ← Atom.GetProp[atom, sctProp];
ct ← NIL;
IF ref =
NIL
THEN {
MakeCellType:
ENTRY
PROC = {
ENABLE UNWIND => NULL;
act: CoreCreate.CellType ← NIL;
IF useSavedCoreFile
THEN
act ← CoreIO.RestoreCellType[cellName ! FS.Error => { act ← NIL; CONTINUE } ];
IF act =
NIL
THEN {
design: CD.Design;
cx: Sisyph.Context;
badProps: LIST OF ATOM ← NIL;
badClasses: LIST OF Core.CellClass ← NIL;
design ← CDViewer.FindDesign[designName];
IF design = NIL THEN design ← PW.OpenDesign[designName];
cx ← Sisyph.Create[design];
act ← Sisyph.ES[name: Rope.Cat[cellName, ".sch"], cx: cx];
IF writeSavedCoreFile
THEN {
[props: badProps, classes: badClasses] ← CoreIO.ReportSaveCellType[act, Rope.Cat[cellName, ".core"]];
IF badProps # NIL THEN TerminalIO.PutF["\nWarning: Couldn't write the following Core properties in the saved core file: \n%g\n", IO.refAny[badProps]];
IF badClasses # NIL THEN TerminalIO.PutF["\nWarning: Couldn't write the following Core classes in the saved core file: \n%g\n", IO.refAny[badClasses]];
};
};
ref ← act;
Atom.PutProp[atom, sctProp, ref];
CedarProcess.DoWithPriority[background, MakeCellType];
};
ct ← NARROW[ref];
};
ResetSchematicCT:
PUBLIC
PROC [ cellName: CoreCreate.
ROPE ] = {
Atom.PutProp[Atom.MakeAtom[cellName], sctProp, NIL];
DO
FS.Delete[Rope.Cat[cellName, ".core!L"] ! FS.Error => GOTO NoMoreVersions ];
REPEAT
NoMoreVersions => NULL;
ENDLOOP;
};
ResetSchematic:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF ←
NIL, msg: Rope.
ROPE ←
NIL]
-- Commander.CommandProc -- = {
argv: CommandTool.ArgumentVector = CommandTool.Parse[cmd];
IF argv.argc >= 2 THEN ResetSchematicCT[argv[1]]
ELSE {
cmd.err.PutF["That didn't work. Maybe the following will help:\n\n%g\n", IO.rope[cmd.procData.doc]]
};
};
ExtractSchematic:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF ←
NIL, msg: Rope.
ROPE ←
NIL]
-- Commander.CommandProc -- = {
argv: CommandTool.ArgumentVector = CommandTool.Parse[cmd];
IF argv.argc >= 3 THEN [] ← SchematicCT[argv[1], argv[2]]
ELSE {
cmd.err.PutF["That didn't work. Maybe the following will help:\n\n%g\n", IO.rope[cmd.procData.doc]]
};
};
Commander.Register["ResetSchematic", ResetSchematic, "ResetSchematic destroys the current Core cell type for the named cell. Usage is:\n ResetSchematic <cell name>\n\nSee also ExtractSchematic."];
Commander.Register["ExtractSchematic", ExtractSchematic, "ExtractSchematic finds or builds a Core cell type. Usage is\n ExtractSchematic <cell name> <.dale file name>\n\nSee also ResetSchematic."];
END.