| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * This library contains the infrastructure to parse and integrate patch files. | 6 * This library contains the infrastructure to parse and integrate patch files. |
| 7 * | 7 * |
| 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], | 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], |
| 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded | 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded |
| 10 * together with the corresponding origin library. Which libraries that are | 10 * together with the corresponding origin library. Which libraries that are |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 return null; | 416 return null; |
| 417 } | 417 } |
| 418 | 418 |
| 419 void validate(Compiler compiler, Element element, | 419 void validate(Compiler compiler, Element element, |
| 420 MetadataAnnotation annotation, ConstantValue constant) { | 420 MetadataAnnotation annotation, ConstantValue constant) { |
| 421 ResolutionDartType annotationType = | 421 ResolutionDartType annotationType = |
| 422 constant.getType(compiler.commonElements); | 422 constant.getType(compiler.commonElements); |
| 423 if (annotationType.element != | 423 if (annotationType.element != |
| 424 compiler.commonElements.nativeAnnotationClass) { | 424 compiler.backend.helpers.nativeAnnotationClass) { |
| 425 DiagnosticReporter reporter = compiler.reporter; | 425 DiagnosticReporter reporter = compiler.reporter; |
| 426 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); | 426 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 /// Annotation handler for pre-resolution detection of `@JS(...)` | 431 /// Annotation handler for pre-resolution detection of `@JS(...)` |
| 432 /// annotations. | 432 /// annotations. |
| 433 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> { | 433 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> { |
| 434 const JsInteropAnnotationHandler(); | 434 const JsInteropAnnotationHandler(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Compiler compiler, Element element, MetadataAnnotation annotation) { | 484 Compiler compiler, Element element, MetadataAnnotation annotation) { |
| 485 return getPatchVersion(annotation); | 485 return getPatchVersion(annotation); |
| 486 } | 486 } |
| 487 | 487 |
| 488 @override | 488 @override |
| 489 void validate(Compiler compiler, Element element, | 489 void validate(Compiler compiler, Element element, |
| 490 MetadataAnnotation annotation, ConstantValue constant) { | 490 MetadataAnnotation annotation, ConstantValue constant) { |
| 491 ResolutionDartType annotationType = | 491 ResolutionDartType annotationType = |
| 492 constant.getType(compiler.commonElements); | 492 constant.getType(compiler.commonElements); |
| 493 if (annotationType.element != | 493 if (annotationType.element != |
| 494 compiler.commonElements.patchAnnotationClass) { | 494 compiler.backend.helpers.patchAnnotationClass) { |
| 495 DiagnosticReporter reporter = compiler.reporter; | 495 DiagnosticReporter reporter = compiler.reporter; |
| 496 reporter.internalError(annotation, 'Invalid patch annotation.'); | 496 reporter.internalError(annotation, 'Invalid patch annotation.'); |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 void tryPatchGetter( | 501 void tryPatchGetter( |
| 502 DiagnosticReporter reporter, Element origin, FunctionElement patch) { | 502 DiagnosticReporter reporter, Element origin, FunctionElement patch) { |
| 503 if (!origin.isAbstractField) { | 503 if (!origin.isAbstractField) { |
| 504 reporter.reportError( | 504 reporter.reportError( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 607 |
| 608 class PatchVersion { | 608 class PatchVersion { |
| 609 final String tag; | 609 final String tag; |
| 610 | 610 |
| 611 const PatchVersion(this.tag); | 611 const PatchVersion(this.tag); |
| 612 | 612 |
| 613 bool isActive(String patchTag) => tag == null || tag == patchTag; | 613 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 614 | 614 |
| 615 String toString() => 'PatchVersion($tag)'; | 615 String toString() => 'PatchVersion($tag)'; |
| 616 } | 616 } |
| OLD | NEW |