DIRECTORY Asserting, IO, Rope, RoseTypes, RoseVectors; RoseVectorsImpl: CEDAR PROGRAM IMPORTS Asserting, IO, Rope EXPORTS RoseVectors = BEGIN OPEN RoseTypes; VectorMemory: TYPE = REF VectorMemoryPrivate; VectorMemoryPrivate: TYPE = RECORD [elts: SEQUENCE length: NAT OF Elt]; Elt: TYPE = RECORD [ someInside, someOutside: BOOL _ FALSE, strength: Strength _ FIRST[Strength], bits: ROPE _ "?Unitialized, you fool!"]; hexDigits: ARRAY [0 .. 16) OF ROPE = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; memory: ATOM = $RoseVectorMemory; WriteHeader: PUBLIC PROC [to: STREAM, cell: Cell] = { vm: VectorMemory = NEW [VectorMemoryPrivate[cell.type.ports.length]]; FOR i: NAT IN [0 .. vm.length) DO vm[i] _ [] ENDLOOP; cell.other _ Asserting.AssertFn1[memory, vm, cell.other]; to.PutF["%g", [integer[cell.type.ports.length]] ]; FOR i: NAT IN [0 .. cell.type.ports.length) DO type: NodeType = cell.type.ports[i].type; to.PutF[ " \"%q\" %g", [rope[cell.type.ports[i].name]], [integer[type.procs.Bits[type].data]] ]; ENDLOOP; to.PutRope["\n"]; }; WriteVector: PUBLIC PROC [to: STREAM, cell: Cell] = { vm: VectorMemory = NARROW[Asserting.FnVal[memory, cell.other]]; FOR i: NAT IN [0 .. cell.interfaceNodes.length) DO node: Node = cell.interfaceNodes[i]; fmt: Format = node.type.procs.GetFormat[node.type, "16"]; head: StrengthRingHead = node.byStrength[node.currentStrength]; elt: Elt _ [FALSE, FALSE, node.currentStrength, NIL]; ropeLength: INT; IF NOT node.type.simple THEN ERROR; IF fmt = NIL THEN ERROR; FOR s: Slot _ head.first, s.cell.realCellStuff.effectivePorts[s.effectivePortIndex].strengthNext WHILE s # nilSlot DO IF IsAncestor[cell, s.cell] THEN elt.someInside _ TRUE ELSE elt.someOutside _ TRUE; ENDLOOP; elt.bits _ fmt.FormatValue[node, fmt, node.valPtr]; ropeLength _ elt.bits.Length[]; IF elt.bits.Fetch[ropeLength-1] # 'H THEN ERROR; elt.bits _ elt.bits.Substr[0, ropeLength-1]; IF elt.someInside = vm[i].someInside AND elt.someOutside = vm[i].someOutside AND elt.strength = vm[i].strength AND elt.bits.Equal[vm[i].bits] THEN to.PutRope[" ."] ELSE { to.PutF[ " %g%g %g", [integer[ (IF elt.someInside THEN 1 ELSE 0) + (IF elt.someOutside THEN 2 ELSE 0)]], [rope[hexDigits[ORD[elt.strength]]]], [rope[elt.bits]] ]; vm[i] _ elt; }; ENDLOOP; to.PutRope["\n"]; }; IsAncestor: PROC [a, d: Cell] RETURNS [is: BOOL] = { FOR d _ d, d.parent WHILE d # NIL DO IF d = a THEN RETURN [TRUE] ENDLOOP; is _ FALSE; }; END. ΐRoseVectorsImpl.Mesa Last Edited by: Spreitzer, December 12, 1985 12:45:17 pm PST Last Edited by: Gasbarro, August 16, 1984 4:03:20 pm PDT Louis Monier December 11, 1985 6:07:45 pm PST ΚŠ– "cedar" style˜šœ™J™