| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 import 'constants/values.dart' show ConstantValue; | 119 import 'constants/values.dart' show ConstantValue; |
| 120 import 'dart2jslib.dart' | 120 import 'dart2jslib.dart' |
| 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 BaseFunctionElementX, |
| 129 ClassElementX, |
| 130 GetterElementX, |
| 131 LibraryElementX, |
| 129 MetadataAnnotationX, | 132 MetadataAnnotationX, |
| 130 ClassElementX, | 133 SetterElementX; |
| 131 BaseFunctionElementX; | |
| 132 import 'helpers/helpers.dart'; // Included for debug helpers. | 134 import 'helpers/helpers.dart'; // Included for debug helpers. |
| 133 import 'library_loader.dart' show LibraryLoader; | 135 import 'library_loader.dart' show LibraryLoader; |
| 134 import 'scanner/scannerlib.dart'; // Scanner, Parsers, Listeners | 136 import 'scanner/scannerlib.dart'; // Scanner, Parsers, Listeners |
| 135 import 'util/util.dart'; | 137 import 'util/util.dart'; |
| 136 | 138 |
| 137 class PatchParserTask extends CompilerTask { | 139 class PatchParserTask extends CompilerTask { |
| 138 final String name = "Patching Parser"; | 140 final String name = "Patching Parser"; |
| 139 | 141 |
| 140 PatchParserTask(Compiler compiler): super(compiler); | 142 PatchParserTask(Compiler compiler): super(compiler); |
| 141 | 143 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 479 } |
| 478 AbstractFieldElement originField = origin; | 480 AbstractFieldElement originField = origin; |
| 479 if (originField.getter == null) { | 481 if (originField.getter == null) { |
| 480 listener.reportError( | 482 listener.reportError( |
| 481 origin, MessageKind.PATCH_NO_GETTER, {'getterName': patch.name}); | 483 origin, MessageKind.PATCH_NO_GETTER, {'getterName': patch.name}); |
| 482 listener.reportInfo( | 484 listener.reportInfo( |
| 483 patch, | 485 patch, |
| 484 MessageKind.PATCH_POINT_TO_GETTER, {'getterName': patch.name}); | 486 MessageKind.PATCH_POINT_TO_GETTER, {'getterName': patch.name}); |
| 485 return; | 487 return; |
| 486 } | 488 } |
| 487 patchFunction(listener, originField.getter, patch); | 489 GetterElementX getter = originField.getter; |
| 490 patchFunction(listener, getter, patch); |
| 488 } | 491 } |
| 489 | 492 |
| 490 void tryPatchSetter(DiagnosticListener listener, | 493 void tryPatchSetter(DiagnosticListener listener, |
| 491 Element origin, | 494 Element origin, |
| 492 FunctionElement patch) { | 495 FunctionElement patch) { |
| 493 if (!origin.isAbstractField) { | 496 if (!origin.isAbstractField) { |
| 494 listener.reportError( | 497 listener.reportError( |
| 495 origin, MessageKind.PATCH_NON_SETTER, {'name': origin.name}); | 498 origin, MessageKind.PATCH_NON_SETTER, {'name': origin.name}); |
| 496 listener.reportInfo( | 499 listener.reportInfo( |
| 497 patch, | 500 patch, |
| 498 MessageKind.PATCH_POINT_TO_SETTER, {'setterName': patch.name}); | 501 MessageKind.PATCH_POINT_TO_SETTER, {'setterName': patch.name}); |
| 499 return; | 502 return; |
| 500 } | 503 } |
| 501 AbstractFieldElement originField = origin; | 504 AbstractFieldElement originField = origin; |
| 502 if (originField.setter == null) { | 505 if (originField.setter == null) { |
| 503 listener.reportError( | 506 listener.reportError( |
| 504 origin, MessageKind.PATCH_NO_SETTER, {'setterName': patch.name}); | 507 origin, MessageKind.PATCH_NO_SETTER, {'setterName': patch.name}); |
| 505 listener.reportInfo( | 508 listener.reportInfo( |
| 506 patch, | 509 patch, |
| 507 MessageKind.PATCH_POINT_TO_SETTER, {'setterName': patch.name}); | 510 MessageKind.PATCH_POINT_TO_SETTER, {'setterName': patch.name}); |
| 508 return; | 511 return; |
| 509 } | 512 } |
| 510 patchFunction(listener, originField.setter, patch); | 513 SetterElementX setter = originField.setter; |
| 514 patchFunction(listener, setter, patch); |
| 511 } | 515 } |
| 512 | 516 |
| 513 void tryPatchConstructor(DiagnosticListener listener, | 517 void tryPatchConstructor(DiagnosticListener listener, |
| 514 Element origin, | 518 Element origin, |
| 515 FunctionElement patch) { | 519 FunctionElement patch) { |
| 516 if (!origin.isConstructor) { | 520 if (!origin.isConstructor) { |
| 517 listener.reportError( | 521 listener.reportError( |
| 518 origin, | 522 origin, |
| 519 MessageKind.PATCH_NON_CONSTRUCTOR, {'constructorName': patch.name}); | 523 MessageKind.PATCH_NON_CONSTRUCTOR, {'constructorName': patch.name}); |
| 520 listener.reportInfo( | 524 listener.reportInfo( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 569 |
| 566 class PatchVersion { | 570 class PatchVersion { |
| 567 final String tag; | 571 final String tag; |
| 568 | 572 |
| 569 const PatchVersion(this.tag); | 573 const PatchVersion(this.tag); |
| 570 | 574 |
| 571 bool isActive(String patchTag) => tag == null || tag == patchTag; | 575 bool isActive(String patchTag) => tag == null || tag == patchTag; |
| 572 | 576 |
| 573 String toString() => 'PatchVersion($tag)'; | 577 String toString() => 'PatchVersion($tag)'; |
| 574 } | 578 } |
| OLD | NEW |