Chromium Code Reviews| 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" |
| 11 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
| 12 #include "vm/dart_api_state.h" | 12 #include "vm/dart_api_state.h" |
| 13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 14 #include "vm/debuginfo.h" | 14 #include "vm/debuginfo.h" |
| 15 #include "vm/exceptions.h" | 15 #include "vm/exceptions.h" |
| 16 #include "vm/growable_array.h" | 16 #include "vm/growable_array.h" |
| 17 #include "vm/longjump.h" | 17 #include "vm/longjump.h" |
| 18 #include "vm/native_entry.h" | 18 #include "vm/native_entry.h" |
| 19 #include "vm/object.h" | 19 #include "vm/object.h" |
| 20 #include "vm/object_store.h" | 20 #include "vm/object_store.h" |
| 21 #include "vm/port.h" | 21 #include "vm/port.h" |
| 22 #include "vm/resolver.h" | 22 #include "vm/resolver.h" |
| 23 #include "vm/snapshot.h" | 23 #include "vm/snapshot.h" |
| 24 #include "vm/stack_frame.h" | 24 #include "vm/stack_frame.h" |
| 25 #include "vm/timer.h" | 25 #include "vm/timer.h" |
| 26 #include "vm/verifier.h" | 26 #include "vm/verifier.h" |
| 27 | 27 |
| 28 namespace dart { | 28 namespace dart { |
| 29 | 29 |
| 30 static const char* CanonicalFunction(const char* func) { | |
| 31 if (strncmp(func, "dart::", 6) == 0) { | |
| 32 return func + 6; | |
| 33 } else { | |
| 34 return func; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) | |
|
cshapiro
2011/11/11 00:51:42
I think you might want __PRETTY_NAME__ on G++ and
| |
| 39 | |
| 30 #define UNWRAP_NONNULL(dart_handle, vm_handle, Type) \ | 40 #define UNWRAP_NONNULL(dart_handle, vm_handle, Type) \ |
| 31 do { \ | 41 do { \ |
| 32 const Object& tmp = Object::Handle(Api::UnwrapHandle((dart_handle))); \ | 42 const Object& tmp = Object::Handle(Api::UnwrapHandle((dart_handle))); \ |
| 33 if (tmp.Is##Type()) { \ | 43 if (tmp.Is##Type()) { \ |
| 34 (vm_handle) ^= tmp.raw(); \ | 44 (vm_handle) ^= tmp.raw(); \ |
| 35 } else if (tmp.IsNull()) { \ | 45 } else if (tmp.IsNull()) { \ |
| 36 return Api::Error("%s expects argument '%s' to be non-null.", \ | 46 return Api::Error("%s expects argument '%s' to be non-null.", \ |
| 37 __FUNCTION__, #dart_handle); \ | 47 CURRENT_FUNC, #dart_handle); \ |
| 38 } else if (tmp.IsApiFailure()) { \ | 48 } else if (tmp.IsApiFailure()) { \ |
| 39 return dart_handle; \ | 49 return dart_handle; \ |
| 40 } else { \ | 50 } else { \ |
| 41 return Api::Error("%s expects argument '%s' to be of type %s.", \ | 51 return Api::Error("%s expects argument '%s' to be of type %s.", \ |
| 42 __FUNCTION__, #dart_handle, #Type); \ | 52 CURRENT_FUNC, #dart_handle, #Type); \ |
| 43 } \ | 53 } \ |
| 44 } while (0) | 54 } while (0) |
| 45 | 55 |
| 46 | 56 |
| 47 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { | 57 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { |
| 48 ASSERT(Isolate::Current() != NULL); | 58 ASSERT(Isolate::Current() != NULL); |
| 49 Zone zone; // Setup a VM zone as we are creating some handles. | 59 Zone zone; // Setup a VM zone as we are creating some handles. |
| 50 HandleScope scope; // Setup a VM handle scope. | 60 HandleScope scope; // Setup a VM handle scope. |
| 51 | 61 |
| 52 // Make sure that the object isn't an ApiFailure. | 62 // Make sure that the object isn't an ApiFailure. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 | 420 |
| 411 | 421 |
| 412 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { | 422 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| 413 Zone zone; // Setup a VM zone as we are creating some handles. | 423 Zone zone; // Setup a VM zone as we are creating some handles. |
| 414 HandleScope scope; // Setup a VM handle scope. | 424 HandleScope scope; // Setup a VM handle scope. |
| 415 String& url_str = String::Handle(); | 425 String& url_str = String::Handle(); |
| 416 UNWRAP_NONNULL(url, url_str, String); | 426 UNWRAP_NONNULL(url, url_str, String); |
| 417 const Library& library = Library::Handle(Library::LookupLibrary(url_str)); | 427 const Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| 418 if (library.IsNull()) { | 428 if (library.IsNull()) { |
| 419 return Api::Error("%s: library '%s' not found.", | 429 return Api::Error("%s: library '%s' not found.", |
| 420 __FUNCTION__, url_str.ToCString()); | 430 CURRENT_FUNC, url_str.ToCString()); |
| 421 } else { | 431 } else { |
| 422 return Api::NewLocalHandle(library); | 432 return Api::NewLocalHandle(library); |
| 423 } | 433 } |
| 424 } | 434 } |
| 425 | 435 |
| 426 | 436 |
| 427 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) { | 437 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) { |
| 428 Zone zone; // Setup a VM zone as we are creating some handles. | 438 Zone zone; // Setup a VM zone as we are creating some handles. |
| 429 HandleScope scope; // Setup a VM handle scope. | 439 HandleScope scope; // Setup a VM handle scope. |
| 430 const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); | 440 const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 ASSERT(isolate != NULL); | 2135 ASSERT(isolate != NULL); |
| 2126 ApiState* state = isolate->api_state(); | 2136 ApiState* state = isolate->api_state(); |
| 2127 ASSERT(state != NULL); | 2137 ASSERT(state != NULL); |
| 2128 ApiLocalScope* scope = state->top_scope(); | 2138 ApiLocalScope* scope = state->top_scope(); |
| 2129 ASSERT(scope != NULL); | 2139 ASSERT(scope != NULL); |
| 2130 return scope->zone().Reallocate(ptr, old_size, new_size); | 2140 return scope->zone().Reallocate(ptr, old_size, new_size); |
| 2131 } | 2141 } |
| 2132 | 2142 |
| 2133 | 2143 |
| 2134 } // namespace dart | 2144 } // namespace dart |
| OLD | NEW |