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

Side by Side Diff: pkg/compiler/lib/src/serialization/equivalence.dart

Issue 1883863002: Serialize JumpTarget and LabelDefinition. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove unused code. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/keys.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Functions for asserting equivalence across serialization. 5 /// Functions for asserting equivalence across serialization.
6 6
7 library dart2js.serialization.equivalence; 7 library dart2js.serialization.equivalence;
8 8
9 import '../common/resolution.dart'; 9 import '../common/resolution.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 final AstIndexComputer indices1; 783 final AstIndexComputer indices1;
784 final AstIndexComputer indices2; 784 final AstIndexComputer indices2;
785 final TreeElements elements1; 785 final TreeElements elements1;
786 final TreeElements elements2; 786 final TreeElements elements2;
787 bool success = true; 787 bool success = true;
788 788
789 TreeElementsEquivalenceVisitor( 789 TreeElementsEquivalenceVisitor(
790 this.indices1, this.indices2, this.elements1, this.elements2, 790 this.indices1, this.indices2, this.elements1, this.elements2,
791 [this.strategy = const TestStrategy()]); 791 [this.strategy = const TestStrategy()]);
792 792
793 bool testJumpTargets(
794 Node node1, Node node2, String property, JumpTarget a, JumpTarget b) {
795 if (identical(a, b)) return true;
796 if (a == null || b == null) return false;
797 return strategy.testElements(a, b, 'executableContext', a.executableContext,
798 b.executableContext) &&
799 strategy.test(a, b, 'nestingLevel', a.nestingLevel, b.nestingLevel) &&
800 strategy.test(a, b, 'statement', indices1.nodeIndices[a.statement],
801 indices2.nodeIndices[b.statement]) &&
802 strategy.test(
803 a, b, 'isBreakTarget', a.isBreakTarget, b.isBreakTarget) &&
804 strategy.test(
805 a, b, 'isContinueTarget', a.isContinueTarget, b.isContinueTarget) &&
806 strategy.testLists(a, b, 'labels', a.labels.toList(), b.labels.toList(),
807 (a, b) {
808 return indices1.nodeIndices[a.label] == indices2.nodeIndices[b.label];
809 });
810 }
811
812 bool testLabelDefinitions(Node node1, Node node2, String property,
813 LabelDefinition a, LabelDefinition b) {
814 if (identical(a, b)) return true;
815 if (a == null || b == null) return false;
816 return strategy.test(a, b, 'label', indices1.nodeIndices[a.label],
817 indices2.nodeIndices[b.label]) &&
818 strategy.test(a, b, 'labelName', a.labelName, b.labelName) &&
819 strategy.test(a, b, 'target', indices1.nodeIndices[a.target.statement],
820 indices2.nodeIndices[b.target.statement]) &&
821 strategy.test(
822 a, b, 'isBreakTarget', a.isBreakTarget, b.isBreakTarget) &&
823 strategy.test(
824 a, b, 'isContinueTarget', a.isContinueTarget, b.isContinueTarget);
825 }
826
793 visitNode(Node node1) { 827 visitNode(Node node1) {
794 if (!success) return; 828 if (!success) return;
795 int index = indices1.nodeIndices[node1]; 829 int index = indices1.nodeIndices[node1];
796 Node node2 = indices2.nodeList[index]; 830 Node node2 = indices2.nodeList[index];
797 success = strategy.testElements( 831 success = strategy.testElements(
798 node1, node2, '[$index]', elements1[node1], elements2[node2]) && 832 node1, node2, '[$index]', elements1[node1], elements2[node2]) &&
799 strategy.testTypes(node1, node2, 'getType($index)', 833 strategy.testTypes(node1, node2, 'getType($index)',
800 elements1.getType(node1), elements2.getType(node2)) && 834 elements1.getType(node1), elements2.getType(node2)) &&
801 strategy.test( 835 strategy.test(
802 node1, 836 node1,
803 node2, 837 node2,
804 'getSelector($index)', 838 'getSelector($index)',
805 elements1.getSelector(node1), 839 elements1.getSelector(node1),
806 elements2.getSelector(node2), 840 elements2.getSelector(node2),
807 areSelectorsEquivalent) && 841 areSelectorsEquivalent) &&
808 strategy.testConstants(node1, node2, 'getConstant($index)', 842 strategy.testConstants(node1, node2, 'getConstant($index)',
809 elements1.getConstant(node1), elements2.getConstant(node2)) && 843 elements1.getConstant(node1), elements2.getConstant(node2)) &&
810 strategy.testTypes(node1, node2, 'typesCache[$index]', 844 strategy.testTypes(node1, node2, 'typesCache[$index]',
811 elements1.typesCache[node1], elements2.typesCache[node2]); 845 elements1.typesCache[node1], elements2.typesCache[node2]) &&
846 testJumpTargets(
847 node1,
848 node2,
849 'getTargetDefinition($index)',
850 elements1.getTargetDefinition(node1),
851 elements2.getTargetDefinition(node2));
812 852
813 node1.visitChildren(this); 853 node1.visitChildren(this);
814 } 854 }
815 855
816 @override 856 @override
817 visitSend(Send node1) { 857 visitSend(Send node1) {
818 visitExpression(node1); 858 visitExpression(node1);
819 if (!success) return; 859 if (!success) return;
820 int index = indices1.nodeIndices[node1]; 860 int index = indices1.nodeIndices[node1];
821 Send node2 = indices2.nodeList[index]; 861 Send node2 = indices2.nodeList[index];
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 if (!success) return; 948 if (!success) return;
909 int index = indices1.nodeIndices[node1]; 949 int index = indices1.nodeIndices[node1];
910 RedirectingFactoryBody node2 = indices2.nodeList[index]; 950 RedirectingFactoryBody node2 = indices2.nodeList[index];
911 success = strategy.testElements( 951 success = strategy.testElements(
912 node1, 952 node1,
913 node2, 953 node2,
914 'getRedirectingTargetConstructor($index)', 954 'getRedirectingTargetConstructor($index)',
915 elements1.getRedirectingTargetConstructor(node1), 955 elements1.getRedirectingTargetConstructor(node1),
916 elements2.getRedirectingTargetConstructor(node2)); 956 elements2.getRedirectingTargetConstructor(node2));
917 } 957 }
958
959 @override
960 visitGotoStatement(GotoStatement node1) {
961 visitStatement(node1);
962 if (!success) return;
963 int index = indices1.nodeIndices[node1];
964 GotoStatement node2 = indices2.nodeList[index];
965 success = testJumpTargets(node1, node2, 'getTargetOf($index)',
966 elements1.getTargetOf(node1), elements2.getTargetOf(node2));
967 if (!success) return;
968 if (node1.target == null && node2.target == null) {
969 return;
970 }
971 success = testLabelDefinitions(node1, node2, 'getTarget($index)',
972 elements1.getTargetLabel(node1), elements2.getTargetLabel(node2));
973 }
974
975 @override
976 visitLabel(Label node1) {
977 visitNode(node1);
978 if (!success) return;
979 int index = indices1.nodeIndices[node1];
980 Label node2 = indices2.nodeList[index];
981 success = testLabelDefinitions(
982 node1,
983 node2,
984 'getLabelDefinition($index)',
985 elements1.getLabelDefinition(node1),
986 elements2.getLabelDefinition(node2));
987 }
918 } 988 }
919 989
920 class NodeEquivalenceVisitor implements Visitor1<bool, Node> { 990 class NodeEquivalenceVisitor implements Visitor1<bool, Node> {
921 final TestStrategy strategy; 991 final TestStrategy strategy;
922 992
923 const NodeEquivalenceVisitor([this.strategy = const TestStrategy()]); 993 const NodeEquivalenceVisitor([this.strategy = const TestStrategy()]);
924 994
925 bool testNodes( 995 bool testNodes(
926 var object1, var object2, String property, Node node1, Node node2) { 996 var object1, var object2, String property, Node node1, Node node2) {
927 if (node1 == node2) return true; 997 if (node1 == node2) return true;
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 @override 1685 @override
1616 bool visitStatement(Statement node1, Statement node2) { 1686 bool visitStatement(Statement node1, Statement node2) {
1617 throw new UnsupportedError('Unexpected nodes: $node1 <> $node2'); 1687 throw new UnsupportedError('Unexpected nodes: $node1 <> $node2');
1618 } 1688 }
1619 1689
1620 @override 1690 @override
1621 bool visitStringNode(StringNode node1, StringNode node2) { 1691 bool visitStringNode(StringNode node1, StringNode node2) {
1622 throw new UnsupportedError('Unexpected nodes: $node1 <> $node2'); 1692 throw new UnsupportedError('Unexpected nodes: $node1 <> $node2');
1623 } 1693 }
1624 } 1694 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/keys.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698