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 compilerIsolate(port) { | 5 compilerIsolate(port) { |
6 Runner runner = new Runner(); | 6 Runner runner = new Runner(); |
7 runner.init(); | 7 runner.init(); |
8 | 8 |
9 port.receive((msg, replyTo) { | 9 port.receive((msg, replyTo) { |
10 replyTo.send(runner.update(msg)); | 10 replyTo.send(runner.update(msg)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 }); | 118 }); |
119 } | 119 } |
120 | 120 |
121 class Runner { | 121 class Runner { |
122 final LeapCompiler compiler; | 122 final LeapCompiler compiler; |
123 | 123 |
124 Runner() : compiler = new LeapCompiler(); | 124 Runner() : compiler = new LeapCompiler(); |
125 | 125 |
126 String init() { | 126 String init() { |
127 Stopwatch sw = new Stopwatch()..start(); | 127 Stopwatch sw = new Stopwatch()..start(); |
128 // TODO(rnystrom): Handle future. | |
Bob Nystrom
2013/06/26 01:03:24
I haven't updated this sample to the new async API
ahe
2013/06/26 07:02:00
Don't bother, it is probably broken anyways. I sho
Bob Nystrom
2013/06/27 00:38:18
That's what I figured. Updated the TODOs to explai
| |
128 compiler.scanBuiltinLibraries(); | 129 compiler.scanBuiltinLibraries(); |
129 sw.stop(); | 130 sw.stop(); |
130 return 'Scanned core libraries in ${sw.elapsedMilliseconds}ms'; | 131 return 'Scanned core libraries in ${sw.elapsedMilliseconds}ms'; |
131 } | 132 } |
132 | 133 |
133 String update(String codeText) { | 134 String update(String codeText) { |
134 StringBuffer sb = new StringBuffer(); | 135 StringBuffer sb = new StringBuffer(); |
135 | 136 |
136 Stopwatch sw = new Stopwatch()..start(); | 137 Stopwatch sw = new Stopwatch()..start(); |
137 | 138 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 final libDir = "../.."; | 215 final libDir = "../.."; |
215 | 216 |
216 LeapCompiler() : cache = new HttpRequestCache(), super() { | 217 LeapCompiler() : cache = new HttpRequestCache(), super() { |
217 tasks = [scanner, dietParser, parser, resolver, checker]; | 218 tasks = [scanner, dietParser, parser, resolver, checker]; |
218 } | 219 } |
219 | 220 |
220 void log(message) { print(message); } | 221 void log(message) { print(message); } |
221 | 222 |
222 String get legDirectory => libDir; | 223 String get legDirectory => libDir; |
223 | 224 |
225 // TODO(rnystrom): Make return future. | |
224 LibraryElement scanBuiltinLibrary(String path) { | 226 LibraryElement scanBuiltinLibrary(String path) { |
225 Uri base = Uri.parse(html.window.location.toString()); | 227 Uri base = Uri.parse(html.window.location.toString()); |
226 Uri libraryRoot = base.resolve(libDir); | 228 Uri libraryRoot = base.resolve(libDir); |
227 Uri resolved = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); | 229 Uri resolved = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); |
230 // TODO(rnystrom): Handle future. | |
228 LibraryElement library = scanner.loadLibrary(resolved, null); | 231 LibraryElement library = scanner.loadLibrary(resolved, null); |
229 return library; | 232 return library; |
230 } | 233 } |
231 | 234 |
232 currentScript() { | 235 currentScript() { |
233 if (currentElement == null) return null; | 236 if (currentElement == null) return null; |
234 CompilationUnitElement compilationUnit = | 237 CompilationUnitElement compilationUnit = |
235 currentElement.getCompilationUnit(); | 238 currentElement.getCompilationUnit(); |
236 if (compilationUnit == null) return null; | 239 if (compilationUnit == null) return null; |
237 return compilationUnit.script; | 240 return compilationUnit.script; |
238 } | 241 } |
239 | 242 |
243 // TODO(rnystrom): Make return future. | |
240 Script readScript(Uri uri, [ScriptTag node]) { | 244 Script readScript(Uri uri, [ScriptTag node]) { |
241 String text = ""; | 245 String text = ""; |
242 try { | 246 try { |
243 text = cache.readAll(uri.path.toString()); | 247 text = cache.readAll(uri.path.toString()); |
244 } catch (exception) { | 248 } catch (exception) { |
245 cancel("${uri.path}: $exception", node: node); | 249 cancel("${uri.path}: $exception", node: node); |
246 } | 250 } |
247 SourceFile sourceFile = new SourceFile(uri.toString(), text); | 251 SourceFile sourceFile = new SourceFile(uri.toString(), text); |
248 return new Script(uri, sourceFile); | 252 return new Script(uri, sourceFile); |
249 } | 253 } |
(...skipping 28 matching lines...) Expand all Loading... | |
278 mainApp = new LibraryElement(script); | 282 mainApp = new LibraryElement(script); |
279 | 283 |
280 universe.libraries.remove(script.uri.toString()); | 284 universe.libraries.remove(script.uri.toString()); |
281 Element element; | 285 Element element; |
282 withCurrentElement(mainApp, () { | 286 withCurrentElement(mainApp, () { |
283 scanner.scan(mainApp); | 287 scanner.scan(mainApp); |
284 }); | 288 }); |
285 return mainApp; | 289 return mainApp; |
286 } | 290 } |
287 } | 291 } |
OLD | NEW |