| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 | 917 |
| 907 DeclarationMirror _owner; | 918 DeclarationMirror _owner; |
| 908 DeclarationMirror get owner { | 919 DeclarationMirror get owner { |
| 909 if (_owner == null) { | 920 if (_owner == null) { |
| 910 _owner = _TypeVariableMirror_owner(_reflectee).originalDeclaration; | 921 _owner = _TypeVariableMirror_owner(_reflectee).originalDeclaration; |
| 911 } | 922 } |
| 912 return _owner; | 923 return _owner; |
| 913 } | 924 } |
| 914 | 925 |
| 915 bool get isPrivate => false; | 926 bool get isPrivate => false; |
| 927 bool get isStatic => false; |
| 916 | 928 |
| 917 final bool isTopLevel = false; | 929 final bool isTopLevel = false; |
| 918 | 930 |
| 919 SourceLocation get location { | 931 SourceLocation get location { |
| 920 throw new UnimplementedError( | 932 throw new UnimplementedError( |
| 921 'TypeVariableMirror.location is not implemented'); | 933 'TypeVariableMirror.location is not implemented'); |
| 922 } | 934 } |
| 923 | 935 |
| 924 TypeMirror _upperBound = null; | 936 TypeMirror _upperBound = null; |
| 925 TypeMirror get upperBound { | 937 TypeMirror get upperBound { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 | 1105 |
| 1094 // Always false for libraries. | 1106 // Always false for libraries. |
| 1095 final bool isTopLevel = false; | 1107 final bool isTopLevel = false; |
| 1096 | 1108 |
| 1097 SourceLocation get location { | 1109 SourceLocation get location { |
| 1098 throw new UnimplementedError('LibraryMirror.location is not implemented'); | 1110 throw new UnimplementedError('LibraryMirror.location is not implemented'); |
| 1099 } | 1111 } |
| 1100 | 1112 |
| 1101 final Uri uri; | 1113 final Uri uri; |
| 1102 | 1114 |
| 1115 Map<Symbol, DeclarationMirror> _declarations; |
| 1116 Map<Symbol, DeclarationMirror> get declarations { |
| 1117 if (_declarations != null) return _declarations; |
| 1118 return _declarations = |
| 1119 new _UnmodifiableMapView<Symbol, DeclarationMirror>(members); |
| 1120 } |
| 1121 |
| 1103 Map<Symbol, Mirror> _members; | 1122 Map<Symbol, Mirror> _members; |
| 1104 Map<Symbol, Mirror> get members { | 1123 Map<Symbol, Mirror> get members { |
| 1105 if (_members == null) { | 1124 if (_members == null) { |
| 1106 _members = _makeMemberMap(_computeMembers(_reflectee)); | 1125 _members = _makeMemberMap(_computeMembers(_reflectee)); |
| 1107 } | 1126 } |
| 1108 return _members; | 1127 return _members; |
| 1109 } | 1128 } |
| 1110 | 1129 |
| 1111 Map<Symbol, ClassMirror> _types; | 1130 Map<Symbol, ClassMirror> _types; |
| 1112 Map<Symbol, TypeMirror> get types { | 1131 Map<Symbol, TypeMirror> get types { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 } | 1277 } |
| 1259 | 1278 |
| 1260 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; | 1279 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; |
| 1261 | 1280 |
| 1262 Symbol _constructorName = null; | 1281 Symbol _constructorName = null; |
| 1263 Symbol get constructorName { | 1282 Symbol get constructorName { |
| 1264 if (_constructorName == null) { | 1283 if (_constructorName == null) { |
| 1265 if (!isConstructor) { | 1284 if (!isConstructor) { |
| 1266 _constructorName = _s(''); | 1285 _constructorName = _s(''); |
| 1267 } else { | 1286 } else { |
| 1268 var parts = _n(simpleName).split('.'); | 1287 var parts = MirrorSystem.getName(simpleName).split('.'); |
| 1269 if (parts.length > 2) { | 1288 if (parts.length > 2) { |
| 1270 throw new MirrorException( | 1289 throw new MirrorException( |
| 1271 'Internal error in MethodMirror.constructorName: ' | 1290 'Internal error in MethodMirror.constructorName: ' |
| 1272 'malformed name <$simpleName>'); | 1291 'malformed name <$simpleName>'); |
| 1273 } else if (parts.length == 2) { | 1292 } else if (parts.length == 2) { |
| 1274 _constructorName = _s(parts[1]); | 1293 _constructorName = _s(parts[1]); |
| 1275 } else { | 1294 } else { |
| 1276 _constructorName = _s(''); | 1295 _constructorName = _s(''); |
| 1277 } | 1296 } |
| 1278 } | 1297 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 if (typeMirror == null) { | 1529 if (typeMirror == null) { |
| 1511 typeMirror = makeLocalTypeMirror(key); | 1530 typeMirror = makeLocalTypeMirror(key); |
| 1512 _instanitationCache[key] = typeMirror; | 1531 _instanitationCache[key] = typeMirror; |
| 1513 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1532 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1514 _declarationCache[key] = typeMirror; | 1533 _declarationCache[key] = typeMirror; |
| 1515 } | 1534 } |
| 1516 } | 1535 } |
| 1517 return typeMirror; | 1536 return typeMirror; |
| 1518 } | 1537 } |
| 1519 } | 1538 } |
| OLD | NEW |