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" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 return NULL; | 458 return NULL; |
| 459 } | 459 } |
| 460 | 460 |
| 461 | 461 |
| 462 // --- Initialization and Globals --- | 462 // --- Initialization and Globals --- |
| 463 | 463 |
| 464 | 464 |
| 465 // TODO(iposva): This is a placeholder for the eventual external Dart API. | 465 // TODO(iposva): This is a placeholder for the eventual external Dart API. |
| 466 DART_EXPORT bool Dart_Initialize(int argc, | 466 DART_EXPORT bool Dart_Initialize(int argc, |
| 467 const char** argv, | 467 const char** argv, |
| 468 Dart_IsolateInitCallback callback) { | 468 Dart_IsolateCreateCallback callback) { |
| 469 if (callback == NULL) { | |
| 470 return Api::Error("Isolate create callback parameter cannot be NULL"); | |
|
turnidge
2011/11/28 18:39:58
I don't think that Api::Error works here, because
siva
2011/11/29 00:54:25
True, I will return false and add a TODO on how to
| |
| 471 } | |
| 469 return Dart::InitOnce(argc, argv, callback); | 472 return Dart::InitOnce(argc, argv, callback); |
| 470 } | 473 } |
| 471 | 474 |
| 472 | 475 |
| 473 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { | 476 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { |
| 474 if (Flags::Lookup(flag_name) != NULL) { | 477 if (Flags::Lookup(flag_name) != NULL) { |
| 475 return true; | 478 return true; |
| 476 } | 479 } |
| 477 return false; | 480 return false; |
| 478 } | 481 } |
| 479 | 482 |
| 480 | 483 |
| 481 // --- Isolates --- | 484 // --- Isolates --- |
| 482 | 485 |
| 483 | 486 |
| 484 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 487 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
| 485 void* data) { | 488 void* callback_data, |
| 489 Dart_ErrorBuffer error) { | |
| 486 Isolate* isolate = Dart::CreateIsolate(); | 490 Isolate* isolate = Dart::CreateIsolate(); |
| 487 ASSERT(isolate != NULL); | 491 ASSERT(isolate != NULL); |
| 488 LongJump* base = isolate->long_jump_base(); | 492 LongJump* base = isolate->long_jump_base(); |
| 489 LongJump jump; | 493 LongJump jump; |
| 490 isolate->set_long_jump_base(&jump); | 494 isolate->set_long_jump_base(&jump); |
| 491 if (setjmp(*jump.Set()) == 0) { | 495 if (setjmp(*jump.Set()) == 0) { |
| 492 Dart::InitializeIsolate(snapshot, data); | 496 Dart::InitializeIsolate(snapshot, callback_data); |
| 493 START_TIMER(time_total_runtime); | 497 START_TIMER(time_total_runtime); |
| 494 isolate->set_long_jump_base(base); | 498 isolate->set_long_jump_base(base); |
| 495 return reinterpret_cast<Dart_Isolate>(isolate); | 499 return reinterpret_cast<Dart_Isolate>(isolate); |
| 496 } else { | 500 } else { |
| 497 { | 501 { |
| 498 DARTSCOPE(isolate); | 502 DARTSCOPE(isolate); |
| 499 const String& error = | 503 const String& errmsg = |
| 500 String::Handle(isolate->object_store()->sticky_error()); | 504 String::Handle(isolate->object_store()->sticky_error()); |
| 501 // TODO(asiva): Need to return this as a error. | 505 OS::SNPrint(error.buffer, error.length, "%s", errmsg.ToCString()); |
| 502 OS::PrintErr(error.ToCString()); | |
| 503 } | 506 } |
| 504 Dart::ShutdownIsolate(); | 507 Dart::ShutdownIsolate(); |
| 505 } | 508 } |
| 506 return reinterpret_cast<Dart_Isolate>(NULL); | 509 return reinterpret_cast<Dart_Isolate>(NULL); |
| 507 } | 510 } |
| 508 | 511 |
| 509 | 512 |
| 510 DART_EXPORT void Dart_ShutdownIsolate() { | 513 DART_EXPORT void Dart_ShutdownIsolate() { |
| 511 ASSERT(Isolate::Current() != NULL); | 514 ASSERT(Isolate::Current() != NULL); |
| 512 STOP_TIMER(time_total_runtime); | 515 STOP_TIMER(time_total_runtime); |
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2295 } | 2298 } |
| 2296 delete debug_region; | 2299 delete debug_region; |
| 2297 } else { | 2300 } else { |
| 2298 *buffer = NULL; | 2301 *buffer = NULL; |
| 2299 *buffer_size = 0; | 2302 *buffer_size = 0; |
| 2300 } | 2303 } |
| 2301 } | 2304 } |
| 2302 | 2305 |
| 2303 | 2306 |
| 2304 } // namespace dart | 2307 } // namespace dart |
| OLD | NEW |