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

Side by Side Diff: lib/compiler/implementation/scanner/scanner_task.dart

Issue 10869012: Revert "Support sourceing files in patches." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
« no previous file with comments | « lib/compiler/implementation/patch_parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class ScannerTask extends CompilerTask { 5 class ScannerTask extends CompilerTask {
6 ScannerTask(Compiler compiler) : super(compiler); 6 ScannerTask(Compiler compiler) : super(compiler);
7 String get name => 'Scanner'; 7 String get name => 'Scanner';
8 8
9 void scanLibrary(LibraryElement library) { 9 void scanLibrary(LibraryElement library) {
10 var compilationUnit = library.entryCompilationUnit; 10 var compilationUnit = library.entryCompilationUnit;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 imports.addLast(tag); 51 imports.addLast(tag);
52 } else if (tag.isLibrary()) { 52 } else if (tag.isLibrary()) {
53 tagState = checkTag(TagState.LIBRARY, tag); 53 tagState = checkTag(TagState.LIBRARY, tag);
54 if (library.libraryTag !== null) { 54 if (library.libraryTag !== null) {
55 compiler.cancel("duplicated library declaration", node: tag); 55 compiler.cancel("duplicated library declaration", node: tag);
56 } else { 56 } else {
57 library.libraryTag = tag; 57 library.libraryTag = tag;
58 } 58 }
59 } else if (tag.isSource()) { 59 } else if (tag.isSource()) {
60 tagState = checkTag(TagState.SOURCE, tag); 60 tagState = checkTag(TagState.SOURCE, tag);
61 compiler.scanner.sourceTagInLibrary(tag, resolved, library); 61 Script script = compiler.readScript(resolved, tag);
62 CompilationUnitElement unit =
63 new CompilationUnitElement(script, library);
64 compiler.withCurrentElement(unit, () => scan(unit));
62 } else if (tag.isResource()) { 65 } else if (tag.isResource()) {
63 tagState = checkTag(TagState.RESOURCE, tag); 66 tagState = checkTag(TagState.RESOURCE, tag);
64 compiler.reportWarning(tag, 'ignoring resource tag'); 67 compiler.reportWarning(tag, 'ignoring resource tag');
65 } else { 68 } else {
66 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); 69 compiler.cancel("illegal script tag: ${tag.tag}", node: tag);
67 } 70 }
68 } 71 }
69 72
70 // Apply patch, if any. 73 // Apply patch, if any.
71 if (library.uri.scheme == 'dart') { 74 if (library.uri.scheme == 'dart') {
72 compiler.patchDartLibrary(library, library.uri.path); 75 compiler.patchDartLibrary(library, library.uri.path);
73 } 76 }
74 77
75 // Now that we have processed all the source tags, it is safe to 78 // Now that we have processed all the source tags, it is safe to
76 // start loading other libraries. 79 // start loading other libraries.
77 80
78 if (library.uri.scheme != 'dart' || library.uri.path != 'core') { 81 if (library.uri.scheme != 'dart' || library.uri.path != 'core') {
79 compiler.importCoreLibrary(library); 82 compiler.importCoreLibrary(library);
80 } 83 }
81 84
82 for (ScriptTag tag in imports.toLink()) { 85 for (ScriptTag tag in imports.toLink()) {
83 importLibraryFromTag(tag, library.entryCompilationUnit); 86 importLibraryFromTag(tag, library.entryCompilationUnit);
84 } 87 }
85 } 88 }
86 89
87 /** 90 /**
88 * Source a tag in the scope of [library]. The [path] given is used as is,
89 * any resolve should be done beforehand.
90 */
91 void sourceTagInLibrary(ScriptTag tag, Uri path, LibraryElement library) {
ahe 2012/08/22 12:55:38 How about keeping this change. It is nice and clea
Anders Johnsen 2012/08/22 13:03:02 I'll do so, but with the cleanup ager suggested (s
92 Script script = compiler.readScript(path, tag);
93 CompilationUnitElement unit = new CompilationUnitElement(script, library);
94 compiler.withCurrentElement(unit, () => compiler.scanner.scan(unit));
95 }
96
97 /**
98 * Handle an import script tag by importing the referenced library into the 91 * Handle an import script tag by importing the referenced library into the
99 * current library. 92 * current library.
100 * Returns the resolved library [Uri]. 93 * Returns the resolved library [Uri].
101 */ 94 */
102 Uri importLibraryFromTag(ScriptTag tag, 95 Uri importLibraryFromTag(ScriptTag tag,
103 CompilationUnitElement compilationUnit) { 96 CompilationUnitElement compilationUnit) {
104 Uri base = compilationUnit.script.uri; 97 Uri base = compilationUnit.script.uri;
105 StringNode argument = tag.argument; 98 StringNode argument = tag.argument;
106 Uri resolved = base.resolve(argument.dartString.slowToString()); 99 Uri resolved = base.resolve(argument.dartString.slowToString());
107 LibraryElement importedLibrary = loadLibrary(resolved, argument, resolved); 100 LibraryElement importedLibrary = loadLibrary(resolved, argument, resolved);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 static final int RESOURCE = 4; 221 static final int RESOURCE = 4;
229 222
230 /** Next state. */ 223 /** Next state. */
231 static final List<int> NEXT = 224 static final List<int> NEXT =
232 const <int>[NO_TAG_SEEN, 225 const <int>[NO_TAG_SEEN,
233 IMPORT, // Only one library tag is allowed. 226 IMPORT, // Only one library tag is allowed.
234 IMPORT, 227 IMPORT,
235 SOURCE, 228 SOURCE,
236 RESOURCE]; 229 RESOURCE];
237 } 230 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/patch_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698