| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 } | 1317 } |
| 1318 // Finalize all classes. | 1318 // Finalize all classes. |
| 1319 Dart_Handle state = Api::CheckIsolateState(isolate); | 1319 Dart_Handle state = Api::CheckIsolateState(isolate); |
| 1320 if (::Dart_IsError(state)) { | 1320 if (::Dart_IsError(state)) { |
| 1321 *value = false; | 1321 *value = false; |
| 1322 return state; | 1322 return state; |
| 1323 } | 1323 } |
| 1324 CHECK_CALLBACK_STATE(isolate); | 1324 CHECK_CALLBACK_STATE(isolate); |
| 1325 Error& malformed_type_error = Error::Handle(isolate); | 1325 Error& malformed_type_error = Error::Handle(isolate); |
| 1326 *value = instance.IsInstanceOf(type_obj, | 1326 *value = instance.IsInstanceOf(type_obj, |
| 1327 Object::null_abstract_type_arguments(), | 1327 Object::null_type_arguments(), |
| 1328 &malformed_type_error); | 1328 &malformed_type_error); |
| 1329 ASSERT(malformed_type_error.IsNull()); // Type was created from a class. | 1329 ASSERT(malformed_type_error.IsNull()); // Type was created from a class. |
| 1330 return Api::Success(); | 1330 return Api::Success(); |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 | 1333 |
| 1334 DART_EXPORT bool Dart_IsInstance(Dart_Handle object) { | 1334 DART_EXPORT bool Dart_IsInstance(Dart_Handle object) { |
| 1335 Isolate* isolate = Isolate::Current(); | 1335 Isolate* isolate = Isolate::Current(); |
| 1336 DARTSCOPE(isolate); | 1336 DARTSCOPE(isolate); |
| 1337 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 1337 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2924 } | 2924 } |
| 2925 | 2925 |
| 2926 // Get the class to instantiate. | 2926 // Get the class to instantiate. |
| 2927 Object& unchecked_type = Object::Handle(Api::UnwrapHandle(type)); | 2927 Object& unchecked_type = Object::Handle(Api::UnwrapHandle(type)); |
| 2928 if (unchecked_type.IsNull() || !unchecked_type.IsType()) { | 2928 if (unchecked_type.IsNull() || !unchecked_type.IsType()) { |
| 2929 RETURN_TYPE_ERROR(isolate, type, Type); | 2929 RETURN_TYPE_ERROR(isolate, type, Type); |
| 2930 } | 2930 } |
| 2931 Type& type_obj = Type::Handle(); | 2931 Type& type_obj = Type::Handle(); |
| 2932 type_obj ^= unchecked_type.raw(); | 2932 type_obj ^= unchecked_type.raw(); |
| 2933 Class& cls = Class::Handle(isolate, type_obj.type_class()); | 2933 Class& cls = Class::Handle(isolate, type_obj.type_class()); |
| 2934 AbstractTypeArguments& type_arguments = | 2934 TypeArguments& type_arguments = |
| 2935 AbstractTypeArguments::Handle(isolate, type_obj.arguments()); | 2935 TypeArguments::Handle(isolate, type_obj.arguments()); |
| 2936 | 2936 |
| 2937 const String& base_constructor_name = String::Handle(isolate, cls.Name()); | 2937 const String& base_constructor_name = String::Handle(isolate, cls.Name()); |
| 2938 | 2938 |
| 2939 // And get the name of the constructor to invoke. | 2939 // And get the name of the constructor to invoke. |
| 2940 String& dot_name = String::Handle(isolate); | 2940 String& dot_name = String::Handle(isolate); |
| 2941 result = Api::UnwrapHandle(constructor_name); | 2941 result = Api::UnwrapHandle(constructor_name); |
| 2942 if (result.IsNull()) { | 2942 if (result.IsNull()) { |
| 2943 dot_name = Symbols::Dot().raw(); | 2943 dot_name = Symbols::Dot().raw(); |
| 2944 } else if (result.IsString()) { | 2944 } else if (result.IsString()) { |
| 2945 dot_name = String::Concat(Symbols::Dot(), String::Cast(result)); | 2945 dot_name = String::Concat(Symbols::Dot(), String::Cast(result)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2978 | 2978 |
| 2979 if (!redirect_type.IsInstantiated()) { | 2979 if (!redirect_type.IsInstantiated()) { |
| 2980 // The type arguments of the redirection type are instantiated from the | 2980 // The type arguments of the redirection type are instantiated from the |
| 2981 // type arguments of the type argument. | 2981 // type arguments of the type argument. |
| 2982 Error& bound_error = Error::Handle(); | 2982 Error& bound_error = Error::Handle(); |
| 2983 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, | 2983 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, |
| 2984 &bound_error); | 2984 &bound_error); |
| 2985 if (!bound_error.IsNull()) { | 2985 if (!bound_error.IsNull()) { |
| 2986 return Api::NewHandle(isolate, bound_error.raw()); | 2986 return Api::NewHandle(isolate, bound_error.raw()); |
| 2987 } | 2987 } |
| 2988 redirect_type ^= redirect_type.Canonicalize(); |
| 2988 } | 2989 } |
| 2989 | 2990 |
| 2990 type_obj = redirect_type.raw(); | 2991 type_obj = redirect_type.raw(); |
| 2991 type_arguments = redirect_type.arguments(); | 2992 type_arguments = redirect_type.arguments(); |
| 2992 | 2993 |
| 2993 cls = type_obj.type_class(); | 2994 cls = type_obj.type_class(); |
| 2994 } | 2995 } |
| 2995 if (constructor.IsConstructor()) { | 2996 if (constructor.IsConstructor()) { |
| 2996 // Create the new object. | 2997 // Create the new object. |
| 2997 new_object = Instance::New(cls); | 2998 new_object = Instance::New(cls); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3139 | 3140 |
| 3140 // Construct name of the constructor to invoke. | 3141 // Construct name of the constructor to invoke. |
| 3141 const Type& type_obj = Type::Handle(isolate, instance.GetType()); | 3142 const Type& type_obj = Type::Handle(isolate, instance.GetType()); |
| 3142 const Class& cls = Class::Handle(isolate, type_obj.type_class()); | 3143 const Class& cls = Class::Handle(isolate, type_obj.type_class()); |
| 3143 const String& class_name = String::Handle(isolate, cls.Name()); | 3144 const String& class_name = String::Handle(isolate, cls.Name()); |
| 3144 const Array& strings = Array::Handle(Array::New(3)); | 3145 const Array& strings = Array::Handle(Array::New(3)); |
| 3145 strings.SetAt(0, class_name); | 3146 strings.SetAt(0, class_name); |
| 3146 strings.SetAt(1, Symbols::Dot()); | 3147 strings.SetAt(1, Symbols::Dot()); |
| 3147 strings.SetAt(2, constructor_name); | 3148 strings.SetAt(2, constructor_name); |
| 3148 const String& dot_name = String::Handle(isolate, String::ConcatAll(strings)); | 3149 const String& dot_name = String::Handle(isolate, String::ConcatAll(strings)); |
| 3149 const AbstractTypeArguments& type_arguments = | 3150 const TypeArguments& type_arguments = |
| 3150 AbstractTypeArguments::Handle(isolate, type_obj.arguments()); | 3151 TypeArguments::Handle(isolate, type_obj.arguments()); |
| 3151 const Function& constructor = | 3152 const Function& constructor = |
| 3152 Function::Handle(isolate, cls.LookupFunctionAllowPrivate(dot_name)); | 3153 Function::Handle(isolate, cls.LookupFunctionAllowPrivate(dot_name)); |
| 3153 const int extra_args = 2; | 3154 const int extra_args = 2; |
| 3154 if (!constructor.IsNull() && | 3155 if (!constructor.IsNull() && |
| 3155 constructor.IsConstructor() && | 3156 constructor.IsConstructor() && |
| 3156 constructor.AreValidArgumentCounts(number_of_arguments + extra_args, | 3157 constructor.AreValidArgumentCounts(number_of_arguments + extra_args, |
| 3157 0, | 3158 0, |
| 3158 NULL)) { | 3159 NULL)) { |
| 3159 // Create the argument list. | 3160 // Create the argument list. |
| 3160 // Constructors get the uninitialized object and a constructor phase. | 3161 // Constructors get the uninitialized object and a constructor phase. |
| (...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4534 } | 4535 } |
| 4535 | 4536 |
| 4536 | 4537 |
| 4537 // --- Service support --- | 4538 // --- Service support --- |
| 4538 | 4539 |
| 4539 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) { | 4540 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) { |
| 4540 return Api::CastIsolate(Service::GetServiceIsolate(callback_data)); | 4541 return Api::CastIsolate(Service::GetServiceIsolate(callback_data)); |
| 4541 } | 4542 } |
| 4542 | 4543 |
| 4543 } // namespace dart | 4544 } // namespace dart |
| OLD | NEW |