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): This is broken now that scanBuiltInLibraries is async. |
| 129 // Delete this sample. |
128 compiler.scanBuiltinLibraries(); | 130 compiler.scanBuiltinLibraries(); |
129 sw.stop(); | 131 sw.stop(); |
130 return 'Scanned core libraries in ${sw.elapsedMilliseconds}ms'; | 132 return 'Scanned core libraries in ${sw.elapsedMilliseconds}ms'; |
131 } | 133 } |
132 | 134 |
133 String update(String codeText) { | 135 String update(String codeText) { |
134 StringBuffer sb = new StringBuffer(); | 136 StringBuffer sb = new StringBuffer(); |
135 | 137 |
136 Stopwatch sw = new Stopwatch()..start(); | 138 Stopwatch sw = new Stopwatch()..start(); |
137 | 139 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 final libDir = "../.."; | 216 final libDir = "../.."; |
215 | 217 |
216 LeapCompiler() : cache = new HttpRequestCache(), super() { | 218 LeapCompiler() : cache = new HttpRequestCache(), super() { |
217 tasks = [scanner, dietParser, parser, resolver, checker]; | 219 tasks = [scanner, dietParser, parser, resolver, checker]; |
218 } | 220 } |
219 | 221 |
220 void log(message) { print(message); } | 222 void log(message) { print(message); } |
221 | 223 |
222 String get legDirectory => libDir; | 224 String get legDirectory => libDir; |
223 | 225 |
| 226 // TODO(rnystrom): This is broken now that scanBuiltInLibraries is async. |
| 227 // Delete this sample. |
224 LibraryElement scanBuiltinLibrary(String path) { | 228 LibraryElement scanBuiltinLibrary(String path) { |
225 Uri base = Uri.parse(html.window.location.toString()); | 229 Uri base = Uri.parse(html.window.location.toString()); |
226 Uri libraryRoot = base.resolve(libDir); | 230 Uri libraryRoot = base.resolve(libDir); |
227 Uri resolved = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); | 231 Uri resolved = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); |
| 232 // TODO(rnystrom): This is broken now that scanBuiltInLibraries is async. |
| 233 // Delete this sample. |
228 LibraryElement library = scanner.loadLibrary(resolved, null); | 234 LibraryElement library = scanner.loadLibrary(resolved, null); |
229 return library; | 235 return library; |
230 } | 236 } |
231 | 237 |
232 currentScript() { | 238 currentScript() { |
233 if (currentElement == null) return null; | 239 if (currentElement == null) return null; |
234 CompilationUnitElement compilationUnit = | 240 CompilationUnitElement compilationUnit = |
235 currentElement.getCompilationUnit(); | 241 currentElement.getCompilationUnit(); |
236 if (compilationUnit == null) return null; | 242 if (compilationUnit == null) return null; |
237 return compilationUnit.script; | 243 return compilationUnit.script; |
238 } | 244 } |
239 | 245 |
| 246 // TODO(rnystrom): This is broken now that scanBuiltInLibraries is async. |
| 247 // Delete this sample. |
240 Script readScript(Uri uri, [ScriptTag node]) { | 248 Script readScript(Uri uri, [ScriptTag node]) { |
241 String text = ""; | 249 String text = ""; |
242 try { | 250 try { |
243 text = cache.readAll(uri.path.toString()); | 251 text = cache.readAll(uri.path.toString()); |
244 } catch (exception) { | 252 } catch (exception) { |
245 cancel("${uri.path}: $exception", node: node); | 253 cancel("${uri.path}: $exception", node: node); |
246 } | 254 } |
247 SourceFile sourceFile = new SourceFile(uri.toString(), text); | 255 SourceFile sourceFile = new SourceFile(uri.toString(), text); |
248 return new Script(uri, sourceFile); | 256 return new Script(uri, sourceFile); |
249 } | 257 } |
(...skipping 28 matching lines...) Expand all Loading... |
278 mainApp = new LibraryElement(script); | 286 mainApp = new LibraryElement(script); |
279 | 287 |
280 universe.libraries.remove(script.uri.toString()); | 288 universe.libraries.remove(script.uri.toString()); |
281 Element element; | 289 Element element; |
282 withCurrentElement(mainApp, () { | 290 withCurrentElement(mainApp, () { |
283 scanner.scan(mainApp); | 291 scanner.scan(mainApp); |
284 }); | 292 }); |
285 return mainApp; | 293 return mainApp; |
286 } | 294 } |
287 } | 295 } |
OLD | NEW |