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

Unified Diff: runtime/bin/dartutils.cc

Issue 1232593003: - Implement .packages specification. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 5 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/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.cc
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index 11c5f5b40d8f1e07c434815cac2e80c4957a6f4b..dd63bec000de6c79ed7a318f7d4231b0924039fb 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -482,12 +482,6 @@ void DartUtils::WriteMagicNumber(File* file) {
Dart_Handle DartUtils::LoadScript(const char* script_uri,
Dart_Handle builtin_lib) {
Dart_Handle uri = Dart_NewStringFromCString(script_uri);
-
- Dart_Port load_port = Dart_ServiceWaitForLoadPort();
- if (load_port == ILLEGAL_PORT) {
- return NewDartUnsupportedError("Service did not return load port.");
- }
- Builtin::SetLoadPort(load_port);
IsolateData* isolate_data =
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
Dart_TimelineAsyncBegin("LoadScript", &(isolate_data->load_async_id));
@@ -632,11 +626,12 @@ void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) {
}
-void DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
- Dart_Handle internal_lib,
- bool is_service_isolate,
- bool trace_loading,
- const char* package_root) {
+Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
+ Dart_Handle internal_lib,
+ bool is_service_isolate,
+ bool trace_loading,
+ const char* package_root,
+ const char* packages_file) {
// Setup the internal library's 'internalPrint' function.
Dart_Handle print = Dart_Invoke(
builtin_lib, NewString("_getPrintClosure"), 0, NULL);
@@ -655,16 +650,20 @@ void DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
NewString("_traceLoading"), Dart_True());
DART_CHECK_VALID(result);
}
- }
-
- if (!is_service_isolate) {
// Set current working directory.
result = SetWorkingDirectory(builtin_lib);
DART_CHECK_VALID(result);
+ // Wait for the service isolate to initialize the load port.
+ Dart_Port load_port = Dart_ServiceWaitForLoadPort();
+ if (load_port == ILLEGAL_PORT) {
+ return NewDartUnsupportedError("Service did not return load port.");
+ }
+ Builtin::SetLoadPort(load_port);
}
// Set up package root if specified.
if (package_root != NULL) {
+ ASSERT(packages_file == NULL);
result = NewString(package_root);
DART_CHECK_VALID(result);
const int kNumArgs = 1;
@@ -675,7 +674,19 @@ void DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
kNumArgs,
dart_args);
DART_CHECK_VALID(result);
+ } else if (packages_file != NULL) {
+ result = NewString(packages_file);
+ DART_CHECK_VALID(result);
+ const int kNumArgs = 1;
+ Dart_Handle dart_args[kNumArgs];
+ dart_args[0] = result;
+ result = Dart_Invoke(builtin_lib,
+ NewString("_loadPackagesMap"),
+ kNumArgs,
+ dart_args);
+ DART_CHECK_VALID(result);
}
+ return Dart_True();
}
@@ -718,6 +729,7 @@ void DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
+ const char* packages_file,
bool is_service_isolate,
bool trace_loading,
Dart_Handle builtin_lib) {
@@ -746,11 +758,14 @@ Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
Dart_Handle result = Dart_FinalizeLoading(false);
DART_CHECK_VALID(result);
- PrepareBuiltinLibrary(builtin_lib,
- internal_lib,
- is_service_isolate,
- trace_loading,
- package_root);
+ result = PrepareBuiltinLibrary(builtin_lib,
+ internal_lib,
+ is_service_isolate,
+ trace_loading,
+ package_root,
+ packages_file);
+ DART_CHECK_VALID(result);
+
PrepareAsyncLibrary(async_lib, isolate_lib);
PrepareCoreLibrary(core_lib, builtin_lib, is_service_isolate);
PrepareIsolateLibrary(isolate_lib);
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698