DIRECTORY Atom, CD, CDBasics, CDCells, CDDirectory, CDExtras, CDInstances, CDOps, CDPrivate, CDProperties, CDSimpleOps, CedarProcess, IO, Process, Rope, SymTab, TerminalIO; CDExtrasImpl: CEDAR MONITOR IMPORTS Atom, CD, CDBasics, CDCells, CDDirectory, CDInstances, CDOps, CDProperties, CDSimpleOps, CedarProcess, IO, Process, Rope, SymTab, TerminalIO EXPORTS CDExtras SHARES CD = BEGIN CreateDummyObject: PUBLIC PROC[design: CD.Design] RETURNS [CD.Object] = BEGIN cellOb: CD.Object _ CDCells.CreateEmptyCell[]; cptr: CD.CellPtr _ NARROW[cellOb.specificRef]; FOR l: LIST OF CD.PushRec _ design.actual, l.rest WHILE l#NIL DO cptr.contents _ CONS[ NEW[CD.InstanceRep _ [ ob: l.first.dummyCell.ob, location: [0, 0], orientation: CD.original, selected: FALSE ]], cptr.contents ]; ENDLOOP; RETURN [cellOb] END; Pair: TYPE = RECORD [p: CDDirectory.EnumerateObjectsProc, x: REF, key: REF]; EnumerationEnteredWhileInProgress: ERROR = CODE; entered: BOOL _ FALSE; Enter: ENTRY PROC [] = BEGIN IF entered THEN RETURN WITH ERROR EnumerationEnteredWhileInProgress; entered_TRUE; END; Leave: ENTRY PROC [] = BEGIN entered_FALSE; END; EnumerateChildrenObjects: PUBLIC PROC[me: CD.Object, p: CDDirectory.EnumerateObjectsProc, x: REF] = BEGIN ENABLE UNWIND => Leave[]; pair: REF Pair _ NEW[Pair]; pair^ _ [p, x, pair]; Enter[]; MyEnum[me, pair]; Leave[]; END; MyEnum: PROC [me: CD.Object, x: REF] = BEGIN pair: REF Pair _ NARROW[x]; v: REF _ CDProperties.GetProp[me, $CDExtrasImplsTouched]; IF v=pair.key THEN RETURN; -- already visited CDProperties.PutProp[me, $CDExtrasImplsTouched, pair.key]; IF me.class.inDirectory THEN CDDirectory.EnumerateChildObjects[me, MyEnum, x]; pair.p[me, pair.x]; -- call clients enumerator proc END; EnumerateDesignObjects: PUBLIC PROC [design: CD.Design, p: CDDirectory.EnumerateObjectsProc, x: REF] = BEGIN ENABLE UNWIND => Leave[]; pair: REF Pair _ NEW[Pair]; EachCell: SymTab.EachPairAction --[key: Key, val: Val] RETURNS [quit: BOOLEAN] -- = BEGIN quit _ FALSE; MyEnum[NARROW[val, CD.Object], pair] END; pair^ _ [p, x, pair]; Enter[]; [] _ SymTab.Pairs[design.cellDirectory, EachCell]; FOR l: LIST OF CD.PushRec _ design.actual, l.rest WHILE l#NIL DO MyEnum[l.first.dummyCell.ob, pair]; IF l.first.mightReplace#NIL THEN MyEnum[l.first.mightReplace.ob, pair]; ENDLOOP; Leave[]; END; BoundingBox: PUBLIC PROC [design: CD.Design] RETURNS [r: CD.Rect _ CDBasics.empty] = BEGIN FOR l: LIST OF CD.PushRec _ design.actual, l.rest WHILE l#NIL DO r _ CDBasics.Surround[r, CDInstances.BoundingRectO[ NARROW[l.first.dummyCell.ob.specificRef, CD.CellPtr].contents ]] ENDLOOP; END; SelectedBox: PUBLIC PROC [design: CD.Design] RETURNS [r: CD.Rect _ CDBasics.empty] = BEGIN r _ CDInstances.BoundingRectO[CDOps.InstList[design], TRUE] END; PushedCellName: PUBLIC PROC [design: CD.Design] RETURNS [Rope.ROPE] = BEGIN RETURN [SELECT TRUE FROM design=NIL => "no design", design.actual.rest=NIL => "top level", ENDCASE => design.actual.first.specific.name ] END; RPEachChildren: CDDirectory.EnumerateObjectsProc --PROC [me: Object, x: REF]-- = BEGIN Process.Yield[]; IF ~me.class.inDirectory THEN CDProperties.PutPropOnObject[onto: me, prop: x, val: NIL] END; RemoveProps: PROC [design: CD.Design, key: REF] = BEGIN RPEachDirectoryEntry: CDDirectory.EachEntryAction = BEGIN CDProperties.PutPropOnObject[onto: ob, prop: key, val: NIL]; IF ob.class.inDirectory THEN CDDirectory.EnumerateChildObjects[me: ob, p: RPEachChildren, x: key]; END; CedarProcess.SetPriority[CedarProcess.Priority[background]]; [] _ CDDirectory.Enumerate[design: design, action: RPEachDirectoryEntry]; END; RemoveProperties: PUBLIC PROC [design: CD.Design, key: REF] = BEGIN TRUSTED {Process.Detach[FORK RemoveProps[design, key]]} END; ToLambda: PUBLIC PROC [n: CD.Number, lambda: CD.Number_1] RETURNS [Rope.ROPE] = BEGIN IF n MOD lambda = 0 THEN RETURN IO.PutFR1[" %g", IO.int[n/lambda]] ELSE { r: Rope.ROPE _ " ("; IF n<0 THEN {n _ ABS[n]; r _ " -("}; IF n/lambda>0 THEN r _ IO.PutFR["%0g%0g+", IO.rope[r], IO.int[n/lambda]]; RETURN [IO.PutFR["%0g%0g/%0g)", IO.rope[r], IO.int[n MOD lambda], IO.int[lambda]]]; } END; PopToTopLayer: PUBLIC PROC [design: CD.Design] = BEGIN WHILE design.actual.rest#NIL DO IF NOT CDCells.PopFromCell[design, newcell] THEN EXIT ENDLOOP; IF design.actual.rest#NIL THEN ERROR END; PopToTopLevel: PUBLIC PROC [design: CD.Design] = BEGIN WHILE CDCells.IsPushedIn[design] DO [] _ CDCells.PopFromCell[design, newcell, "--wasPushedIn--"]; ENDLOOP; END; Cellize: PUBLIC PROC [design: CD.Design, name: Rope.ROPE_NIL] RETURNS [cell: CD.Object_NIL, pos: CD.Position] = BEGIN done: BOOL; il: CD.InstanceList; PopToTopLayer[design]; CDSimpleOps.SelectAll[design]; IF (il_CDOps.InstList[design])#NIL THEN { IF il.rest=NIL AND ISTYPE[il.first.ob.specificRef, CD.CellPtr] AND il.first.orientation=CD.original THEN { cell _ il.first.ob; IF name#NIL THEN [] _ CDDirectory.Rename[design, cell, name]; done _ TRUE } ELSE { IF name=NIL THEN name _ design.name; IF name=NIL THEN name _ "no named design"; [done, cell] _ CDCells.CreateCellSelected[design, name]; }; IF done THEN { pos _ CDOps.InstList[design].first.location; } ELSE cell _ NIL }; CDOps.SetInstList[design, NIL] END; RopeNeeded: SIGNAL [ ref: REF REF ] = CODE; ToRope: PUBLIC PROC [x: REF, whenFailed: REF_NIL] RETURNS [rope: Rope.ROPE_NIL] = BEGIN WITH x SELECT FROM r: Rope.ROPE => rope _ r; rt: REF TEXT => rope _ Rope.FromRefText[rt]; i: REF INT => rope _ IO.PutFR["%0g", IO.int[i^]]; a: ATOM => rope _ Atom.GetPName[a]; l: CDPrivate.LayerRef => rope _ CDOps.LayerName[l.number]; ob: CD.Object => rope _ CDOps.Info[ob]; inst: CD.Instance => rope _ inst.ob.class.describeInst[inst]; d: CD.Design => rope _ d.name; t: CD.Technology => rope _ t.name; ENDCASE => SELECT whenFailed FROM NIL => rope _ NIL; $Interactive => { refRef: REF REF = NEW[REF _ x]; TerminalIO.WriteRope["please enter a ROPE using the debugger"]; SIGNAL RopeNeeded[refRef]; rope _ ToRope[refRef^ ! RopeNeeded => ERROR]; }; ENDCASE => rope _ ToRope[whenFailed]; END; GetTechnology: PUBLIC PROC [name: Rope.ROPE] RETURNS [t: CD.Technology] = BEGIN EachTechnology: CD.TechnologyEnumerator = { IF Rope.Equal[tech.name, name, FALSE] OR Rope.Equal[Atom.GetPName[tech.key], name, FALSE] THEN {quit _ TRUE; t _ tech} }; [] _ CD.EnumerateTechnologies[EachTechnology]; END; END. .CDExtrasImpl.mesa (part of ChipNDale) Copyright c 1983, 1985 by Xerox Corporation. All rights reserved. by Christian Jacobi, September 8, 1983 9:45 am last edited by Christian Jacobi, February 19, 1986 8:48:42 pm PST --create a dummy cell object which contains the whole design. --On future changes of the design, the dummy object may or may not --get obsolete. --enumerate me and its children objects --mark visited --enumerate my children first --RemoveProps --tries to remove the propertiy "key" from all objects of "design"; --may be delayed or incomplete --(only from objects, not instances...) --if "design" is pushed in, it will be popped out, either by flushing, --replacing cells or creating new cells --makes a single "cell" of of the "design", removes all instances; --pos: if "cell" is included at position "pos" in an empty design we would get "design" again --if "design" is pushed in, it will be popped out, either by flushing, --replacing cells or creating new cells --far more friendly version of CD.GetTechnology --NIL if not found Κ »˜codešœ,™,Kšœ Οmœ7™BKšœ0™0KšœB™BK˜—šΟk ˜ K˜Kšžœ˜K˜ K˜K˜ K˜ K˜ K˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜K˜K˜K˜K˜K˜ —K˜šΠbl œžœžœ˜Kšžœhžœ$˜•Kšžœ ˜Kšžœžœ˜ —Kšž˜K˜š Οnœžœžœ žœ žœžœ ˜GKšœ=™=KšœB™Bšœ™Kšž˜Kšœžœ$˜.Kšœžœ žœ˜.š žœžœžœžœ!žœžœž˜@šœžœ˜šžœžœ˜Kšœ˜Kšœ˜Kšœ žœ ˜Kšœ ž˜Kšœ˜—Kšœ ˜ Kšœ˜—Kšžœ˜—Kšžœ ˜Kšžœ˜K˜——Kš œžœžœ*žœžœ˜LK˜Kšœ#žœžœ˜0Kšœ žœžœ˜K˜K˜š œžœžœ˜Kšž˜Kš žœ žœžœžœžœ#˜DKšœžœ˜ Kšžœ˜K˜—š œžœžœ˜Kšž˜Kšœžœ˜Kšžœ˜K˜K˜—š  œžœžœžœ1žœ˜cKšœ'™'Kšžœžœžœ ˜Kšœžœžœ˜K˜K˜K˜K˜Kšžœ˜K˜—š œžœžœ žœ˜*Kšž˜Kšœžœžœ˜Kšœžœ3˜9Kšžœ žœžœΟc˜-Kšœ™Kšœ:˜:Kšœ™Kšžœžœ2˜NKšœ‘˜3Kšžœ˜K˜—š  œžœžœ žœ1žœ˜fKšžœžœžœ ˜Kšœžœžœ˜K˜šΟbœ‘1œ˜SKšž˜Kšœžœ˜ Kšœžœžœ˜$Kšžœ˜K˜—K˜K˜K˜2š žœžœžœžœ!žœžœž˜@K˜#Kšžœžœžœ'˜GKšžœ˜—K˜Kšžœ˜K˜—š  œžœžœ žœ ˜-Kšžœžœ˜'Kšž˜š žœžœžœžœ!žœžœž˜@˜3Kšžœ#žœ˜@—Kšžœ˜—Kšžœ˜K˜—š  œžœžœ žœ ˜-Kšžœžœ˜'Kšž˜Kšœ6žœ˜;Kšžœ˜K˜—š  œžœžœ žœ žœžœ˜EKšž˜šžœžœžœž˜Kšœžœ˜Kšœžœ˜&Kšžœ&˜-Kšœ˜—Kšžœ˜—K˜š’œ#‘œ˜PKšž˜Kšœ˜Kšžœžœ6žœ˜WKšžœ˜—K˜š  œžœ žœžœ˜1Kšž˜K˜š’œ˜3Kšžœ˜Kšœ7žœ˜<šžœžœ˜KšœE˜E—Kšžœ˜—K˜Kšœ ™ Kšœ<˜