CDSimplifyStructureImpl.mesa (a ChipNDale module)
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by Christian October 28, 1986 10:47:15 am PST
Last edited by: Christian Jacobi, October 28, 1986 12:24:40 pm PST
DIRECTORY
CD,
CDBottomUp,
CDCells,
CDCommandOps,
CDCommandOpsExtras2,
CDInstances,
CDOps,
CDProperties,
CDSequencer,
CDSimplifyStructure,
IO,
Rope,
TerminalIO;
CDSimplifyStructureImpl: CEDAR PROGRAM
IMPORTS CDBottomUp, CDCells, CDCommandOps, CDCommandOpsExtras2, CDInstances, CDOps, CDProperties, IO, Rope, TerminalIO
EXPORTS CDSimplifyStructure =
BEGIN
Simplify: PUBLIC PROC [design: CD.Design, root: CD.Object, log: IO.STREAMNIL] = {
IF log=NIL THEN log ← TerminalIO.TOS[];
[] ← CDBottomUp.StartRecurse[simplifyClass, design, root, log];
};
DoSimplify: CDBottomUp.DoProc = {
IF CDCells.IsCell[ob] THEN {
cnt: INT ← 0;
cp: CD.CellPtr ← NARROW[ob.specificRef];
FOR il: CD.InstanceList ← cp.contents, il.rest WHILE il#NIL DO
IF CDCells.IsCell[il.first.ob] THEN {
icp: CD.CellPtr ← NARROW[il.first.ob.specificRef];
IF icp.contents#NIL AND icp.contents.rest=NIL THEN {
stream: IO.STREAMNARROW[handle.data];
composed: CD.Instance ← CDInstances.Composed[icp.contents.first, il.first.location, il.first.ob.size, il.first.orientation];
composed.properties ← CDProperties.DAppendProps[winner: il.first.properties, looser: composed.properties];
IF (cnt𡤌nt+1)=1 THEN
IO.PutRope[stream, Rope.Cat["in ", CDOps.ObjectInfo[ob], "\n"]];
IO.PutRope[stream, Rope.Cat[" instance of ", CDOps.ObjectInfo[il.first.ob], " replaced by ", CDOps.ObjectInfo[composed.ob], "\n"]];
il.first^ ← composed^;
};
}
ENDLOOP;
};
};
HierarchicalSimplificationComm: PROC [comm: CDSequencer.Command] = {
inst: CD.Instance ← CDCommandOps.TheInstance[comm, "hierarchical simplification\n"];
IF inst#NIL THEN {
Simplify[comm.design, inst.ob];
TerminalIO.WriteRope["--finished\n"]
}
};
simplifyClass: CDBottomUp.Class ← CDBottomUp.Register[DoSimplify, NIL, $CDSimplify, $CDSimplify];
--use the CDBottomUp mechanism because we want to deal every object just once but
--some silly user didn't include the objects in the directory.
CDCommandOpsExtras2.RegisterWithMenu[menu: $ProgramMenu, entry: "Hierarchical Simplification", proc: HierarchicalSimplificationComm, key: $CDSimplify];
END.