<> <> <> <> <> <<>> 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; <> 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: ROPE _ CDIO.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]; <> CoreThyme.Simulate[thymeFileName, thymeHandle]; }; <> 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 cellcan'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]; }; <> <> CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Sisyph Extract and Thyme", p: ExtractSelectedObjAndRunThyme, key: $CoreThymeExtractSelectedObjAndRunThyme]; END.