SisyphCmdsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Pradeep Sindhu, December 9, 1985 10:01:52 pm PST
Pradeep Sindhu, May 2, 1986 7:44:59 pm PDT
Barth, January 13, 1986 3:30:05 pm PST
Bertrand Serlet June 1, 1986 3:47:54 pm PDT
DIRECTORY
CD, CDCells, CDDirectory, CDMenus, CDOps, CDOrient, CDProperties, CDSatellites, CDSequencer, Core, CoreClasses, CoreOps, Rope, Sinix, SinixHighlight, Sisyph, TerminalIO;
SisyphCmdsImpl: CEDAR PROGRAM
IMPORTS CDCells, CDDirectory, CDMenus, CDOps, CDProperties, CDSatellites, CoreClasses, CoreOps, Rope, Sinix, SinixHighlight, Sisyph, TerminalIO = BEGIN
ROPE: TYPE = Rope.ROPE;
Wire: TYPE = Core.Wire;
CellType: TYPE = Core.CellType;
Command Procs
MakeIcon: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
CDProperties.PutObjectProp[selected.ob, Sisyph.sisyphMode.cacheProp, NIL];
CDMenus.CallMenuAndExecute[$SisyphIconMenu, comm];
};
MakeInvisibleToExtractor: PROC [comm: CDSequencer.Command] = {
FOR w: LIST OF CD.Instance ← CDOps.InstList[comm.design], w.rest WHILE w#NIL DO
inst: CD.Instance ← w.first;
IF inst.selected THEN CDProperties.PutProp[inst, Sisyph.sisyphMode.extractProcProp, $ExtractNull];
ENDLOOP;
};
MakeVisibleToExtractor: PROC [comm: CDSequencer.Command] = {
FOR w: LIST OF CD.Instance ← CDOps.InstList[comm.design], w.rest WHILE w#NIL DO
inst: CD.Instance ← w.first;
IF inst.selected THEN CDProperties.PutProp[inst, Sisyph.sisyphMode.extractProcProp, NIL];
ENDLOOP;
};
FlushSisyphCaches: PROC [comm: CDSequencer.Command] = {
FlushCache: PROC [obj: CD.Object] = {
CDProperties.PutProp[obj, Sisyph.sisyphMode.cacheProp, NIL];
IF CDCells.IsCell[obj] THEN {
cellPtr: CD.CellPtr ← NARROW[obj.specificRef];
FOR l: LIST OF CD.Instance ← cellPtr.contents, l.rest WHILE l#NIL DO
FlushCache[l.first.ob];
ENDLOOP;
};
};
FOR w: LIST OF CD.Instance ← CDOps.InstList[comm.design], w.rest WHILE w#NIL DO
IF w.first.selected THEN FlushCache[w.first.ob];
ENDLOOP;
};
ExtractSelectedObj: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cx: Sisyph.Context ← Sisyph.Create[comm.design];
result: REF;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
[] ← CDSatellites.EnforceInvariants[comm.design, CDOps.InstList[comm.design]];
[result] ← Sinix.Extract[obj: selected.ob, mode: Sisyph.sisyphMode, properties: selected.properties, userData: cx];
IF result=NIL
THEN TerminalIO.WriteF["Result of extraction is NIL.\n"]
ELSE WITH result SELECT FROM
wire: Wire => CoreOps.PrintWire[wire: wire, out: TerminalIO.TOS[], level: LAST [NAT]];
cellType: CellType => {
IF cellType.class=CoreClasses.identityCellClass THEN cellType ← CoreOps.Recast[cellType];
CoreOps.PrintCellType[cellType: cellType, out: TerminalIO.TOS[], level: LAST [NAT]];
};
ENDCASE => ERROR;
};
MakeCellIconWithCodeDef: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cellIconExprPrefix: ROPE ← Rope.Cat[Sisyph.cellIconRope, " ← "];
cellIconExpr: ROPE;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
cellIconExpr ← TerminalIO.RequestRope[Rope.Cat["\nType code: ", cellIconExprPrefix]];
cellIconExpr ← Rope.Cat[cellIconExprPrefix, cellIconExpr];
exprs ← NARROW [CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
exprs ← CONS [cellIconExpr, StripResultExprs[exprs]];
CDProperties.PutProp[selected.ob, Sisyph.expressionsProp, exprs];
};
MakeCellIconWithGeometryDef: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
schematicName: ROPE;
cellIconExprPrefix: ROPE ← Rope.Cat[Sisyph.cellIconRope, " ← "];
cellIconExpr: ROPE;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
schematicName ← TerminalIO.RequestRope["\nType schematic name: "];
IF CDDirectory.Fetch[comm.design, schematicName].object = NIL THEN {
TerminalIO.WriteRope["\n** No such object in design.\n"];
RETURN;
};
cellIconExpr ← Rope.Cat[cellIconExprPrefix, "ES[\"", schematicName, "\", cx]"];
exprs ← NARROW [CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
exprs ← CONS [cellIconExpr, StripResultExprs[exprs]];
CDProperties.PutProp[selected.ob, Sisyph.expressionsProp, exprs];
};
MakeWireIconWithCodeDef: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
wireIconExprPrefix: ROPE ← Rope.Cat[Sisyph.wireIconRope, " ← "];
wireIconExpr: ROPE;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
wireIconExpr ← TerminalIO.RequestRope[Rope.Cat["\nType code: ", wireIconExprPrefix]];
wireIconExpr ← Rope.Cat[wireIconExprPrefix, wireIconExpr];
exprs ← NARROW [CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
exprs ← CONS [wireIconExpr, StripResultExprs[exprs]];
CDProperties.PutProp[selected.ob, Sisyph.expressionsProp, exprs];
};
Not implemented yet
MakeWireIconWithGeometryDef: PROC [comm: CDSequencer.Command] = {
};
ShowInstExpressions: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Instance Expressions:"];
exprs ← NARROW[CDProperties.GetInstanceProp[selected, Sisyph.expressionsProp]];
WHILE exprs#NIL DO
TerminalIO.WriteRope[Rope.Cat["\n ", exprs.first]];
exprs ← exprs.rest;
ENDLOOP;
TerminalIO.WriteRope["\n"];
};
AddInstExpression: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Add Instance Expression\n"];
exprs ← NARROW[CDProperties.GetInstanceProp[selected, Sisyph.expressionsProp]];
exprs ← CONS[TerminalIO.RequestRope[Rope.Cat[" New Expression: "]], exprs];
CDProperties.PutInstanceProp[selected, Sisyph.expressionsProp, exprs]
};
EditInstExpressions: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Edit Instance Expressions\n"];
exprs ← NARROW[CDProperties.GetInstanceProp[selected, Sisyph.expressionsProp]];
exprs ← EditExpressions[exprs, "Expression"];
CDProperties.PutInstanceProp[selected, Sisyph.expressionsProp, exprs]
};
ShowObjExpressions: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Object Expressions:"];
exprs ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
WHILE exprs#NIL DO
TerminalIO.WriteRope[Rope.Cat["\n ", exprs.first]];
exprs ← exprs.rest;
ENDLOOP;
TerminalIO.WriteRope["\n"];
};
AddObjExpression: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Add Object Expression\n"];
exprs ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
exprs ← CONS[TerminalIO.RequestRope[Rope.Cat[" New Expression: "]], exprs];
CDProperties.PutObjectProp[selected.ob, Sisyph.expressionsProp, exprs]
};
EditObjExpressions: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
exprs: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Edit Object Expressions\n"];
exprs ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.expressionsProp]];
exprs ← EditExpressions[exprs, "Expression"];
CDProperties.PutObjectProp[selected.ob, Sisyph.expressionsProp, exprs]
};
ShowParmNames: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
parms: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Parm Names:"];
parms ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.parmNamesProp]];
WHILE parms#NIL DO
TerminalIO.WriteRope[Rope.Cat["\n ", parms.first]];
parms ← parms.rest;
ENDLOOP;
TerminalIO.WriteRope["\n"];
};
AddParmName: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
parms: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Add Parameter Name\n"];
parms ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.parmNamesProp]];
parms ← CONS[TerminalIO.RequestRope[Rope.Cat[" New Parameter: "]], parms];
CDProperties.PutObjectProp[selected.ob, Sisyph.parmNamesProp, parms]
};
EditParmNames: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
parms: LIST OF ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelected[selected, multiple] THEN RETURN;
TerminalIO.WriteRope["Edit Object Expressions\n"];
parms ← NARROW[CDProperties.GetObjectProp[selected.ob, Sisyph.parmNamesProp]];
parms ← EditExpressions[parms, "Parameter"];
CDProperties.PutObjectProp[selected.ob, Sisyph.parmNamesProp, parms]
};
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];
};
StripResultExprs: PROC [in: LIST OF ROPE] RETURNS [out: LIST OF ROPE] = {
out ← NIL;
FOR l: LIST OF ROPE ← in, l.rest WHILE l#NIL DO
IF ~Sisyph.IsResultExpression[l.first] THEN out ← CONS [l.first, out]
ENDLOOP;
};
EditExpressions: PROC [oldExprs: LIST OF ROPE, prompt: ROPE] RETURNS [allExprs: LIST OF ROPE] = {
replExprs, newExprs: LIST OF ROPENIL;
input: ROPE;
TerminalIO.WriteRope["\n"];
WHILE oldExprs#NIL DO
input ← TerminalIO.RequestRope[Rope.Cat[" ", prompt, ": ", oldExprs.first, " Replacement: "]];
SELECT TRUE FROM
Rope.Equal[input, "-"] => TerminalIO.WriteRope[" ** Deleted\n"];
Rope.Equal[input, ""] => replExprs ← CONS[Rope.Translate[oldExprs.first], replExprs];
ENDCASE => replExprs ← CONS[input, replExprs];
oldExprs ← oldExprs.rest;
ENDLOOP;
input ← TerminalIO.RequestRope[Rope.Cat[" New ", prompt, ": "]];
WHILE ~Rope.Equal[input, ""] AND ~Rope.Equal[input, "-"] DO
newExprs ← CONS[input, newExprs];
input ← TerminalIO.RequestRope[Rope.Cat[" New ", prompt, ": "]];
ENDLOOP;
allExprs ← NIL;
FOR l: LIST OF ROPE ← newExprs, l.rest WHILE l#NIL DO
allExprs ← CONS[l.first, allExprs];
ENDLOOP;
FOR l: LIST OF ROPE ← replExprs, l.rest WHILE l#NIL DO
allExprs ← CONS[l.first, allExprs];
ENDLOOP;
};
SisyphContextCreator: SinixHighlight.ExtractContextCreator = {
context ← NEW [SinixHighlight.ExtractContextRec ← [mode: Sisyph.sisyphMode, userData: Sisyph.Create[design]]];
};
Initialization
Main Menu
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Make Icon", p: MakeIcon, key: $SisyphMakeIcon, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Make Invisible to Sisyph", p: MakeInvisibleToExtractor, key: $MakeInvisibleToExtractor, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Make Visible to Sisyph", p: MakeVisibleToExtractor, key: $MakeVisibleToExtractor, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Flush Sisyph Caches", p: FlushSisyphCaches, key: $FlushSisyphCaches];
CDMenus.ImplementEntryCommand[menu: $OtherProgramMenu, entry: "Sisyph Extract", p: ExtractSelectedObj, key: $SisyphExtractSelectedObj];
Make Icon Menu
[] ← CDMenus.CreateMenu["Sisyph: Make Icon", $SisyphIconMenu];
CDMenus.ImplementCommandToCallMenu[$SisyphIconMenu, $SisyphIconMenu];
CDMenus.ImplementEntryCommand[menu: $SisyphIconMenu, entry: "CELL Icon ← CODE", p: MakeCellIconWithCodeDef, key: $MakeCellIconWithCodeDef, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SisyphIconMenu, entry: "CELL Icon ← GEOMETRY", p: MakeCellIconWithGeometryDef, key: $MakeCellIconWithGeometryDef, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SisyphIconMenu, entry: "WIRE Icon ← CODE", p: MakeWireIconWithCodeDef, key: $MakeWireIconWithCodeDef, queue: doQueueAndMark];
Make Parameter Menu
[] ← CDMenus.CreateMenu["Sisyph: Parameter Specification", $SisyphParameterMenu];
CDMenus.ImplementCommandToCallMenu[$SisyphParameterMenu, $SisyphParameterMenu];
CDMenus.ImplementEntryCommand[menu: $SisyphParameterMenu, entry: "Show Parameter Names", p: ShowParmNames, key: $SisyphShowParmNames];
CDMenus.ImplementEntryCommand[menu: $SisyphParameterMenu, entry: "Add Parameter Name", p: AddParmName, key: $SisyphAddParmName, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SisyphParameterMenu, entry: "Edit Parameter Names", p: EditParmNames, key: $SisyphEditParmNames, queue: doQueueAndMark];
Expressions Menu
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Show Instance Expressions (LI-Left)", p: ShowInstExpressions, key: $SisyphShowInstExpressions];
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Add Instance Expression (LI-Middle)", p: AddInstExpression, key: $SisyphAddInstExpression, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Edit Instance Expressions (LI-Right)", p: EditInstExpressions, key: $SisyphEditInstExpressions, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Show Object Expressions (LO-Left)", p: ShowObjExpressions, key: $SisyphShowObjExpressions];
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Add Object Expression (LO-Middle)", p: AddObjExpression, key: $SisyphAddObjExpression, queue: doQueueAndMark];
CDMenus.ImplementEntryCommand[menu: $SatellitesMenu, entry: "Edit Object Expressions (LO-Right)", p: EditObjExpressions, key: $SisyphEditObjExpressions, queue: doQueueAndMark];
SinixHighlight.RegisterHighlightCommand[
contextCreator: SisyphContextCreator,
prompt: "Highlight net in schematic",
key: $HighlightNetInSchematic];
END.