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

Unified Diff: runtime/bin/dartutils.cc

Issue 1403693002: - Implement package map parameter when spawning isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 2 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 83ffcd35f994e5b5ed2c8a97908e91a960927c50..3c01e64f8f7cbd986fb0083a436aba90869f5d91 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -637,6 +637,7 @@ Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
bool is_service_isolate,
bool trace_loading,
const char* package_root,
+ const char** package_map,
const char* packages_file) {
// Setup the internal library's 'internalPrint' function.
Dart_Handle print = Dart_Invoke(
@@ -670,6 +671,7 @@ Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
// Set up package root if specified.
if (package_root != NULL) {
+ ASSERT(package_map == NULL);
ASSERT(packages_file == NULL);
result = NewString(package_root);
RETURN_IF_ERROR(result);
@@ -681,6 +683,33 @@ Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
kNumArgs,
dart_args);
RETURN_IF_ERROR(result);
+ } else if (package_map != NULL) {
+ ASSERT(packages_file == NULL);
+ Dart_Handle func_name = NewString("_addPackageMapEntry");
+ RETURN_IF_ERROR(func_name);
+
+ for (int i = 0; package_map[i] != NULL; i +=2) {
+ const int kNumArgs = 2;
+ Dart_Handle dart_args[kNumArgs];
+ // Get the key.
+ result = NewString(package_map[i]);
+ RETURN_IF_ERROR(result);
+ dart_args[0] = result;
+ if (package_map[i + 1] == NULL) {
+ return Dart_NewUnhandledExceptionError(
+ NewDartArgumentError("Adding package map entry without value."));
+ }
+ // Get the value.
+ result = NewString(package_map[i + 1]);
+ RETURN_IF_ERROR(result);
+ dart_args[1] = result;
+ // Setup the next package map entry.
+ result = Dart_Invoke(builtin_lib,
+ func_name,
+ kNumArgs,
+ dart_args);
+ RETURN_IF_ERROR(result);
+ }
} else if (packages_file != NULL) {
result = NewString(packages_file);
RETURN_IF_ERROR(result);
@@ -738,6 +767,7 @@ Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
+ const char** package_map,
const char* packages_file,
bool is_service_isolate,
bool trace_loading,
@@ -772,6 +802,7 @@ Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
is_service_isolate,
trace_loading,
package_root,
+ package_map,
packages_file);
RETURN_IF_ERROR(result);
« 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