Chromium Code Reviews| Index: runtime/bin/main.cc |
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
| index 4f5e752da3edb87cb4fb4bde388ad39978d0dd8a..ec1643475e6705495417b54da163c7749bed3010 100644 |
| --- a/runtime/bin/main.cc |
| +++ b/runtime/bin/main.cc |
| @@ -54,7 +54,7 @@ static const int DEFAULT_DEBUG_PORT = 5858; |
| // Value of the --package-root flag. |
| // (This pointer points into an argv buffer and does not need to be |
| // free'd.) |
| -static const char* package_root = NULL; |
| +static const char* commandline_package_root = NULL; |
| // Global flag that is used to indicate that we want to compile all the |
| @@ -136,7 +136,7 @@ static bool ProcessPackageRootOption(const char* arg, |
| if (*arg == '\0' || *arg == '-') { |
| return false; |
| } |
| - package_root = arg; |
| + commandline_package_root = arg; |
| return true; |
| } |
| @@ -549,11 +549,12 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) { |
| // Returns true on success, false on failure. |
| static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| const char* main, |
| - void* data, |
| + const char* package_root, |
| + IsolateData* isolate_data, |
| char** error, |
| bool* is_compile_error) { |
|
turnidge
2014/09/09 15:46:41
Thanks Anders.
I think I want to change my earlie
Anders Johnsen
2014/09/10 05:42:17
Done.
|
| - Dart_Isolate isolate = |
| - Dart_CreateIsolate(script_uri, main, snapshot_buffer, data, error); |
| + Dart_Isolate isolate = Dart_CreateIsolate( |
| + script_uri, main, snapshot_buffer, isolate_data, error); |
| if (isolate == NULL) { |
| return NULL; |
| } |
| @@ -582,14 +583,14 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| CHECK_RESULT(builtin_lib); |
| + ASSERT(isolate_data != NULL); |
| + ASSERT(isolate_data->script_url != NULL); |
|
turnidge
2014/09/09 15:46:41
Remove if you follow the above recommendation.
Anders Johnsen
2014/09/10 05:42:17
Done.
|
| + |
| // 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); |
| - IsolateData* isolate_data = reinterpret_cast<IsolateData*>(data); |
| - ASSERT(isolate_data != NULL); |
| - ASSERT(isolate_data->script_url != NULL); |
| result = DartUtils::LoadScript(isolate_data->script_url, builtin_lib); |
|
turnidge
2014/09/09 15:46:41
Use script_uri instead of isolate_data->script_url
Anders Johnsen
2014/09/10 05:42:17
Done.
|
| CHECK_RESULT(result); |
| @@ -631,23 +632,28 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
| const char* main, |
| + const char* package_root, |
| void* data, char** error) { |
| + IsolateData* parent_isolate_data = reinterpret_cast<IsolateData*>(data); |
| bool is_compile_error = false; |
| if (script_uri == NULL) { |
| if (data == NULL) { |
| *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); |
| return NULL; |
| } |
| - IsolateData* parent_isolate_data = reinterpret_cast<IsolateData*>(data); |
| script_uri = parent_isolate_data->script_url; |
| if (script_uri == NULL) { |
| *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); |
| return NULL; |
| } |
| } |
| - IsolateData* isolate_data = new IsolateData(script_uri); |
| + if (package_root == NULL) { |
| + package_root = parent_isolate_data->package_root; |
| + } |
| + IsolateData* isolate_data = new IsolateData(script_uri, package_root); |
|
turnidge
2014/09/09 15:46:41
Creation moves into helper function.
Anders Johnsen
2014/09/10 05:42:16
Done.
|
| return CreateIsolateAndSetupHelper(script_uri, |
| main, |
| + package_root, |
| isolate_data, |
| error, |
| &is_compile_error); |
| @@ -664,7 +670,7 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
| static Dart_Isolate CreateServiceIsolate(void* data, char** error) { |
| const char* script_uri = DartUtils::kVMServiceLibURL; |
| - IsolateData* isolate_data = new IsolateData(script_uri); |
| + IsolateData* isolate_data = new IsolateData(script_uri, NULL); |
| Dart_Isolate isolate = |
| Dart_CreateIsolate(script_uri, "main", snapshot_buffer, isolate_data, |
| error); |
| @@ -688,9 +694,9 @@ static Dart_Isolate CreateServiceIsolate(void* data, char** error) { |
| 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); |
| + result = DartUtils::PrepareForScriptLoading(NULL, builtin_lib); |
| CHECK_RESULT(result); |
| - Platform::SetPackageRoot(package_root); |
| + Platform::SetPackageRoot(commandline_package_root); |
| Dart_Handle io_lib_url = DartUtils::NewString(DartUtils::kIOLibURL); |
| CHECK_RESULT(io_lib_url); |
| Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); |
| @@ -1039,9 +1045,11 @@ void main(int argc, char** argv) { |
| char* error = NULL; |
| bool is_compile_error = false; |
| char* isolate_name = BuildIsolateName(script_name, "main"); |
| - IsolateData* isolate_data = new IsolateData(script_name); |
| + IsolateData* isolate_data = new IsolateData(script_name, |
| + commandline_package_root); |
|
turnidge
2014/09/09 15:46:41
Creation moves into helper function.
Anders Johnsen
2014/09/10 05:42:17
Done.
|
| Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, |
| "main", |
| + commandline_package_root, |
| isolate_data, |
| &error, |
| &is_compile_error); |