OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library compiler_isolate; | 5 library compiler_isolate; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:convert' show JSON; | 10 import 'dart:convert' show JSON; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 replyTo.send(['diagnostic', { 'uri': '$uri', | 100 replyTo.send(['diagnostic', { 'uri': '$uri', |
101 'begin': begin, | 101 'begin': begin, |
102 'end': end, | 102 'end': end, |
103 'message': message, | 103 'message': message, |
104 'kind': kind.name }]); | 104 'kind': kind.name }]); |
105 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { | 105 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { |
106 throw new Exception('Throw on error'); | 106 throw new Exception('Throw on error'); |
107 } | 107 } |
108 } | 108 } |
109 Stopwatch compilationTimer = new Stopwatch()..start(); | 109 Stopwatch compilationTimer = new Stopwatch()..start(); |
110 cachedCompiler = reuseCompiler( | 110 reuseCompiler( |
111 diagnosticHandler: handler, | 111 diagnosticHandler: handler, |
112 inputProvider: inputProvider, | 112 inputProvider: inputProvider, |
113 options: options, | 113 options: options, |
114 cachedCompiler: cachedCompiler, | 114 cachedCompiler: cachedCompiler, |
115 libraryRoot: sdkLocation, | 115 libraryRoot: sdkLocation, |
116 packageRoot: Uri.base.resolve('/packages/'), | 116 packageRoot: Uri.base.resolve('/packages/'), |
117 packagesAreImmutable: true); | 117 packagesAreImmutable: true).then((Compiler newCompiler) { |
118 | 118 cachedCompiler = newCompiler; |
119 cachedCompiler.run(Uri.parse('$PRIVATE_SCHEME:/main.dart')).then((success) { | 119 return cachedCompiler.run(Uri.parse('$PRIVATE_SCHEME:/main.dart')); |
| 120 }).then((success) { |
120 compilationTimer.stop(); | 121 compilationTimer.stop(); |
121 print('Compilation took ${compilationTimer.elapsed}'); | 122 print('Compilation took ${compilationTimer.elapsed}'); |
122 if (cachedCompiler.libraryLoader | 123 if (cachedCompiler.libraryLoader |
123 .lookupLibrary(Uri.parse('dart:html')) != null) { | 124 .lookupLibrary(Uri.parse('dart:html')) != null) { |
124 notifyDartHtml(replyTo); | 125 notifyDartHtml(replyTo); |
125 } | 126 } |
126 String js = cachedCompiler.assembledCode; | 127 String js = cachedCompiler.assembledCode; |
127 if (js == null) { | 128 if (js == null) { |
128 if (!options.contains('--analyze-only')) replyTo.send('failed'); | 129 if (!options.contains('--analyze-only')) replyTo.send('failed'); |
129 } else { | 130 } else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 port.send(replyTo.sendPort); | 163 port.send(replyTo.sendPort); |
163 replyTo.listen((message) { | 164 replyTo.listen((message) { |
164 try { | 165 try { |
165 List list = message as List; | 166 List list = message as List; |
166 compile(list[0], list[1]); | 167 compile(list[0], list[1]); |
167 } catch (exception, stack) { | 168 } catch (exception, stack) { |
168 port.send('$exception\n$stack'); | 169 port.send('$exception\n$stack'); |
169 } | 170 } |
170 }); | 171 }); |
171 } | 172 } |
OLD | NEW |