| 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 | 1047 |
| 1048 TypeMirror _upperBound = null; | 1048 TypeMirror _upperBound = null; |
| 1049 TypeMirror get upperBound { | 1049 TypeMirror get upperBound { |
| 1050 if (_upperBound == null) { | 1050 if (_upperBound == null) { |
| 1051 _upperBound = reflectType(_TypeVariableMirror_upper_bound(_reflectee)); | 1051 _upperBound = reflectType(_TypeVariableMirror_upper_bound(_reflectee)); |
| 1052 } | 1052 } |
| 1053 return _upperBound; | 1053 return _upperBound; |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 bool get hasReflectedType => false; | 1056 bool get hasReflectedType => false; |
| 1057 Type get reflectedType => throw new UnsupportedError(); | 1057 Type get reflectedType { |
| 1058 throw new UnsupportedError('Type variables have no reflected type'); |
| 1059 } |
| 1058 Type get _reflectedType => _reflectee; | 1060 Type get _reflectedType => _reflectee; |
| 1059 | 1061 |
| 1060 List<TypeVariableMirror> get typeVariables => emptyList; | 1062 List<TypeVariableMirror> get typeVariables => emptyList; |
| 1061 List<TypeMirror> get typeArguments => emptyList; | 1063 List<TypeMirror> get typeArguments => emptyList; |
| 1062 | 1064 |
| 1063 bool get isOriginalDeclaration => true; | 1065 bool get isOriginalDeclaration => true; |
| 1064 TypeMirror get originalDeclaration => this; | 1066 TypeMirror get originalDeclaration => this; |
| 1065 | 1067 |
| 1066 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; | 1068 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; |
| 1067 | 1069 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 | 1126 |
| 1125 TypeMirror _referent = null; | 1127 TypeMirror _referent = null; |
| 1126 TypeMirror get referent { | 1128 TypeMirror get referent { |
| 1127 if (_referent == null) { | 1129 if (_referent == null) { |
| 1128 _referent = _nativeReferent(_reflectedType); | 1130 _referent = _nativeReferent(_reflectedType); |
| 1129 _referent._instantiator = _reflectedType; | 1131 _referent._instantiator = _reflectedType; |
| 1130 } | 1132 } |
| 1131 return _referent; | 1133 return _referent; |
| 1132 } | 1134 } |
| 1133 | 1135 |
| 1136 bool get hasReflectedType => !_isGenericDeclaration; |
| 1137 Type get reflectedType { |
| 1138 if (!hasReflectedType) { |
| 1139 throw new UnsupportedError( |
| 1140 "Declarations of generics have no reflected type"); |
| 1141 } |
| 1142 return _reflectedType; |
| 1143 } |
| 1144 |
| 1134 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; | 1145 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; |
| 1135 | 1146 |
| 1136 TypedefMirror get originalDeclaration { | 1147 TypedefMirror get originalDeclaration { |
| 1137 if (isOriginalDeclaration) { | 1148 if (isOriginalDeclaration) { |
| 1138 return this; | 1149 return this; |
| 1139 } else { | 1150 } else { |
| 1140 return _nativeDeclaration(_reflectedType); | 1151 return _nativeDeclaration(_reflectedType); |
| 1141 } | 1152 } |
| 1142 } | 1153 } |
| 1143 | 1154 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 | 1542 |
| 1532 _SpecialTypeMirror(String name) : simpleName = _s(name); | 1543 _SpecialTypeMirror(String name) : simpleName = _s(name); |
| 1533 | 1544 |
| 1534 bool get isPrivate => false; | 1545 bool get isPrivate => false; |
| 1535 bool get isTopLevel => true; | 1546 bool get isTopLevel => true; |
| 1536 | 1547 |
| 1537 DeclarationMirror get owner => null; | 1548 DeclarationMirror get owner => null; |
| 1538 | 1549 |
| 1539 List<InstanceMirror> get metadata => emptyList; | 1550 List<InstanceMirror> get metadata => emptyList; |
| 1540 | 1551 |
| 1552 bool get hasReflectedType => simpleName == #dynamic; |
| 1553 Type get reflectedType { |
| 1554 if (simpleName == #dynamic) return dynamic; |
| 1555 throw new UnsupportedError("void has no reflected type"); |
| 1556 } |
| 1557 |
| 1541 List<TypeVariableMirror> get typeVariables => emptyList; | 1558 List<TypeVariableMirror> get typeVariables => emptyList; |
| 1542 List<TypeMirror> get typeArguments => emptyList; | 1559 List<TypeMirror> get typeArguments => emptyList; |
| 1543 | 1560 |
| 1544 bool get isOriginalDeclaration => true; | 1561 bool get isOriginalDeclaration => true; |
| 1545 TypeMirror get originalDeclaration => this; | 1562 TypeMirror get originalDeclaration => this; |
| 1546 | 1563 |
| 1547 SourceLocation get location { | 1564 SourceLocation get location { |
| 1548 throw new UnimplementedError('TypeMirror.location is not implemented'); | 1565 throw new UnimplementedError('TypeMirror.location is not implemented'); |
| 1549 } | 1566 } |
| 1550 | 1567 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 if (typeMirror == null) { | 1636 if (typeMirror == null) { |
| 1620 typeMirror = makeLocalTypeMirror(key); | 1637 typeMirror = makeLocalTypeMirror(key); |
| 1621 _instanitationCache[key] = typeMirror; | 1638 _instanitationCache[key] = typeMirror; |
| 1622 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1639 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1623 _declarationCache[key] = typeMirror; | 1640 _declarationCache[key] = typeMirror; |
| 1624 } | 1641 } |
| 1625 } | 1642 } |
| 1626 return typeMirror; | 1643 return typeMirror; |
| 1627 } | 1644 } |
| 1628 } | 1645 } |
| OLD | NEW |