| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 /// Checks that the annotation value is valid. | 355 /// Checks that the annotation value is valid. |
| 356 void validate(Compiler compiler, | 356 void validate(Compiler compiler, |
| 357 Element element, | 357 Element element, |
| 358 MetadataAnnotation annotation, | 358 MetadataAnnotation annotation, |
| 359 ConstantValue constant); | 359 ConstantValue constant); |
| 360 | 360 |
| 361 | 361 |
| 362 /// Checks [element] for metadata matching the [handler]. Return a non-null | 362 /// Checks [element] for metadata matching the [handler]. Return a non-null |
| 363 /// annotation marker matching metadata was found. | 363 /// annotation marker matching metadata was found. |
| 364 static checkAnnotation(Compiler compiler, | 364 static checkAnnotation(Compiler compiler, |
| 365 Element element, | 365 Element element, |
| 366 EagerAnnotationHandler handler) { | 366 EagerAnnotationHandler handler) { |
| 367 for (Link<MetadataAnnotation> link = element.metadata; | 367 for (Link<MetadataAnnotation> link = element.metadata; |
| 368 !link.isEmpty; | 368 !link.isEmpty; |
| 369 link = link.tail) { | 369 link = link.tail) { |
| 370 MetadataAnnotation annotation = link.head; | 370 MetadataAnnotation annotation = link.head; |
| 371 var result = handler.apply(compiler, element, annotation); | 371 var result = handler.apply(compiler, element, annotation); |
| 372 if (result != null) { | 372 if (result != null) { |
| 373 // TODO(johnniwinther): Perform this check in | 373 // TODO(johnniwinther): Perform this check in |
| 374 // [Compiler.onLibrariesLoaded]. | 374 // [Compiler.onLibrariesLoaded]. |
| 375 compiler.enqueuer.resolution.addDeferredAction(element, () { | 375 compiler.enqueuer.resolution.addDeferredAction(element, () { |
| 376 annotation.ensureResolved(compiler); | 376 annotation.ensureResolved(compiler); |
| 377 handler.validate( | 377 handler.validate( |
| 378 compiler, element, annotation, annotation.constant.value); | 378 compiler, element, annotation, |
| 379 compiler.constants.getConstantValue(annotation.constant)); |
| 379 }); | 380 }); |
| 380 return result; | 381 return result; |
| 381 } | 382 } |
| 382 } | 383 } |
| 383 return null; | 384 return null; |
| 384 } | 385 } |
| 385 } | 386 } |
| 386 | 387 |
| 387 /// Annotation handler for pre-resolution detection of `@Native(...)` | 388 /// Annotation handler for pre-resolution detection of `@Native(...)` |
| 388 /// annotations. | 389 /// annotations. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 565 |
| 565 class PatchVersion { | 566 class PatchVersion { |
| 566 final String tag; | 567 final String tag; |
| 567 | 568 |
| 568 const PatchVersion(this.tag); | 569 const PatchVersion(this.tag); |
| 569 | 570 |
| 570 bool isActive(String patchTag) => tag == null || tag == patchTag; | 571 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 571 | 572 |
| 572 String toString() => 'PatchVersion($tag)'; | 573 String toString() => 'PatchVersion($tag)'; |
| 573 } | 574 } |
| OLD | NEW |