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 #library("patchparser"); | 5 #library("patchparser"); |
6 #import("dart:uri"); | 6 #import("dart:uri"); |
7 | 7 |
8 #import("tree/tree.dart", prefix: "tree"); | 8 #import("tree/tree.dart", prefix: "tree"); |
9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. | 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. |
10 #import("apiimpl.dart"); | 10 #import("apiimpl.dart"); |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 void patchLibrary(Uri patchUri, LibraryElement library) { | 24 void patchLibrary(Uri patchUri, LibraryElement library) { |
25 leg.Script script = compiler.readScript(patchUri, null); | 25 leg.Script script = compiler.readScript(patchUri, null); |
26 CompilationUnitElement compilationUnit = | 26 CompilationUnitElement compilationUnit = |
27 new CompilationUnitElement(script, library); | 27 new CompilationUnitElement(script, library); |
28 library.addCompilationUnit(compilationUnit); | 28 library.addCompilationUnit(compilationUnit); |
29 LinkBuilder<tree.ScriptTag> imports = new LinkBuilder<tree.ScriptTag>(); | 29 LinkBuilder<tree.ScriptTag> imports = new LinkBuilder<tree.ScriptTag>(); |
30 compiler.withCurrentElement(compilationUnit, () { | 30 compiler.withCurrentElement(compilationUnit, () { |
31 // This patches the elements of the patch library into [library]. | 31 // This patches the elements of the patch library into [library]. |
32 // Injected elements are added directly under the compilation unit. | 32 // Injected elements are added directly under the compilation unit. |
33 // Patche elements are stored on the patched functions or classes. | 33 // Patch elements are stored on the patched functions or classes. |
34 scanLibraryElements(compilationUnit, imports); | 34 scanLibraryElements(compilationUnit, imports); |
35 }); | 35 }); |
36 // After scanning declarations, we handle the import tags in the patch. | 36 // After scanning declarations, we handle the import tags in the patch. |
37 // TODO(lrn): These imports end up in the original library and are in | 37 // TODO(lrn): These imports end up in the original library and are in |
38 // scope for the original methods too. This should be fixed. | 38 // scope for the original methods too. This should be fixed. |
39 for (tree.ScriptTag tag in imports.toLink()) { | 39 for (tree.ScriptTag tag in imports.toLink()) { |
40 if (tag.isSource()) { | 40 if (tag.isSource()) { |
41 Uri resolved = patchUri.resolve(tag.argument.dartString.slowToString()); | 41 Uri resolved = patchUri.resolve(tag.argument.dartString.slowToString()); |
42 compiler.scanner.sourceTagInLibrary(tag, resolved, library); | 42 compiler.scanner.sourceTagInLibrary(tag, resolved, library); |
43 } else { | 43 } else { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 void addMember(Element element) { | 282 void addMember(Element element) { |
283 if (isMemberPatch || (isClassPatch && element is ClassElement)) { | 283 if (isMemberPatch || (isClassPatch && element is ClassElement)) { |
284 element.addMetadata(popNode()); | 284 element.addMetadata(popNode()); |
285 } | 285 } |
286 super.addMember(element); | 286 super.addMember(element); |
287 } | 287 } |
288 } | 288 } |
OLD | NEW |