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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 return NULL; | 515 return NULL; |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 // --- Initialization and Globals --- | 519 // --- Initialization and Globals --- |
520 | 520 |
521 | 521 |
522 // TODO(iposva): This is a placeholder for the eventual external Dart API. | 522 // TODO(iposva): This is a placeholder for the eventual external Dart API. |
523 DART_EXPORT bool Dart_Initialize(int argc, | 523 DART_EXPORT bool Dart_Initialize(int argc, |
524 const char** argv, | 524 const char** argv, |
525 Dart_IsolateInitCallback callback) { | 525 Dart_IsolateCreateCallback callback) { |
526 return Dart::InitOnce(argc, argv, callback); | 526 return Dart::InitOnce(argc, argv, callback); |
527 } | 527 } |
528 | 528 |
529 | 529 |
530 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { | 530 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { |
531 if (Flags::Lookup(flag_name) != NULL) { | 531 if (Flags::Lookup(flag_name) != NULL) { |
532 return true; | 532 return true; |
533 } | 533 } |
534 return false; | 534 return false; |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 // --- Isolates --- | 538 // --- Isolates --- |
539 | 539 |
540 | 540 |
541 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 541 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
542 void* data) { | 542 void* callback_data, |
| 543 char** error) { |
543 Isolate* isolate = Dart::CreateIsolate(); | 544 Isolate* isolate = Dart::CreateIsolate(); |
544 ASSERT(isolate != NULL); | 545 ASSERT(isolate != NULL); |
545 LongJump* base = isolate->long_jump_base(); | 546 LongJump* base = isolate->long_jump_base(); |
546 LongJump jump; | 547 LongJump jump; |
547 isolate->set_long_jump_base(&jump); | 548 isolate->set_long_jump_base(&jump); |
548 if (setjmp(*jump.Set()) == 0) { | 549 if (setjmp(*jump.Set()) == 0) { |
549 Dart::InitializeIsolate(snapshot, data); | 550 Dart::InitializeIsolate(snapshot, callback_data); |
550 START_TIMER(time_total_runtime); | 551 START_TIMER(time_total_runtime); |
551 isolate->set_long_jump_base(base); | 552 isolate->set_long_jump_base(base); |
552 return reinterpret_cast<Dart_Isolate>(isolate); | 553 return reinterpret_cast<Dart_Isolate>(isolate); |
553 } else { | 554 } else { |
554 { | 555 { |
555 DARTSCOPE(isolate); | 556 DARTSCOPE(isolate); |
556 const String& error = | 557 const String& errmsg = |
557 String::Handle(isolate->object_store()->sticky_error()); | 558 String::Handle(isolate->object_store()->sticky_error()); |
558 // TODO(asiva): Need to return this as a error. | 559 *error = strdup(errmsg.ToCString()); |
559 OS::PrintErr(error.ToCString()); | |
560 } | 560 } |
561 Dart::ShutdownIsolate(); | 561 Dart::ShutdownIsolate(); |
562 } | 562 } |
563 return reinterpret_cast<Dart_Isolate>(NULL); | 563 return reinterpret_cast<Dart_Isolate>(NULL); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 DART_EXPORT void Dart_ShutdownIsolate() { | 567 DART_EXPORT void Dart_ShutdownIsolate() { |
568 ASSERT(Isolate::Current() != NULL); | 568 ASSERT(Isolate::Current() != NULL); |
569 STOP_TIMER(time_total_runtime); | 569 STOP_TIMER(time_total_runtime); |
(...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 } | 2361 } |
2362 delete debug_region; | 2362 delete debug_region; |
2363 } else { | 2363 } else { |
2364 *buffer = NULL; | 2364 *buffer = NULL; |
2365 *buffer_size = 0; | 2365 *buffer_size = 0; |
2366 } | 2366 } |
2367 } | 2367 } |
2368 | 2368 |
2369 | 2369 |
2370 } // namespace dart | 2370 } // namespace dart |
OLD | NEW |