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 library mirrors_dart2js; | 5 library mirrors_dart2js; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show LinkedHashMap; | 8 import 'dart:collection' show LinkedHashMap; |
9 | 9 |
10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 compilationFailed = true; | 219 compilationFailed = true; |
220 } | 220 } |
221 diagnosticHandler(uri, begin, end, message, kind); | 221 diagnosticHandler(uri, begin, end, message, kind); |
222 } | 222 } |
223 | 223 |
224 Compiler compiler = new apiimpl.Compiler(inputProvider, | 224 Compiler compiler = new apiimpl.Compiler(inputProvider, |
225 null, | 225 null, |
226 internalDiagnosticHandler, | 226 internalDiagnosticHandler, |
227 libraryRoot, packageRoot, options); | 227 libraryRoot, packageRoot, options); |
228 compiler.librariesToAnalyzeWhenRun = libraries; | 228 compiler.librariesToAnalyzeWhenRun = libraries; |
229 bool success = compiler.run(null); | 229 return compiler.run(null).then((bool success) { |
230 if (success && !compilationFailed) { | 230 if (success && !compilationFailed) { |
231 return new Future<MirrorSystem>.value(new Dart2JsMirrorSystem(compiler)); | 231 return new Dart2JsMirrorSystem(compiler); |
232 } else { | 232 } else { |
233 return new Future<MirrorSystem>.error('Failed to create mirror system.'); | 233 throw 'Failed to create mirror system.'; |
234 } | 234 } |
| 235 }); |
235 } | 236 } |
236 | 237 |
237 //------------------------------------------------------------------------------ | 238 //------------------------------------------------------------------------------ |
238 // Dart2Js specific extensions of mirror interfaces | 239 // Dart2Js specific extensions of mirror interfaces |
239 //------------------------------------------------------------------------------ | 240 //------------------------------------------------------------------------------ |
240 | 241 |
241 abstract class Dart2JsMirror implements Mirror { | 242 abstract class Dart2JsMirror implements Mirror { |
242 Dart2JsMirrorSystem get mirrors; | 243 Dart2JsMirrorSystem get mirrors; |
243 } | 244 } |
244 | 245 |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 * | 1750 * |
1750 * All API in this class is experimental. | 1751 * All API in this class is experimental. |
1751 */ | 1752 */ |
1752 class BackDoor { | 1753 class BackDoor { |
1753 /// Return the compilation units comprising [library]. | 1754 /// Return the compilation units comprising [library]. |
1754 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { | 1755 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { |
1755 return library._library.compilationUnits.toList().map( | 1756 return library._library.compilationUnits.toList().map( |
1756 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); | 1757 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); |
1757 } | 1758 } |
1758 } | 1759 } |
OLD | NEW |