DIRECTORY Core, CoreProperties, IO, Rope, RoseBind, RoseBindPrivate, RoseTranslate, RoseWireTypes; RoseTypeStringImpl: CEDAR PROGRAM IMPORTS CoreProperties, IO, Rope, RoseBind EXPORTS RoseBind, RoseTranslate = BEGIN OPEN RoseWireTypes, RoseTranslate; BehaviorClassRec: PUBLIC TYPE = RoseBindPrivate.BehaviorClassRec; TypeStringFromClass: PUBLIC PROC [bc: RoseBindPrivate.BehaviorClass] RETURNS [ts: TypeString] = { out: IO.STREAM _ IO.ROS[]; Work: PROC [w: Core.Wire] = { first: BOOL _ FALSE; DoProp: PROC [key: ATOM] = { val: REF ANY _ CoreProperties.GetProp[w.properties, key]; IF val = NIL THEN RETURN; IF first THEN first _ FALSE ELSE out.PutRope[" "]; WITH val SELECT FROM rb: REF BOOL => out.PutF["(%g %g)", [atom[key]], [boolean[rb^]] ]; ENDCASE => out.PutF["(%g %g)", [atom[key]], [refAny[val]] ]; }; out.PutF["(%g ", [refAny[w.name]]]; SELECT w.structure FROM atom => out.PutRope["(atom) "]; sequence => { out.PutRope["(sequence "]; Work[w.elements[0]]; out.PutRope[") "]; }; record => { out.PutRope["(record "]; FOR i: NAT IN [0 .. w.elements.size) DO Work[w.elements[i]]; ENDLOOP; out.PutRope[") "]; }; ENDCASE => ERROR; out.PutRope["("]; DoProp[RoseBind.switchWire]; DoProp[RoseBind.variableWire]; DoProp[RoseBind.complexDrive]; DoProp[RoseBind.simpleDrive]; out.PutRope["))"]; }; Work[bc.publicWirePrototype]; ts _ out.RopeFromROS[]; }; CompareTypeStrings: PUBLIC PROC [a, b: TypeString] RETURNS [differenceReport: ROPE--NIL means equal--] = { la: LORA _ NARROW[IO.RIS[a].GetRefAny[]]; lb: LORA _ NARROW[IO.RIS[b].GetRefAny[]]; Work: PROC [la, lb: LORA, namePrefixA, namePrefixB: ROPE] RETURNS [differenceReport: ROPE] = { nameStepA: ROPE = ToName[la.first]; nameStepB: ROPE = ToName[lb.first]; nameA: ROPE = namePrefixA.Cat[".", nameStepA]; nameB: ROPE = namePrefixB.Cat[".", nameStepB]; strA: LORA = NARROW[la.rest.first]; strB: LORA = NARROW[lb.rest.first]; propsA: LORA _ NARROW[la.rest.rest.first]; propsB: LORA _ NARROW[lb.rest.rest.first]; IF la.rest.rest.rest # NIL OR lb.rest.rest.rest # NIL THEN ERROR; IF NOT nameStepA.Equal[nameStepB] THEN RETURN [IO.PutFR[ "name disagreement at %g ~ %g", [rope[nameA]], [rope[nameB]] ]]; IF strA.first # strB.first THEN RETURN [IO.PutFR[ "structural disagreement (%g vs %g) at %g ~ %g", [atom[NARROW[strA.first]]], [atom[NARROW[strB.first]]], [rope[nameA]], [rope[nameB]] ]]; SELECT strA.first FROM $atom => NULL; $sequence => IF (differenceReport _ Work[NARROW[strA.rest.first], NARROW[strB.rest.first], nameA, nameB]) # NIL THEN RETURN; $record => { subsA: LORA _ strA.rest; subsB: LORA _ strB.rest; WHILE subsA # NIL AND subsB # NIL DO IF (differenceReport _ Work[NARROW[subsA.first], NARROW[subsB.first], nameA, nameB]) # NIL THEN RETURN; subsA _ subsA.rest; subsB _ subsB.rest; ENDLOOP; IF subsA # NIL OR subsB # NIL THEN RETURN [IO.PutFR[ "different number of children at %g ~ %g", [rope[nameA]], [rope[nameB]] ]]; }; ENDCASE => ERROR; WHILE propsA # NIL AND propsB # NIL DO pairA: LORA = NARROW[propsA.first]; pairB: LORA = NARROW[propsB.first]; keyA: ATOM = NARROW[pairA.first]; keyB: ATOM = NARROW[pairB.first]; valA: REF ANY = pairA.rest.first; valB: REF ANY = pairB.rest.first; valEq: BOOL _ valA = valB; IF pairA.rest.rest # NIL OR pairB.rest.rest # NIL THEN ERROR; IF keyA # keyB THEN RETURN [IO.PutFR[ "property list difference (%g vs %g) at %g ~ %g", [atom[keyA]], [atom[keyB]], [rope[nameA]], [rope[nameB]] ]]; WITH valA SELECT FROM rba: REF BOOL => WITH valB SELECT FROM rbb: REF BOOL => valEq _ rba^ = rbb^; ENDCASE; ENDCASE; IF NOT valEq THEN RETURN [IO.PutFR[ "property %g value difference (%g vs %g) at %g ~ %g", [atom[keyA]], [refAny[valA]], [refAny[valB]], [rope[nameA]], [rope[nameB]] ]]; propsA _ propsA.rest; propsB _ propsB.rest; ENDLOOP; IF propsA # NIL OR propsB # NIL THEN RETURN [IO.PutFR[ "different number of properties, at %g ~ %g", [rope[nameA]], [rope[nameB]] ]]; RETURN [NIL]; }; differenceReport _ Work[la, lb, NIL, NIL]; }; ToName: PROC [ra: REF ANY] RETURNS [asRope: ROPE] = { asRope _ NARROW[ra]; }; END. rRoseTypeStringImpl.Mesa Spreitzer, October 1, 1985 6:59:10 pm PDT Barth, September 10, 1985 8:26:25 pm PDT Κζ˜™J™*Icode™(—J˜KšΟk œœ@˜bK˜šΠbxœœ˜!Kšœœ˜*Kšœ˜Kšœ˜—K˜Kšœœ˜(K˜Kšœœœ$˜AK˜šΟnœœœ%œ˜aKš œœœœœ˜šŸœœ˜Kšœœœ˜šŸœœœ˜Kšœœœ-˜9Kšœœœœ˜Kšœœ œœ˜2šœœ˜Kšœœœ6˜BKšœ5˜<—K˜—K˜#šœ ˜K˜˜ K˜K˜K˜K˜—˜ K˜šœœœ˜'K˜Kšœ˜—K˜K˜—Kšœœ˜—K˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜K˜—K˜K˜K˜—K˜š ŸœœœœΟcœ˜jKš œœœœœ˜)Kš œœœœœ˜)š Ÿœœ œœœœ˜^Kšœ œ˜#Kšœ œ˜#Kšœœ#˜.Kšœœ#˜.Kšœœœ˜#Kšœœœ˜#Kšœœœ˜*Kšœœœ˜*Kš œœœœœœ˜Aš œœœœœ˜8K˜K˜K˜ K˜—šœœœœ˜1K˜0Kšœœ˜Kšœœ˜Kšœ˜Kšœ ˜ K˜—šœ ˜Kšœ œ˜Kš œ œœœ$œœœ˜|˜ Kšœœ ˜Kšœœ ˜š œ œœ œ˜$Kš œœœ œœœ˜gK˜K˜Kšœ˜—šœ œœ œœœœ˜4K˜*K˜K˜ K˜—K˜—Kšœœ˜—š œ œœ œ˜&Kšœœœ˜#Kšœœœ˜#Kšœœœ˜!Kšœœœ˜!Kšœœœ˜!Kšœœœ˜!Kšœœ˜Kš œœœœœœ˜=šœ œœœ˜%K˜1K˜ Kšœ ˜ K˜K˜ K˜—šœœ˜š œœœœœ˜&Kšœœœ˜%Kšœ˜—Kšœ˜—š œœœœœ˜#K˜5K˜ K˜K˜K˜K˜ K˜—Kšœ˜Kšœ˜Kšœ˜—šœ œœ œœœœ˜6K˜-K˜K˜ K˜—Kšœœ˜ K˜—Kšœ œœ˜*K˜—K˜š Ÿœœœœœ œ˜5Kšœ œ˜K˜—K˜Kšœ˜—…—°