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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 backend.nativeData.setNativeClassTagInfo(element, native); | 425 backend.nativeData.setNativeClassTagInfo(element, native); |
426 return native; | 426 return native; |
427 } | 427 } |
428 } | 428 } |
429 return null; | 429 return null; |
430 } | 430 } |
431 | 431 |
432 void validate(Compiler compiler, Element element, | 432 void validate(Compiler compiler, Element element, |
433 MetadataAnnotation annotation, ConstantValue constant) { | 433 MetadataAnnotation annotation, ConstantValue constant) { |
434 DartType annotationType = constant.getType(compiler.coreTypes); | 434 DartType annotationType = constant.getType(compiler.coreTypes); |
435 if (annotationType.element != compiler.nativeAnnotationClass) { | 435 if (annotationType.element != |
| 436 compiler.commonElements.nativeAnnotationClass) { |
436 DiagnosticReporter reporter = compiler.reporter; | 437 DiagnosticReporter reporter = compiler.reporter; |
437 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); | 438 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); |
438 } | 439 } |
439 } | 440 } |
440 } | 441 } |
441 | 442 |
442 /// Annotation handler for pre-resolution detection of `@JS(...)` | 443 /// Annotation handler for pre-resolution detection of `@JS(...)` |
443 /// annotations. | 444 /// annotations. |
444 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> { | 445 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> { |
445 const JsInteropAnnotationHandler(); | 446 const JsInteropAnnotationHandler(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 @override | 494 @override |
494 PatchVersion apply( | 495 PatchVersion apply( |
495 Compiler compiler, Element element, MetadataAnnotation annotation) { | 496 Compiler compiler, Element element, MetadataAnnotation annotation) { |
496 return getPatchVersion(annotation); | 497 return getPatchVersion(annotation); |
497 } | 498 } |
498 | 499 |
499 @override | 500 @override |
500 void validate(Compiler compiler, Element element, | 501 void validate(Compiler compiler, Element element, |
501 MetadataAnnotation annotation, ConstantValue constant) { | 502 MetadataAnnotation annotation, ConstantValue constant) { |
502 DartType annotationType = constant.getType(compiler.coreTypes); | 503 DartType annotationType = constant.getType(compiler.coreTypes); |
503 if (annotationType.element != compiler.patchAnnotationClass) { | 504 if (annotationType.element != |
| 505 compiler.commonElements.patchAnnotationClass) { |
504 DiagnosticReporter reporter = compiler.reporter; | 506 DiagnosticReporter reporter = compiler.reporter; |
505 reporter.internalError(annotation, 'Invalid patch annotation.'); | 507 reporter.internalError(annotation, 'Invalid patch annotation.'); |
506 } | 508 } |
507 } | 509 } |
508 } | 510 } |
509 | 511 |
510 void tryPatchGetter( | 512 void tryPatchGetter( |
511 DiagnosticReporter reporter, Element origin, FunctionElement patch) { | 513 DiagnosticReporter reporter, Element origin, FunctionElement patch) { |
512 if (!origin.isAbstractField) { | 514 if (!origin.isAbstractField) { |
513 reporter.reportError( | 515 reporter.reportError( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 618 |
617 class PatchVersion { | 619 class PatchVersion { |
618 final String tag; | 620 final String tag; |
619 | 621 |
620 const PatchVersion(this.tag); | 622 const PatchVersion(this.tag); |
621 | 623 |
622 bool isActive(String patchTag) => tag == null || tag == patchTag; | 624 bool isActive(String patchTag) => tag == null || tag == patchTag; |
623 | 625 |
624 String toString() => 'PatchVersion($tag)'; | 626 String toString() => 'PatchVersion($tag)'; |
625 } | 627 } |
OLD | NEW |