Skip to content

Commit

Permalink
[VM / Service] Update core library source loading to use resolved_url
Browse files Browse the repository at this point in the history
Source URIs for the core libraries in kernel take the form of
`org-dartlang-sdk://'. Previously, we had to do some manual
modifications to the URI stored by script objects which pointed to core
library scripts as they were often replaced with `dart:*` of being an
actual URI. Now that we have resolved_uri() in Script, we can use this
method to get the `org-dartlang-sdk://` URI and avoid the brittle
hacking of URIs.

For example, the resolved URI for the 'dart:io' script is
`org-dartlang-sdk:///sdk/lib/io/io.dart`.

Change-Id: I8e9f590be8e4b50d1476fc06a5c3928e63bef3b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97660
Reviewed-by: Siva Annamalai <asiva@google.com>
  • Loading branch information
bkonyi committed Mar 26, 2019
1 parent 093c290 commit 432e5fa
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9094,10 +9094,7 @@ bool Script::IsPartOfDartColonLibrary() const {
#if !defined(DART_PRECOMPILED_RUNTIME)
void Script::LoadSourceFromKernel(const uint8_t* kernel_buffer,
intptr_t kernel_buffer_len) const {
const char* dart_prefix = "dart:";
const size_t dart_prefix_len = strlen(dart_prefix);
String& uri = String::Handle(url());
uri ^= String::SubString(uri, dart_prefix_len);
String& uri = String::Handle(resolved_url());
String& source = String::Handle(kernel::KernelLoader::FindSourceForScript(
kernel_buffer, kernel_buffer_len, uri));
set_source(source);
Expand Down

0 comments on commit 432e5fa

Please sign in to comment.