| 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 '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 11 import 'backend.dart'; | 11 import 'backend.dart'; |
| 12 | 12 |
| 13 /// Handling of special annotations for tests. | 13 /// Handling of special annotations for tests. |
| 14 class Annotations { | 14 class Annotations { |
| 15 static final Uri PACKAGE_EXPECT = | 15 static final Uri PACKAGE_EXPECT = |
| 16 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 16 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
| 17 | 17 |
| 18 final Compiler compiler; | 18 final Compiler compiler; |
| 19 | 19 |
| 20 ClassElement expectNoInlineClass; | 20 ClassElement expectNoInlineClass; |
| 21 ClassElement expectTrustTypeAnnotationsClass; | 21 ClassElement expectTrustTypeAnnotationsClass; |
| 22 ClassElement expectAssumeDynamicClass; | 22 ClassElement expectAssumeDynamicClass; |
| 23 | 23 |
| 24 JavaScriptBackend get backend => compiler.backend; | 24 JavaScriptBackend get backend => compiler.backend; |
| 25 | 25 |
| 26 DiagnosticReporter get reporter => compiler.reporter; | 26 DiagnosticReporter get reporter => compiler.reporter; |
| 27 | 27 |
| 28 Annotations(this.compiler); | 28 Annotations(this.compiler); |
| 29 | 29 |
| 30 void onLibraryScanned(LibraryElement library) { | 30 void onLibraryLoaded(LibraryElement library) { |
| 31 if (library.canonicalUri == PACKAGE_EXPECT) { | 31 if (library.canonicalUri == PACKAGE_EXPECT) { |
| 32 expectNoInlineClass = library.find('NoInline'); | 32 expectNoInlineClass = library.find('NoInline'); |
| 33 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); | 33 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); |
| 34 expectAssumeDynamicClass = library.find('AssumeDynamic'); | 34 expectAssumeDynamicClass = library.find('AssumeDynamic'); |
| 35 if (expectNoInlineClass == null || | 35 if (expectNoInlineClass == null || |
| 36 expectTrustTypeAnnotationsClass == null || | 36 expectTrustTypeAnnotationsClass == null || |
| 37 expectAssumeDynamicClass == null) { | 37 expectAssumeDynamicClass == null) { |
| 38 // This is not the package you're looking for. | 38 // This is not the package you're looking for. |
| 39 expectNoInlineClass = null; | 39 expectNoInlineClass = null; |
| 40 expectTrustTypeAnnotationsClass = null; | 40 expectTrustTypeAnnotationsClass = null; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ConstructedConstantValue constructedConstant = value; | 76 ConstructedConstantValue constructedConstant = value; |
| 77 if (constructedConstant.type.element == annotationClass) { | 77 if (constructedConstant.type.element == annotationClass) { |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 return false; | 82 return false; |
| 83 }); | 83 }); |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |