Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Unified Diff: runtime/bin/main.cc

Issue 590123002: Revert "Per isolate package root." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index a65592e14b48dc320e20bfd20fde983a16baabd1..b96d513fe01dfeae2cd3c684100e46842438f248 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* commandline_package_root = NULL;
+static const char* 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;
}
- commandline_package_root = arg;
+ package_root = arg;
return true;
}
@@ -549,13 +549,11 @@ 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,
- const char* package_root,
+ void* data,
char** error,
bool* is_compile_error) {
- ASSERT(script_uri != NULL);
- IsolateData* isolate_data = new IsolateData(script_uri, package_root);
- Dart_Isolate isolate = Dart_CreateIsolate(
- script_uri, main, snapshot_buffer, isolate_data, error);
+ Dart_Isolate isolate =
+ Dart_CreateIsolate(script_uri, main, snapshot_buffer, data, error);
if (isolate == NULL) {
return NULL;
}
@@ -589,7 +587,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib);
CHECK_RESULT(result);
- result = DartUtils::LoadScript(script_uri, builtin_lib);
+ 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);
CHECK_RESULT(result);
// Run event-loop and wait for script loading to complete.
@@ -630,27 +631,24 @@ 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;
}
}
- if (package_root == NULL) {
- package_root = parent_isolate_data->package_root;
- }
+ IsolateData* isolate_data = new IsolateData(script_uri);
return CreateIsolateAndSetupHelper(script_uri,
main,
- package_root,
+ isolate_data,
error,
&is_compile_error);
}
@@ -666,7 +664,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, NULL);
+ IsolateData* isolate_data = new IsolateData(script_uri);
Dart_Isolate isolate =
Dart_CreateIsolate(script_uri, "main", snapshot_buffer, isolate_data,
error);
@@ -690,7 +688,7 @@ 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(NULL, builtin_lib);
+ result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib);
CHECK_RESULT(result);
Dart_ExitScope();
@@ -1027,9 +1025,10 @@ 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);
Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
"main",
- commandline_package_root,
+ isolate_data,
&error,
&is_compile_error);
if (isolate == NULL) {
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698