| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 JavaScriptBackend backend = compiler.backend; | 421 JavaScriptBackend backend = compiler.backend; |
| 422 backend.nativeData.setNativeClassTagInfo(element, native); | 422 backend.nativeData.setNativeClassTagInfo(element, native); |
| 423 return native; | 423 return native; |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 return null; | 426 return null; |
| 427 } | 427 } |
| 428 | 428 |
| 429 void validate(Compiler compiler, Element element, | 429 void validate(Compiler compiler, Element element, |
| 430 MetadataAnnotation annotation, ConstantValue constant) { | 430 MetadataAnnotation annotation, ConstantValue constant) { |
| 431 DartType annotationType = constant.getType(compiler.coreTypes); | 431 DartType annotationType = constant.getType(compiler.commonElements); |
| 432 if (annotationType.element != | 432 if (annotationType.element != |
| 433 compiler.commonElements.nativeAnnotationClass) { | 433 compiler.commonElements.nativeAnnotationClass) { |
| 434 DiagnosticReporter reporter = compiler.reporter; | 434 DiagnosticReporter reporter = compiler.reporter; |
| 435 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); | 435 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 | 439 |
| 440 /// Annotation handler for pre-resolution detection of `@JS(...)` | 440 /// Annotation handler for pre-resolution detection of `@JS(...)` |
| 441 /// annotations. | 441 /// annotations. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 454 } | 454 } |
| 455 // Due to semantics of apply in the baseclass we have to return null to | 455 // Due to semantics of apply in the baseclass we have to return null to |
| 456 // indicate that no match was found. | 456 // indicate that no match was found. |
| 457 return hasJsInterop ? true : null; | 457 return hasJsInterop ? true : null; |
| 458 } | 458 } |
| 459 | 459 |
| 460 @override | 460 @override |
| 461 void validate(Compiler compiler, Element element, | 461 void validate(Compiler compiler, Element element, |
| 462 MetadataAnnotation annotation, ConstantValue constant) { | 462 MetadataAnnotation annotation, ConstantValue constant) { |
| 463 JavaScriptBackend backend = compiler.backend; | 463 JavaScriptBackend backend = compiler.backend; |
| 464 if (constant.getType(compiler.coreTypes).element != | 464 if (constant.getType(compiler.commonElements).element != |
| 465 backend.helpers.jsAnnotationClass) { | 465 backend.helpers.jsAnnotationClass) { |
| 466 compiler.reporter | 466 compiler.reporter |
| 467 .internalError(annotation, 'Invalid @JS(...) annotation.'); | 467 .internalError(annotation, 'Invalid @JS(...) annotation.'); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 /// Annotation handler for pre-resolution detection of `@patch` annotations. | 472 /// Annotation handler for pre-resolution detection of `@patch` annotations. |
| 473 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> { | 473 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> { |
| 474 const PatchAnnotationHandler(); | 474 const PatchAnnotationHandler(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 490 | 490 |
| 491 @override | 491 @override |
| 492 PatchVersion apply( | 492 PatchVersion apply( |
| 493 Compiler compiler, Element element, MetadataAnnotation annotation) { | 493 Compiler compiler, Element element, MetadataAnnotation annotation) { |
| 494 return getPatchVersion(annotation); | 494 return getPatchVersion(annotation); |
| 495 } | 495 } |
| 496 | 496 |
| 497 @override | 497 @override |
| 498 void validate(Compiler compiler, Element element, | 498 void validate(Compiler compiler, Element element, |
| 499 MetadataAnnotation annotation, ConstantValue constant) { | 499 MetadataAnnotation annotation, ConstantValue constant) { |
| 500 DartType annotationType = constant.getType(compiler.coreTypes); | 500 DartType annotationType = constant.getType(compiler.commonElements); |
| 501 if (annotationType.element != | 501 if (annotationType.element != |
| 502 compiler.commonElements.patchAnnotationClass) { | 502 compiler.commonElements.patchAnnotationClass) { |
| 503 DiagnosticReporter reporter = compiler.reporter; | 503 DiagnosticReporter reporter = compiler.reporter; |
| 504 reporter.internalError(annotation, 'Invalid patch annotation.'); | 504 reporter.internalError(annotation, 'Invalid patch annotation.'); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 void tryPatchGetter( | 509 void tryPatchGetter( |
| 510 DiagnosticReporter reporter, Element origin, FunctionElement patch) { | 510 DiagnosticReporter reporter, Element origin, FunctionElement patch) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 class PatchVersion { | 616 class PatchVersion { |
| 617 final String tag; | 617 final String tag; |
| 618 | 618 |
| 619 const PatchVersion(this.tag); | 619 const PatchVersion(this.tag); |
| 620 | 620 |
| 621 bool isActive(String patchTag) => tag == null || tag == patchTag; | 621 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 622 | 622 |
| 623 String toString() => 'PatchVersion($tag)'; | 623 String toString() => 'PatchVersion($tag)'; |
| 624 } | 624 } |
| OLD | NEW |