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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 import 'scanner/scanner.dart' show Scanner; | 142 import 'scanner/scanner.dart' show Scanner; |
143 import 'script.dart'; | 143 import 'script.dart'; |
144 import 'tokens/token.dart' show StringToken, Token; | 144 import 'tokens/token.dart' show StringToken, Token; |
145 | 145 |
146 class PatchParserTask extends CompilerTask { | 146 class PatchParserTask extends CompilerTask { |
147 final String name = "Patching Parser"; | 147 final String name = "Patching Parser"; |
148 final Compiler compiler; | 148 final Compiler compiler; |
149 DiagnosticReporter get reporter => compiler.reporter; | 149 DiagnosticReporter get reporter => compiler.reporter; |
150 | 150 |
151 PatchParserTask(Compiler compiler) | 151 PatchParserTask(Compiler compiler) |
152 : compiler = compiler, super(compiler.measurer); | 152 : compiler = compiler, |
| 153 super(compiler.measurer); |
153 | 154 |
154 /** | 155 /** |
155 * Scans a library patch file, applies the method patches and | 156 * Scans a library patch file, applies the method patches and |
156 * injections to the library, and returns a list of class | 157 * injections to the library, and returns a list of class |
157 * patches. | 158 * patches. |
158 */ | 159 */ |
159 Future patchLibrary( | 160 Future patchLibrary( |
160 LibraryLoader loader, Uri patchUri, LibraryElement originLibrary) { | 161 LibraryLoader loader, Uri patchUri, LibraryElement originLibrary) { |
161 return compiler.readScript(patchUri, originLibrary).then((Script script) { | 162 return compiler.readScript(patchUri, originLibrary).then((Script script) { |
162 var patchLibrary = new LibraryElementX(script, null, originLibrary); | 163 var patchLibrary = new LibraryElementX(script, null, originLibrary); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 enclosingClass.addMember(patch, reporter); | 242 enclosingClass.addMember(patch, reporter); |
242 } | 243 } |
243 } | 244 } |
244 } | 245 } |
245 | 246 |
246 /** | 247 /** |
247 * Partial parser for patch files that also handles the members of class | 248 * Partial parser for patch files that also handles the members of class |
248 * declarations. | 249 * declarations. |
249 */ | 250 */ |
250 class PatchClassElementParser extends PartialParser { | 251 class PatchClassElementParser extends PartialParser { |
251 PatchClassElementParser(Listener listener): super(listener); | 252 PatchClassElementParser(Listener listener) : super(listener); |
252 | 253 |
253 Token parseClassBody(Token token) => fullParseClassBody(token); | 254 Token parseClassBody(Token token) => fullParseClassBody(token); |
254 } | 255 } |
255 | 256 |
256 /** | 257 /** |
257 * Extension of [ElementListener] for parsing patch files. | 258 * Extension of [ElementListener] for parsing patch files. |
258 */ | 259 */ |
259 class PatchElementListener extends ElementListener implements Listener { | 260 class PatchElementListener extends ElementListener implements Listener { |
260 final Compiler compiler; | 261 final Compiler compiler; |
261 | 262 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 615 |
615 class PatchVersion { | 616 class PatchVersion { |
616 final String tag; | 617 final String tag; |
617 | 618 |
618 const PatchVersion(this.tag); | 619 const PatchVersion(this.tag); |
619 | 620 |
620 bool isActive(String patchTag) => tag == null || tag == patchTag; | 621 bool isActive(String patchTag) => tag == null || tag == patchTag; |
621 | 622 |
622 String toString() => 'PatchVersion($tag)'; | 623 String toString() => 'PatchVersion($tag)'; |
623 } | 624 } |
OLD | NEW |