StructuralComparisonLog.Mesa
Last Edited by: Spreitzer, May 7, 1986 4:18:02 pm PDT
Bertrand Serlet June 4, 1986 4:16:24 pm PDT
DIRECTORY IntHashTableThreaded, IO, Rope, StructuralComparisonDataStructure, StructuralComparisonOps, ViewerIO;
StructuralComparisonLog: CEDAR PROGRAM
IMPORTS IntHashTableThreaded, IO, Rope, StructuralComparisonDataStructure, ViewerIO
EXPORTS StructuralComparisonOps
SHARES StructuralComparisonDataStructure
=
BEGIN OPEN StructuralComparisonDataStructure;
log: IO.STREAM ← ViewerIO.CreateViewerStreams["Structural Comparison Debug Log"].out;
Log: PUBLIC PROC [format: ROPE, v1, v2, v3, v4, v5: IO.Value ← [null[]]] =
{log.PutF[format, v1, v2, v3, v4, v5]};
FlushLog: PUBLIC PROC = {log.Flush[]};
WriteAll: PUBLIC PROC [when: ROPE, a, b: CellType, oldColorData, curColorData: ColorTable] =
BEGIN
Log["\n%g\n", IO.rope[when]];
WriteColorTable[curColorData];
WriteParts["A", a];
WriteParts["B", b];
Log["\nDone %g\n", IO.rope[when]];
END;
WriteColorTable: PUBLIC PROC [colorTable: ColorTable] =
BEGIN
WriteColor: PROC [key: INT, value: REF ANY] RETURNS [quit: BOOLFALSE] --IntHashTableThreaded.EachPairAction-- = {
color: Color = key;
ccd: ColorData = NARROW[value];
Log["%011d %4g %4g", IO.int[color], IO.card[ccd.count[A]], IO.card[ccd.count[B]]];
Log[" %5g", IO.bool[ccd.suspect]];
FOR v: Vertex ← ccd.firstVertex, GetColorNext[v] WHILE v # NIL DO
Log[" %g.%g", IO.rope[graphIDToRope[GetGraph[v]]], IO.rope[VerboseVName[v]]];
ENDLOOP;
Log["\n"];
};
Log["\nColorTable:\n"];
[] ← colorTable.Pairs[WriteColor];
Log["\n"];
END;
WriteParts: PROC [graphID: ROPE, ct: CellType] =
BEGIN
WriteVertex: PROC [v: Vertex] = {
Log["%011d)\t%011d\t%5g\t%5g\t%12g", IO.int[OldColor[v]], IO.int[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["\nGraph %g vertices:\n", IO.rope[graphID]];
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.