Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: vm/dart_api_impl.cc

Issue 11188070: - Remove a couple static_cast and make them safe, by checking (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl.cc
===================================================================
--- vm/dart_api_impl.cc (revision 13792)
+++ vm/dart_api_impl.cc (working copy)
@@ -457,12 +457,14 @@
DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) {
Isolate* isolate = Isolate::Current();
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
- if (!obj.IsError()) {
- return Api::NewError(
- "%s expects argument 'handle' to be an error handle. "
- "Did you forget to check Dart_IsError first?",
- CURRENT_FUNC);
+ {
+ const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
+ if (!obj.IsError()) {
+ return Api::NewError(
+ "%s expects argument 'handle' to be an error handle. "
+ "Did you forget to check Dart_IsError first?",
+ CURRENT_FUNC);
+ }
}
if (isolate->top_exit_frame_info() == 0) {
// There are no dart frames on the stack so it would be illegal to
@@ -480,7 +482,7 @@
// that GC won't touch the raw error object before creating a valid
// handle for it in the surviving zone.
NoGCScope no_gc;
- RawError* raw_error = static_cast<RawError*>(Api::UnwrapHandle(handle));
+ RawError* raw_error = Api::UnwrapErrorHandle(isolate, handle).raw();
state->UnwindScopes(isolate->top_exit_frame_info());
error = &Error::Handle(isolate, raw_error);
}
@@ -3926,7 +3928,7 @@
{
NoGCScope no_gc;
RawInstance* raw_exception =
- static_cast<RawInstance*>(Api::UnwrapHandle(exception));
+ Api::UnwrapInstanceHandle(isolate, exception).raw();
state->UnwindScopes(isolate->top_exit_frame_info());
saved_exception = &Instance::Handle(raw_exception);
}
@@ -3963,9 +3965,9 @@
{
NoGCScope no_gc;
RawInstance* raw_exception =
- static_cast<RawInstance*>(Api::UnwrapHandle(exception));
+ Api::UnwrapInstanceHandle(isolate, exception).raw();
RawInstance* raw_stacktrace =
- static_cast<RawInstance*>(Api::UnwrapHandle(stacktrace));
+ Api::UnwrapInstanceHandle(isolate, stacktrace).raw();
state->UnwindScopes(isolate->top_exit_frame_info());
saved_exception = &Instance::Handle(raw_exception);
saved_stacktrace = &Instance::Handle(raw_stacktrace);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698