<> <> <> 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.STREAM _ NIL; 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: BOOL _ FALSE] --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: BOOL _ TRUE; 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.