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

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

Issue 2667473003: Move Entity and Local to entities.dart (Closed)
Patch Set: Created 3 years, 10 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';
11 import '../constants/expressions.dart'; 11 import '../constants/expressions.dart';
12 import '../constants/values.dart'; 12 import '../constants/values.dart';
13 import '../elements/resolution_types.dart'; 13 import '../elements/resolution_types.dart';
14 import '../elements/elements.dart'; 14 import '../elements/elements.dart';
15 import '../elements/types.dart';
15 import '../elements/visitor.dart'; 16 import '../elements/visitor.dart';
16 import '../js_backend/backend_serialization.dart' 17 import '../js_backend/backend_serialization.dart'
17 show NativeBehaviorSerialization; 18 show NativeBehaviorSerialization;
18 import '../native/native.dart' show NativeBehavior; 19 import '../native/native.dart' show NativeBehavior;
19 import '../resolution/access_semantics.dart'; 20 import '../resolution/access_semantics.dart';
20 import '../resolution/send_structure.dart'; 21 import '../resolution/send_structure.dart';
21 import '../resolution/tree_elements.dart'; 22 import '../resolution/tree_elements.dart';
22 import '../tokens/token.dart'; 23 import '../tokens/token.dart';
23 import '../tree/nodes.dart'; 24 import '../tree/nodes.dart';
24 import '../universe/selector.dart'; 25 import '../universe/selector.dart';
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 91 }
91 92
92 /// Returns `true` if elements [a] and [b] are equivalent. 93 /// Returns `true` if elements [a] and [b] are equivalent.
93 bool areElementsEquivalent(Element a, Element b) { 94 bool areElementsEquivalent(Element a, Element b) {
94 if (identical(a, b)) return true; 95 if (identical(a, b)) return true;
95 if (a == null || b == null) return false; 96 if (a == null || b == null) return false;
96 return const ElementIdentityEquivalence().visit(a, b); 97 return const ElementIdentityEquivalence().visit(a, b);
97 } 98 }
98 99
99 /// Returns `true` if types [a] and [b] are equivalent. 100 /// Returns `true` if types [a] and [b] are equivalent.
100 bool areTypesEquivalent(ResolutionDartType a, ResolutionDartType b) { 101 bool areTypesEquivalent(DartType a, DartType b) {
101 if (identical(a, b)) return true; 102 if (identical(a, b)) return true;
102 if (a == null || b == null) return false; 103 if (a == null || b == null) return false;
103 return const TypeEquivalence().visit(a, b); 104 return const TypeEquivalence().visit(a, b);
104 } 105 }
105 106
106 /// Returns `true` if constants [exp1] and [exp2] are equivalent. 107 /// Returns `true` if constants [exp1] and [exp2] are equivalent.
107 bool areConstantsEquivalent(ConstantExpression exp1, ConstantExpression exp2) { 108 bool areConstantsEquivalent(ConstantExpression exp1, ConstantExpression exp2) {
108 if (identical(exp1, exp2)) return true; 109 if (identical(exp1, exp2)) return true;
109 if (exp1 == null || exp2 == null) return false; 110 if (exp1 == null || exp2 == null) return false;
110 return const ConstantEquivalence().visit(exp1, exp2); 111 return const ConstantEquivalence().visit(exp1, exp2);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 513
513 @override 514 @override
514 bool visitSetterElement(SetterElement element1, SetterElement element2) { 515 bool visitSetterElement(SetterElement element1, SetterElement element2) {
515 return checkMembers(element1, element2); 516 return checkMembers(element1, element2);
516 } 517 }
517 518
518 @override 519 @override
519 bool visitLocalFunctionElement( 520 bool visitLocalFunctionElement(
520 LocalFunctionElement element1, LocalFunctionElement element2) { 521 LocalFunctionElement element1, LocalFunctionElement element2) {
521 // TODO(johnniwinther): Define an equivalence on locals. 522 // TODO(johnniwinther): Define an equivalence on locals.
523 MemberElement member1 = element1.memberContext;
524 MemberElement member2 = element2.memberContext;
522 return strategy.test( 525 return strategy.test(
523 element1, element2, 'name', element1.name, element2.name) && 526 element1, element2, 'name', element1.name, element2.name) &&
524 checkMembers(element1.memberContext, element2.memberContext); 527 checkMembers(member1, member2);
525 } 528 }
526 529
527 @override 530 @override
528 bool visitLocalVariableElement( 531 bool visitLocalVariableElement(
529 LocalVariableElement element1, LocalVariableElement element2) { 532 LocalVariableElement element1, LocalVariableElement element2) {
530 // TODO(johnniwinther): Define an equivalence on locals. 533 // TODO(johnniwinther): Define an equivalence on locals.
531 return strategy.test( 534 return strategy.test(
532 element1, element2, 'name', element1.name, element2.name) && 535 element1, element2, 'name', element1.name, element2.name) &&
533 checkMembers(element1.memberContext, element2.memberContext); 536 checkMembers(element1.memberContext, element2.memberContext);
534 } 537 }
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 } 2048 }
2046 2049
2047 bool areMetadataAnnotationsEquivalent( 2050 bool areMetadataAnnotationsEquivalent(
2048 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { 2051 MetadataAnnotation metadata1, MetadataAnnotation metadata2) {
2049 if (metadata1 == metadata2) return true; 2052 if (metadata1 == metadata2) return true;
2050 if (metadata1 == null || metadata2 == null) return false; 2053 if (metadata1 == null || metadata2 == null) return false;
2051 return areElementsEquivalent( 2054 return areElementsEquivalent(
2052 metadata1.annotatedElement, metadata2.annotatedElement) && 2055 metadata1.annotatedElement, metadata2.annotatedElement) &&
2053 areConstantsEquivalent(metadata1.constant, metadata2.constant); 2056 areConstantsEquivalent(metadata1.constant, metadata2.constant);
2054 } 2057 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_adapter.dart ('k') | pkg/compiler/lib/src/serialization/impact_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698