Chromium Code Reviews| 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 dart2js.mirrors; | 5 library dart2js.mirrors; |
| 6 | 6 |
| 7 import 'dart:collection' show UnmodifiableListView; | 7 import 'dart:collection' show UnmodifiableListView, UnmodifiableMapView; |
| 8 | 8 |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../scanner/scannerlib.dart'; | 10 import '../scanner/scannerlib.dart'; |
| 11 import '../resolution/resolution.dart' show Scope; | 11 import '../resolution/resolution.dart' show Scope; |
| 12 import '../dart2jslib.dart'; | 12 import '../dart2jslib.dart'; |
| 13 import '../dart_types.dart'; | 13 import '../dart_types.dart'; |
| 14 import '../tree/tree.dart'; | 14 import '../tree/tree.dart'; |
| 15 import '../util/util.dart' | 15 import '../util/util.dart' |
| 16 show Spannable, | 16 show Spannable, |
| 17 Link, | 17 Link, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 compiler.libraries.forEach((_, LibraryElement v) { | 296 compiler.libraries.forEach((_, LibraryElement v) { |
| 297 var mirror = new Dart2JsLibraryMirror(mirrorSystem, v); | 297 var mirror = new Dart2JsLibraryMirror(mirrorSystem, v); |
| 298 _libraries[mirror.uri] = mirror; | 298 _libraries[mirror.uri] = mirror; |
| 299 _libraryMap[v] = mirror; | 299 _libraryMap[v] = mirror; |
| 300 }); | 300 }); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 Map<Uri, LibraryMirror> get libraries { | 304 Map<Uri, LibraryMirror> get libraries { |
| 305 _ensureLibraries(); | 305 _ensureLibraries(); |
| 306 return new FilteredImmutableMap<Uri, LibraryMirror>(_libraries, | 306 return new FilteredImmutableMap<Uri, LibraryMirror>(_libraries, |
|
herhut
2014/04/28 08:24:41
Can we get rid of this, too, and base it on someth
kevmoo
2014/04/28 09:23:01
Done.
| |
| 307 (library) => const bool.fromEnvironment("list_all_libraries") || | 307 (library) => const bool.fromEnvironment("list_all_libraries") || |
| 308 !library._element.isInternalLibrary); | 308 !library._element.isInternalLibrary); |
| 309 } | 309 } |
| 310 | 310 |
| 311 Dart2JsLibraryMirror _getLibrary(LibraryElement element) => | 311 Dart2JsLibraryMirror _getLibrary(LibraryElement element) => |
| 312 _libraryMap[element]; | 312 _libraryMap[element]; |
| 313 | 313 |
| 314 Dart2JsMirrorSystem get mirrorSystem => this; | 314 Dart2JsMirrorSystem get mirrorSystem => this; |
| 315 | 315 |
| 316 TypeMirror get dynamicType => | 316 TypeMirror get dynamicType => |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 } | 378 } |
| 379 | 379 |
| 380 Element get _element; | 380 Element get _element; |
| 381 | 381 |
| 382 void _forEachElement(f(Element element)); | 382 void _forEachElement(f(Element element)); |
| 383 | 383 |
| 384 Iterable<Dart2JsMemberMirror> _getDeclarationMirrors(Element element); | 384 Iterable<Dart2JsMemberMirror> _getDeclarationMirrors(Element element); |
| 385 | 385 |
| 386 Map<Symbol, DeclarationMirror> get declarations { | 386 Map<Symbol, DeclarationMirror> get declarations { |
| 387 _ensureDeclarations(); | 387 _ensureDeclarations(); |
| 388 return new ImmutableMapWrapper<Symbol, DeclarationMirror>(_declarations); | 388 return new UnmodifiableMapView<Symbol, DeclarationMirror>(_declarations); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * Converts [element] into its corresponding [DeclarationMirror], if any. | 393 * Converts [element] into its corresponding [DeclarationMirror], if any. |
| 394 * | 394 * |
| 395 * If [element] is an [AbstractFieldElement] the mirror for its getter is | 395 * If [element] is an [AbstractFieldElement] the mirror for its getter is |
| 396 * returned or, if not present, the mirror for its setter. | 396 * returned or, if not present, the mirror for its setter. |
| 397 */ | 397 */ |
| 398 DeclarationMirror _convertElementToDeclarationMirror(Dart2JsMirrorSystem system, | 398 DeclarationMirror _convertElementToDeclarationMirror(Dart2JsMirrorSystem system, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 * | 458 * |
| 459 * All API in this class is experimental. | 459 * All API in this class is experimental. |
| 460 */ | 460 */ |
| 461 class BackDoor { | 461 class BackDoor { |
| 462 /// Return the compilation units comprising [library]. | 462 /// Return the compilation units comprising [library]. |
| 463 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { | 463 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { |
| 464 return library._element.compilationUnits.toList().map( | 464 return library._element.compilationUnits.toList().map( |
| 465 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); | 465 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); |
| 466 } | 466 } |
| 467 } | 467 } |
| OLD | NEW |