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 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 [Path packageRoot, List<String> opts = const <String>[]]) | 271 [Path packageRoot, List<String> opts = const <String>[]]) |
272 : cwd = getCurrentDirectory(), | 272 : cwd = getCurrentDirectory(), |
273 provider = new SourceFileProvider() { | 273 provider = new SourceFileProvider() { |
274 var libraryUri = cwd.resolve(libraryRoot.toString()); | 274 var libraryUri = cwd.resolve(libraryRoot.toString()); |
275 var packageUri; | 275 var packageUri; |
276 if (packageRoot != null) { | 276 if (packageRoot != null) { |
277 packageUri = cwd.resolve(packageRoot.toString()); | 277 packageUri = cwd.resolve(packageRoot.toString()); |
278 } else { | 278 } else { |
279 packageUri = libraryUri; | 279 packageUri = libraryUri; |
280 } | 280 } |
281 opts = new List<String>.from(opts, growable: true); | 281 opts = new List<String>.from(opts); |
282 opts.add('--analyze-only'); | 282 opts.add('--analyze-only'); |
283 opts.add('--analyze-all'); | 283 opts.add('--analyze-all'); |
284 _compiler = new Compiler(provider.readStringFromUri, | 284 _compiler = new Compiler(provider.readStringFromUri, |
285 null, | 285 null, |
286 silentDiagnosticHandler, | 286 silentDiagnosticHandler, |
287 libraryUri, packageUri, opts); | 287 libraryUri, packageUri, opts); |
288 var librariesUri = <Uri>[]; | 288 var librariesUri = <Uri>[]; |
289 for (Path library in libraries) { | 289 for (Path library in libraries) { |
290 librariesUri.add(cwd.resolve(library.toString())); | 290 librariesUri.add(cwd.resolve(library.toString())); |
291 // TODO(johnniwinther): Detect file not found | 291 // TODO(johnniwinther): Detect file not found |
292 } | 292 } |
293 _compiler.librariesToAnalyzeWhenRun = librariesUri; | 293 _compiler.librariesToAnalyzeWhenRun = librariesUri; |
294 _compiler.run(null); | 294 _compiler.run(null); |
295 } | 295 } |
296 | 296 |
297 MirrorSystem get mirrors => new Dart2JsMirrorSystem(_compiler); | 297 MirrorSystem get mirrors => new Dart2JsMirrorSystem(_compiler); |
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 return new Future.immediate( | 1733 return new Future.immediate( |
1734 new Dart2JsStringConstantMirror.fromString(mirrors, text)); | 1734 new Dart2JsStringConstantMirror.fromString(mirrors, text)); |
1735 } else if (fieldName == 'trimmedText') { | 1735 } else if (fieldName == 'trimmedText') { |
1736 return new Future.immediate( | 1736 return new Future.immediate( |
1737 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText)); | 1737 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText)); |
1738 } | 1738 } |
1739 // TODO(johnniwinther): Which exception/error should be thrown here? | 1739 // TODO(johnniwinther): Which exception/error should be thrown here? |
1740 throw new UnsupportedError('InstanceMirror does not have a reflectee'); | 1740 throw new UnsupportedError('InstanceMirror does not have a reflectee'); |
1741 } | 1741 } |
1742 } | 1742 } |
OLD | NEW |