| Index: runtime/vm/parser.cc
|
| ===================================================================
|
| --- runtime/vm/parser.cc (revision 7916)
|
| +++ runtime/vm/parser.cc (working copy)
|
| @@ -3530,8 +3530,7 @@
|
|
|
| Dart_Handle Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
|
| intptr_t token_pos,
|
| - const String& url,
|
| - const Array& import_map) {
|
| + const String& url) {
|
| Isolate* isolate = Isolate::Current();
|
| Dart_LibraryTagHandler handler = isolate->library_tag_handler();
|
| if (handler == NULL) {
|
| @@ -3539,8 +3538,7 @@
|
| }
|
| Dart_Handle result = handler(tag,
|
| Api::NewHandle(isolate, library_.raw()),
|
| - Api::NewHandle(isolate, url.raw()),
|
| - Api::NewHandle(isolate, import_map.raw()));
|
| + Api::NewHandle(isolate, url.raw()));
|
| if (Dart_IsError(result)) {
|
| Error& prev_error = Error::Handle();
|
| prev_error ^= Api::UnwrapHandle(result);
|
| @@ -3580,17 +3578,15 @@
|
| }
|
| ExpectToken(Token::kRPAREN);
|
| ExpectToken(Token::kSEMICOLON);
|
| - const Array& import_map = Array::Handle(library_.import_map());
|
| Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl,
|
| import_pos,
|
| - url,
|
| - import_map);
|
| + url);
|
| const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle));
|
| // Lookup the library URL.
|
| Library& library = Library::Handle(Library::LookupLibrary(canon_url));
|
| if (library.IsNull()) {
|
| // Call the library tag handler to load the library.
|
| - CallLibraryTagHandler(kImportTag, import_pos, canon_url, import_map);
|
| + CallLibraryTagHandler(kImportTag, import_pos, canon_url);
|
| // If the library tag handler succeded without registering the
|
| // library we create an empty library to import.
|
| library = Library::LookupLibrary(canon_url);
|
| @@ -3618,7 +3614,6 @@
|
|
|
| void Parser::ParseLibraryInclude() {
|
| TRACE_PARSER("ParseLibraryInclude");
|
| - const Array& import_map = Array::Handle(library_.import_map());
|
| while (CurrentToken() == Token::kSOURCE) {
|
| const intptr_t source_pos = token_index_;
|
| ConsumeToken();
|
| @@ -3631,10 +3626,9 @@
|
| ExpectToken(Token::kSEMICOLON);
|
| Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl,
|
| source_pos,
|
| - url,
|
| - import_map);
|
| + url);
|
| const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle));
|
| - CallLibraryTagHandler(kSourceTag, source_pos, canon_url, import_map);
|
| + CallLibraryTagHandler(kSourceTag, source_pos, canon_url);
|
| }
|
| }
|
|
|
| @@ -7216,9 +7210,20 @@
|
| // when the script is loaded.
|
| RawString* Parser::ResolveImportVar(intptr_t ident_pos, const String& ident) {
|
| TRACE_PARSER("ResolveImportVar");
|
| - String& map_name = String::Handle(library_.LookupImportMap(ident));
|
| - if (!map_name.IsNull()) {
|
| - return map_name.raw();
|
| + const Array& import_map =
|
| + Array::Handle(Isolate::Current()->object_store()->import_map());
|
| + if (!import_map.IsNull()) {
|
| + intptr_t length = import_map.Length();
|
| + intptr_t index = 0;
|
| + String& name = String::Handle();
|
| + while (index < (length - 1)) {
|
| + name ^= import_map.At(index);
|
| + if (name.Equals(ident)) {
|
| + name ^= import_map.At(index + 1);
|
| + return name.raw();
|
| + }
|
| + index += 2;
|
| + }
|
| }
|
| ErrorMsg(ident_pos, "import variable '%s' has not been defined",
|
| ident.ToCString());
|
|
|