| 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 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 3537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 if (::Dart_IsError(state)) { | 3548 if (::Dart_IsError(state)) { |
| 3549 return state; | 3549 return state; |
| 3550 } | 3550 } |
| 3551 | 3551 |
| 3552 // Resolve the constructor. | 3552 // Resolve the constructor. |
| 3553 result = ResolveConstructor( | 3553 result = ResolveConstructor( |
| 3554 "Dart_New", cls, base_constructor_name, dot_name, number_of_arguments); | 3554 "Dart_New", cls, base_constructor_name, dot_name, number_of_arguments); |
| 3555 if (result.IsError()) { | 3555 if (result.IsError()) { |
| 3556 return Api::NewHandle(isolate, result.raw()); | 3556 return Api::NewHandle(isolate, result.raw()); |
| 3557 } | 3557 } |
| 3558 // TODO(turnidge): Support redirecting factories. | |
| 3559 ASSERT(result.IsFunction()); | 3558 ASSERT(result.IsFunction()); |
| 3560 Function& constructor = Function::Handle(isolate); | 3559 Function& constructor = Function::Handle(isolate); |
| 3561 constructor ^= result.raw(); | 3560 constructor ^= result.raw(); |
| 3562 | 3561 |
| 3563 Instance& new_object = Instance::Handle(isolate); | 3562 Instance& new_object = Instance::Handle(isolate); |
| 3563 if (constructor.IsRedirectingFactory()) { |
| 3564 Type& type = Type::Handle(constructor.RedirectionType()); |
| 3565 cls = type.type_class(); |
| 3566 constructor = constructor.RedirectionTarget(); |
| 3567 } |
| 3564 if (constructor.IsConstructor()) { | 3568 if (constructor.IsConstructor()) { |
| 3565 // Create the new object. | 3569 // Create the new object. |
| 3566 new_object = Instance::New(cls); | 3570 new_object = Instance::New(cls); |
| 3567 } | 3571 } |
| 3568 | 3572 |
| 3569 // Create the argument list. | 3573 // Create the argument list. |
| 3570 intptr_t arg_index = 0; | 3574 intptr_t arg_index = 0; |
| 3571 int extra_args = (constructor.IsConstructor() ? 2 : 1); | 3575 int extra_args = (constructor.IsConstructor() ? 2 : 1); |
| 3572 const Array& args = | 3576 const Array& args = |
| 3573 Array::Handle(isolate, Array::New(number_of_arguments + extra_args)); | 3577 Array::Handle(isolate, Array::New(number_of_arguments + extra_args)); |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4709 } | 4713 } |
| 4710 { | 4714 { |
| 4711 NoGCScope no_gc; | 4715 NoGCScope no_gc; |
| 4712 RawObject* raw_obj = obj.raw(); | 4716 RawObject* raw_obj = obj.raw(); |
| 4713 isolate->heap()->SetPeer(raw_obj, peer); | 4717 isolate->heap()->SetPeer(raw_obj, peer); |
| 4714 } | 4718 } |
| 4715 return Api::Success(isolate); | 4719 return Api::Success(isolate); |
| 4716 } | 4720 } |
| 4717 | 4721 |
| 4718 } // namespace dart | 4722 } // namespace dart |
| OLD | NEW |