RoseVectorsImpl.Mesa
Last Edited by: Spreitzer, July 11, 1985 9:52:45 pm PDT
Last Edited by: Gasbarro, August 16, 1984 4:03:20 pm PDT
Louis Monier December 11, 1985 6:07:45 pm PST
DIRECTORY IO, RoseTypes, RoseVectors;
RoseVectorsImpl: CEDAR PROGRAM
IMPORTS IO
EXPORTS RoseVectors
=
BEGIN OPEN RoseTypes;
hexDigits: ARRAY [0 .. 16) OF ROPE = [
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "A", "B", "C", "D", "E", "F"];
WriteHeader: PUBLIC PROC [to: STREAM, cell: Cell] = {
FOR i: NAT IN [0 .. cell.type.ports.length) DO
to.PutF[" \"%q\"", [rope[cell.type.ports[i].name]]];
ENDLOOP;
to.PutRope["\n"];
};
WriteVector: PUBLIC PROC [to: STREAM, cell: Cell] = {
FOR i: NAT IN [0 .. cell.interfaceNodes.length) DO
node: Node = cell.interfaceNodes[i];
fmt: Format = node.type.procs.GetFormat[node.type, NIL];
head: StrengthRingHead = node.byStrength[node.currentStrength];
someInside, someOutside: BOOLFALSE;
IF NOT node.type.simple THEN ERROR;
FOR s: Slot ← head.first, s.cell.realCellStuff.effectivePorts[s.effectivePortIndex].strengthNext WHILE s # nilSlot DO
IF IsAncestor[cell, s.cell] THEN someInside ← TRUE ELSE someOutside ← TRUE;
ENDLOOP;
to.PutRope[IF (someInside AND NOT someOutside) THEN "O" ELSE "I"];
to.PutRope[" "];
to.PutRope[hexDigits[ORD[node.currentStrength]]];
to.PutF[" \"%q\" ", [rope[fmt.FormatValue[node, fmt, node.valPtr]]] ];
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.