[VM / Service] Update core library source loading to use resolved_url
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>
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 3d3fc57..2b4f29b 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -9094,10 +9094,7 @@
#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);