| 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 // These values are allowed to be passed directly over the wire. | 9 // These values are allowed to be passed directly over the wire. |
| 10 bool _isSimpleValue(var value) { | 10 bool _isSimpleValue(var value) { |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 this._owner, | 917 this._owner, |
| 918 this.isStatic, | 918 this.isStatic, |
| 919 this.isAbstract, | 919 this.isAbstract, |
| 920 this.isGetter, | 920 this.isGetter, |
| 921 this.isSetter, | 921 this.isSetter, |
| 922 this.isConstructor, | 922 this.isConstructor, |
| 923 this.isConstConstructor, | 923 this.isConstConstructor, |
| 924 this.isGenerativeConstructor, | 924 this.isGenerativeConstructor, |
| 925 this.isRedirectingConstructor, | 925 this.isRedirectingConstructor, |
| 926 this.isFactoryConstructor) | 926 this.isFactoryConstructor) |
| 927 : super(reflectee, _s(simpleName)); | 927 : this.isOperator = _operators.contains(simpleName), |
| 928 super(reflectee, _s(simpleName)); |
| 929 |
| 930 static const _operators = const ["%", "&", "*", "+", "-", "/", "<", "<<", |
| 931 "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/"]; |
| 932 |
| 933 final bool isStatic; |
| 934 final bool isAbstract; |
| 935 final bool isGetter; |
| 936 final bool isSetter; |
| 937 final bool isConstructor; |
| 938 final bool isConstConstructor; |
| 939 final bool isGenerativeConstructor; |
| 940 final bool isRedirectingConstructor; |
| 941 final bool isFactoryConstructor; |
| 942 final bool isOperator; |
| 928 | 943 |
| 929 DeclarationMirror _owner; | 944 DeclarationMirror _owner; |
| 930 DeclarationMirror get owner { | 945 DeclarationMirror get owner { |
| 931 // For nested closures it is possible, that the mirror for the owner has not | 946 // For nested closures it is possible, that the mirror for the owner has not |
| 932 // been created yet. | 947 // been created yet. |
| 933 if (_owner == null) { | 948 if (_owner == null) { |
| 934 _owner = _MethodMirror_owner(_reflectee); | 949 _owner = _MethodMirror_owner(_reflectee); |
| 935 } | 950 } |
| 936 return _owner; | 951 return _owner; |
| 937 } | 952 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 962 } | 977 } |
| 963 | 978 |
| 964 List<ParameterMirror> _parameters = null; | 979 List<ParameterMirror> _parameters = null; |
| 965 List<ParameterMirror> get parameters { | 980 List<ParameterMirror> get parameters { |
| 966 if (_parameters == null) { | 981 if (_parameters == null) { |
| 967 _parameters = _MethodMirror_parameters(_reflectee); | 982 _parameters = _MethodMirror_parameters(_reflectee); |
| 968 } | 983 } |
| 969 return _parameters; | 984 return _parameters; |
| 970 } | 985 } |
| 971 | 986 |
| 972 final bool isStatic; | |
| 973 final bool isAbstract; | |
| 974 | |
| 975 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; | 987 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; |
| 976 | 988 |
| 977 TypeMirror get isOperator { | |
| 978 throw new UnimplementedError( | |
| 979 'MethodMirror.isOperator is not implemented'); | |
| 980 } | |
| 981 | |
| 982 final bool isGetter; | |
| 983 final bool isSetter; | |
| 984 final bool isConstructor; | |
| 985 | |
| 986 Symbol _constructorName = null; | 989 Symbol _constructorName = null; |
| 987 Symbol get constructorName { | 990 Symbol get constructorName { |
| 988 if (_constructorName == null) { | 991 if (_constructorName == null) { |
| 989 if (!isConstructor) { | 992 if (!isConstructor) { |
| 990 _constructorName = _s(''); | 993 _constructorName = _s(''); |
| 991 } else { | 994 } else { |
| 992 var parts = _n(simpleName).split('.'); | 995 var parts = _n(simpleName).split('.'); |
| 993 if (parts.length > 2) { | 996 if (parts.length > 2) { |
| 994 throw new MirrorException( | 997 throw new MirrorException( |
| 995 'Internal error in MethodMirror.constructorName: ' | 998 'Internal error in MethodMirror.constructorName: ' |
| 996 'malformed name <$simpleName>'); | 999 'malformed name <$simpleName>'); |
| 997 } else if (parts.length == 2) { | 1000 } else if (parts.length == 2) { |
| 998 _constructorName = _s(parts[1]); | 1001 _constructorName = _s(parts[1]); |
| 999 } else { | 1002 } else { |
| 1000 _constructorName = _s(''); | 1003 _constructorName = _s(''); |
| 1001 } | 1004 } |
| 1002 } | 1005 } |
| 1003 } | 1006 } |
| 1004 return _constructorName; | 1007 return _constructorName; |
| 1005 } | 1008 } |
| 1006 | 1009 |
| 1007 final bool isConstConstructor; | |
| 1008 final bool isGenerativeConstructor; | |
| 1009 final bool isRedirectingConstructor; | |
| 1010 final bool isFactoryConstructor; | |
| 1011 | |
| 1012 String toString() => "MethodMirror on '${_n(simpleName)}'"; | 1010 String toString() => "MethodMirror on '${_n(simpleName)}'"; |
| 1013 | 1011 |
| 1014 static dynamic _MethodMirror_owner(reflectee) | 1012 static dynamic _MethodMirror_owner(reflectee) |
| 1015 native "MethodMirror_owner"; | 1013 native "MethodMirror_owner"; |
| 1016 | 1014 |
| 1017 static dynamic _MethodMirror_return_type(reflectee) | 1015 static dynamic _MethodMirror_return_type(reflectee) |
| 1018 native "MethodMirror_return_type"; | 1016 native "MethodMirror_return_type"; |
| 1019 | 1017 |
| 1020 List<ParameterMirror> _MethodMirror_parameters(reflectee) | 1018 List<ParameterMirror> _MethodMirror_parameters(reflectee) |
| 1021 native "MethodMirror_parameters"; | 1019 native "MethodMirror_parameters"; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 if (typeMirror == null) { | 1210 if (typeMirror == null) { |
| 1213 typeMirror = makeLocalTypeMirror(key); | 1211 typeMirror = makeLocalTypeMirror(key); |
| 1214 _instanitationCache[key] = typeMirror; | 1212 _instanitationCache[key] = typeMirror; |
| 1215 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1213 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1216 _declarationCache[key] = typeMirror; | 1214 _declarationCache[key] = typeMirror; |
| 1217 } | 1215 } |
| 1218 } | 1216 } |
| 1219 return typeMirror; | 1217 return typeMirror; |
| 1220 } | 1218 } |
| 1221 } | 1219 } |
| OLD | NEW |