Index: runtime/bin/dartutils.cc |
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc |
index 396b116fdd6d6dadb4b3fff83cba50a42d8796e2..b5a784cbf4c3f15e81ef8b0e8e410472676cac69 100644 |
--- a/runtime/bin/dartutils.cc |
+++ b/runtime/bin/dartutils.cc |
@@ -41,6 +41,7 @@ const char* const DartUtils::kInternalLibURL = "dart:_internal"; |
const char* const DartUtils::kIsolateLibURL = "dart:isolate"; |
const char* const DartUtils::kIOLibURL = "dart:io"; |
const char* const DartUtils::kIOLibPatchURL = "dart:io-patch"; |
+const char* const DartUtils::kHTMLLibURL = "dart:html"; |
siva
2016/04/25 23:38:31
Ditto.
Ivan Posva
2016/04/26 21:17:43
Done.
|
const char* const DartUtils::kUriLibURL = "dart:uri"; |
const char* const DartUtils::kHttpScheme = "http:"; |
const char* const DartUtils::kVMServiceLibURL = "dart:vmservice"; |
@@ -395,37 +396,37 @@ Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, |
} |
bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
- bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string); |
+ bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); |
// Handle URI canonicalization requests. |
if (tag == Dart_kCanonicalizeUrl) { |
// If this is a Dart Scheme URL or 'part' of a io library |
siva
2016/04/25 23:38:31
Comment needs to change from io library to 'part'
Ivan Posva
2016/04/26 21:17:43
Done.
|
// then it is not modified as it will be handled internally. |
- if (is_dart_scheme_url || is_io_library) { |
+ if (is_dart_scheme_url || is_dart_library) { |
return url; |
} |
// Resolve the url within the context of the library's URL. |
return ResolveUri(library_url, url); |
} |
- // Handle 'import' of dart scheme URIs (i.e they start with 'dart:'). |
- if (is_dart_scheme_url) { |
+ // Handle 'import' and 'part' of dart scheme URIs (i.e. they |
+ // start with 'dart:'). |
+ if (is_dart_scheme_url || is_dart_library) { |
if (tag == Dart_kImportTag) { |
- // Handle imports of other built-in libraries present in the SDK. |
- if (DartUtils::IsDartIOLibURL(url_string)) { |
- return Builtin::LoadLibrary(url, Builtin::kIOLibrary); |
+ Builtin::BuiltinLibraryId id = Builtin::FindId(url_string); |
+ if (id == Builtin::kInvalidLibrary) { |
+ return NewError("The built-in library '%s' is not available" |
+ " on the stand-alone VM.\n", url_string); |
} |
siva
2016/04/25 23:38:31
This FindId part can be hoisted out of the if (...
Ivan Posva
2016/05/03 21:46:40
Unfortunately not as for one case you are looking
|
- return NewError("The built-in library '%s' is not available" |
- " on the stand-alone VM.\n", url_string); |
+ return Builtin::LoadLibrary(url, id); |
} else { |
ASSERT(tag == Dart_kSourceTag); |
- return NewError("Unable to load source '%s' ", url_string); |
- } |
- } |
- |
- // Handle 'part' of IO library. |
- if (is_io_library) { |
- if (tag == Dart_kSourceTag) { |
+ Builtin::BuiltinLibraryId id = Builtin::FindId(library_url_string); |
+ if (id == Builtin::kInvalidLibrary) { |
+ return NewError("The built-in library '%s' is not available" |
+ " on the stand-alone VM. Trying to load" |
+ " '%s'.\n", library_url_string, url_string); |
+ } |
// Prepend the library URI to form a unique script URI for the part. |
intptr_t len = snprintf(NULL, 0, "%s/%s", library_url_string, url_string); |
char* part_uri = reinterpret_cast<char*>(malloc(len + 1)); |
@@ -433,15 +434,17 @@ Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, |
Dart_Handle part_uri_obj = DartUtils::NewString(part_uri); |
free(part_uri); |
return Dart_LoadSource( |
- library, |
- part_uri_obj, |
- Builtin::PartSource(Builtin::kIOLibrary, url_string), 0, 0); |
- } else { |
- ASSERT(tag == Dart_kImportTag); |
- return NewError("Unable to import '%s' ", url_string); |
+ library, |
+ part_uri_obj, |
+ Builtin::PartSource(id, url_string), 0, 0); |
} |
} |
+ // Handle 'part' of dart: library being supplied by the embedder. |
+ if (is_dart_library) { |
+ UNREACHABLE(); |
+ } |
siva
2016/04/25 23:38:31
This is not needed right?
Ivan Posva
2016/04/26 21:17:43
Refactored this code here and above...
|
+ |
if (DartUtils::IsDartExtensionSchemeURL(url_string)) { |
// Load a native code shared library to use in a native extension |
if (tag != Dart_kImportTag) { |