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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 15250009: Adapt gen_snapshot to the recent changes in bootstrap sources loading scheme. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 41d71f10f2fffcf99707adf9711a9d926afa5b32..5e5b61a0565df1e1f324d208858506dbc2640826 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -267,6 +267,17 @@ static Dart_Handle ResolveUri(const char* library_uri, const char* uri) {
}
+static Builtin::BuiltinLibraryId BuiltinId(const char* url) {
+ if (DartUtils::IsDartBuiltinLibURL(url)) {
+ return Builtin::kBuiltinLibrary;
+ }
+ if (DartUtils::IsDartIOLibURL(url)) {
+ return Builtin::kIOLibrary;
+ }
+ return Builtin::kInvalidLibrary;
+}
+
+
static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
Dart_Handle library,
Dart_Handle url) {
@@ -292,17 +303,36 @@ static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
const char* mapped_url_string = DartUtils::MapLibraryUrl(url_mapping,
url_string);
+ Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string);
if (tag == kCanonicalizeUrl) {
- // Keep original names for libraries that have a mapping (e.g. dart:io).
if (mapped_url_string) {
return url;
}
+ // Parts of internal libraries are handled internally.
+ if (libraryBuiltinId != Builtin::kInvalidLibrary) {
+ return url;
+ }
return ResolveUri(library_url_string, url_string);
}
- if (DartUtils::IsDartIOLibURL(url_string) && mapped_url_string == NULL) {
- // No url mapping for dart:io. Load original version.
- return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
+ Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string);
+ if (builtinId != Builtin::kInvalidLibrary) {
+ // Special case for importing a builtin library.
+ if (tag == kImportTag) {
+ return Builtin::LoadAndCheckLibrary(builtinId);
+ }
+ ASSERT(tag == kSourceTag);
+ return Dart_Error("Unable to part '%s' ", url_string);
+ }
+
+ if (libraryBuiltinId != Builtin::kInvalidLibrary) {
+ // Special case for parting sources of a builtin library.
+ if (tag == kSourceTag) {
+ return Dart_LoadSource(
+ library, url, Builtin::PartSource(libraryBuiltinId, url_string));
+ }
+ ASSERT(tag == kImportTag);
+ return Dart_Error("Unable to import '%s' ", url_string);
}
Dart_Handle resolved_url = url;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698