StructuralComparisonLog.Mesa
Bertrand Serlet June 4, 1986 4:16:24 pm PDT
Last tweaked by Mike Spreitzer on March 26, 1987 12:54:09 pm PST
DIRECTORY CardHashTableThreaded, IO, Rope, StructuralComparisonDataStructure, StructuralComparisonOps, TiogaOps, ViewerClasses, ViewerForkers, ViewerIO;
StructuralComparisonLog: CEDAR PROGRAM
IMPORTS CardHashTableThreaded, IO, Rope, StructuralComparisonDataStructure, TiogaOps, ViewerForkers, ViewerIO
EXPORTS StructuralComparisonOps
SHARES StructuralComparisonDataStructure
=
BEGIN OPEN StructuralComparisonDataStructure;
log: IO.STREAMNIL;
viewer: ViewerClasses.Viewer ← NIL;
EnsureLog: PROC = {
IF log = NIL OR viewer = NIL OR viewer.destroyed THEN {
log ← ViewerIO.CreateViewerStreams["Structural Comparison Debug Log"].out;
viewer ← ViewerIO.GetViewerFromStream[log];
IF viewer = NIL THEN ERROR;
TiogaOps.SetNodeStyle["Ascii", TiogaOps.ViewerDoc[viewer]];
viewer.newVersion ← FALSE;
ViewerForkers.ForkPaint[viewer: viewer, hint: caption, tryShortCuts: TRUE];
};
};
Log: PUBLIC PROC [format: ROPE, v1, v2, v3, v4, v5: IO.Value ← [null[]]] = {
EnsureLog[];
log.PutF[format, v1, v2, v3, v4, v5]};
FlushLog: PUBLIC PROC = {EnsureLog[]; log.Flush[]};
WriteAll: PUBLIC PROC [when: ROPE, descriptions: RealGraphDescriptions, a, b: CellType, oldColorData, curColorData: ColorTable] =
BEGIN
Log["\n%g\n", IO.rope[when]];
WriteColorTable[curColorData, descriptions];
WriteParts[descriptions[A], a];
WriteParts[descriptions[B], b];
Log["\nDone %g\n", IO.rope[when]];
END;
WriteColorTable: PUBLIC PROC [colorTable: ColorTable, descriptions: RealGraphDescriptions] =
BEGIN
WriteColor: PROC [key: CARD, value: REF ANY] RETURNS [quit: BOOLFALSE] --CardHashTableThreaded.EachPairAction-- = {
color: Color = key;
ccd: ColorData = NARROW[value];
Log["%08x %4g %4g", IO.card[color], IO.card[ccd.count[A]], IO.card[ccd.count[B]]];
Log[" %5g", IO.bool[ccd.suspect]];
FOR g: RealGraphID IN RealGraphID DO
first: BOOLTRUE;
FOR v: Vertex ← ccd.firstVertex, GetColorNext[v] WHILE v # NIL DO
IF GetGraph[v]=g THEN {
Log[" "];
IF first THEN {Log["%g: {", [rope[descriptions[g]]]]; first ← FALSE};
Log[VerboseVName[v]];
};
ENDLOOP;
IF NOT first THEN Log["}"];
ENDLOOP;
Log["\n"];
};
Log["\nColorTable:\n"];
Log["Color, number of %g vertices, num %g, suspect, vertex list\n", [rope[descriptions[A]]], [rope[descriptions[B]]]];
[] ← colorTable.Pairs[WriteColor];
Log["\n"];
END;
WriteParts: PROC [description: ROPE, ct: CellType] =
BEGIN
WriteVertex: PROC [v: Vertex] = {
Log["%08x %08x %5g %5g %12g", IO.card[OldColor[v]], IO.card[CurColor[v]], IO.bool[GetUnique[v]], IO.bool[GetSuspect[v]], IO.rope[VerboseVName[v]]];
IF GetEquiv[v] # NIL THEN Log["\t%g\n", IO.rope[VerboseVName[GetEquiv[v]]]] ELSE Log["\n"];
};
Log["\n%g vertices:\n", IO.rope[description]];
Log["OldColor CurColor Unique Suspect Name\t\tPartner\n"];
EnumerateParts[ct, WriteVertex, TRUE];
END;
VerboseVName: PUBLIC PROC [v: Vertex] RETURNS [name: ROPE] = {
name ← IF VName[v].Length[] # 0 THEN VName[v] ELSE IO.PutFR["%bB^", [cardinal[LOOPHOLE[v]]]];
};
PrintCellType: PROC [to: IO.STREAM, ct: CellType] = {
PrintIfNet: PROC [v: Vertex] = {
SELECT v.class FROM
net => {to.PutChar[' ]; to.PutRope[VerboseVName[v]]};
cell => NULL;
ENDCASE => ERROR;
};
PrintIfCI: PROC [v: Vertex] = {
SELECT v.class FROM
net => NULL;
cell => PrintCI[to, v];
ENDCASE => ERROR;
};
to.PutF["%g: CellType\n\tNets:", [rope[ct.name]]];
EnumerateParts[ct, PrintIfNet, FALSE];
to.PutRope["\n\tChildren:"];
EnumerateParts[ct, PrintIfCI, TRUE];
to.PutRope["\n\tEndCellType\n"];
};
PrintCI: PROC [to: IO.STREAM, v: Vertex] = {
first: BOOLTRUE;
pi: PortIndex ← 0;
to.PutF["\n\t\t%g: %g[", [rope[VerboseVName[v]]], [rope[v.type.name]]];
FOR e: Edge ← v.firstEdge, e.sides[cell].next WHILE e # NIL DO
portName: ROPE = v.type.ports[pi].name;
netName: ROPE = VerboseVName[e.sides[net].v];
IF NOT portName.Equal[netName] THEN {
IF first THEN first ← FALSE ELSE to.PutRope[", "];
to.PutF["%g: %g", [rope[portName]], [rope[netName]]];
};
pi ← pi + 1;
ENDLOOP;
to.PutF["]"];
};
END.