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