| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // The reflectee is not a mixin application. | 586 // The reflectee is not a mixin application. |
| 587 _mixin = this; | 587 _mixin = this; |
| 588 } else { | 588 } else { |
| 589 _mixin = reflectType(mixinType); | 589 _mixin = reflectType(mixinType); |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 return _mixin; | 593 return _mixin; |
| 594 } | 594 } |
| 595 | 595 |
| 596 Map<Symbol, DeclarationMirror> _declarations; |
| 597 Map<Symbol, DeclarationMirror> get declarations { |
| 598 if (_declarations != null) return _declarations; |
| 599 var decls = new Map<Symbol, DeclarationMirror>(); |
| 600 decls.addAll(members); |
| 601 decls.addAll(constructors); |
| 602 typeVariables.forEach((tv) => decls[tv.simpleName] = tv); |
| 603 return _declarations = |
| 604 new _UnmodifiableMapView<Symbol, DeclarationMirror>(decls); |
| 605 } |
| 606 |
| 596 Map<Symbol, Mirror> _members; | 607 Map<Symbol, Mirror> _members; |
| 597 Map<Symbol, Mirror> get members { | 608 Map<Symbol, Mirror> get members { |
| 598 if (_members == null) { | 609 if (_members == null) { |
| 599 var whoseMembers = _isMixinTypedef ? _trueSuperclass : this; | 610 var whoseMembers = _isMixinTypedef ? _trueSuperclass : this; |
| 600 _members = _makeMemberMap(mixin._computeMembers(whoseMembers._reflectee)); | 611 _members = _makeMemberMap(mixin._computeMembers(whoseMembers._reflectee)); |
| 601 } | 612 } |
| 602 return _members; | 613 return _members; |
| 603 } | 614 } |
| 604 | 615 |
| 605 Map<Symbol, MethodMirror> _methods; | 616 Map<Symbol, MethodMirror> _methods; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 916 |
| 906 DeclarationMirror _owner; | 917 DeclarationMirror _owner; |
| 907 DeclarationMirror get owner { | 918 DeclarationMirror get owner { |
| 908 if (_owner == null) { | 919 if (_owner == null) { |
| 909 _owner = _TypeVariableMirror_owner(_reflectee); | 920 _owner = _TypeVariableMirror_owner(_reflectee); |
| 910 } | 921 } |
| 911 return _owner; | 922 return _owner; |
| 912 } | 923 } |
| 913 | 924 |
| 914 bool get isPrivate => false; | 925 bool get isPrivate => false; |
| 926 bool get isStatic => false; |
| 915 | 927 |
| 916 final bool isTopLevel = false; | 928 final bool isTopLevel = false; |
| 917 | 929 |
| 918 SourceLocation get location { | 930 SourceLocation get location { |
| 919 throw new UnimplementedError( | 931 throw new UnimplementedError( |
| 920 'TypeVariableMirror.location is not implemented'); | 932 'TypeVariableMirror.location is not implemented'); |
| 921 } | 933 } |
| 922 | 934 |
| 923 TypeMirror _upperBound = null; | 935 TypeMirror _upperBound = null; |
| 924 TypeMirror get upperBound { | 936 TypeMirror get upperBound { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 | 1103 |
| 1092 // Always false for libraries. | 1104 // Always false for libraries. |
| 1093 final bool isTopLevel = false; | 1105 final bool isTopLevel = false; |
| 1094 | 1106 |
| 1095 SourceLocation get location { | 1107 SourceLocation get location { |
| 1096 throw new UnimplementedError('LibraryMirror.location is not implemented'); | 1108 throw new UnimplementedError('LibraryMirror.location is not implemented'); |
| 1097 } | 1109 } |
| 1098 | 1110 |
| 1099 final Uri uri; | 1111 final Uri uri; |
| 1100 | 1112 |
| 1113 Map<Symbol, DeclarationMirror> _declarations; |
| 1114 Map<Symbol, DeclarationMirror> get declarations { |
| 1115 if (_declarations != null) return _declarations; |
| 1116 return _declarations = |
| 1117 new _UnmodifiableMapView<Symbol, DeclarationMirror>(members); |
| 1118 } |
| 1119 |
| 1101 Map<Symbol, Mirror> _members; | 1120 Map<Symbol, Mirror> _members; |
| 1102 Map<Symbol, Mirror> get members { | 1121 Map<Symbol, Mirror> get members { |
| 1103 if (_members == null) { | 1122 if (_members == null) { |
| 1104 _members = _makeMemberMap(_computeMembers(_reflectee)); | 1123 _members = _makeMemberMap(_computeMembers(_reflectee)); |
| 1105 } | 1124 } |
| 1106 return _members; | 1125 return _members; |
| 1107 } | 1126 } |
| 1108 | 1127 |
| 1109 Map<Symbol, ClassMirror> _types; | 1128 Map<Symbol, ClassMirror> _types; |
| 1110 Map<Symbol, TypeMirror> get types { | 1129 Map<Symbol, TypeMirror> get types { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 } | 1275 } |
| 1257 | 1276 |
| 1258 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; | 1277 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; |
| 1259 | 1278 |
| 1260 Symbol _constructorName = null; | 1279 Symbol _constructorName = null; |
| 1261 Symbol get constructorName { | 1280 Symbol get constructorName { |
| 1262 if (_constructorName == null) { | 1281 if (_constructorName == null) { |
| 1263 if (!isConstructor) { | 1282 if (!isConstructor) { |
| 1264 _constructorName = _s(''); | 1283 _constructorName = _s(''); |
| 1265 } else { | 1284 } else { |
| 1266 var parts = _n(simpleName).split('.'); | 1285 var parts = MirrorSystem.getName(simpleName).split('.'); |
| 1267 if (parts.length > 2) { | 1286 if (parts.length > 2) { |
| 1268 throw new MirrorException( | 1287 throw new MirrorException( |
| 1269 'Internal error in MethodMirror.constructorName: ' | 1288 'Internal error in MethodMirror.constructorName: ' |
| 1270 'malformed name <$simpleName>'); | 1289 'malformed name <$simpleName>'); |
| 1271 } else if (parts.length == 2) { | 1290 } else if (parts.length == 2) { |
| 1272 _constructorName = _s(parts[1]); | 1291 _constructorName = _s(parts[1]); |
| 1273 } else { | 1292 } else { |
| 1274 _constructorName = _s(''); | 1293 _constructorName = _s(''); |
| 1275 } | 1294 } |
| 1276 } | 1295 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 if (typeMirror == null) { | 1522 if (typeMirror == null) { |
| 1504 typeMirror = makeLocalTypeMirror(key); | 1523 typeMirror = makeLocalTypeMirror(key); |
| 1505 _instanitationCache[key] = typeMirror; | 1524 _instanitationCache[key] = typeMirror; |
| 1506 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1525 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1507 _declarationCache[key] = typeMirror; | 1526 _declarationCache[key] = typeMirror; |
| 1508 } | 1527 } |
| 1509 } | 1528 } |
| 1510 return typeMirror; | 1529 return typeMirror; |
| 1511 } | 1530 } |
| 1512 } | 1531 } |
| OLD | NEW |