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; |
11 | 11 |
12 import 'compilation.dart' show PRIVATE_SCHEME; | 12 import 'compilation.dart' show PRIVATE_SCHEME; |
13 | 13 |
14 import 'package:compiler/compiler.dart' as compiler; | 14 import 'package:compiler/compiler.dart' as compiler; |
15 | 15 |
| 16 import 'package:compiler/src/old_to_new_api.dart' show |
| 17 LegacyCompilerDiagnostics, LegacyCompilerInput; |
| 18 |
16 import 'package:dart2js_incremental/dart2js_incremental.dart' show | 19 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
17 reuseCompiler, OutputProvider; | 20 reuseCompiler, OutputProvider; |
18 | 21 |
19 import 'package:compiler/src/dart2jslib.dart' show | 22 import 'package:compiler/src/dart2jslib.dart' show |
20 Compiler; | 23 Compiler; |
21 | 24 |
22 const bool THROW_ON_ERROR = false; | 25 const bool THROW_ON_ERROR = false; |
23 | 26 |
24 final cachedSources = new Map<Uri, Future<String>>(); | 27 final cachedSources = new Map<Uri, Future<String>>(); |
25 | 28 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 'end': end, | 108 'end': end, |
106 'message': message, | 109 'message': message, |
107 'kind': kind.name }]); | 110 'kind': kind.name }]); |
108 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { | 111 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { |
109 throw new Exception('Throw on error'); | 112 throw new Exception('Throw on error'); |
110 } | 113 } |
111 } | 114 } |
112 Stopwatch compilationTimer = new Stopwatch()..start(); | 115 Stopwatch compilationTimer = new Stopwatch()..start(); |
113 OutputProvider outputProvider = new OutputProvider(); | 116 OutputProvider outputProvider = new OutputProvider(); |
114 reuseCompiler( | 117 reuseCompiler( |
115 diagnosticHandler: handler, | 118 diagnosticHandler: new LegacyCompilerDiagnostics(handler), |
116 inputProvider: inputProvider, | 119 inputProvider: new LegacyCompilerInput(inputProvider), |
117 outputProvider: outputProvider, | 120 outputProvider: outputProvider, |
118 options: options, | 121 options: options, |
119 cachedCompiler: cachedCompiler, | 122 cachedCompiler: cachedCompiler, |
120 libraryRoot: sdkLocation, | 123 libraryRoot: sdkLocation, |
121 packageRoot: Uri.base.resolve('/packages/'), | 124 packageRoot: Uri.base.resolve('/packages/'), |
122 packagesAreImmutable: true).then((Compiler newCompiler) { | 125 packagesAreImmutable: true).then((Compiler newCompiler) { |
123 cachedCompiler = newCompiler; | 126 cachedCompiler = newCompiler; |
124 return cachedCompiler.run(Uri.parse('$PRIVATE_SCHEME:/main.dart')); | 127 return cachedCompiler.run(Uri.parse('$PRIVATE_SCHEME:/main.dart')); |
125 }).then((success) { | 128 }).then((success) { |
126 compilationTimer.stop(); | 129 compilationTimer.stop(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 port.send(replyTo.sendPort); | 171 port.send(replyTo.sendPort); |
169 replyTo.listen((message) { | 172 replyTo.listen((message) { |
170 try { | 173 try { |
171 List list = message as List; | 174 List list = message as List; |
172 compile(list[0], list[1]); | 175 compile(list[0], list[1]); |
173 } catch (exception, stack) { | 176 } catch (exception, stack) { |
174 port.send('$exception\n$stack'); | 177 port.send('$exception\n$stack'); |
175 } | 178 } |
176 }); | 179 }); |
177 } | 180 } |
OLD | NEW |