DIRECTORY IO, LichenCollections, LichenDataOps, LichenDataStructure, LichenIntFunctions, LichenPairCollections, LichenTransforms, LichenTransformsPrivate; LichenOtherTransforms: CEDAR PROGRAM IMPORTS IO, LichenCollections, LichenDataOps, LichenDataStructure, LichenIntFunctions, LichenPairCollections, LichenTransforms EXPORTS LichenTransforms = BEGIN OPEN LichenDataStructure, LichenTransforms, LichenDataOps, LichenTransformsPrivate, Colls:LichenCollections, PCs:LichenPairCollections, IntFns:LichenIntFunctions; CellTypeList: TYPE ~ LIST OF CellType; GroupUnorganized: PUBLIC PROC [ design: Design, mapper: ConstFunction--any _ Seq (role f sibling: instance of array* of type of newType's roleth child)--] RETURNS [newType: CellType, pairs: PCs.ConstOneToOne--domain of mapper f instance of array* of newType--, gcs: Seq--role f instance in newType--] ~ { ComputeName: PROC [] RETURNS [r: ROPE] ~ { pair: PCs.Pair ~ mapper.First[].P; r _ IO.PutFR["#gen%g", [integer[nGen _ nGen+1]]]; RETURN}; newTypeName: ROPE ~ ComputeName[]; pairsV: PCs.OneToOne ~ PCs.CreateHashOTO[]; Seed: PROC [pair: PCs.Pair] ~ { seq: Seq--role f sibling: instance of array* of type of newType's roleth child-- ~ IntFns.DeRef[pair[right]]; ci0: CellInstance ~ NARROW[seq.Apply[0].val]; ti: CellInstance ~ FullyInstantiate[newType, ci0.containingCT]; IF NOT pairsV.Store[[pair[left], ti]] THEN ERROR; RETURN}; newType _ CreateCellType[design, newTypeName, NIL, TRUE, NIL, NIL]; mapper.Enumerate[Seed]; pairs _ pairsV.Freeze; gcs _ LowerChildren[design, newType, PCs.Compose[[pairs.Invert, mapper]].AsConst]; RETURN}; nGen: NATURAL _ 0; SimpleGrouper: PROC [design: Design, cellTypes: Set--of CellType--] RETURNS [grouper: ConstFunction--any _ Seq (role f sibling: instance of array* of cellTypes[role])--] ~ { roles: NATURAL ~ cellTypes.Size[]; ctSeq: Seq--role f CellType-- ~ IntFns.CreateFromCollection[coll: cellTypes]; grouperV: PCs.OneToOne ~ PCs.CreateHashOTO[]; PerCellType: PROC [ra: REF ANY] ~ { ct: CellType ~ NARROW[ra]; IF ct.asUnorganized#NIL THEN { sibs: Seq--role f sibling: instance of array* of cellTypes[role]-- ~ CreateSeq[len: roles, oneToOne: TRUE]; PerInstance: PROC [ra: REF ANY] ~ { ci: CellInstance ~ NARROW[ra]; cit: CellType _ ci.type; DO mr: IntFns.MaybeInt ~ ctSeq.InvApply[cit]; IF mr.found THEN { role: NAT ~ mr.i; IF sibs.AddPair[[role, ci], PCs.addIfNew][leftToRight]#new THEN ERROR; RETURN}; IF cit.asArray=NIL THEN EXIT; cit _ cit.asArray.eltType; ENDLOOP; RETURN}; ct.asUnorganized.containedInstances.Enumerate[PerInstance]; SELECT sibs.Size[] FROM 0 => NULL; roles => IF NOT grouperV.Store[[ct, sibs.Freeze.Refify]] THEN ERROR; ENDCASE => ERROR; }; RETURN}; design.cellTypes.Enumerate[PerCellType]; grouper _ grouperV.Freeze; RETURN}; CellTypeListLength: PROC [cellTypes: CellTypeList] RETURNS [length: NATURAL] ~ { length _ 0; FOR cellTypes _ cellTypes, cellTypes.rest WHILE cellTypes # NIL DO length _ length + 1 ENDLOOP; RETURN}; BaseStar: PROC [ct: CellType] RETURNS [CellType] ~ { WHILE ct.asArray#NIL DO ct _ ct.asArray.eltType ENDLOOP; RETURN [ct]}; END. ΆLichenOtherTransforms.Mesa Last tweaked by Mike Spreitzer on August 28, 1987 11:18:00 am PDT l {ti _ Instantiate[newType, seq[0].parent]; pairs _ pairs + } Κχ˜™IcodešœA™A—J˜KšΟk œœŽ˜šK˜šΟnœœ˜$Kšœœt˜~Kšœ˜Kšœ˜—K˜Kš œœPžœžœžœ˜¨K˜Kšœœœœ ˜&K˜šžœœ˜šœ˜Kšœ˜Kš œΟcΠcmŸ  ŸΠcuŸ‘Ÿ œ˜j—šœ˜KšœŸ Ÿ‘Ÿ œ˜MKšœŸ Ÿœ˜+—šž œœœœ˜*Kšœ"˜"Kšœœ+˜1Kšœ˜—Kšœ œ˜"Kšœ+˜+šžœœ˜KšΟgœQ™RKš œŸ Ÿ‘Ÿ‘Ÿœ˜mKšœœ˜-Kšœ?˜?Kšœœ œœ˜1Kšœ˜—Kš œ.œœœœ˜CKšœ˜Kšœ˜KšœR˜RKšœ˜Kšœœ˜—K˜šž œœ ŸœœŸ Ÿ  Ÿ‘Ÿœ˜­Kšœœ˜"Kšœ Ÿ Ÿ œ0˜MKšœ-˜-šž œœœœ˜#Kšœœ˜šœœœ˜Kš œ Ÿ Ÿ‘Ÿœ#œ˜kšž œœœœ˜#Kšœœ˜K˜š˜Kšœ*˜*šœ œ˜Kšœœ˜Kšœ9œœ˜FKšœ˜—Kšœ œœœ˜Kšœ˜Kšœ˜—Kšœ˜—Kšœ;˜;šœ ˜Kšœœ˜ Kš œ œœ*œœ˜DKšœœ˜—K˜—Kšœ˜—K˜(Kšœ˜Kšœ˜—K˜šžœœœ œ˜PK˜ Kš œ'œ œœœ˜_Kšœ˜—K˜šžœœœ˜4Kšœ œœœ˜8Kšœ˜ —K˜Kšœ˜—…— »