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

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

Issue 10414081: Parameterize WorkItem.run. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix a typo Created 8 years, 7 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 | « dart/lib/compiler/implementation/compiler.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 scan(CompilationUnitElement compilationUnit) { 9 void scan(CompilationUnitElement compilationUnit) {
10 measure(() { 10 measure(() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 if (implicitlyImportCoreLibrary) { 85 if (implicitlyImportCoreLibrary) {
86 importLibrary(library, compiler.coreLibrary, null); 86 importLibrary(library, compiler.coreLibrary, null);
87 } 87 }
88 } 88 }
89 89
90 void scanElements(CompilationUnitElement compilationUnit) { 90 void scanElements(CompilationUnitElement compilationUnit) {
91 Script script = compilationUnit.script; 91 Script script = compilationUnit.script;
92 Token tokens; 92 Token tokens;
93 try { 93 try {
94 try { 94 tokens = new StringScanner(script.text).tokenize();
95 tokens = new StringScanner(script.text).tokenize(); 95 } catch (MalformedInputException ex) {
96 } catch (MalformedInputException ex) { 96 Token token;
97 Token token; 97 var message;
98 var message; 98 if (ex.position is num) {
99 if (ex.position is num) { 99 // TODO(ahe): Always use tokens in MalformedInputException.
100 // TODO(ahe): Always use tokens in MalformedInputException. 100 token = new Token(EOF_INFO, ex.position);
101 token = new Token(EOF_INFO, ex.position); 101 } else {
102 } else { 102 token = ex.position;
103 token = ex.position;
104 }
105 compiler.cancel(ex.message, token: token);
106 } 103 }
107 compiler.dietParser.dietParse(compilationUnit, tokens); 104 compiler.cancel(ex.message, token: token);
108 } catch (CompilerCancelledException ex) {
109 throw;
110 } catch (var ex) {
111 compiler.unhandledExceptionOnElement(compilationUnit);
112 throw;
113 } 105 }
106 compiler.dietParser.dietParse(compilationUnit, tokens);
114 } 107 }
115 108
116 LibraryElement loadLibrary(Uri uri, Node node) { 109 LibraryElement loadLibrary(Uri uri, Node node) {
117 bool newLibrary = false; 110 bool newLibrary = false;
118 LibraryElement library = 111 LibraryElement library =
119 compiler.libraries.putIfAbsent(uri.toString(), () { 112 compiler.libraries.putIfAbsent(uri.toString(), () {
120 newLibrary = true; 113 newLibrary = true;
121 Script script = compiler.readScript(uri, node); 114 Script script = compiler.readScript(uri, node);
122 LibraryElement element = new LibraryElement(script); 115 LibraryElement element = new LibraryElement(script);
123 native.maybeEnableNative(compiler, element, uri); 116 native.maybeEnableNative(compiler, element, uri);
124 return element; 117 return element;
125 }); 118 });
126 if (newLibrary) { 119 if (newLibrary) {
127 compiler.withCurrentElement(library, () => scan(library)); 120 compiler.withCurrentElement(library, () {
128 compiler.onLibraryLoaded(library, uri); 121 scan(library);
122 compiler.onLibraryLoaded(library, uri);
123 });
129 } 124 }
130 return library; 125 return library;
131 } 126 }
132 127
133 void importLibrary(LibraryElement library, LibraryElement imported, 128 void importLibrary(LibraryElement library, LibraryElement imported,
134 ScriptTag tag) { 129 ScriptTag tag) {
135 if (!imported.hasLibraryName()) { 130 if (!imported.hasLibraryName()) {
136 compiler.withCurrentElement(library, () { 131 compiler.withCurrentElement(library, () {
137 compiler.reportError(tag === null ? null : tag.argument, 132 compiler.reportError(tag === null ? null : tag.argument,
138 'no #library tag found in ${imported.script.uri}'); 133 'no #library tag found in ${imported.script.uri}');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 static final int RESOURCE = 4; 200 static final int RESOURCE = 4;
206 201
207 /** Next state. */ 202 /** Next state. */
208 static final List<int> NEXT = 203 static final List<int> NEXT =
209 const <int>[NO_TAG_SEEN, 204 const <int>[NO_TAG_SEEN,
210 IMPORT, // Only one library tag is allowed. 205 IMPORT, // Only one library tag is allowed.
211 IMPORT, 206 IMPORT,
212 SOURCE, 207 SOURCE,
213 RESOURCE]; 208 RESOURCE];
214 } 209 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698