OLD | NEW |
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.dart'; | 10 import '../common.dart'; |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 return visit(element1.exportedLibrary, element2.exportedLibrary) && | 509 return visit(element1.exportedLibrary, element2.exportedLibrary) && |
510 visit(element1.library, element2.library); | 510 visit(element1.library, element2.library); |
511 } | 511 } |
512 | 512 |
513 @override | 513 @override |
514 bool visitPrefixElement(PrefixElement element1, PrefixElement element2) { | 514 bool visitPrefixElement(PrefixElement element1, PrefixElement element2) { |
515 return strategy.test( | 515 return strategy.test( |
516 element1, element2, 'name', element1.name, element2.name) && | 516 element1, element2, 'name', element1.name, element2.name) && |
517 visit(element1.library, element2.library); | 517 visit(element1.library, element2.library); |
518 } | 518 } |
| 519 |
| 520 @override |
| 521 bool visitErroneousElement( |
| 522 ErroneousElement element1, ErroneousElement element2) { |
| 523 return strategy.test(element1, element2, 'messageKind', |
| 524 element1.messageKind, element2.messageKind); |
| 525 } |
519 } | 526 } |
520 | 527 |
521 /// Visitor that checks for equivalence of [DartType]s. | 528 /// Visitor that checks for equivalence of [DartType]s. |
522 class TypeEquivalence implements DartTypeVisitor<bool, DartType> { | 529 class TypeEquivalence implements DartTypeVisitor<bool, DartType> { |
523 final TestStrategy strategy; | 530 final TestStrategy strategy; |
524 | 531 |
525 const TypeEquivalence([this.strategy = const TestStrategy()]); | 532 const TypeEquivalence([this.strategy = const TestStrategy()]); |
526 | 533 |
527 bool visit(DartType type1, DartType type2) { | 534 bool visit(DartType type1, DartType type2) { |
528 return strategy.test(type1, type2, 'kind', type1.kind, type2.kind) && | 535 return strategy.test(type1, type2, 'kind', type1.kind, type2.kind) && |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 } | 1843 } |
1837 | 1844 |
1838 bool areMetadataAnnotationsEquivalent( | 1845 bool areMetadataAnnotationsEquivalent( |
1839 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { | 1846 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { |
1840 if (metadata1 == metadata2) return true; | 1847 if (metadata1 == metadata2) return true; |
1841 if (metadata1 == null || metadata2 == null) return false; | 1848 if (metadata1 == null || metadata2 == null) return false; |
1842 return areElementsEquivalent( | 1849 return areElementsEquivalent( |
1843 metadata1.annotatedElement, metadata2.annotatedElement) && | 1850 metadata1.annotatedElement, metadata2.annotatedElement) && |
1844 areConstantsEquivalent(metadata1.constant, metadata2.constant); | 1851 areConstantsEquivalent(metadata1.constant, metadata2.constant); |
1845 } | 1852 } |
OLD | NEW |