| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library js_backend.backend.annotations; | 5 library js_backend.backend.annotations; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common_elements.dart' show ElementEnvironment; |
| 8 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 9 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| 10 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../elements/entities.dart'; |
| 11 import 'backend.dart'; | 13 import 'backend.dart'; |
| 12 | 14 |
| 13 /// Handling of special annotations for tests. | 15 /// Handling of special annotations for tests. |
| 14 class Annotations { | 16 class Annotations { |
| 15 static final Uri PACKAGE_EXPECT = | 17 static final Uri PACKAGE_EXPECT = |
| 16 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 18 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
| 17 | 19 |
| 18 final Compiler compiler; | 20 final Compiler compiler; |
| 19 | 21 |
| 20 ClassElement expectNoInlineClass; | 22 ClassElement expectNoInlineClass; |
| 21 ClassElement expectTrustTypeAnnotationsClass; | 23 ClassElement expectTrustTypeAnnotationsClass; |
| 22 ClassElement expectAssumeDynamicClass; | 24 ClassElement expectAssumeDynamicClass; |
| 23 | 25 |
| 24 JavaScriptBackend get backend => compiler.backend; | 26 JavaScriptBackend get backend => compiler.backend; |
| 25 | 27 |
| 26 DiagnosticReporter get reporter => compiler.reporter; | 28 DiagnosticReporter get reporter => compiler.reporter; |
| 27 | 29 |
| 30 ElementEnvironment get _elementEnvironment => compiler.elementEnvironment; |
| 31 |
| 28 Annotations(this.compiler); | 32 Annotations(this.compiler); |
| 29 | 33 |
| 30 void onLibraryLoaded(LibraryElement library) { | 34 void onLibraryLoaded(LibraryEntity library) { |
| 31 if (library.canonicalUri == PACKAGE_EXPECT) { | 35 if (library.canonicalUri == PACKAGE_EXPECT) { |
| 32 expectNoInlineClass = library.find('NoInline'); | 36 expectNoInlineClass = |
| 33 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); | 37 _elementEnvironment.lookupClass(library, 'NoInline'); |
| 34 expectAssumeDynamicClass = library.find('AssumeDynamic'); | 38 expectTrustTypeAnnotationsClass = |
| 39 _elementEnvironment.lookupClass(library, 'TrustTypeAnnotations'); |
| 40 expectAssumeDynamicClass = |
| 41 _elementEnvironment.lookupClass(library, 'AssumeDynamic'); |
| 35 if (expectNoInlineClass == null || | 42 if (expectNoInlineClass == null || |
| 36 expectTrustTypeAnnotationsClass == null || | 43 expectTrustTypeAnnotationsClass == null || |
| 37 expectAssumeDynamicClass == null) { | 44 expectAssumeDynamicClass == null) { |
| 38 // This is not the package you're looking for. | 45 // This is not the package you're looking for. |
| 39 expectNoInlineClass = null; | 46 expectNoInlineClass = null; |
| 40 expectTrustTypeAnnotationsClass = null; | 47 expectTrustTypeAnnotationsClass = null; |
| 41 expectAssumeDynamicClass = null; | 48 expectAssumeDynamicClass = null; |
| 42 } | 49 } |
| 43 } | 50 } |
| 44 } | 51 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ConstructedConstantValue constructedConstant = value; | 83 ConstructedConstantValue constructedConstant = value; |
| 77 if (constructedConstant.type.element == annotationClass) { | 84 if (constructedConstant.type.element == annotationClass) { |
| 78 return true; | 85 return true; |
| 79 } | 86 } |
| 80 } | 87 } |
| 81 } | 88 } |
| 82 return false; | 89 return false; |
| 83 }); | 90 }); |
| 84 } | 91 } |
| 85 } | 92 } |
| OLD | NEW |