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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
6 | 6 |
7 import "dart:collection"; | 7 import "dart:collection"; |
8 | 8 |
9 final emptyList = new UnmodifiableListView([]); | 9 final emptyList = new UnmodifiableListView([]); |
10 final emptyMap = new _UnmodifiableMapView({}); | 10 final emptyMap = new _UnmodifiableMapView({}); |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 throw new UnimplementedError('LibraryMirror.location is not implemented'); | 1222 throw new UnimplementedError('LibraryMirror.location is not implemented'); |
1223 } | 1223 } |
1224 | 1224 |
1225 Map<Symbol, DeclarationMirror> _declarations; | 1225 Map<Symbol, DeclarationMirror> _declarations; |
1226 Map<Symbol, DeclarationMirror> get declarations { | 1226 Map<Symbol, DeclarationMirror> get declarations { |
1227 if (_declarations != null) return _declarations; | 1227 if (_declarations != null) return _declarations; |
1228 return _declarations = | 1228 return _declarations = |
1229 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); | 1229 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); |
1230 } | 1230 } |
1231 | 1231 |
1232 | |
1233 var _cachedTopLevelMembers; | |
1234 Map<Symbol, MethodMirror> get topLevelMembers { | |
1235 if (_cachedTopLevelMembers == null) { | |
1236 var result = new Map<Symbol, MethodMirror>(); | |
1237 declarations.values.forEach((decl) { | |
1238 if (decl is MethodMirror) { | |
1239 result[decl.simpleName] = decl; | |
1240 } | |
1241 if (decl is VariableMirror) { | |
1242 var getterName = decl.simpleName; | |
1243 result[getterName] = | |
1244 new _SyntheticAccessor(this, getterName, true, true, true, decl); | |
1245 if (!decl.isFinal) { | |
1246 var setterName = _asSetter(decl.simpleName, this); | |
1247 result[setterName] = new _SyntheticAccessor( | |
1248 this, setterName, false, true, true, decl); | |
1249 } | |
1250 } | |
1251 }); | |
1252 _cachedTopLevelMembers = | |
1253 new _UnmodifiableMapView<Symbol, MethodMirror>(result); | |
1254 } | |
1255 return _cachedTopLevelMembers; | |
1256 } | |
1257 | |
1258 | |
1259 Map<Symbol, Mirror> _cachedMembers; | 1232 Map<Symbol, Mirror> _cachedMembers; |
1260 Map<Symbol, Mirror> get _members { | 1233 Map<Symbol, Mirror> get _members { |
1261 if (_cachedMembers == null) { | 1234 if (_cachedMembers == null) { |
1262 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee)); | 1235 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee)); |
1263 } | 1236 } |
1264 return _cachedMembers; | 1237 return _cachedMembers; |
1265 } | 1238 } |
1266 | 1239 |
1267 Map<Symbol, MethodMirror> _cachedFunctions; | 1240 Map<Symbol, MethodMirror> _cachedFunctions; |
1268 Map<Symbol, MethodMirror> get _functions { | 1241 Map<Symbol, MethodMirror> get _functions { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 if (typeMirror == null) { | 1619 if (typeMirror == null) { |
1647 typeMirror = makeLocalTypeMirror(key); | 1620 typeMirror = makeLocalTypeMirror(key); |
1648 _instanitationCache[key] = typeMirror; | 1621 _instanitationCache[key] = typeMirror; |
1649 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1622 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1650 _declarationCache[key] = typeMirror; | 1623 _declarationCache[key] = typeMirror; |
1651 } | 1624 } |
1652 } | 1625 } |
1653 return typeMirror; | 1626 return typeMirror; |
1654 } | 1627 } |
1655 } | 1628 } |
OLD | NEW |