| 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 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3110 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { | 3110 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { |
| 3111 Isolate* isolate = Isolate::Current(); | 3111 Isolate* isolate = Isolate::Current(); |
| 3112 DARTSCOPE(isolate); | 3112 DARTSCOPE(isolate); |
| 3113 CHECK_CALLBACK_STATE(isolate); | 3113 CHECK_CALLBACK_STATE(isolate); |
| 3114 | 3114 |
| 3115 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); | 3115 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); |
| 3116 // Get the class to instantiate. | 3116 // Get the class to instantiate. |
| 3117 if (type_obj.IsNull()) { | 3117 if (type_obj.IsNull()) { |
| 3118 RETURN_TYPE_ERROR(isolate, type, Type); | 3118 RETURN_TYPE_ERROR(isolate, type, Type); |
| 3119 } | 3119 } |
| 3120 REUSABLE_CLASS_HANDLESCOPE(isolate); | 3120 const Class& cls = Class::Handle(isolate, type_obj.type_class()); |
| 3121 Class& cls = isolate->ClassHandle(); | |
| 3122 cls = type_obj.type_class(); | |
| 3123 | |
| 3124 if (!cls.is_fields_marked_nullable()) { | 3121 if (!cls.is_fields_marked_nullable()) { |
| 3125 // Mark all fields as nullable. | 3122 // Mark all fields as nullable. |
| 3126 Class& iterate_cls = Class::Handle(isolate, cls.raw()); | 3123 Class& iterate_cls = Class::Handle(isolate, cls.raw()); |
| 3127 Field& field = Field::Handle(isolate); | 3124 Field& field = Field::Handle(isolate); |
| 3128 Array& fields = Array::Handle(isolate); | 3125 Array& fields = Array::Handle(isolate); |
| 3129 while (!iterate_cls.IsNull()) { | 3126 while (!iterate_cls.IsNull()) { |
| 3130 iterate_cls.set_is_fields_marked_nullable(); | 3127 iterate_cls.set_is_fields_marked_nullable(); |
| 3131 fields = iterate_cls.fields(); | 3128 fields = iterate_cls.fields(); |
| 3132 iterate_cls = iterate_cls.SuperClass(); | 3129 iterate_cls = iterate_cls.SuperClass(); |
| 3133 for (int field_num = 0; field_num < fields.Length(); field_num++) { | 3130 for (int field_num = 0; field_num < fields.Length(); field_num++) { |
| 3134 field ^= fields.At(field_num); | 3131 field ^= fields.At(field_num); |
| 3135 if (field.is_static()) { | 3132 if (field.is_static()) { |
| 3136 continue; | 3133 continue; |
| 3137 } | 3134 } |
| 3138 field.UpdateGuardedCidAndLength(Object::null_object()); | 3135 field.UpdateGuardedCidAndLength(Object::null_object()); |
| 3139 } | 3136 } |
| 3140 } | 3137 } |
| 3141 } | 3138 } |
| 3142 | 3139 |
| 3143 REUSABLE_ERROR_HANDLESCOPE(isolate); | 3140 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); |
| 3144 Error& error = isolate->ErrorHandle(); | |
| 3145 error = cls.EnsureIsFinalized(isolate); | |
| 3146 if (!error.IsNull()) { | 3141 if (!error.IsNull()) { |
| 3147 // An error occurred, return error object. | 3142 // An error occurred, return error object. |
| 3148 return Api::NewHandle(isolate, error.raw()); | 3143 return Api::NewHandle(isolate, error.raw()); |
| 3149 } | 3144 } |
| 3150 // Allocate an object for the given class. | 3145 // Allocate an object for the given class. |
| 3151 return Api::NewHandle(isolate, Instance::New(cls)); | 3146 return Api::NewHandle(isolate, Instance::New(cls)); |
| 3152 } | 3147 } |
| 3153 | 3148 |
| 3154 | 3149 |
| 3155 static Dart_Handle SetupArguments(Isolate* isolate, | 3150 static Dart_Handle SetupArguments(Isolate* isolate, |
| (...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4633 | 4628 |
| 4634 | 4629 |
| 4635 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4630 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 4636 const char* name, | 4631 const char* name, |
| 4637 Dart_ServiceRequestCallback callback, | 4632 Dart_ServiceRequestCallback callback, |
| 4638 void* user_data) { | 4633 void* user_data) { |
| 4639 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4634 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 4640 } | 4635 } |
| 4641 | 4636 |
| 4642 } // namespace dart | 4637 } // namespace dart |
| OLD | NEW |