CoreThymeCmdsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Pradeep Sindhu, March 31, 1986 6:25:43 pm PST
Pradeep Sindhu, April 29, 1986 0:19:46 am PDT
Bertrand Serlet June 3, 1986 2:11:14 pm PDT
DIRECTORY
CD, CDCells, CDIO, CDMenus, CDOps, CDOrient, CDSatellites, CDSequencer, Core, CoreClasses, CoreOps, CoreThyme, Rope, Sinix, Sisyph, TerminalIO;
CoreThymeCmdsImpl: CEDAR PROGRAM
IMPORTS CDCells, CDIO, CDMenus, CDOps, CDSatellites, CoreClasses, CoreOps, CoreThyme, Rope, Sinix, Sisyph, TerminalIO = BEGIN
ROPE: TYPE = Rope.ROPE;
ThymeHandle: TYPE = CoreThyme.ThymeHandle;
Command Procs
thymeHandles: LIST OF ThymeHandle ← NIL;
ExtractSelectedObjAndRunThyme: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cx: Sisyph.Context ← Sisyph.Create[comm.design];
cellType: Core.CellType;
wDir: ROPECDIO.GetWorkingDirectory[comm.design];
thymeHandle: ThymeHandle ← GetThymeHandle[wDir];
thymeFileName: ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
[] ← CDSatellites.EnforceInvariants[comm.design, CDOps.InstList[comm.design]];
cellType ← NARROW [Sinix.Extract[obj: selected.ob, mode: Sisyph.sisyphMode, properties: selected.properties, userData: cx].result];
WHILE cellType.class=CoreClasses.identityCellClass DO
cellType ← CoreOps.Recast[cellType];
ENDLOOP;
IF CoreOps.GetCellTypeName[cellType]=NIL
THEN thymeFileName ← Rope.Cat[wDir, "CoreThymeDefaultFile.thy"]
ELSE thymeFileName ← Rope.Cat[wDir, CoreOps.GetCellTypeName[cellType], ".thy"];
CoreThyme.Translate[cellType, thymeFileName];
CoreOps.PrintCellType[cellType, TerminalIO.TOS[]];
CoreThyme.Simulate[thymeFileName, thymeHandle];
};
Internal Utilities
IsSingleSelectedAndCell: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] = {
IF ~IsSingleSelected[selected, multiple] THEN RETURN [FALSE];
IF ~CDCells.IsCell[selected.ob] THEN {
TerminalIO.WriteRope["\n** Selected instance is not a cell—can't do it.\n"];
RETURN[FALSE];
};
RETURN[TRUE];
};
IsSingleSelected: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] = {
IF selected=NIL THEN {
TerminalIO.WriteRope["\n** No current selection--can't do it.\n"];
RETURN[FALSE];
};
IF multiple THEN {
TerminalIO.WriteRope["\n** Multiple instances selected--can't do it.\n"];
RETURN[FALSE];
};
RETURN[TRUE];
};
GetThymeHandle: PROC [wDir: ROPE] RETURNS [thymeHandle: ThymeHandle] = {
FOR l: LIST OF ThymeHandle ← thymeHandles, l.rest WHILE l#NIL DO
IF l.first.outer#NIL AND l.first.stage=idle THEN {
CoreThyme.SetWorkingDirectory[wDir, l.first];
RETURN [l.first];
};
ENDLOOP;
thymeHandle ← CoreThyme.CreateThymeViewer[wDir];
thymeHandles ← CONS[thymeHandle, thymeHandles];
};
Initialization
Entry goes in Sisyph Menu
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Sisyph Extract and Thyme", p: ExtractSelectedObjAndRunThyme, key: $CoreThymeExtractSelectedObjAndRunThyme];
END.