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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 show Compiler, | 121 show Compiler, |
122 CompilerTask, | 122 CompilerTask, |
123 DiagnosticListener, | 123 DiagnosticListener, |
124 MessageKind, | 124 MessageKind, |
125 Script; | 125 Script; |
126 import 'elements/elements.dart'; | 126 import 'elements/elements.dart'; |
127 import 'elements/modelx.dart' | 127 import 'elements/modelx.dart' |
128 show LibraryElementX, | 128 show LibraryElementX, |
129 MetadataAnnotationX, | 129 MetadataAnnotationX, |
130 ClassElementX, | 130 ClassElementX, |
131 FunctionElementX; | 131 BaseFunctionElementX; |
132 import 'helpers/helpers.dart'; // Included for debug helpers. | 132 import 'helpers/helpers.dart'; // Included for debug helpers. |
133 import 'library_loader.dart' show LibraryLoader; | 133 import 'library_loader.dart' show LibraryLoader; |
134 import 'scanner/scannerlib.dart'; // Scanner, Parsers, Listeners | 134 import 'scanner/scannerlib.dart'; // Scanner, Parsers, Listeners |
135 import 'util/util.dart'; | 135 import 'util/util.dart'; |
136 | 136 |
137 class PatchParserTask extends CompilerTask { | 137 class PatchParserTask extends CompilerTask { |
138 final String name = "Patching Parser"; | 138 final String name = "Patching Parser"; |
139 | 139 |
140 PatchParserTask(Compiler compiler): super(compiler); | 140 PatchParserTask(Compiler compiler): super(compiler); |
141 | 141 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 MessageKind.PATCH_NON_FUNCTION, {'functionName': patch.name}); | 534 MessageKind.PATCH_NON_FUNCTION, {'functionName': patch.name}); |
535 listener.reportInfo( | 535 listener.reportInfo( |
536 patch, | 536 patch, |
537 MessageKind.PATCH_POINT_TO_FUNCTION, {'functionName': patch.name}); | 537 MessageKind.PATCH_POINT_TO_FUNCTION, {'functionName': patch.name}); |
538 return; | 538 return; |
539 } | 539 } |
540 patchFunction(listener, origin, patch); | 540 patchFunction(listener, origin, patch); |
541 } | 541 } |
542 | 542 |
543 void patchFunction(DiagnosticListener listener, | 543 void patchFunction(DiagnosticListener listener, |
544 FunctionElementX origin, | 544 BaseFunctionElementX origin, |
545 FunctionElementX patch) { | 545 BaseFunctionElementX patch) { |
546 if (!origin.modifiers.isExternal) { | 546 if (!origin.modifiers.isExternal) { |
547 listener.reportError(origin, MessageKind.PATCH_NON_EXTERNAL); | 547 listener.reportError(origin, MessageKind.PATCH_NON_EXTERNAL); |
548 listener.reportInfo( | 548 listener.reportInfo( |
549 patch, | 549 patch, |
550 MessageKind.PATCH_POINT_TO_FUNCTION, {'functionName': patch.name}); | 550 MessageKind.PATCH_POINT_TO_FUNCTION, {'functionName': patch.name}); |
551 return; | 551 return; |
552 } | 552 } |
553 if (origin.isPatched) { | 553 if (origin.isPatched) { |
554 listener.internalError(origin, | 554 listener.internalError(origin, |
555 "Trying to patch a function more than once."); | 555 "Trying to patch a function more than once."); |
556 } | 556 } |
557 origin.applyPatch(patch); | 557 origin.applyPatch(patch); |
558 } | 558 } |
559 | 559 |
560 PatchVersion getPatchVersion(Compiler compiler, Element element) { | 560 PatchVersion getPatchVersion(Compiler compiler, Element element) { |
561 return EagerAnnotationHandler.checkAnnotation(compiler, element, | 561 return EagerAnnotationHandler.checkAnnotation(compiler, element, |
562 const PatchAnnotationHandler()); | 562 const PatchAnnotationHandler()); |
563 } | 563 } |
564 | 564 |
565 class PatchVersion { | 565 class PatchVersion { |
566 final String tag; | 566 final String tag; |
567 | 567 |
568 const PatchVersion(this.tag); | 568 const PatchVersion(this.tag); |
569 | 569 |
570 bool isActive(String patchTag) => tag == null || tag == patchTag; | 570 bool isActive(String patchTag) => tag == null || tag == patchTag; |
571 | 571 |
572 String toString() => 'PatchVersion($tag)'; | 572 String toString() => 'PatchVersion($tag)'; |
573 } | 573 } |
OLD | NEW |