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 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3262 Isolate* isolate = Isolate::Current(); | 3262 Isolate* isolate = Isolate::Current(); |
3263 DARTSCOPE(isolate); | 3263 DARTSCOPE(isolate); |
3264 CHECK_CALLBACK_STATE(isolate); | 3264 CHECK_CALLBACK_STATE(isolate); |
3265 | 3265 |
3266 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); | 3266 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); |
3267 // Get the class to instantiate. | 3267 // Get the class to instantiate. |
3268 if (type_obj.IsNull()) { | 3268 if (type_obj.IsNull()) { |
3269 RETURN_TYPE_ERROR(isolate, type, Type); | 3269 RETURN_TYPE_ERROR(isolate, type, Type); |
3270 } | 3270 } |
3271 const Class& cls = Class::Handle(isolate, type_obj.type_class()); | 3271 const Class& cls = Class::Handle(isolate, type_obj.type_class()); |
3272 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); | |
3273 if (!error.IsNull()) { | |
3274 // An error occurred, return error object. | |
3275 return Api::NewHandle(isolate, error.raw()); | |
3276 } | |
3277 | |
3272 if (!cls.is_fields_marked_nullable()) { | 3278 if (!cls.is_fields_marked_nullable()) { |
3273 // Mark all fields as nullable. | 3279 // Mark all fields as nullable. |
3274 Class& iterate_cls = Class::Handle(isolate, cls.raw()); | 3280 Class& iterate_cls = Class::Handle(isolate, cls.raw()); |
3275 Field& field = Field::Handle(isolate); | 3281 Field& field = Field::Handle(isolate); |
3276 Array& fields = Array::Handle(isolate); | 3282 Array& fields = Array::Handle(isolate); |
3277 while (!iterate_cls.IsNull()) { | 3283 while (!iterate_cls.IsNull()) { |
3284 ASSERT(iterate_cls.is_finalized()); | |
srdjan
2014/05/19 23:39:10
Strictly, this is not necessary since all super cl
siva
2014/05/19 23:42:16
Agreed but I was just being extra careful.
On 201
| |
3278 iterate_cls.set_is_fields_marked_nullable(); | 3285 iterate_cls.set_is_fields_marked_nullable(); |
3279 fields = iterate_cls.fields(); | 3286 fields = iterate_cls.fields(); |
3280 iterate_cls = iterate_cls.SuperClass(); | 3287 iterate_cls = iterate_cls.SuperClass(); |
3281 for (int field_num = 0; field_num < fields.Length(); field_num++) { | 3288 for (int field_num = 0; field_num < fields.Length(); field_num++) { |
3282 field ^= fields.At(field_num); | 3289 field ^= fields.At(field_num); |
3283 if (field.is_static()) { | 3290 if (field.is_static()) { |
3284 continue; | 3291 continue; |
3285 } | 3292 } |
3286 field.UpdateGuardedCidAndLength(Object::null_object()); | 3293 field.UpdateGuardedCidAndLength(Object::null_object()); |
3287 } | 3294 } |
3288 } | 3295 } |
3289 } | 3296 } |
3290 | 3297 |
3291 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); | |
3292 if (!error.IsNull()) { | |
3293 // An error occurred, return error object. | |
3294 return Api::NewHandle(isolate, error.raw()); | |
3295 } | |
3296 // Allocate an object for the given class. | 3298 // Allocate an object for the given class. |
3297 return Api::NewHandle(isolate, Instance::New(cls)); | 3299 return Api::NewHandle(isolate, Instance::New(cls)); |
3298 } | 3300 } |
3299 | 3301 |
3300 | 3302 |
3301 static Dart_Handle SetupArguments(Isolate* isolate, | 3303 static Dart_Handle SetupArguments(Isolate* isolate, |
3302 int num_args, | 3304 int num_args, |
3303 Dart_Handle* arguments, | 3305 Dart_Handle* arguments, |
3304 int extra_args, | 3306 int extra_args, |
3305 Array* args) { | 3307 Array* args) { |
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4783 | 4785 |
4784 | 4786 |
4785 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4787 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
4786 const char* name, | 4788 const char* name, |
4787 Dart_ServiceRequestCallback callback, | 4789 Dart_ServiceRequestCallback callback, |
4788 void* user_data) { | 4790 void* user_data) { |
4789 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4791 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
4790 } | 4792 } |
4791 | 4793 |
4792 } // namespace dart | 4794 } // namespace dart |
OLD | NEW |