| 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:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 Map<String,Constant> get _fieldMap { | 1580 Map<String,Constant> get _fieldMap { |
| 1581 if (_fieldMapCache == null) { | 1581 if (_fieldMapCache == null) { |
| 1582 _fieldMapCache = new LinkedHashMap<String,Constant>(); | 1582 _fieldMapCache = new LinkedHashMap<String,Constant>(); |
| 1583 if (identical(_constant.type.element.kind, ElementKind.CLASS)) { | 1583 if (identical(_constant.type.element.kind, ElementKind.CLASS)) { |
| 1584 var index = 0; | 1584 var index = 0; |
| 1585 ClassElement element = _constant.type.element; | 1585 ClassElement element = _constant.type.element; |
| 1586 element.forEachInstanceField((_, Element field) { | 1586 element.forEachInstanceField((_, Element field) { |
| 1587 String fieldName = field.name.slowToString(); | 1587 String fieldName = field.name.slowToString(); |
| 1588 _fieldMapCache.putIfAbsent(fieldName, () => _constant.fields[index]); | 1588 _fieldMapCache.putIfAbsent(fieldName, () => _constant.fields[index]); |
| 1589 index++; | 1589 index++; |
| 1590 }, includeBackendMembers: true, includeSuperMembers: true); | 1590 }, includeSuperAndInjectedMembers: true); |
| 1591 } | 1591 } |
| 1592 } | 1592 } |
| 1593 return _fieldMapCache; | 1593 return _fieldMapCache; |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 InstanceMirror getField(String fieldName) { | 1596 InstanceMirror getField(String fieldName) { |
| 1597 Constant fieldConstant = _fieldMap[fieldName]; | 1597 Constant fieldConstant = _fieldMap[fieldName]; |
| 1598 if (fieldConstant != null) { | 1598 if (fieldConstant != null) { |
| 1599 return _convertConstantToInstanceMirror(mirrors, fieldConstant); | 1599 return _convertConstantToInstanceMirror(mirrors, fieldConstant); |
| 1600 } | 1600 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 * | 1689 * |
| 1690 * All API in this class is experimental. | 1690 * All API in this class is experimental. |
| 1691 */ | 1691 */ |
| 1692 class BackDoor { | 1692 class BackDoor { |
| 1693 /// Return the compilation units comprising [library]. | 1693 /// Return the compilation units comprising [library]. |
| 1694 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { | 1694 static List<Mirror> compilationUnitsOf(Dart2JsLibraryMirror library) { |
| 1695 return library._library.compilationUnits.toList().map( | 1695 return library._library.compilationUnits.toList().map( |
| 1696 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); | 1696 (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); |
| 1697 } | 1697 } |
| 1698 } | 1698 } |
| OLD | NEW |