Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 19780002: Convert MethodMirror.returnType to native calls (and more) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 : this.libraries = _createLibrariesMap(libraries), 96 : this.libraries = _createLibrariesMap(libraries),
97 _functionTypes = new Map<String, FunctionTypeMirror>(); 97 _functionTypes = new Map<String, FunctionTypeMirror>();
98 98
99 final Map<Uri, LibraryMirror> libraries; 99 final Map<Uri, LibraryMirror> libraries;
100 final IsolateMirror isolate; 100 final IsolateMirror isolate;
101 101
102 TypeMirror _dynamicType = null; 102 TypeMirror _dynamicType = null;
103 103
104 TypeMirror get dynamicType { 104 TypeMirror get dynamicType {
105 if (_dynamicType == null) { 105 if (_dynamicType == null) {
106 _dynamicType = new _SpecialTypeMirrorImpl(_s('dynamic')); 106 _dynamicType = new _SpecialTypeMirrorImpl('dynamic');
107 } 107 }
108 return _dynamicType; 108 return _dynamicType;
109 } 109 }
110 110
111 TypeMirror _voidType = null; 111 TypeMirror _voidType = null;
112 112
113 TypeMirror get voidType { 113 TypeMirror get voidType {
114 if (_voidType == null) { 114 if (_voidType == null) {
115 _voidType = new _SpecialTypeMirrorImpl(_s('void')); 115 _voidType = new _SpecialTypeMirrorImpl('void');
116 } 116 }
117 return _voidType; 117 return _voidType;
118 } 118 }
119 119
120 final Map<String, FunctionTypeMirror> _functionTypes; 120 final Map<String, FunctionTypeMirror> _functionTypes;
121 FunctionTypeMirror _lookupFunctionTypeMirror( 121 FunctionTypeMirror _lookupFunctionTypeMirror(
122 TypeMirror returnType, 122 TypeMirror returnType,
123 List<ParameterMirror> parameters) { 123 List<ParameterMirror> parameters) {
124 var sigString = _makeSignatureString(returnType, parameters); 124 var sigString = _makeSignatureString(returnType, parameters);
125 var mirror = _functionTypes[sigString]; 125 var mirror = _functionTypes[sigString];
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 868
869 _invokeSetter(reflectee, setterName, value) 869 _invokeSetter(reflectee, setterName, value)
870 native 'LibraryMirror_invokeSetter'; 870 native 'LibraryMirror_invokeSetter';
871 } 871 }
872 872
873 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl 873 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl
874 implements MethodMirror { 874 implements MethodMirror {
875 _LocalMethodMirrorImpl(reflectee, 875 _LocalMethodMirrorImpl(reflectee,
876 this._owner, 876 this._owner,
877 this.parameters, 877 this.parameters,
878 this._returnType,
879 this.isStatic, 878 this.isStatic,
880 this.isAbstract, 879 this.isAbstract,
881 this.isGetter, 880 this.isGetter,
882 this.isSetter, 881 this.isSetter,
883 this.isConstructor, 882 this.isConstructor,
884 this.isConstConstructor, 883 this.isConstConstructor,
885 this.isGenerativeConstructor, 884 this.isGenerativeConstructor,
886 this.isRedirectingConstructor, 885 this.isRedirectingConstructor,
887 this.isFactoryConstructor) : super(reflectee); 886 this.isFactoryConstructor) : super(reflectee);
888 887
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 _n(constructorName).startsWith('_'); 920 _n(constructorName).startsWith('_');
922 } 921 }
923 922
924 bool get isTopLevel => owner is LibraryMirror; 923 bool get isTopLevel => owner is LibraryMirror;
925 924
926 SourceLocation get location { 925 SourceLocation get location {
927 throw new UnimplementedError( 926 throw new UnimplementedError(
928 'MethodMirror.location is not implemented'); 927 'MethodMirror.location is not implemented');
929 } 928 }
930 929
931 var _returnType; 930 TypeMirror _returnType = null;
932 TypeMirror get returnType { 931 TypeMirror get returnType {
933 if (_returnType is! Mirror) { 932 if (_returnType == null) {
934 _returnType = _returnType.resolve(mirrors); 933 if (isConstructor) {
934 _returnType = owner;
935 } else {
936 _returnType = _MethodMirror_return_type(_reflectee);
937 }
935 } 938 }
936 return _returnType; 939 return _returnType;
937 } 940 }
938 941
939 final List<ParameterMirror> parameters; 942 final List<ParameterMirror> parameters;
940 943
941 final bool isStatic; 944 final bool isStatic;
942 final bool isAbstract; 945 final bool isAbstract;
943 946
944 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; 947 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 final bool isRedirectingConstructor; 981 final bool isRedirectingConstructor;
979 final bool isFactoryConstructor; 982 final bool isFactoryConstructor;
980 983
981 String toString() => "MethodMirror on '${_n(simpleName)}'"; 984 String toString() => "MethodMirror on '${_n(simpleName)}'";
982 985
983 static String _MethodMirror_name(reflectee) 986 static String _MethodMirror_name(reflectee)
984 native "MethodMirror_name"; 987 native "MethodMirror_name";
985 988
986 static dynamic _MethodMirror_owner(reflectee) 989 static dynamic _MethodMirror_owner(reflectee)
987 native "MethodMirror_owner"; 990 native "MethodMirror_owner";
991
992 static dynamic _MethodMirror_return_type(reflectee)
993 native "MethodMirror_return_type";
988 } 994 }
989 995
990 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl 996 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl
991 implements VariableMirror { 997 implements VariableMirror {
992 _LocalVariableMirrorImpl(reflectee, 998 _LocalVariableMirrorImpl(reflectee,
993 String simpleName, 999 String simpleName,
994 this._owner, 1000 this._owner,
995 this._type, 1001 this._type,
996 this.isStatic, 1002 this.isStatic,
997 this.isFinal) 1003 this.isFinal)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 1068
1063 // TODO(11418): Implement. 1069 // TODO(11418): Implement.
1064 List<InstanceMirror> get metadata { 1070 List<InstanceMirror> get metadata {
1065 throw new UnimplementedError( 1071 throw new UnimplementedError(
1066 'ParameterMirror.metadata is not implemented'); 1072 'ParameterMirror.metadata is not implemented');
1067 } 1073 }
1068 } 1074 }
1069 1075
1070 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl 1076 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
1071 implements TypeMirror, DeclarationMirror { 1077 implements TypeMirror, DeclarationMirror {
1072 _SpecialTypeMirrorImpl(this.simpleName); 1078 _SpecialTypeMirrorImpl(String name) : simpleName = _s(name);
1073 1079
1074 final bool isPrivate = false; 1080 final bool isPrivate = false;
1075 final bool isTopLevel = true; 1081 final bool isTopLevel = true;
1076 1082
1077 // Fixed length 0, therefore immutable. 1083 // Fixed length 0, therefore immutable.
1078 final List<InstanceMirror> metadata = new List(0); 1084 final List<InstanceMirror> metadata = new List(0);
1079 1085
1080 final DeclarationMirror owner = null; 1086 final DeclarationMirror owner = null;
1081 final Symbol simpleName; 1087 final Symbol simpleName;
1082 1088
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1147 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1142 static ClassMirror reflectClass(Type key) { 1148 static ClassMirror reflectClass(Type key) {
1143 var classMirror = _classMirrorCache[key]; 1149 var classMirror = _classMirrorCache[key];
1144 if (classMirror == null) { 1150 if (classMirror == null) {
1145 classMirror = makeLocalClassMirror(key); 1151 classMirror = makeLocalClassMirror(key);
1146 _classMirrorCache[key] = classMirror; 1152 _classMirrorCache[key] = classMirror;
1147 } 1153 }
1148 return classMirror; 1154 return classMirror;
1149 } 1155 }
1150 } 1156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698