Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: pkg/compiler/lib/src/serialization/equivalence.dart

Issue 1945263003: Serialize ParameterElement.node and ParameterElement.initializer for type inference (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/serialization/equivalence.dart
diff --git a/pkg/compiler/lib/src/serialization/equivalence.dart b/pkg/compiler/lib/src/serialization/equivalence.dart
index 969ef408d23cdb4b69b78e87b8ad5416fe3866e7..be8ff7fc8a2fe65415fb46c95a77a21d03c157a6 100644
--- a/pkg/compiler/lib/src/serialization/equivalence.dart
+++ b/pkg/compiler/lib/src/serialization/equivalence.dart
@@ -276,6 +276,13 @@ bool areNewStructuresEquivalent(NewStructure a, NewStructure b) {
}
}
+/// Returns `true` if nodes [a] and [b] are equivalent.
+bool areNodesEquivalent(Node node1, Node node2) {
+ if (identical(node1, node2)) return true;
+ if (node1 == null || node2 == null) return false;
+ return node1.accept1(const NodeEquivalenceVisitor(), node2);
+}
+
/// Strategy for testing equivalence.
///
/// Use this strategy to determine equivalence without failing on inequivalence.
@@ -323,6 +330,11 @@ class TestStrategy {
List<ConstantExpression> list1, List<ConstantExpression> list2) {
return areConstantListsEquivalent(list1, list2);
}
+
+ bool testNodes(
+ Object object1, Object object2, String property, Node node1, Node node2) {
+ return areNodesEquivalent(node1, node2);
+ }
}
/// Visitor that checks for equivalence of [Element]s.
@@ -765,15 +777,33 @@ bool testResolvedAstEquivalence(
// Nothing more to check.
return true;
}
- return strategy.testElements(resolvedAst1, resolvedAst2, 'element',
+ bool result = strategy.testElements(resolvedAst1, resolvedAst2, 'element',
resolvedAst1.element, resolvedAst2.element) &&
- new NodeEquivalenceVisitor(strategy).testNodes(resolvedAst1, resolvedAst2,
- 'node', resolvedAst1.node, resolvedAst2.node) &&
- new NodeEquivalenceVisitor(strategy).testNodes(resolvedAst1, resolvedAst2,
- 'body', resolvedAst1.body, resolvedAst2.body) &&
+ strategy.testNodes(resolvedAst1, resolvedAst2, 'node', resolvedAst1.node,
+ resolvedAst2.node) &&
+ strategy.testNodes(resolvedAst1, resolvedAst2, 'body', resolvedAst1.body,
+ resolvedAst2.body) &&
testTreeElementsEquivalence(resolvedAst1, resolvedAst2, strategy) &&
strategy.test(resolvedAst1, resolvedAst2, 'sourceUri',
resolvedAst1.sourceUri, resolvedAst2.sourceUri);
+ if (resolvedAst1.element is FunctionElement) {
+ FunctionElement element1 = resolvedAst1.element;
+ FunctionElement element2 = resolvedAst2.element;
+ for (int index = 0; index < element1.parameters.length; index++) {
+ var parameter1 = element1.parameters[index];
+ var parameter2 = element2.parameters[index];
+ result = result &&
+ strategy.testNodes(parameter1, parameter2, 'node',
+ parameter1.implementation.node, parameter2.implementation.node) &&
+ strategy.testNodes(
+ parameter1,
+ parameter2,
+ 'initializer',
+ parameter1.implementation.initializer,
+ parameter2.implementation.initializer);
+ }
+ }
+ return result;
}
/// Tests the equivalence of the data stored in the [TreeElements] of
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698