| 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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 754 |
| 755 DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception) { | 755 DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception) { |
| 756 Isolate* isolate = Isolate::Current(); | 756 Isolate* isolate = Isolate::Current(); |
| 757 DARTSCOPE(isolate); | 757 DARTSCOPE(isolate); |
| 758 CHECK_CALLBACK_STATE(isolate); | 758 CHECK_CALLBACK_STATE(isolate); |
| 759 | 759 |
| 760 const Instance& obj = Api::UnwrapInstanceHandle(isolate, exception); | 760 const Instance& obj = Api::UnwrapInstanceHandle(isolate, exception); |
| 761 if (obj.IsNull()) { | 761 if (obj.IsNull()) { |
| 762 RETURN_TYPE_ERROR(isolate, exception, Instance); | 762 RETURN_TYPE_ERROR(isolate, exception, Instance); |
| 763 } | 763 } |
| 764 const Instance& stacktrace = Instance::Handle(isolate); | 764 const Stacktrace& stacktrace = Stacktrace::Handle(isolate); |
| 765 return Api::NewHandle(isolate, UnhandledException::New(obj, stacktrace)); | 765 return Api::NewHandle(isolate, UnhandledException::New(obj, stacktrace)); |
| 766 } | 766 } |
| 767 | 767 |
| 768 | 768 |
| 769 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) { | 769 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) { |
| 770 Isolate* isolate = Isolate::Current(); | 770 Isolate* isolate = Isolate::Current(); |
| 771 { | 771 { |
| 772 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); | 772 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); |
| 773 if (!obj.IsError()) { | 773 if (!obj.IsError()) { |
| 774 return Api::NewError( | 774 return Api::NewError( |
| (...skipping 3591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4366 // There are no dart frames on the stack so it would be illegal to | 4366 // There are no dart frames on the stack so it would be illegal to |
| 4367 // throw an exception here. | 4367 // throw an exception here. |
| 4368 return Api::NewError("No Dart frames on stack, cannot throw exception"); | 4368 return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| 4369 } | 4369 } |
| 4370 | 4370 |
| 4371 // Unwind all the API scopes till the exit frame before throwing an | 4371 // Unwind all the API scopes till the exit frame before throwing an |
| 4372 // exception. | 4372 // exception. |
| 4373 ApiState* state = isolate->api_state(); | 4373 ApiState* state = isolate->api_state(); |
| 4374 ASSERT(state != NULL); | 4374 ASSERT(state != NULL); |
| 4375 const Instance* saved_exception; | 4375 const Instance* saved_exception; |
| 4376 const Instance* saved_stacktrace; | 4376 const Stacktrace* saved_stacktrace; |
| 4377 { | 4377 { |
| 4378 NoGCScope no_gc; | 4378 NoGCScope no_gc; |
| 4379 RawInstance* raw_exception = | 4379 RawInstance* raw_exception = |
| 4380 Api::UnwrapInstanceHandle(isolate, exception).raw(); | 4380 Api::UnwrapInstanceHandle(isolate, exception).raw(); |
| 4381 RawInstance* raw_stacktrace = | 4381 RawStacktrace* raw_stacktrace = |
| 4382 Api::UnwrapInstanceHandle(isolate, stacktrace).raw(); | 4382 Api::UnwrapStacktraceHandle(isolate, stacktrace).raw(); |
| 4383 state->UnwindScopes(isolate->top_exit_frame_info()); | 4383 state->UnwindScopes(isolate->top_exit_frame_info()); |
| 4384 saved_exception = &Instance::Handle(raw_exception); | 4384 saved_exception = &Instance::Handle(raw_exception); |
| 4385 saved_stacktrace = &Instance::Handle(raw_stacktrace); | 4385 saved_stacktrace = &Stacktrace::Handle(raw_stacktrace); |
| 4386 } | 4386 } |
| 4387 Exceptions::ReThrow(isolate, *saved_exception, *saved_stacktrace); | 4387 Exceptions::ReThrow(isolate, *saved_exception, *saved_stacktrace); |
| 4388 return Api::NewError("Exception was not re thrown, internal error"); | 4388 return Api::NewError("Exception was not re thrown, internal error"); |
| 4389 } | 4389 } |
| 4390 | 4390 |
| 4391 | 4391 |
| 4392 // --- Native fields and functions --- | 4392 // --- Native fields and functions --- |
| 4393 | 4393 |
| 4394 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library, | 4394 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library, |
| 4395 Dart_Handle name, | 4395 Dart_Handle name, |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5443 | 5443 |
| 5444 | 5444 |
| 5445 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5445 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 5446 const char* name, | 5446 const char* name, |
| 5447 Dart_ServiceRequestCallback callback, | 5447 Dart_ServiceRequestCallback callback, |
| 5448 void* user_data) { | 5448 void* user_data) { |
| 5449 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5449 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 5450 } | 5450 } |
| 5451 | 5451 |
| 5452 } // namespace dart | 5452 } // namespace dart |
| OLD | NEW |