Index: runtime/bin/main.cc |
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
index 59cf35a5a3199cefb7b9486f2950ca946d392468..2ca7ec6e334268c698cde9f555f405ce236c1ea7 100644 |
--- a/runtime/bin/main.cc |
+++ b/runtime/bin/main.cc |
@@ -542,7 +542,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
Dart_SetField(platform_type, script_name_name, dart_script); |
CHECK_RESULT(set_script_name); |
- VmService::SendIsolateStartupMessage(); |
+ Dart_RegisterWithService(); |
// Make the isolate runnable so that it is ready to handle messages. |
Dart_ExitScope(); |
@@ -584,6 +584,59 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
} |
+static Dart_Isolate CreateServiceIsolate(void* data, char** error) { |
+ const char* script_uri = "dart:vmservice"; |
siva
2014/01/10 00:01:54
You could add a DartUtils::kVMServiceLibURL value
Cutch
2014/01/10 21:01:42
Done.
|
+ bool is_compile_error_ = false; |
+ bool *is_compile_error = &is_compile_error_; |
siva
2014/01/10 00:01:54
I don't see the variables is_compile_error and is_
Cutch
2014/01/10 21:01:42
They are used in the CHECK_RESULT macro. I've adde
|
+ IsolateData* isolate_data = new IsolateData(script_uri); |
+ Dart_Isolate isolate = |
+ Dart_CreateIsolate(script_uri, "main", snapshot_buffer, isolate_data, |
+ error); |
+ if (isolate == NULL) { |
+ return NULL; |
+ } |
+ Dart_EnterScope(); |
+ if (snapshot_buffer != NULL) { |
+ // Setup the native resolver as the snapshot does not carry it. |
+ Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
+ Builtin::SetNativeResolver(Builtin::kIOLibrary); |
+ } |
+ // Set up the library tag handler for this isolate. |
+ Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); |
+ CHECK_RESULT(result); |
+ result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
+ CHECK_RESULT(result); |
+ // Prepare builtin and its dependent libraries for use to resolve URIs. |
+ Dart_Handle builtin_lib = |
+ Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
+ CHECK_RESULT(builtin_lib); |
+ // Prepare for script loading by setting up the 'print' and 'timer' |
+ // closures and setting up 'package root' for URI resolution. |
+ result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); |
+ CHECK_RESULT(result); |
+ Platform::SetPackageRoot(package_root); |
+ Dart_Handle io_lib_url = DartUtils::NewString("dart:io"); |
siva
2014/01/10 00:01:54
DartUtils::kIOLibURL instead of "dart:io"
Cutch
2014/01/10 21:01:42
Done here and elsewhere.
|
+ CHECK_RESULT(io_lib_url); |
+ Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); |
+ CHECK_RESULT(io_lib); |
+ Dart_Handle platform_class_name = DartUtils::NewString("Platform"); |
+ CHECK_RESULT(platform_class_name); |
+ Dart_Handle platform_type = |
+ Dart_GetType(io_lib, platform_class_name, 0, NULL); |
siva
2014/01/10 00:01:54
You could use
Dart_Handle platform_type = DartUtil
Cutch
2014/01/10 21:01:42
Done here and elsewhere.
|
+ CHECK_RESULT(platform_type); |
+ Dart_Handle script_name_name = DartUtils::NewString("_nativeScript"); |
siva
2014/01/10 00:01:54
Why does the variable have to be called script_nam
Cutch
2014/01/10 21:01:42
Done here and elsewhere.
|
+ CHECK_RESULT(script_name_name); |
+ Dart_Handle dart_script = DartUtils::NewString(script_uri); |
+ CHECK_RESULT(dart_script); |
+ Dart_Handle set_script_name = |
+ Dart_SetField(platform_type, script_name_name, dart_script); |
+ CHECK_RESULT(set_script_name); |
+ Dart_ExitScope(); |
+ Dart_ExitIsolate(); |
+ return isolate; |
+} |
+ |
+ |
static void PrintVersion() { |
Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); |
} |
@@ -716,7 +769,7 @@ static void DartExitOnError(Dart_Handle error) { |
static void ShutdownIsolate(void* callback_data) { |
- VmService::VmServiceShutdownCallback(callback_data); |
+ Dart_UnregisterFromService(); |
IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data); |
delete isolate_data; |
} |
@@ -812,7 +865,8 @@ void main(int argc, char** argv) { |
DartUtils::ReadFile, |
DartUtils::WriteFile, |
DartUtils::CloseFile, |
- DartUtils::EntropySource)) { |
+ DartUtils::EntropySource, |
+ CreateServiceIsolate)) { |
fprintf(stderr, "%s", "VM initialization failed\n"); |
fflush(stderr); |
exit(kErrorExitCode); |