| Index: vm/dart_api_impl.cc
|
| ===================================================================
|
| --- vm/dart_api_impl.cc (revision 4054)
|
| +++ vm/dart_api_impl.cc (working copy)
|
| @@ -2176,7 +2176,8 @@
|
|
|
| DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
| Dart_Handle source,
|
| - Dart_LibraryTagHandler handler) {
|
| + Dart_LibraryTagHandler handler,
|
| + Dart_Handle import_map) {
|
| TIMERSCOPE(time_script_loading);
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| @@ -2188,6 +2189,10 @@
|
| if (source_str.IsNull()) {
|
| RETURN_TYPE_ERROR(source, String);
|
| }
|
| + const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
|
| + if (mapping_array.IsNull()) {
|
| + RETURN_TYPE_ERROR(import_map, Array);
|
| + }
|
| Library& library = Library::Handle(isolate->object_store()->root_library());
|
| if (!library.IsNull()) {
|
| const String& library_url = String::Handle(library.url());
|
| @@ -2196,6 +2201,7 @@
|
| }
|
| isolate->set_library_tag_handler(handler);
|
| library = Library::New(url_str);
|
| + library.set_import_map(mapping_array);
|
| library.Register();
|
| isolate->object_store()->set_root_library(library);
|
| Dart_Handle result;
|
| @@ -2321,7 +2327,9 @@
|
| }
|
|
|
|
|
| -DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) {
|
| +DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
| + Dart_Handle source,
|
| + Dart_Handle import_map) {
|
| TIMERSCOPE(time_script_loading);
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| @@ -2333,9 +2341,14 @@
|
| if (source_str.IsNull()) {
|
| RETURN_TYPE_ERROR(source, String);
|
| }
|
| + const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
|
| + if (mapping_array.IsNull()) {
|
| + RETURN_TYPE_ERROR(import_map, Array);
|
| + }
|
| Library& library = Library::Handle(Library::LookupLibrary(url_str));
|
| if (library.IsNull()) {
|
| library = Library::New(url_str);
|
| + library.set_import_map(mapping_array);
|
| library.Register();
|
| } else if (!library.LoadNotStarted()) {
|
| // The source for this library has either been loaded or is in the
|
|
|