| 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 Symbol get simpleName => _simpleName; | 951 Symbol get simpleName => _simpleName; |
| 952 | 952 |
| 953 Symbol _qualifiedName = null; | 953 Symbol _qualifiedName = null; |
| 954 Symbol get qualifiedName { | 954 Symbol get qualifiedName { |
| 955 if (_qualifiedName == null) { | 955 if (_qualifiedName == null) { |
| 956 _qualifiedName = _computeQualifiedName(owner, simpleName); | 956 _qualifiedName = _computeQualifiedName(owner, simpleName); |
| 957 } | 957 } |
| 958 return _qualifiedName; | 958 return _qualifiedName; |
| 959 } | 959 } |
| 960 | 960 |
| 961 bool get isPrivate => _n(simpleName).startsWith('_'); |
| 962 |
| 961 List<InstanceMirror> get metadata { | 963 List<InstanceMirror> get metadata { |
| 962 // Get the metadata objects, convert them into InstanceMirrors using | 964 // Get the metadata objects, convert them into InstanceMirrors using |
| 963 // reflect() and then make them into a Dart list. | 965 // reflect() and then make them into a Dart list. |
| 964 return new UnmodifiableListView(_metadata(_reflectee).map(reflect)); | 966 return new UnmodifiableListView(_metadata(_reflectee).map(reflect)); |
| 965 } | 967 } |
| 966 | 968 |
| 967 bool operator ==(other) { | 969 bool operator ==(other) { |
| 968 return this.runtimeType == other.runtimeType && | 970 return this.runtimeType == other.runtimeType && |
| 969 this._reflectee == other._reflectee; | 971 this._reflectee == other._reflectee; |
| 970 } | 972 } |
| 971 | 973 |
| 972 int get hashCode => simpleName.hashCode; | 974 int get hashCode => simpleName.hashCode; |
| 973 } | 975 } |
| 974 | 976 |
| 975 class _LocalTypeVariableMirror extends _LocalDeclarationMirror | 977 class _LocalTypeVariableMirror extends _LocalDeclarationMirror |
| 976 implements TypeVariableMirror { | 978 implements TypeVariableMirror { |
| 977 _LocalTypeVariableMirror(reflectee, | 979 _LocalTypeVariableMirror(reflectee, |
| 978 String simpleName, | 980 String simpleName, |
| 979 this._owner) | 981 this._owner) |
| 980 : super(reflectee, _s(simpleName)); | 982 : super(reflectee, _s(simpleName)); |
| 981 | 983 |
| 982 DeclarationMirror _owner; | 984 DeclarationMirror _owner; |
| 983 DeclarationMirror get owner { | 985 DeclarationMirror get owner { |
| 984 if (_owner == null) { | 986 if (_owner == null) { |
| 985 _owner = _TypeVariableMirror_owner(_reflectee).originalDeclaration; | 987 _owner = _TypeVariableMirror_owner(_reflectee).originalDeclaration; |
| 986 } | 988 } |
| 987 return _owner; | 989 return _owner; |
| 988 } | 990 } |
| 989 | 991 |
| 990 bool get isPrivate => false; | |
| 991 bool get isStatic => false; | 992 bool get isStatic => false; |
| 992 bool get isTopLevel => false; | 993 bool get isTopLevel => false; |
| 993 | 994 |
| 994 SourceLocation get location { | 995 SourceLocation get location { |
| 995 throw new UnimplementedError( | 996 throw new UnimplementedError( |
| 996 'TypeVariableMirror.location is not implemented'); | 997 'TypeVariableMirror.location is not implemented'); |
| 997 } | 998 } |
| 998 | 999 |
| 999 TypeMirror _upperBound = null; | 1000 TypeMirror _upperBound = null; |
| 1000 TypeMirror get upperBound { | 1001 TypeMirror get upperBound { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 | 1055 |
| 1055 _LocalTypedefMirror(reflectee, | 1056 _LocalTypedefMirror(reflectee, |
| 1056 this._reflectedType, | 1057 this._reflectedType, |
| 1057 String simpleName, | 1058 String simpleName, |
| 1058 this._isGeneric, | 1059 this._isGeneric, |
| 1059 this._isGenericDeclaration, | 1060 this._isGenericDeclaration, |
| 1060 this._owner) | 1061 this._owner) |
| 1061 : super(reflectee, _s(simpleName)); | 1062 : super(reflectee, _s(simpleName)); |
| 1062 | 1063 |
| 1063 bool get isTopLevel => true; | 1064 bool get isTopLevel => true; |
| 1064 bool get isPrivate => false; | |
| 1065 | 1065 |
| 1066 DeclarationMirror _owner; | 1066 DeclarationMirror _owner; |
| 1067 DeclarationMirror get owner { | 1067 DeclarationMirror get owner { |
| 1068 if (_owner == null) { | 1068 if (_owner == null) { |
| 1069 _owner = _LocalClassMirror._library(_reflectee); | 1069 _owner = _LocalClassMirror._library(_reflectee); |
| 1070 } | 1070 } |
| 1071 return _owner; | 1071 return _owner; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 SourceLocation get location { | 1074 SourceLocation get location { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 | 1420 |
| 1421 _LocalVariableMirror(reflectee, | 1421 _LocalVariableMirror(reflectee, |
| 1422 String simpleName, | 1422 String simpleName, |
| 1423 this.owner, | 1423 this.owner, |
| 1424 this._type, | 1424 this._type, |
| 1425 this.isStatic, | 1425 this.isStatic, |
| 1426 this.isFinal, | 1426 this.isFinal, |
| 1427 this.isConst) | 1427 this.isConst) |
| 1428 : super(reflectee, _s(simpleName)); | 1428 : super(reflectee, _s(simpleName)); |
| 1429 | 1429 |
| 1430 bool get isPrivate => _n(simpleName).startsWith('_'); | |
| 1431 | |
| 1432 bool get isTopLevel => owner is LibraryMirror; | 1430 bool get isTopLevel => owner is LibraryMirror; |
| 1433 | 1431 |
| 1434 SourceLocation get location { | 1432 SourceLocation get location { |
| 1435 throw new UnimplementedError('VariableMirror.location is not implemented'); | 1433 throw new UnimplementedError('VariableMirror.location is not implemented'); |
| 1436 } | 1434 } |
| 1437 | 1435 |
| 1438 Type get _instantiator { | 1436 Type get _instantiator { |
| 1439 return owner._instantiator; | 1437 return owner._instantiator; |
| 1440 } | 1438 } |
| 1441 | 1439 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 if (typeMirror == null) { | 1616 if (typeMirror == null) { |
| 1619 typeMirror = makeLocalTypeMirror(key); | 1617 typeMirror = makeLocalTypeMirror(key); |
| 1620 _instanitationCache[key] = typeMirror; | 1618 _instanitationCache[key] = typeMirror; |
| 1621 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1619 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1622 _declarationCache[key] = typeMirror; | 1620 _declarationCache[key] = typeMirror; |
| 1623 } | 1621 } |
| 1624 } | 1622 } |
| 1625 return typeMirror; | 1623 return typeMirror; |
| 1626 } | 1624 } |
| 1627 } | 1625 } |
| OLD | NEW |