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" show UnmodifiableListView, UnmodifiableMapView; | 7 import "dart:collection" show UnmodifiableListView, UnmodifiableMapView; |
8 import "dart:async" show Future; | 8 import "dart:async" show Future; |
9 | 9 |
10 var dirty = false; | 10 var dirty = false; |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 | 938 |
939 static _ClassMirror_type_variables(reflectee) | 939 static _ClassMirror_type_variables(reflectee) |
940 native "ClassMirror_type_variables"; | 940 native "ClassMirror_type_variables"; |
941 | 941 |
942 static _computeTypeArguments(reflectee) | 942 static _computeTypeArguments(reflectee) |
943 native "ClassMirror_type_arguments"; | 943 native "ClassMirror_type_arguments"; |
944 } | 944 } |
945 | 945 |
946 class _LocalFunctionTypeMirror extends _LocalClassMirror | 946 class _LocalFunctionTypeMirror extends _LocalClassMirror |
947 implements FunctionTypeMirror { | 947 implements FunctionTypeMirror { |
948 _LocalFunctionTypeMirror(reflectee, reflectedType) | 948 final _functionReflectee; |
| 949 _LocalFunctionTypeMirror(reflectee, this._functionReflectee, reflectedType) |
949 : super(reflectee, reflectedType, null, null, false, false, false, false,
false); | 950 : super(reflectee, reflectedType, null, null, false, false, false, false,
false); |
950 | 951 |
951 bool get _isAnonymousMixinApplication => false; | 952 bool get _isAnonymousMixinApplication => false; |
952 | 953 |
953 // FunctionTypeMirrors have a simpleName generated from their signature. | 954 // FunctionTypeMirrors have a simpleName generated from their signature. |
954 Symbol _simpleName = null; | 955 Symbol _simpleName = null; |
955 Symbol get simpleName { | 956 Symbol get simpleName { |
956 if (_simpleName == null) { | 957 if (_simpleName == null) { |
957 _simpleName = _s(_makeSignatureString(returnType, parameters)); | 958 _simpleName = _s(_makeSignatureString(returnType, parameters)); |
958 } | 959 } |
959 return _simpleName; | 960 return _simpleName; |
960 } | 961 } |
961 | 962 |
962 MethodMirror _callMethod; | 963 MethodMirror _callMethod; |
963 MethodMirror get callMethod { | 964 MethodMirror get callMethod { |
964 if (_callMethod == null) { | 965 if (_callMethod == null) { |
965 _callMethod = this._FunctionTypeMirror_call_method(_reflectee); | 966 _callMethod = _FunctionTypeMirror_call_method(_functionReflectee); |
966 } | 967 } |
967 return _callMethod; | 968 return _callMethod; |
968 } | 969 } |
969 | 970 |
970 TypeMirror _returnType = null; | 971 TypeMirror _returnType = null; |
971 TypeMirror get returnType { | 972 TypeMirror get returnType { |
972 if (_returnType == null) { | 973 if (_returnType == null) { |
973 _returnType = reflectType( | 974 _returnType = reflectType( |
974 _FunctionTypeMirror_return_type(_reflectee, _instantiator)); | 975 _FunctionTypeMirror_return_type(_functionReflectee, _instantiator)); |
975 } | 976 } |
976 return _returnType; | 977 return _returnType; |
977 } | 978 } |
978 | 979 |
979 List<ParameterMirror> _parameters = null; | 980 List<ParameterMirror> _parameters = null; |
980 List<ParameterMirror> get parameters { | 981 List<ParameterMirror> get parameters { |
981 if (_parameters == null) { | 982 if (_parameters == null) { |
982 _parameters = _FunctionTypeMirror_parameters(_reflectee); | 983 _parameters = _FunctionTypeMirror_parameters(_functionReflectee); |
983 _parameters = new UnmodifiableListView(_parameters); | 984 _parameters = new UnmodifiableListView(_parameters); |
984 } | 985 } |
985 return _parameters; | 986 return _parameters; |
986 } | 987 } |
987 | 988 |
988 bool get isOriginalDeclaration => true; | 989 bool get isOriginalDeclaration => true; |
989 get originalDeclaration => this; | 990 get originalDeclaration => this; |
990 get typeVariables => emptyList; | 991 get typeVariables => emptyList; |
991 get typeArguments => emptyList; | 992 get typeArguments => emptyList; |
992 get metadata => emptyList; | 993 get metadata => emptyList; |
| 994 get location => null; |
993 | 995 |
994 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; | 996 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; |
995 | 997 |
996 MethodMirror _FunctionTypeMirror_call_method(reflectee) | 998 MethodMirror _FunctionTypeMirror_call_method(functionReflectee) |
997 native "FunctionTypeMirror_call_method"; | 999 native "FunctionTypeMirror_call_method"; |
998 | 1000 |
999 static Type _FunctionTypeMirror_return_type(reflectee, instantiator) | 1001 static Type _FunctionTypeMirror_return_type(functionReflectee, instantiator) |
1000 native "FunctionTypeMirror_return_type"; | 1002 native "FunctionTypeMirror_return_type"; |
1001 | 1003 |
1002 List<ParameterMirror> _FunctionTypeMirror_parameters(reflectee) | 1004 List<ParameterMirror> _FunctionTypeMirror_parameters(functionReflectee) |
1003 native "FunctionTypeMirror_parameters"; | 1005 native "FunctionTypeMirror_parameters"; |
1004 } | 1006 } |
1005 | 1007 |
1006 abstract class _LocalDeclarationMirror extends _LocalMirror | 1008 abstract class _LocalDeclarationMirror extends _LocalMirror |
1007 implements DeclarationMirror { | 1009 implements DeclarationMirror { |
1008 final _reflectee; | 1010 final _reflectee; |
1009 Symbol _simpleName; | 1011 Symbol _simpleName; |
1010 | 1012 |
1011 _LocalDeclarationMirror(this._reflectee, this._simpleName); | 1013 _LocalDeclarationMirror(this._reflectee, this._simpleName); |
1012 | 1014 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 ? new _LocalClosureMirror(reflectee) | 1643 ? new _LocalClosureMirror(reflectee) |
1642 : new _LocalInstanceMirror(reflectee); | 1644 : new _LocalInstanceMirror(reflectee); |
1643 } | 1645 } |
1644 | 1646 |
1645 static ClassMirror makeLocalClassMirror(Type key) | 1647 static ClassMirror makeLocalClassMirror(Type key) |
1646 native "Mirrors_makeLocalClassMirror"; | 1648 native "Mirrors_makeLocalClassMirror"; |
1647 static TypeMirror makeLocalTypeMirror(Type key) | 1649 static TypeMirror makeLocalTypeMirror(Type key) |
1648 native "Mirrors_makeLocalTypeMirror"; | 1650 native "Mirrors_makeLocalTypeMirror"; |
1649 | 1651 |
1650 static Expando<ClassMirror> _declarationCache = new Expando("ClassMirror"); | 1652 static Expando<ClassMirror> _declarationCache = new Expando("ClassMirror"); |
1651 static Expando<TypeMirror> _instanitationCache = new Expando("TypeMirror"); | 1653 static Expando<TypeMirror> _instantiationCache = new Expando("TypeMirror"); |
1652 | 1654 |
1653 static ClassMirror reflectClass(Type key) { | 1655 static ClassMirror reflectClass(Type key) { |
1654 var classMirror = _declarationCache[key]; | 1656 var classMirror = _declarationCache[key]; |
1655 if (classMirror == null) { | 1657 if (classMirror == null) { |
1656 classMirror = makeLocalClassMirror(key); | 1658 classMirror = makeLocalClassMirror(key); |
1657 _declarationCache[key] = classMirror; | 1659 _declarationCache[key] = classMirror; |
1658 if (!classMirror._isGeneric) { | 1660 if (!classMirror._isGeneric) { |
1659 _instanitationCache[key] = classMirror; | 1661 _instantiationCache[key] = classMirror; |
1660 } | 1662 } |
1661 } | 1663 } |
1662 return classMirror; | 1664 return classMirror; |
1663 } | 1665 } |
1664 | 1666 |
1665 static TypeMirror reflectType(Type key) { | 1667 static TypeMirror reflectType(Type key) { |
1666 var typeMirror = _instanitationCache[key]; | 1668 var typeMirror = _instantiationCache[key]; |
1667 if (typeMirror == null) { | 1669 if (typeMirror == null) { |
1668 typeMirror = makeLocalTypeMirror(key); | 1670 typeMirror = makeLocalTypeMirror(key); |
1669 _instanitationCache[key] = typeMirror; | 1671 _instantiationCache[key] = typeMirror; |
1670 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1672 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1671 _declarationCache[key] = typeMirror; | 1673 _declarationCache[key] = typeMirror; |
1672 } | 1674 } |
1673 } | 1675 } |
1674 return typeMirror; | 1676 return typeMirror; |
1675 } | 1677 } |
1676 } | 1678 } |
OLD | NEW |