PipalCDCommands.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet, May 15, 1988 8:52:39 pm PDT
Bertrand Serlet May 15, 1988 10:35:33 pm PDT
DIRECTORY
Atom,
Pipal, PipalInt, PipalMos, PipalOps, PipalUI,
RefTab, Rope, RopeList, TerminalIO;
PipalCDCommands:
CEDAR
PROGRAM
IMPORTS Atom, Pipal, PipalInt, PipalMos, PipalOps, PipalUI, RefTab, Rope, RopeList, TerminalIO =
BEGIN
Prerequisite
ROPE: TYPE = Pipal.ROPE;
ROPES: TYPE = LIST OF ROPE;
Expand
expandMethod: Pipal.Method ← Pipal.RegisterMethod["Expand"];
Expand: PipalUI.ReplaceCommandProc = {
Each: PipalOps.EachChildProc = {
[] ← Expand[design, child, table, data, issuer];
};
refReplaceCommandProc: REF PipalUI.ReplaceCommandProc ← NARROW [Pipal.ObjectMethod[object, expandMethod]];
SELECT
TRUE
FROM
refReplaceCommandProc#NIL => refReplaceCommandProc^[design, object, table, data, issuer];
PipalOps.HasEnumerate[object] => [] ← PipalOps.Enumerate[object, Each];
ENDCASE => {};
};
GenericExpand: PipalUI.ReplaceCommandProc = {
[] ← RefTab.Store[table, object, PipalOps.Recast[object]];
};
Make an Annotation
EditExpressions:
PROC [oldExprs:
ROPES, prompt:
ROPE]
RETURNS [allExprs:
ROPES ←
NIL] = {
input: ROPE;
noOldExprs: BOOL ← oldExprs=NIL;
TerminalIO.PutF["\n"];
WHILE oldExprs#
NIL
DO
input ← TerminalIO.RequestRope[Rope.Cat[" ", prompt, ": ", oldExprs.first, " Replacement: "]];
SELECT
TRUE
FROM
Rope.Equal[input, "-"] => TerminalIO.PutF[" ** Deleted\n"];
Rope.IsEmpty[input] => allExprs ← CONS [oldExprs.first, allExprs];
ENDCASE => allExprs ← CONS [input, allExprs];
oldExprs ← oldExprs.rest;
ENDLOOP;
IF noOldExprs
THEN {
input ← TerminalIO.RequestRope[Rope.Cat[" New ", prompt, ": "]];
WHILE ~Rope.IsEmpty[input]
AND ~Rope.Equal[input, "-"]
DO
allExprs ← CONS [input, allExprs];
input ← TerminalIO.RequestRope[Rope.Cat[" New ", prompt, ": "]];
ENDLOOP};
allExprs ← RopeList.Reverse[allExprs];
};
Atomize:
PROC [r:
ROPE]
RETURNS [
ATOM ←
NIL] = {
IF Rope.Length[r]>1 AND Rope.Fetch[r]='$ THEN r ← Rope.Substr[r, 1, Rope.Length[r]-1];
IF ~Rope.IsEmpty[r] THEN RETURN [Atom.MakeAtom[r]]
};
RequestValue:
PROC []
RETURNS [value:
REF ←
NIL] = {
SELECT TerminalIO.RequestSelection["Annotation value",
LIST["NIL", "BOOL", "INT", "ROPE", "ROPES", "ATOM", "Rectangle"]]
FROM
1 => RETURN [NIL];
2 => RETURN [NEW [BOOL ← TerminalIO.Confirm["TRUE"]]];
3 => RETURN [NEW [INT ← TerminalIO.RequestInt["Integer: "]]];
4 => RETURN [TerminalIO.RequestRope["Rope: "]];
5 => RETURN [EditExpressions[NIL, "Rope "]];
6 => RETURN [Atomize[TerminalIO.RequestRope["Atom: "]]];
7 => {
rect: PipalInt.Rectangle;
rect.base.x ← TerminalIO.RequestInt["base.x: "];
rect.base.x ← TerminalIO.RequestInt["base.x: "];
rect.size.y ← TerminalIO.RequestInt["size.y: "];
rect.size.y ← TerminalIO.RequestInt["size.y: "];
RETURN [NEW [PipalInt.Rectangle ← rect]];
};
ENDCASE => {};
};
MakeAnnotation: PipalUI.ReplaceCommandProc = {
key: ATOM ← Atomize[TerminalIO.RequestRope["Annotation key: "]];
IF key=
NIL
THEN {
TerminalIO.PutF["*** MakeAnnotation: empty key.\n"];
RETURN;
};
[] ← RefTab.Store[table, object, Pipal.CreateAnnotation[object, key, RequestValue[]]];
};
Make a Schematic Icon
MakeSchematicIcon: PipalUI.ReplaceCommandProc = {
choice: NAT ← TerminalIO.RequestSelection["Schematic Icon Type", LIST ["Cell icon", "Wire icon", "Unnamed wire icon"]];
type: PipalMos.SchematicIconType;
code: BOOL;
expression: Pipal.ROPE;
IF choice=0
THEN {
TerminalIO.PutF["*** MakeSchematicIcon: aborted.\n"]; -- should do something else that just returning!
RETURN;
};
type ← VAL [choice];
code ← TerminalIO.Confirm["From Code?"];
expression ← TerminalIO.RequestRope[IF code THEN "Code: " ELSE "Name of the schematic: "];
[] ← RefTab.Store[table, object, PipalMos.CreateSchematicIcon[object, expression, code, type]];
};
Make a Schematic Sequence
MakeSchematicSequence: PipalUI.ReplaceCommandProc = {
[] ← RefTab.Store[table, object, PipalMos.CreateSchematicSequence[object, TerminalIO.RequestRope["Repetition factor: "]]];
};
Change Layer
changeLayerMethod: Pipal.Method ← Pipal.RegisterMethod["ChangeLayer"];
ChangeLayer: PipalUI.ReplaceCommandProc = {
Each: PipalOps.EachChildProc = {
[] ← ChangeLayer[design, child, table, data, issuer];
};
refReplaceCommandProc: REF PipalUI.ReplaceCommandProc ← NARROW [Pipal.ObjectMethod[object, changeLayerMethod]];
SELECT
TRUE
FROM
refReplaceCommandProc#NIL => refReplaceCommandProc^[design, object, table, data, issuer];
PipalOps.HasEnumerate[object] => [] ← PipalOps.Enumerate[object, Each];
ENDCASE => {};
};
ChangeBoxLayer: PipalUI.ReplaceCommandProc = {
box: PipalMos.Box = NARROW [object];
[] ← RefTab.Store[table, object, PipalMos.CreateBox[box.size, NARROW [data]]];
};
SchematicIconLayer: PipalUI.ReplaceCommandProc = {
marker: PipalMos.Marker = NARROW [object];
[] ← RefTab.Store[table, object, PipalMos.CreateMarker[marker.size, NARROW [data]]];
};
Expand Initialization
PipalUI.RegisterReplaceSelectionCommand[key: $Expand, proc: Expand, allSelected:
TRUE, replaceMethod: alongPath];
Pipal.PutClassMethod[Pipal.annotationClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalInt.abutClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalMos.starClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalMos.routingClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalMos.tilingClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalMos.schematicIconClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Pipal.PutClassMethod[PipalMos.schematicSequenceClass, expandMethod, NEW [PipalUI.ReplaceCommandProc ← GenericExpand]];
Make Objects Initialization
PipalUI.RegisterReplaceSelectionCommand[key: $MakeAnnotation, proc: MakeAnnotation, allSelected: FALSE, replaceMethod: alongPath];
PipalUI.RegisterReplaceSelectionCommand[key: $MakeSchematicIcon, proc: MakeSchematicIcon, allSelected: FALSE, replaceMethod: alongPath];
PipalUI.RegisterReplaceSelectionCommand[key: $MakeSchematicSequence, proc: MakeSchematicSequence, allSelected: FALSE, replaceMethod: alongPath];
Change Layer Initialization
PipalUI.RegisterReplaceSelectionCommand[key: $ChangeToBlue, proc: ChangeLayer, allSelected: TRUE, replaceMethod: alongPath, data: PipalMos.blueCommentLayer];
PipalUI.RegisterReplaceSelectionCommand[key: $ChangeToBlack, proc: ChangeLayer, allSelected: TRUE, replaceMethod: alongPath, data: PipalMos.commentLayer];
Pipal.PutClassMethod[PipalMos.boxClass, changeLayerMethod, NEW [PipalUI.ReplaceCommandProc ← ChangeBoxLayer]];
Pipal.PutClassMethod[PipalMos.markerClass, changeLayerMethod, NEW [PipalUI.ReplaceCommandProc ← SchematicIconLayer]];
END.