LichenComparisonLog.Mesa
Bertrand Serlet June 4, 1986 4:16:24 pm PDT
Last tweaked by Mike Spreitzer on May 4, 1987 2:43:52 pm PDT
DIRECTORY CardHashTableThreaded, IO, Rope, LichenDataStructure, LichenComparisonOps, TiogaOps, ViewerClasses, ViewerForkers, ViewerIO;
LichenComparisonLog: CEDAR PROGRAM
IMPORTS CardHashTableThreaded, IO, Rope, LichenDataStructure, TiogaOps, ViewerForkers, ViewerIO
EXPORTS LichenComparisonOps
=
BEGIN OPEN LichenDataStructure, LichenComparisonOps;
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, v.colorNext WHILE v # NIL DO
IF v.graph=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[v.oldColor], IO.card[v.curColor], IO.bool[v.unique], IO.bool[v.suspect], IO.rope[VerboseVName[v]]];
IF v.equiv # NIL THEN Log["\t%g\n", IO.rope[VerboseVName[v.equiv]]] 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 ← Describe[v, v.containingCT];
IF name.Length[]=0 THEN name ← IO.PutFR["%bB^", [cardinal[LOOPHOLE[v]]]];
};
END.