| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 ASSERT(state != NULL); | 298 ASSERT(state != NULL); |
| 299 ApiLocalScope* scope = state->top_scope(); | 299 ApiLocalScope* scope = state->top_scope(); |
| 300 ASSERT(scope != NULL); | 300 ASSERT(scope != NULL); |
| 301 return scope->zone().Reallocate(ptr, old_size, new_size); | 301 return scope->zone().Reallocate(ptr, old_size, new_size); |
| 302 } | 302 } |
| 303 | 303 |
| 304 | 304 |
| 305 // --- Handles --- | 305 // --- Handles --- |
| 306 | 306 |
| 307 | 307 |
| 308 DART_EXPORT bool Dart_IsError(const Dart_Handle& handle) { | 308 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { |
| 309 DARTSCOPE(Isolate::Current()); | 309 DARTSCOPE(Isolate::Current()); |
| 310 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); | 310 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
| 311 return obj.IsApiError(); | 311 return obj.IsApiError(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 | 314 |
| 315 static const char* MakeUnhandledExceptionCString( | 315 static const char* MakeUnhandledExceptionCString( |
| 316 const UnhandledException& uhe) { | 316 const UnhandledException& uhe) { |
| 317 const Instance& exception = Instance::Handle(uhe.exception()); | 317 const Instance& exception = Instance::Handle(uhe.exception()); |
| 318 Object& strtmp = Object::Handle(DartLibraryCalls::ToString(exception)); | 318 Object& strtmp = Object::Handle(DartLibraryCalls::ToString(exception)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 333 const char* format = "Unhandled exception:\n%s\n%s"; | 333 const char* format = "Unhandled exception:\n%s\n%s"; |
| 334 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format) | 334 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format) |
| 335 - 4 // Two '%s' | 335 - 4 // Two '%s' |
| 336 + 1); // '\0' | 336 + 1); // '\0' |
| 337 char* buffer = reinterpret_cast<char*>(Api::Allocate(len)); | 337 char* buffer = reinterpret_cast<char*>(Api::Allocate(len)); |
| 338 OS::SNPrint(buffer, len, format, exc_str, stack_str); | 338 OS::SNPrint(buffer, len, format, exc_str, stack_str); |
| 339 return buffer; | 339 return buffer; |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| 343 DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) { | 343 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) { |
| 344 DARTSCOPE(Isolate::Current()); | 344 DARTSCOPE(Isolate::Current()); |
| 345 | 345 |
| 346 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); | 346 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
| 347 if (!obj.IsApiError()) { | 347 if (!obj.IsApiError()) { |
| 348 return ""; | 348 return ""; |
| 349 } | 349 } |
| 350 ApiError& failure = ApiError::Handle(); | 350 ApiError& failure = ApiError::Handle(); |
| 351 failure ^= obj.raw(); | 351 failure ^= obj.raw(); |
| 352 const Object& data = Object::Handle(failure.data()); | 352 const Object& data = Object::Handle(failure.data()); |
| 353 if (data.IsString()) { | 353 if (data.IsString()) { |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 } | 2535 } |
| 2536 delete debug_region; | 2536 delete debug_region; |
| 2537 } else { | 2537 } else { |
| 2538 *buffer = NULL; | 2538 *buffer = NULL; |
| 2539 *buffer_size = 0; | 2539 *buffer_size = 0; |
| 2540 } | 2540 } |
| 2541 } | 2541 } |
| 2542 | 2542 |
| 2543 | 2543 |
| 2544 } // namespace dart | 2544 } // namespace dart |
| OLD | NEW |