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

Unified Diff: runtime/bin/builtin.cc

Issue 1449163003: - Include sources in gen_snapshot and dart_no_snapshot to allow (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Simplify logic. Created 5 years, 1 month 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 | « no previous file | runtime/bin/builtin_in.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.cc
diff --git a/runtime/bin/builtin.cc b/runtime/bin/builtin.cc
index c52f314aa76ed322608017dc0f3d9eb276371f48..021140bea78dc4540595dc91d6d222f04eeeada8 100644
--- a/runtime/bin/builtin.cc
+++ b/runtime/bin/builtin.cc
@@ -27,8 +27,14 @@ Dart_Port Builtin::load_port_ = ILLEGAL_PORT;
static void LoadPatchFiles(Dart_Handle library,
const char* patch_uri,
const char** patch_files) {
- for (intptr_t j = 0; patch_files[j] != NULL; j += 2) {
+ for (intptr_t j = 0; patch_files[j] != NULL; j += 3) {
Dart_Handle patch_src = DartUtils::ReadStringFromFile(patch_files[j + 1]);
+ if (!Dart_IsString(patch_src)) {
+ // In case reading the file caused an error, use the sources directly.
+ const char* source = patch_files[j + 2];
+ patch_src = Dart_NewStringFromUTF8(
+ reinterpret_cast<const uint8_t*>(source), strlen(source));
+ }
// Prepend the patch library URI to form a unique script URI for the patch.
intptr_t len = snprintf(NULL, 0, "%s/%s", patch_uri, patch_files[j]);
@@ -69,17 +75,20 @@ Dart_Handle Builtin::GetSource(const char** source_paths, const char* uri) {
if (source_paths == NULL) {
return Dart_Null(); // No path mapping information exists for library.
}
- const char* source_path = NULL;
- for (intptr_t i = 0; source_paths[i] != NULL; i += 2) {
+ for (intptr_t i = 0; source_paths[i] != NULL; i += 3) {
if (!strcmp(uri, source_paths[i])) {
- source_path = source_paths[i + 1];
- break;
+ const char* source_path = source_paths[i + 1];
+ Dart_Handle src = DartUtils::ReadStringFromFile(source_path);
+ if (!Dart_IsString(src)) {
+ // In case reading the file caused an error, use the sources directly.
+ const char* source = source_paths[i + 2];
+ src = Dart_NewStringFromUTF8(
+ reinterpret_cast<const uint8_t*>(source), strlen(source));
+ }
+ return src;
}
}
- if (source_path == NULL) {
- return Dart_Null(); // Uri does not exist in path mapping information.
- }
- return DartUtils::ReadStringFromFile(source_path);
+ return Dart_Null(); // Uri does not exist in path mapping information.
}
« no previous file with comments | « no previous file | runtime/bin/builtin_in.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698