Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/patch_parser.dart

Issue 11967010: Internal libraries supported. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update MockCompiler Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 /** 130 /**
131 * Scans a library patch file, applies the method patches and 131 * Scans a library patch file, applies the method patches and
132 * injections to the library, and returns a list of class 132 * injections to the library, and returns a list of class
133 * patches. 133 * patches.
134 */ 134 */
135 void patchLibrary(leg.LibraryDependencyHandler handler, 135 void patchLibrary(leg.LibraryDependencyHandler handler,
136 Uri patchUri, LibraryElement originLibrary) { 136 Uri patchUri, LibraryElement originLibrary) {
137 137
138 leg.Script script = compiler.readScript(patchUri, null); 138 leg.Script script = compiler.readScript(patchUri, null);
139 var patchLibrary = new LibraryElementX(script, patchUri, originLibrary); 139 var patchLibrary = new LibraryElementX(script, null, originLibrary);
140 handler.registerNewLibrary(patchLibrary); 140 compiler.withCurrentElement(patchLibrary, () {
141 LinkBuilder<tree.LibraryTag> imports = new LinkBuilder<tree.LibraryTag>(); 141 handler.registerNewLibrary(patchLibrary);
142 compiler.withCurrentElement(patchLibrary.entryCompilationUnit, () { 142 LinkBuilder<tree.LibraryTag> imports = new LinkBuilder<tree.LibraryTag>();
143 // This patches the elements of the patch library into [library]. 143 compiler.withCurrentElement(patchLibrary.entryCompilationUnit, () {
144 // Injected elements are added directly under the compilation unit. 144 // This patches the elements of the patch library into [library].
145 // Patch elements are stored on the patched functions or classes. 145 // Injected elements are added directly under the compilation unit.
146 scanLibraryElements(patchLibrary.entryCompilationUnit, imports); 146 // Patch elements are stored on the patched functions or classes.
147 scanLibraryElements(patchLibrary.entryCompilationUnit, imports);
148 });
149 // After scanning declarations, we handle the import tags in the patch.
150 // TODO(lrn): These imports end up in the original library and are in
151 // scope for the original methods too. This should be fixed.
152 compiler.importHelperLibrary(originLibrary);
153 for (tree.LibraryTag tag in imports.toLink()) {
154 compiler.libraryLoader.registerLibraryFromTag(
155 handler, patchLibrary, tag);
156 }
147 }); 157 });
148 // After scanning declarations, we handle the import tags in the patch.
149 // TODO(lrn): These imports end up in the original library and are in
150 // scope for the original methods too. This should be fixed.
151 compiler.importHelperLibrary(originLibrary);
152 for (tree.LibraryTag tag in imports.toLink()) {
153 compiler.libraryLoader.registerLibraryFromTag(handler, patchLibrary, tag);
154 }
155 } 158 }
156 159
157 void scanLibraryElements( 160 void scanLibraryElements(
158 CompilationUnitElement compilationUnit, 161 CompilationUnitElement compilationUnit,
159 LinkBuilder<tree.LibraryTag> imports) { 162 LinkBuilder<tree.LibraryTag> imports) {
160 measure(() { 163 measure(() {
161 // TODO(lrn): Possibly recursively handle #source directives in patch. 164 // TODO(lrn): Possibly recursively handle #source directives in patch.
162 leg.Script script = compilationUnit.script; 165 leg.Script script = compilationUnit.script;
163 Token tokens = new StringScanner(script.text).tokenize(); 166 Token tokens = new StringScanner(script.text).tokenize();
164 Function idGenerator = compiler.getNextFreeClassId; 167 Function idGenerator = compiler.getNextFreeClassId;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 502 }
500 503
501 // TODO(ahe): Get rid of this class. 504 // TODO(ahe): Get rid of this class.
502 class PatchMetadataAnnotation extends MetadataAnnotationX { 505 class PatchMetadataAnnotation extends MetadataAnnotationX {
503 final leg.Constant value = null; 506 final leg.Constant value = null;
504 507
505 PatchMetadataAnnotation() : super(STATE_DONE); 508 PatchMetadataAnnotation() : super(STATE_DONE);
506 509
507 Token get beginToken => null; 510 Token get beginToken => null;
508 } 511 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698