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

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

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 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
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 '../closure.dart'; 9 import '../closure.dart';
10 import '../common/resolution.dart'; 10 import '../common/resolution.dart';
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 859
860 bool visit(ConstantValue value1, ConstantValue value2) { 860 bool visit(ConstantValue value1, ConstantValue value2) {
861 if (identical(value1, value2)) return true; 861 if (identical(value1, value2)) return true;
862 return strategy.test(value1, value2, 'kind', value1.kind, value2.kind) && 862 return strategy.test(value1, value2, 'kind', value1.kind, value2.kind) &&
863 value1.accept(this, value2); 863 value1.accept(this, value2);
864 } 864 }
865 865
866 @override 866 @override
867 bool visitConstructed( 867 bool visitConstructed(
868 ConstructedConstantValue value1, ConstructedConstantValue value2) { 868 ConstructedConstantValue value1, ConstructedConstantValue value2) {
869 return strategy.testTypes( 869 ResolutionInterfaceType type1 = value1.type;
870 value1, value2, 'type', value1.type, value2.type) && 870 ResolutionInterfaceType type2 = value2.type;
871 return strategy.testTypes(value1, value2, 'type', type1, type2) &&
871 strategy.testMaps( 872 strategy.testMaps(
872 value1, 873 value1,
873 value2, 874 value2,
874 'fields', 875 'fields',
875 value1.fields, 876 value1.fields,
876 value2.fields, 877 value2.fields,
877 areElementsEquivalent, 878 areElementsEquivalent,
878 (a, b) => strategy.testConstantValues( 879 (a, b) => strategy.testConstantValues(
879 value1, value2, 'fields.values', a, b)); 880 value1, value2, 'fields.values', a, b));
880 } 881 }
881 882
882 @override 883 @override
883 bool visitFunction( 884 bool visitFunction(
884 FunctionConstantValue value1, FunctionConstantValue value2) { 885 FunctionConstantValue value1, FunctionConstantValue value2) {
885 MethodElement method1 = value1.element; 886 MethodElement method1 = value1.element;
886 MethodElement method2 = value2.element; 887 MethodElement method2 = value2.element;
887 return strategy.testElements(value1, value2, 'element', method1, method2); 888 return strategy.testElements(value1, value2, 'element', method1, method2);
888 } 889 }
889 890
890 @override 891 @override
891 bool visitList(ListConstantValue value1, ListConstantValue value2) { 892 bool visitList(ListConstantValue value1, ListConstantValue value2) {
892 return strategy.testTypes( 893 ResolutionInterfaceType type1 = value1.type;
893 value1, value2, 'type', value1.type, value2.type) && 894 ResolutionInterfaceType type2 = value2.type;
895 return strategy.testTypes(value1, value2, 'type', type1, type2) &&
894 strategy.testConstantValueLists( 896 strategy.testConstantValueLists(
895 value1, value2, 'entries', value1.entries, value2.entries); 897 value1, value2, 'entries', value1.entries, value2.entries);
896 } 898 }
897 899
898 @override 900 @override
899 bool visitMap(MapConstantValue value1, MapConstantValue value2) { 901 bool visitMap(MapConstantValue value1, MapConstantValue value2) {
900 return strategy.testTypes( 902 ResolutionInterfaceType type1 = value1.type;
901 value1, value2, 'type', value1.type, value2.type) && 903 ResolutionInterfaceType type2 = value2.type;
904 return strategy.testTypes(value1, value2, 'type', type1, type2) &&
902 strategy.testConstantValueLists( 905 strategy.testConstantValueLists(
903 value1, value2, 'keys', value1.keys, value2.keys) && 906 value1, value2, 'keys', value1.keys, value2.keys) &&
904 strategy.testConstantValueLists( 907 strategy.testConstantValueLists(
905 value1, value2, 'values', value1.values, value2.values); 908 value1, value2, 'values', value1.values, value2.values);
906 } 909 }
907 910
908 @override 911 @override
909 bool visitType(TypeConstantValue value1, TypeConstantValue value2) { 912 bool visitType(TypeConstantValue value1, TypeConstantValue value2) {
910 return strategy.testTypes(value1, value2, 'type', value1.type, value2.type); 913 ResolutionInterfaceType type1 = value1.type;
914 ResolutionInterfaceType type2 = value2.type;
915 return strategy.testTypes(value1, value2, 'type', type1, type2);
911 } 916 }
912 917
913 @override 918 @override
914 bool visitBool(BoolConstantValue value1, BoolConstantValue value2) { 919 bool visitBool(BoolConstantValue value1, BoolConstantValue value2) {
915 return strategy.test(value1, value2, 'primitiveValue', 920 return strategy.test(value1, value2, 'primitiveValue',
916 value1.primitiveValue, value2.primitiveValue); 921 value1.primitiveValue, value2.primitiveValue);
917 } 922 }
918 923
919 @override 924 @override
920 bool visitDouble(DoubleConstantValue value1, DoubleConstantValue value2) { 925 bool visitDouble(DoubleConstantValue value1, DoubleConstantValue value2) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 SyntheticConstantValue value1, SyntheticConstantValue value2) { 963 SyntheticConstantValue value1, SyntheticConstantValue value2) {
959 return strategy.test( 964 return strategy.test(
960 value1, value2, 'payload', value1.payload, value2.payload) && 965 value1, value2, 'payload', value1.payload, value2.payload) &&
961 strategy.test( 966 strategy.test(
962 value1, value2, 'valueKind', value1.valueKind, value2.valueKind); 967 value1, value2, 'valueKind', value1.valueKind, value2.valueKind);
963 } 968 }
964 969
965 @override 970 @override
966 bool visitInterceptor( 971 bool visitInterceptor(
967 InterceptorConstantValue value1, InterceptorConstantValue value2) { 972 InterceptorConstantValue value1, InterceptorConstantValue value2) {
968 return strategy.testTypes(value1, value2, 'dispatchedType', 973 ClassElement cls1 = value1.cls;
969 value1.dispatchedType, value2.dispatchedType); 974 ClassElement cls2 = value2.cls;
975 return strategy.testElements(value1, value2, 'cls', cls1, cls2);
970 } 976 }
971 } 977 }
972 978
973 /// Tests the equivalence of [impact1] and [impact2] using [strategy]. 979 /// Tests the equivalence of [impact1] and [impact2] using [strategy].
974 bool testResolutionImpactEquivalence( 980 bool testResolutionImpactEquivalence(
975 ResolutionImpact impact1, ResolutionImpact impact2, 981 ResolutionImpact impact1, ResolutionImpact impact2,
976 [TestStrategy strategy = const TestStrategy()]) { 982 [TestStrategy strategy = const TestStrategy()]) {
977 return strategy.testSets(impact1, impact2, 'constSymbolNames', 983 return strategy.testSets(impact1, impact2, 'constSymbolNames',
978 impact1.constSymbolNames, impact2.constSymbolNames) && 984 impact1.constSymbolNames, impact2.constSymbolNames) &&
979 strategy.testSets( 985 strategy.testSets(
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 } 2043 }
2038 2044
2039 bool areMetadataAnnotationsEquivalent( 2045 bool areMetadataAnnotationsEquivalent(
2040 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { 2046 MetadataAnnotation metadata1, MetadataAnnotation metadata2) {
2041 if (metadata1 == metadata2) return true; 2047 if (metadata1 == metadata2) return true;
2042 if (metadata1 == null || metadata2 == null) return false; 2048 if (metadata1 == null || metadata2 == null) return false;
2043 return areElementsEquivalent( 2049 return areElementsEquivalent(
2044 metadata1.annotatedElement, metadata2.annotatedElement) && 2050 metadata1.annotatedElement, metadata2.annotatedElement) &&
2045 areConstantsEquivalent(metadata1.constant, metadata2.constant); 2051 areConstantsEquivalent(metadata1.constant, metadata2.constant);
2046 } 2052 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698