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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 27728004: Generic typedefs and their referents. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "lib/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ASSERT(type.IsFinalized()); 228 ASSERT(type.IsFinalized());
229 name ^= type.name(); 229 name ^= type.name();
230 result.SetAt(2 * i, name); 230 result.SetAt(2 * i, name);
231 result.SetAt(2 * i + 1, type); 231 result.SetAt(2 * i + 1, type);
232 } 232 }
233 return result.raw(); 233 return result.raw();
234 } 234 }
235 235
236 236
237 static RawInstance* CreateTypedefMirror(const Class& cls, 237 static RawInstance* CreateTypedefMirror(const Class& cls,
238 const AbstractType& type,
239 const Bool& is_declaration,
238 const Instance& owner_mirror) { 240 const Instance& owner_mirror) {
239 const Array& args = Array::Handle(Array::New(3)); 241 const Array& args = Array::Handle(Array::New(6));
240 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 242 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
241 args.SetAt(1, String::Handle(cls.UserVisibleName())); 243 args.SetAt(1, type);
242 args.SetAt(2, owner_mirror); 244 args.SetAt(2, String::Handle(cls.UserVisibleName()));
245 args.SetAt(3, Bool::Get(cls.NumTypeParameters() != 0));
246 args.SetAt(4, cls.NumTypeParameters() == 0 ? Bool::False() : is_declaration);
247 args.SetAt(5, owner_mirror);
243 return CreateMirror(Symbols::_LocalTypedefMirrorImpl(), args); 248 return CreateMirror(Symbols::_LocalTypedefMirrorImpl(), args);
244 } 249 }
245 250
246 251
247 static RawInstance* CreateFunctionTypeMirror(const Class& cls, 252 static RawInstance* CreateFunctionTypeMirror(const Class& cls,
248 const AbstractType& type) { 253 const AbstractType& type) {
249 const Array& args = Array::Handle(Array::New(2)); 254 const Array& args = Array::Handle(Array::New(2));
250 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 255 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
251 args.SetAt(1, type); 256 args.SetAt(1, type);
252 return CreateMirror(Symbols::_LocalFunctionTypeMirrorImpl(), args); 257 return CreateMirror(Symbols::_LocalFunctionTypeMirrorImpl(), args);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass()); 326 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass());
322 ASSERT(!type.IsNull()); 327 ASSERT(!type.IsNull());
323 ASSERT(type.IsFinalized()); 328 ASSERT(type.IsFinalized());
324 329
325 if (cls.IsSignatureClass()) { 330 if (cls.IsSignatureClass()) {
326 if (cls.IsCanonicalSignatureClass()) { 331 if (cls.IsCanonicalSignatureClass()) {
327 // We represent function types as canonical signature classes. 332 // We represent function types as canonical signature classes.
328 return CreateFunctionTypeMirror(cls, type); 333 return CreateFunctionTypeMirror(cls, type);
329 } else { 334 } else {
330 // We represent typedefs as non-canonical signature classes. 335 // We represent typedefs as non-canonical signature classes.
331 return CreateTypedefMirror(cls, owner_mirror); 336 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror);
332 } 337 }
333 } 338 }
334 339
335 const Bool& is_generic = Bool::Get(cls.NumTypeParameters() != 0); 340 const Bool& is_generic = Bool::Get(cls.NumTypeParameters() != 0);
336 const Bool& is_mixin_typedef = Bool::Get(cls.is_mixin_typedef()); 341 const Bool& is_mixin_typedef = Bool::Get(cls.is_mixin_typedef());
337 342
338 const Array& args = Array::Handle(Array::New(6)); 343 const Array& args = Array::Handle(Array::New(6));
339 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 344 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
340 args.SetAt(1, type); 345 args.SetAt(1, type);
341 // We do not set the names of anonymous mixin applications because the mirrors 346 // We do not set the names of anonymous mixin applications because the mirrors
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 826 }
822 } 827 }
823 828
824 // Fall through case: Indicate that we didn't find any function or field using 829 // Fall through case: Indicate that we didn't find any function or field using
825 // a special null instance. This is different from a field being null. Callers 830 // a special null instance. This is different from a field being null. Callers
826 // make sure that this null does not leak into Dartland. 831 // make sure that this null does not leak into Dartland.
827 return Object::sentinel().raw(); 832 return Object::sentinel().raw();
828 } 833 }
829 834
830 835
836 static RawAbstractType* InstantiateType(const AbstractType& type,
837 const AbstractType& instantiator) {
838 ASSERT(type.IsFinalized());
839 ASSERT(instantiator.IsFinalized());
840 ASSERT(!type.IsMalformed());
841 ASSERT(!instantiator.IsMalformed());
842
843 if (type.IsInstantiated()) {
844 return type.raw();
regis 2013/10/21 19:42:27 Do you care if the type is canonical or not?
rmacnak 2013/10/21 19:57:06 We do want to deal with canonical types, and rely
845 }
846
847 const AbstractTypeArguments& type_args =
848 AbstractTypeArguments::Handle(instantiator.arguments());
849 Error& bound_error = Error::Handle();
850 AbstractType& result =
851 AbstractType::Handle(type.InstantiateFrom(type_args, &bound_error));
852 if (!bound_error.IsNull()) {
853 ThrowInvokeError(bound_error);
regis 2013/10/21 19:42:27 Are you sure you want to throw the bound error dir
rmacnak 2013/10/21 19:57:06 ThrowInvokeError will wrap it in a MirroredCompila
854 UNREACHABLE();
855 }
856 ASSERT(result.IsFinalized());
857 return result.Canonicalize();
858 }
859
860
831 DEFINE_NATIVE_ENTRY(Mirrors_makeLocalMirrorSystem, 0) { 861 DEFINE_NATIVE_ENTRY(Mirrors_makeLocalMirrorSystem, 0) {
832 return CreateMirrorSystem(); 862 return CreateMirrorSystem();
833 } 863 }
834 864
835 865
836 DEFINE_NATIVE_ENTRY(Mirrors_makeLocalClassMirror, 1) { 866 DEFINE_NATIVE_ENTRY(Mirrors_makeLocalClassMirror, 1) {
837 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 867 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
838 ASSERT(!type.IsMalformed()); 868 ASSERT(!type.IsMalformed());
839 ASSERT(type.IsFinalized()); 869 ASSERT(type.IsFinalized());
840 ASSERT(type.HasResolvedTypeClass()); 870 ASSERT(type.HasResolvedTypeClass());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if (!type.HasResolvedTypeClass()) { 1002 if (!type.HasResolvedTypeClass()) {
973 Exceptions::ThrowArgumentError(type); 1003 Exceptions::ThrowArgumentError(type);
974 UNREACHABLE(); 1004 UNREACHABLE();
975 } 1005 }
976 const Class& cls = Class::Handle(type.type_class()); 1006 const Class& cls = Class::Handle(type.type_class());
977 const AbstractType& super_type = AbstractType::Handle(cls.super_type()); 1007 const AbstractType& super_type = AbstractType::Handle(cls.super_type());
978 ASSERT(super_type.IsNull() || super_type.IsFinalized()); 1008 ASSERT(super_type.IsNull() || super_type.IsFinalized());
979 return super_type.raw(); 1009 return super_type.raw();
980 } 1010 }
981 1011
1012
982 DEFINE_NATIVE_ENTRY(ClassMirror_supertype_instantiated, 1) { 1013 DEFINE_NATIVE_ENTRY(ClassMirror_supertype_instantiated, 1) {
983 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 1014 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
984 ASSERT(!type.IsMalformed()); 1015 ASSERT(!type.IsMalformed());
985 ASSERT(type.IsFinalized()); 1016 ASSERT(type.IsFinalized());
986 if (!type.HasResolvedTypeClass()) { 1017 if (!type.HasResolvedTypeClass()) {
987 Exceptions::ThrowArgumentError(type); 1018 Exceptions::ThrowArgumentError(type);
988 UNREACHABLE(); 1019 UNREACHABLE();
989 } 1020 }
990 const Class& cls = Class::Handle(type.type_class()); 1021 const Class& cls = Class::Handle(type.type_class());
991 AbstractType& super_type = AbstractType::Handle(cls.super_type()); 1022 const AbstractType& super_type = AbstractType::Handle(cls.super_type());
992 AbstractType& result = AbstractType::Handle(super_type.raw()); 1023 return InstantiateType(super_type, type);
993
994 ASSERT(super_type.IsType());
995 if (!super_type.IsInstantiated()) {
996 AbstractTypeArguments& type_args =
997 AbstractTypeArguments::Handle(type.arguments());
998 Error& bound_error = Error::Handle();
999 result ^= super_type.InstantiateFrom(type_args, &bound_error);
1000 if (!bound_error.IsNull()) {
1001 ThrowInvokeError(bound_error);
1002 UNREACHABLE();
1003 }
1004 result ^= result.Canonicalize();
1005 ASSERT(result.IsType());
1006 }
1007
1008 ASSERT(result.IsFinalized());
1009 return result.raw();
1010 } 1024 }
1011 1025
1012 1026
1013 DEFINE_NATIVE_ENTRY(ClassMirror_interfaces, 1) { 1027 DEFINE_NATIVE_ENTRY(ClassMirror_interfaces, 1) {
1014 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 1028 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
1015 ASSERT(!type.IsMalformed()); 1029 ASSERT(!type.IsMalformed());
1016 ASSERT(type.IsFinalized()); 1030 ASSERT(type.IsFinalized());
1017 if (!type.HasResolvedTypeClass()) { 1031 if (!type.HasResolvedTypeClass()) {
1018 Exceptions::ThrowArgumentError(type); 1032 Exceptions::ThrowArgumentError(type);
1019 UNREACHABLE(); 1033 UNREACHABLE();
(...skipping 14 matching lines...) Expand all
1034 if (!type.HasResolvedTypeClass()) { 1048 if (!type.HasResolvedTypeClass()) {
1035 Exceptions::ThrowArgumentError(type); 1049 Exceptions::ThrowArgumentError(type);
1036 UNREACHABLE(); 1050 UNREACHABLE();
1037 } 1051 }
1038 const Class& cls = Class::Handle(type.type_class()); 1052 const Class& cls = Class::Handle(type.type_class());
1039 const Error& error = Error::Handle(cls.EnsureIsFinalized(isolate)); 1053 const Error& error = Error::Handle(cls.EnsureIsFinalized(isolate));
1040 if (!error.IsNull()) { 1054 if (!error.IsNull()) {
1041 ThrowInvokeError(error); 1055 ThrowInvokeError(error);
1042 } 1056 }
1043 1057
1044 AbstractTypeArguments& type_args =
1045 AbstractTypeArguments::Handle(type.arguments());
1046 Error& bound_error = Error::Handle();
1047
1048 Array& interfaces = Array::Handle(cls.interfaces()); 1058 Array& interfaces = Array::Handle(cls.interfaces());
1049 Array& interfaces_inst = Array::Handle(Array::New(interfaces.Length())); 1059 Array& interfaces_inst = Array::Handle(Array::New(interfaces.Length()));
1050 AbstractType& interface = AbstractType::Handle(); 1060 AbstractType& interface = AbstractType::Handle();
1051 1061
1052 for (int i = 0; i < interfaces.Length(); i++) { 1062 for (int i = 0; i < interfaces.Length(); i++) {
1053 interface ^= interfaces.At(i); 1063 interface ^= interfaces.At(i);
1054 ASSERT(interface.IsType()); 1064 interface = InstantiateType(interface, type);
1055 if (!interface.IsInstantiated()) {
1056 bound_error ^= Object::null();
1057 interface ^= interface.InstantiateFrom(type_args, &bound_error);
1058 if (!bound_error.IsNull()) {
1059 ThrowInvokeError(bound_error);
1060 UNREACHABLE();
1061 }
1062 interface ^= interface.Canonicalize();
1063 ASSERT(interface.IsType());
1064 }
1065 interfaces_inst.SetAt(i, interface); 1065 interfaces_inst.SetAt(i, interface);
1066 } 1066 }
1067 1067
1068 return interfaces_inst.raw(); 1068 return interfaces_inst.raw();
1069 } 1069 }
1070 1070
1071 1071
1072 DEFINE_NATIVE_ENTRY(ClassMirror_mixin, 1) { 1072 DEFINE_NATIVE_ENTRY(ClassMirror_mixin, 1) {
1073 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 1073 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
1074 ASSERT(!type.IsMalformed()); 1074 ASSERT(!type.IsMalformed());
(...skipping 18 matching lines...) Expand all
1093 ASSERT(type.IsFinalized()); 1093 ASSERT(type.IsFinalized());
1094 if (!type.HasResolvedTypeClass()) { 1094 if (!type.HasResolvedTypeClass()) {
1095 Exceptions::ThrowArgumentError(type); 1095 Exceptions::ThrowArgumentError(type);
1096 UNREACHABLE(); 1096 UNREACHABLE();
1097 } 1097 }
1098 const Class& cls = Class::Handle(type.type_class()); 1098 const Class& cls = Class::Handle(type.type_class());
1099 const AbstractType& mixin_type = AbstractType::Handle(cls.mixin()); 1099 const AbstractType& mixin_type = AbstractType::Handle(cls.mixin());
1100 if (mixin_type.IsNull()) { 1100 if (mixin_type.IsNull()) {
1101 return mixin_type.raw(); 1101 return mixin_type.raw();
1102 } 1102 }
1103 ASSERT(mixin_type.IsFinalized());
1104 1103
1105 ASSERT(!instantiator.IsMalformed()); 1104 return InstantiateType(mixin_type, instantiator);
1106 ASSERT(instantiator.IsFinalized());
1107
1108 AbstractType& result = AbstractType::Handle(mixin_type.raw());
1109
1110 ASSERT(mixin_type.IsType());
1111 if (!mixin_type.IsInstantiated()) {
1112 AbstractTypeArguments& type_args =
1113 AbstractTypeArguments::Handle(instantiator.arguments());
1114 Error& bound_error = Error::Handle();
1115 result ^= mixin_type.InstantiateFrom(type_args, &bound_error);
1116 if (!bound_error.IsNull()) {
1117 ThrowInvokeError(bound_error);
1118 UNREACHABLE();
1119 }
1120 result ^= result.Canonicalize();
1121 ASSERT(result.IsType());
1122 }
1123
1124 ASSERT(result.IsFinalized());
1125 return result.raw();
1126 } 1105 }
1127 1106
1128 1107
1129 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { 1108 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) {
1130 GET_NON_NULL_NATIVE_ARGUMENT(Instance, 1109 GET_NON_NULL_NATIVE_ARGUMENT(Instance,
1131 owner_mirror, 1110 owner_mirror,
1132 arguments->NativeArgAt(0)); 1111 arguments->NativeArgAt(0));
1133 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 1112 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
1134 const Class& klass = Class::Handle(ref.GetClassReferent()); 1113 const Class& klass = Class::Handle(ref.GetClassReferent());
1135 1114
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 1291
1313 DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) { 1292 DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) {
1314 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); 1293 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0));
1315 return param.bound(); 1294 return param.bound();
1316 } 1295 }
1317 1296
1318 1297
1319 DEFINE_NATIVE_ENTRY(TypeVariableMirror_instantiate_from, 2) { 1298 DEFINE_NATIVE_ENTRY(TypeVariableMirror_instantiate_from, 2) {
1320 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); 1299 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0));
1321 GET_NON_NULL_NATIVE_ARGUMENT(Type, instantiator, arguments->NativeArgAt(1)); 1300 GET_NON_NULL_NATIVE_ARGUMENT(Type, instantiator, arguments->NativeArgAt(1));
1322
1323 ASSERT(param.parameterized_class() == instantiator.type_class()); 1301 ASSERT(param.parameterized_class() == instantiator.type_class());
1324 1302 return InstantiateType(param, instantiator);
1325 AbstractTypeArguments& type_args =
1326 AbstractTypeArguments::Handle(instantiator.arguments());
1327 Error& bound_error = Error::Handle();
1328 AbstractType& result =
1329 AbstractType::Handle(param.InstantiateFrom(type_args, &bound_error));
1330 ASSERT(bound_error.IsNull());
1331 ASSERT(result.IsFinalized());
1332 return result.raw();
1333 } 1303 }
1334 1304
1335 1305
1306 DEFINE_NATIVE_ENTRY(TypedefMirror_instantiate_from, 2) {
1307 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
1308 GET_NON_NULL_NATIVE_ARGUMENT(Type, instantiator, arguments->NativeArgAt(1));
1309 const Class& cls = Class::Handle(type.type_class());
1310 // We represent typedefs as non-canonical signature classes.
1311 ASSERT(cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass());
1312 return InstantiateType(type, instantiator);
1313 }
1314
1315
1316
1317 DEFINE_NATIVE_ENTRY(TypedefMirror_declaration, 1) {
1318 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
1319 const Class& cls = Class::Handle(type.type_class());
1320 // We represent typedefs as non-canonical signature classes.
1321 ASSERT(cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass());
1322 return CreateTypedefMirror(cls,
1323 AbstractType::Handle(cls.DeclarationType()),
1324 Bool::True(), // is_declaration
1325 Object::null_instance());
1326 }
1327
1336 DEFINE_NATIVE_ENTRY(InstanceMirror_invoke, 5) { 1328 DEFINE_NATIVE_ENTRY(InstanceMirror_invoke, 5) {
1337 // Argument 0 is the mirror, which is unused by the native. It exists 1329 // Argument 0 is the mirror, which is unused by the native. It exists
1338 // because this native is an instance method in order to be polymorphic 1330 // because this native is an instance method in order to be polymorphic
1339 // with its cousins. 1331 // with its cousins.
1340 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1)); 1332 GET_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(1));
1341 GET_NON_NULL_NATIVE_ARGUMENT( 1333 GET_NON_NULL_NATIVE_ARGUMENT(
1342 String, function_name, arguments->NativeArgAt(2)); 1334 String, function_name, arguments->NativeArgAt(2));
1343 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3)); 1335 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3));
1344 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4)); 1336 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4));
1345 1337
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 (tkit.CurrentTokenKind() == Token::kRPAREN) || // Case 2. 1941 (tkit.CurrentTokenKind() == Token::kRPAREN) || // Case 2.
1950 (tkit.CurrentTokenKind() == Token::kSEMICOLON && 1942 (tkit.CurrentTokenKind() == Token::kSEMICOLON &&
1951 String::Handle(func.name()).Equals("<anonymous closure>"))) { // Case 3. 1943 String::Handle(func.name()).Equals("<anonymous closure>"))) { // Case 3.
1952 last_tok_len = 0; 1944 last_tok_len = 0;
1953 } 1945 }
1954 return script.GetSnippet(from_line, from_col, to_line, to_col + last_tok_len); 1946 return script.GetSnippet(from_line, from_col, to_line, to_col + last_tok_len);
1955 } 1947 }
1956 1948
1957 1949
1958 DEFINE_NATIVE_ENTRY(TypedefMirror_referent, 1) { 1950 DEFINE_NATIVE_ENTRY(TypedefMirror_referent, 1) {
1959 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1951 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
1960 const Class& cls = Class::Handle(ref.GetClassReferent()); 1952 const Class& cls = Class::Handle(type.type_class());
1961 const Function& sig_func = Function::Handle(cls.signature_function()); 1953 const Function& sig_func = Function::Handle(cls.signature_function());
1962 const Class& sig_cls = Class::Handle(sig_func.signature_class()); 1954 const Class& sig_cls = Class::Handle(sig_func.signature_class());
1963 return MirrorReference::New(sig_cls); 1955
1956 AbstractType& referent_type = AbstractType::Handle(sig_cls.DeclarationType());
1957 referent_type = InstantiateType(referent_type, type);
1958
1959 return CreateFunctionTypeMirror(sig_cls, referent_type);
1964 } 1960 }
1965 1961
1966 1962
1967 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 2) { 1963 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 2) {
1968 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1964 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1969 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); 1965 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1));
1970 const Function& func = Function::Handle(ref.GetFunctionReferent()); 1966 const Function& func = Function::Handle(ref.GetFunctionReferent());
1971 return func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value()); 1967 return func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value());
1972 } 1968 }
1973 1969
1974 1970
1975 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1971 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1976 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1972 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1977 const Field& field = Field::Handle(ref.GetFieldReferent()); 1973 const Field& field = Field::Handle(ref.GetFieldReferent());
1978 return field.type(); 1974 return field.type();
1979 } 1975 }
1980 1976
1981 } // namespace dart 1977 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698