| 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 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { | 3132 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { |
| 3133 Isolate* isolate = Isolate::Current(); | 3133 Isolate* isolate = Isolate::Current(); |
| 3134 DARTSCOPE(isolate); | 3134 DARTSCOPE(isolate); |
| 3135 CHECK_CALLBACK_STATE(isolate); | 3135 CHECK_CALLBACK_STATE(isolate); |
| 3136 | 3136 |
| 3137 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); | 3137 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); |
| 3138 // Get the class to instantiate. | 3138 // Get the class to instantiate. |
| 3139 if (type_obj.IsNull()) { | 3139 if (type_obj.IsNull()) { |
| 3140 RETURN_TYPE_ERROR(isolate, type, Type); | 3140 RETURN_TYPE_ERROR(isolate, type, Type); |
| 3141 } | 3141 } |
| 3142 const Class& cls = Class::Handle(isolate, type_obj.type_class()); | 3142 REUSABLE_CLASS_HANDLESCOPE(isolate); |
| 3143 Class& cls = isolate->ClassHandle(); |
| 3144 cls = type_obj.type_class(); |
| 3143 | 3145 |
| 3144 if (!cls.is_fields_marked_nullable()) { | 3146 if (!cls.is_fields_marked_nullable()) { |
| 3145 // Mark all fields as nullable. | 3147 // Mark all fields as nullable. |
| 3146 Class& iterate_cls = Class::Handle(isolate, cls.raw()); | 3148 Class& iterate_cls = Class::Handle(isolate, cls.raw()); |
| 3147 Field& field = Field::Handle(isolate); | 3149 Field& field = Field::Handle(isolate); |
| 3148 Array& fields = Array::Handle(isolate); | 3150 Array& fields = Array::Handle(isolate); |
| 3149 while (!iterate_cls.IsNull()) { | 3151 while (!iterate_cls.IsNull()) { |
| 3150 iterate_cls.set_is_fields_marked_nullable(); | 3152 iterate_cls.set_is_fields_marked_nullable(); |
| 3151 fields = iterate_cls.fields(); | 3153 fields = iterate_cls.fields(); |
| 3152 iterate_cls = iterate_cls.SuperClass(); | 3154 iterate_cls = iterate_cls.SuperClass(); |
| 3153 for (int field_num = 0; field_num < fields.Length(); field_num++) { | 3155 for (int field_num = 0; field_num < fields.Length(); field_num++) { |
| 3154 field ^= fields.At(field_num); | 3156 field ^= fields.At(field_num); |
| 3155 if (field.is_static()) { | 3157 if (field.is_static()) { |
| 3156 continue; | 3158 continue; |
| 3157 } | 3159 } |
| 3158 field.UpdateGuardedCidAndLength(Object::null_object()); | 3160 field.UpdateGuardedCidAndLength(Object::null_object()); |
| 3159 } | 3161 } |
| 3160 } | 3162 } |
| 3161 } | 3163 } |
| 3162 | 3164 |
| 3165 REUSABLE_ERROR_HANDLESCOPE(isolate); |
| 3166 Error& error = isolate->ErrorHandle(); |
| 3167 error = cls.EnsureIsFinalized(isolate); |
| 3168 if (!error.IsNull()) { |
| 3169 // An error occurred, return error object. |
| 3170 return Api::NewHandle(isolate, error.raw()); |
| 3171 } |
| 3163 // Allocate an object for the given class. | 3172 // Allocate an object for the given class. |
| 3164 return Api::NewHandle(isolate, Instance::New(cls)); | 3173 return Api::NewHandle(isolate, Instance::New(cls)); |
| 3165 } | 3174 } |
| 3166 | 3175 |
| 3167 | 3176 |
| 3168 static Dart_Handle SetupArguments(Isolate* isolate, | 3177 static Dart_Handle SetupArguments(Isolate* isolate, |
| 3169 int num_args, | 3178 int num_args, |
| 3170 Dart_Handle* arguments, | 3179 Dart_Handle* arguments, |
| 3171 int extra_args, | 3180 int extra_args, |
| 3172 Array* args) { | 3181 Array* args) { |
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4646 | 4655 |
| 4647 | 4656 |
| 4648 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4657 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 4649 const char* name, | 4658 const char* name, |
| 4650 Dart_ServiceRequestCallback callback, | 4659 Dart_ServiceRequestCallback callback, |
| 4651 void* user_data) { | 4660 void* user_data) { |
| 4652 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4661 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 4653 } | 4662 } |
| 4654 | 4663 |
| 4655 } // namespace dart | 4664 } // namespace dart |
| OLD | NEW |