StructuralComparisonOuter.Mesa
Last Edited by: Spreitzer, May 7, 1986 4:19:01 pm PDT
DIRECTORY Asserting, Core, CoreClasses, CoreOps, CoreProperties, CoreStructuralComparison, HashTable, IntHashTableThreaded, Rope, RopeHash, StructuralComparisonDataStructure, StructuralComparisonOps, StructureFromCore;
StructuralComparisonOuter:
CEDAR
PROGRAM
IMPORTS HashTable, IntHashTableThreaded, StructuralComparisonDataStructure, StructuralComparisonOps, StructureFromCore
EXPORTS CoreStructuralComparison
SHARES StructuralComparisonDataStructure
=
BEGIN OPEN CoreStructuralComparison, StructuralComparisonDataStructure, StructuralComparisonOps, StructureFromCore;
Warning
:
PUBLIC
SIGNAL [
kind: WarningKind,
fromA, fromB: LIST OF Descendant
]
= CODE;
FlattenAndCompare
:
PUBLIC
PROC [
ctA, ctB: Core.CellType,
wireHints, instanceHints: HashTable.Table
]
RETURNS [isomorphic: BOOL]
= {
sctA: CellType = GetGraph[ctA, TRUE, TRUE];
sctB: CellType = GetGraph[ctB, TRUE, TRUE];
GenerateHints:
PROC [
Consume:
PROC [vA, vB: Vertex]] = {
TranslateAssn:
PROC [key, value:
REF
ANY]
RETURNS [quit:
BOOL ←
FALSE]
--HashTable.EachPairAction-- = {
Consume[GetStructure[sctA, key], GetStructure[sctB, value]];
};
[] ← wireHints.Pairs[TranslateAssn];
[] ← instanceHints.Pairs[TranslateAssn];
};
ReportColor:
PROC [key:
INT, value:
REF
ANY]
RETURNS [quit:
BOOL ←
FALSE]
--IntHashTableThreaded.EachPairAction-- = {
cd: ColorData = NARROW[value];
IF cd.count =
ALL[1]
THEN {
ds: ARRAY RealGraphID OF Descendant ← ALL[NIL];
ds[cd.firstVertex.GetGraph[]] ← GetCore[cd.firstVertex];
ds[GetColorNext[cd.firstVertex].GetGraph[]] ← GetCore[GetColorNext[cd.firstVertex]];
IF ds[A] #
NIL
AND ds[B] #
NIL
THEN
WITH ds[A]
SELECT
FROM
dw: DescendantWire => [] ← wireHints.Store[ds[A], ds[B]];
di: DescendantCellInstance => [] ← wireHints.Store[ds[A], ds[B]];
ENDCASE => ERROR;
}
ELSE {
ds: ARRAY RealGraphID OF DescendantList ← ALL[NIL];
FOR v: Vertex ← cd.firstVertex, GetColorNext[v]
WHILE v #
NIL
DO
container: CellType = SELECT v.graph FROM A => sctA, B => sctB, ENDCASE => ERROR;
IF NOT IsMirror[v] THEN ds[v.GetGraph[]] ← CONS[GetCore[v], ds[v.GetGraph[]]];
ENDLOOP;
SIGNAL Warning[
kind: IF cd.count[A] = cd.count[B] THEN stuck ELSE difference,
fromA: ds[A],
fromB: ds[B]];
};
};
partition: ColorTable;
[isomorphic, partition] ← CompareGraphs[sctA, sctB, GenerateHints, FALSE, FALSE];
[] ← partition.Pairs[ReportColor];
ForgetGraph[sctA];
ForgetGraph[sctB];
};
END.