| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 34a8d33f97af77b721ac7514d7c0b81924c5279b..83ab446bbc45e5f5fafbe690e8bf9f67f178f4ba 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -21,6 +21,7 @@
|
| #include "vm/flags.h"
|
| #include "vm/growable_array.h"
|
| #include "vm/lockers.h"
|
| +#include "vm/isolate_reload.h"
|
| #include "vm/message.h"
|
| #include "vm/message_handler.h"
|
| #include "vm/native_entry.h"
|
| @@ -5221,6 +5222,7 @@ static void CompileSource(Thread* thread,
|
|
|
|
|
| DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
| + Dart_Handle resolved_url,
|
| Dart_Handle source,
|
| intptr_t line_offset,
|
| intptr_t column_offset) {
|
| @@ -5231,6 +5233,13 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
| if (url_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, url, String);
|
| }
|
| + if (Dart_IsNull(resolved_url)) {
|
| + resolved_url = url;
|
| + }
|
| + const String& resolved_url_str = Api::UnwrapStringHandle(Z, resolved_url);
|
| + if (resolved_url_str.IsNull()) {
|
| + RETURN_TYPE_ERROR(Z, resolved_url, String);
|
| + }
|
| const String& source_str = Api::UnwrapStringHandle(Z, source);
|
| if (source_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, source, String);
|
| @@ -5259,8 +5268,9 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
| library.Register(T);
|
| I->object_store()->set_root_library(library);
|
|
|
| - const Script& script = Script::Handle(Z,
|
| - Script::New(url_str, source_str, RawScript::kScriptTag));
|
| + const Script& script =
|
| + Script::Handle(Z, Script::New(url_str, resolved_url_str, source_str,
|
| + RawScript::kScriptTag));
|
| script.SetLocationOffset(line_offset, column_offset);
|
| Dart_Handle result;
|
| CompileSource(T, library, script, &result);
|
| @@ -5498,6 +5508,7 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in,
|
|
|
|
|
| DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
| + Dart_Handle resolved_url,
|
| Dart_Handle source,
|
| intptr_t line_offset,
|
| intptr_t column_offset) {
|
| @@ -5508,6 +5519,13 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
| if (url_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, url, String);
|
| }
|
| + if (Dart_IsNull(resolved_url)) {
|
| + resolved_url = url;
|
| + }
|
| + const String& resolved_url_str = Api::UnwrapStringHandle(Z, resolved_url);
|
| + if (resolved_url_str.IsNull()) {
|
| + RETURN_TYPE_ERROR(Z, resolved_url, String);
|
| + }
|
| const String& source_str = Api::UnwrapStringHandle(Z, source);
|
| if (source_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, source, String);
|
| @@ -5537,8 +5555,9 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
| return Api::NewError("%s: library '%s' has already been loaded.",
|
| CURRENT_FUNC, url_str.ToCString());
|
| }
|
| - const Script& script = Script::Handle(Z,
|
| - Script::New(url_str, source_str, RawScript::kLibraryTag));
|
| + const Script& script =
|
| + Script::Handle(Z, Script::New(url_str, resolved_url_str, source_str,
|
| + RawScript::kLibraryTag));
|
| script.SetLocationOffset(line_offset, column_offset);
|
| Dart_Handle result;
|
| CompileSource(T, library, script, &result);
|
| @@ -5604,6 +5623,7 @@ DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
|
|
|
| DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
|
| Dart_Handle url,
|
| + Dart_Handle resolved_url,
|
| Dart_Handle source,
|
| intptr_t line_offset,
|
| intptr_t column_offset) {
|
| @@ -5618,6 +5638,13 @@ DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
|
| if (url_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, url, String);
|
| }
|
| + if (Dart_IsNull(resolved_url)) {
|
| + resolved_url = url;
|
| + }
|
| + const String& resolved_url_str = Api::UnwrapStringHandle(Z, resolved_url);
|
| + if (resolved_url_str.IsNull()) {
|
| + RETURN_TYPE_ERROR(Z, resolved_url, String);
|
| + }
|
| const String& source_str = Api::UnwrapStringHandle(Z, source);
|
| if (source_str.IsNull()) {
|
| RETURN_TYPE_ERROR(Z, source, String);
|
| @@ -5635,8 +5662,9 @@ DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
|
|
|
| NoHeapGrowthControlScope no_growth_control;
|
|
|
| - const Script& script = Script::Handle(Z,
|
| - Script::New(url_str, source_str, RawScript::kSourceTag));
|
| + const Script& script =
|
| + Script::Handle(Z, Script::New(url_str, resolved_url_str, source_str,
|
| + RawScript::kSourceTag));
|
| script.SetLocationOffset(line_offset, column_offset);
|
| Dart_Handle result;
|
| CompileSource(T, lib, script, &result);
|
| @@ -5667,8 +5695,9 @@ DART_EXPORT Dart_Handle Dart_LibraryLoadPatch(Dart_Handle library,
|
|
|
| NoHeapGrowthControlScope no_growth_control;
|
|
|
| - const Script& script = Script::Handle(Z,
|
| - Script::New(url_str, source_str, RawScript::kPatchTag));
|
| + const Script& script =
|
| + Script::Handle(Z, Script::New(url_str, url_str, source_str,
|
| + RawScript::kPatchTag));
|
| Dart_Handle result;
|
| CompileSource(T, lib, script, &result);
|
| return result;
|
| @@ -5844,6 +5873,12 @@ DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id,
|
| }
|
|
|
|
|
| +DART_EXPORT Dart_Handle Dart_SetFileModifiedCallback(
|
| + Dart_FileModifiedCallback file_mod_callback) {
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) {
|
| return;
|
| }
|
| @@ -5956,6 +5991,30 @@ DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id,
|
| }
|
|
|
|
|
| +DART_EXPORT Dart_Handle Dart_SetFileModifiedCallback(
|
| + Dart_FileModifiedCallback file_modified_callback) {
|
| + if (!FLAG_support_service) {
|
| + return Api::Success();
|
| + }
|
| + if (file_modified_callback != NULL) {
|
| + if (IsolateReloadContext::file_modified_callback() != NULL) {
|
| + return Api::NewError(
|
| + "%s permits only one callback to be registered, please "
|
| + "remove the existing callback and then add this callback",
|
| + CURRENT_FUNC);
|
| + }
|
| + } else {
|
| + if (IsolateReloadContext::file_modified_callback() == NULL) {
|
| + return Api::NewError(
|
| + "%s expects 'file_modified_callback' to be set before it is cleared.",
|
| + CURRENT_FUNC);
|
| + }
|
| + }
|
| + IsolateReloadContext::SetFileModifiedCallback(file_modified_callback);
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) {
|
| if (!FLAG_support_timeline) {
|
| return;
|
|
|