DIRECTORY CD, CDInstances, CDCallSpecific, CDCells, CDCommandOps, CDDirectory, CDOps, CDOrient, CDRepetitions, CDSequencer, Rope, TerminalIO; CDRepetitionCommands: CEDAR PROGRAM IMPORTS CDInstances, CDCallSpecific, CDCells, CDCommandOps, CDDirectory, CDOps, CDOrient, CDRepetitions, CDSequencer, TerminalIO = BEGIN MakeRepetition: PROC [comm: CDSequencer.Command] = BEGIN sel: CD.InstanceList; ob: CD.Object; offset, location: CD.Position; count: INT; first: CD.Instance; multiple: BOOL; TerminalIO.WriteRope["make a repetition "]; [first, multiple] _ CDOps.SelectedInstance[comm.design]; IF first=NIL THEN {TerminalIO.WriteRope["no selected object\n"]; RETURN}; count _ TerminalIO.RequestInt["number: "]; IF count<1 OR count>=LAST[NAT] THEN { TerminalIO.WriteRope["bad number\n"]; RETURN }; IF count>=257 THEN { TerminalIO.WriteRope["don't exagerate\n"]; RETURN }; IF multiple THEN { [done: multiple, cellOb: ob] _ CDCells.CreateCellSelected[comm.design, "-dummy"]; IF NOT multiple THEN {TerminalIO.WriteRope["not done\n"]; RETURN}; }; [selected: sel, others: comm.design.actual.first.specific.contents] _ CDInstances.SplitSelected[comm.design.actual.first.specific.contents]; IF sel.first=NIL OR sel.rest#NIL THEN ERROR; -- therefore sel#NIL ! offset _ [comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y]; ob _ CDRepetitions.CreateRepetition[comm.design, sel.first.ob, count, offset, sel.first.orientation]; location _ sel.first.location; IF offset.x<0 THEN location.x _ location.x+(count-1)*offset.x; IF offset.y<0 THEN location.y _ location.y+(count-1)*offset.y; CDOps.IncludeObjectI[comm.design, ob, location, CDOrient.original]; END; ChangeRepetition: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance = CDCommandOps.TheInstance[comm, "change a repetition "]; IF inst#NIL THEN IF ~ISTYPE[inst.ob.specificRef, CDRepetitions.RepPtr] THEN TerminalIO.WriteRope["selected ob not a repetition"] ELSE { offset: CD.Position = [comm.pos.x-comm.sPos.x, comm.pos.y-comm.sPos.y]; rp: CDRepetitions.RepPtr = NARROW[inst.ob.specificRef]; CDOps.RedrawInstance[comm.design, inst]; inst.ob _ CDRepetitions.CreateRepetition[comm.design, rp.ob, rp.count, offset, CDOrient.ComposeOrient[rp.orientation, inst.orientation]]; inst.orientation _ CDOrient.original; CDOps.RedrawInstance[comm.design, inst, FALSE]; TerminalIO.WriteRope[" done\n"] }; END; TransformToCellS: PROC [comm: CDSequencer.Command] = BEGIN n: NAT; TerminalIO.WriteRope["transform to cell\n"]; n _ CDCallSpecific.CallForSelected[design: comm.design, objectSpecific: $TransformToCell, whatElse: TransformOthers]; TerminalIO.WriteInt[n]; TerminalIO.WriteRope[" objects transformed\n"]; END; TransformOthers: PROC [design: CD.Design, inst: CD.Instance, x: REF] RETURNS [done: BOOL_TRUE, removeMe: BOOL_FALSE, include: CD.InstanceList_NIL, repaintMe: BOOL_FALSE, repaintInclude: BOOL_FALSE] = BEGIN IF inst.ob.class.inDirectory AND ~CDCells.IsCell[inst.ob] THEN { cob: CD.Object _ CDDirectory.ExpandComplete[inst.ob, design, design]; IF done _ cob#NIL THEN { ci: CD.Instance _ CDInstances.Copy[inst]; repaintInclude _ removeMe _ repaintMe _ TRUE; include _ LIST[ci]; ci.ob _ cob; } }; END; CDSequencer.ImplementCommand[$DrawRepetition, MakeRepetition]; CDSequencer.ImplementCommand[$ChangeRepetition, ChangeRepetition]; CDSequencer.ImplementCommand[$TransformToCellS, TransformToCellS]; END. ÒCDRepetitionCommands.mesa (part of ChipNDale) Copyright c 1983, 1984 by Xerox Corporation. All rights reserved. by Christian Jacobi, July 11, 1983 3:42 pm last edited Christian Jacobi, March 17, 1986 5:20:43 pm PST AllRepetitionsToCells: PROC [comm: CDSequencer.Command] = BEGIN n: NAT _ 0; repList: LIST OF CD.Object _ NIL; --we make a list first, otherwise: directory changes while the enumeration FindRepetitions: CDDirectory.EachEntryAction = -- PROC [name: Rope.ROPE, ob: CD.Object] RETURNS [quit: BOOL_FALSE] BEGIN WITH ob.specificRef SELECT FROM rp: CDRepetitions.RepPtr => repList _ CONS[ob, repList]; ENDCASE => NULL END; TerminalIO.WriteRope["transform all repetitions to cells\n"]; [] _ CDDirectory.Enumerate[design: comm.design, action: FindRepetitions]; FOR list: LIST OF CD.Object _ repList, list.rest WHILE list#NIL DO name: Rope.ROPE _ CDDirectory.Name[list.first]; rCell: CD.Object _ CDDirectory.Expand[list.first, comm.design, comm.design]; IF rCell=NIL THEN TerminalIO.WriteRope[Rope.Cat["** ", name, " not transformed\n"]] ELSE { [] _ CDDirectory.Remove[design: comm.design, name: name, expectObject: list.first]; [] _ CDDirectory.Rename[design: comm.design, object: rCell, newName: name]; n _ n+1; CDDirectory.ReplaceObject[design: comm.design, old: list.first, new: rCell]; TerminalIO.WriteRope[Rope.Cat[" cell ", CDDirectory.Name[rCell], " generated\n"]] }; ENDLOOP; TerminalIO.WriteInt[n]; TerminalIO.WriteRope[" repetitions transformed\n"]; END; Êô˜codešœ/™/Kšœ Ïmœ7™BKšœ,™,Kšœ<™Kšžœ žœ,˜>K˜CKšžœ˜—K˜š œžœ˜4Kšž˜KšœžœD˜Lšžœžœžœ˜šžœžœ,žœ˜;Kšœ4˜4—šžœ˜Kšœžœ=˜GKšœžœ˜7Kšœ(˜(Kšœ‰˜‰Kšœ%˜%Kšœ(žœ˜/Kšœ˜Kšœ˜——Kšžœ˜—K˜š œžœ˜4Kšž˜Kšœžœ˜K˜,Kšœu˜uK˜GKšžœ˜K˜—š  œžœ žœžœžœ˜EKšžœžœžœ žœžœ žœžœ˜MKš œ žœžœžœžœ˜4Kšž˜šžœžœžœ˜@Kšœžœ>˜Ešžœ žœžœ˜Kšœžœ#˜)Kšœ%žœ˜-Kšœ žœ˜Kšœ ˜ K˜—K˜—Kšžœ˜—K˜š œžœ™9Kšž™Kšœžœ™ š œ žœžœžœ žœ™!KšœJ™J—K™šÏbœ™.KšœC™CKšž™šžœžœž™Kšœ&žœ™8Kšžœž™—Kšžœ™—K™Kšœ=™=KšœI™Iš žœžœžœžœžœžœž™BKšœ žœ ™/KšœžœC™Lšžœžœžœ™KšœA™A—šžœ™KšœS™SKšœK™KKšœ™KšœL™LKšœS™SKšœ™—Kšžœ™—K™KKšžœ™K™K™—K˜>K˜BKšœB˜BKšžœ˜K˜K˜K˜K˜—…— ,ò