| 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 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 throw new UnimplementedError('LibraryMirror.location is not implemented'); | 1068 throw new UnimplementedError('LibraryMirror.location is not implemented'); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 Map<Symbol, DeclarationMirror> _declarations; | 1071 Map<Symbol, DeclarationMirror> _declarations; |
| 1072 Map<Symbol, DeclarationMirror> get declarations { | 1072 Map<Symbol, DeclarationMirror> get declarations { |
| 1073 if (_declarations != null) return _declarations; | 1073 if (_declarations != null) return _declarations; |
| 1074 return _declarations = | 1074 return _declarations = |
| 1075 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); | 1075 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 |
| 1079 var _cachedTopLevelMembers; |
| 1078 Map<Symbol, MethodMirror> get topLevelMembers { | 1080 Map<Symbol, MethodMirror> get topLevelMembers { |
| 1079 throw new UnimplementedError( | 1081 if (_cachedTopLevelMembers != null) return _cachedTopLevelMembers; |
| 1080 'LibraryMirror.topLevelMembers is not implemented'); | 1082 var result = new Map<Symbol, MethodMirror>(); |
| 1083 declarations.values.forEach((decl) { |
| 1084 if (decl is MethodMirror && !decl.isAbstract) { |
| 1085 result[decl.simpleName] = decl; |
| 1086 } |
| 1087 if (decl is VariableMirror) { |
| 1088 var getterName = decl.simpleName; |
| 1089 result[getterName] = |
| 1090 new _SyntheticAccessor(this, getterName, true, true, true, decl); |
| 1091 if (!decl.isFinal) { |
| 1092 var setterName = _asSetter(decl.simpleName, this); |
| 1093 result[setterName] = new _SyntheticAccessor( |
| 1094 this, setterName, false, true, true, decl); |
| 1095 } |
| 1096 } |
| 1097 // if (decl is TypeMirror) { |
| 1098 // var getterName = decl.simpleName; |
| 1099 // result[getterName] = new _SyntheticTypeGetter(this, getterName, decl); |
| 1100 // } |
| 1101 }); |
| 1102 return _cachedTopLevelMembers = result; |
| 1081 } | 1103 } |
| 1082 | 1104 |
| 1105 |
| 1083 Map<Symbol, Mirror> _cachedMembers; | 1106 Map<Symbol, Mirror> _cachedMembers; |
| 1084 Map<Symbol, Mirror> get _members { | 1107 Map<Symbol, Mirror> get _members { |
| 1085 if (_cachedMembers == null) { | 1108 if (_cachedMembers == null) { |
| 1086 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee)); | 1109 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee)); |
| 1087 } | 1110 } |
| 1088 return _cachedMembers; | 1111 return _cachedMembers; |
| 1089 } | 1112 } |
| 1090 | 1113 |
| 1091 Map<Symbol, MethodMirror> _cachedFunctions; | 1114 Map<Symbol, MethodMirror> _cachedFunctions; |
| 1092 Map<Symbol, MethodMirror> get _functions { | 1115 Map<Symbol, MethodMirror> get _functions { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 if (typeMirror == null) { | 1489 if (typeMirror == null) { |
| 1467 typeMirror = makeLocalTypeMirror(key); | 1490 typeMirror = makeLocalTypeMirror(key); |
| 1468 _instanitationCache[key] = typeMirror; | 1491 _instanitationCache[key] = typeMirror; |
| 1469 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1492 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1470 _declarationCache[key] = typeMirror; | 1493 _declarationCache[key] = typeMirror; |
| 1471 } | 1494 } |
| 1472 } | 1495 } |
| 1473 return typeMirror; | 1496 return typeMirror; |
| 1474 } | 1497 } |
| 1475 } | 1498 } |
| OLD | NEW |