OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 5138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5149 } | 5149 } |
5150 if (hide_list.Length() > 0) { | 5150 if (hide_list.Length() > 0) { |
5151 hide_names = Array::MakeArray(hide_list); | 5151 hide_names = Array::MakeArray(hide_list); |
5152 } | 5152 } |
5153 } | 5153 } |
5154 ExpectSemicolon(); | 5154 ExpectSemicolon(); |
5155 | 5155 |
5156 // Canonicalize library URL. | 5156 // Canonicalize library URL. |
5157 const String& canon_url = String::CheckedHandle( | 5157 const String& canon_url = String::CheckedHandle( |
5158 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url)); | 5158 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url)); |
5159 // Lookup the library URL. | 5159 |
5160 Library& library = Library::Handle(isolate(), | 5160 // Create a new library if it does not exist yet. |
5161 Library::LookupLibrary(canon_url)); | 5161 Library& library = |
| 5162 Library::Handle(isolate(), Library::LookupLibrary(canon_url)); |
5162 if (library.IsNull()) { | 5163 if (library.IsNull()) { |
5163 // Create an empty library to mark that we have initiated loading of this | |
5164 // library. | |
5165 library = Library::New(canon_url); | 5164 library = Library::New(canon_url); |
5166 library.Register(); | 5165 library.Register(); |
5167 // Call the library tag handler to load the library. | 5166 } |
5168 // TODO(hausner): do not load eagerly if import is deferred. | 5167 |
| 5168 // If loading hasn't been requested yet, and if this is not a deferred |
| 5169 // library import, call the library tag handler to request loading |
| 5170 // the library. |
| 5171 if (library.LoadNotStarted() && !is_deferred_import) { |
| 5172 library.SetLoadRequested(); |
5169 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); | 5173 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); |
5170 } | 5174 } |
5171 | 5175 |
5172 Namespace& ns = Namespace::Handle(isolate(), | 5176 Namespace& ns = Namespace::Handle(isolate(), |
5173 Namespace::New(library, show_names, hide_names)); | 5177 Namespace::New(library, show_names, hide_names)); |
5174 if (metadata_pos >= 0) { | 5178 if (metadata_pos >= 0) { |
5175 ns.AddMetadata(metadata_pos, current_class()); | 5179 ns.AddMetadata(metadata_pos, current_class()); |
5176 } | 5180 } |
5177 | 5181 |
5178 if (is_import) { | 5182 if (is_import) { |
(...skipping 16 matching lines...) Expand all Loading... |
5195 if (!is_deferred_import && library_prefix.is_deferred_load()) { | 5199 if (!is_deferred_import && library_prefix.is_deferred_load()) { |
5196 ErrorMsg(prefix_pos, | 5200 ErrorMsg(prefix_pos, |
5197 "prefix '%s' already used in a deferred import clause", | 5201 "prefix '%s' already used in a deferred import clause", |
5198 prefix.ToCString()); | 5202 prefix.ToCString()); |
5199 } | 5203 } |
5200 if (is_deferred_import) { | 5204 if (is_deferred_import) { |
5201 ErrorMsg(prefix_pos, "prefix of deferred import must be uniqe"); | 5205 ErrorMsg(prefix_pos, "prefix of deferred import must be uniqe"); |
5202 } | 5206 } |
5203 library_prefix.AddImport(ns); | 5207 library_prefix.AddImport(ns); |
5204 } else { | 5208 } else { |
5205 library_prefix = LibraryPrefix::New(prefix, ns, is_deferred_import); | 5209 library_prefix = |
| 5210 LibraryPrefix::New(prefix, ns, is_deferred_import, library_); |
5206 library_.AddObject(library_prefix, prefix); | 5211 library_.AddObject(library_prefix, prefix); |
5207 } | 5212 } |
5208 } | 5213 } |
5209 } else { | 5214 } else { |
5210 ASSERT(is_export); | 5215 ASSERT(is_export); |
5211 library_.AddExport(ns); | 5216 library_.AddExport(ns); |
5212 } | 5217 } |
5213 } | 5218 } |
5214 | 5219 |
5215 | 5220 |
(...skipping 5850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11066 void Parser::SkipQualIdent() { | 11071 void Parser::SkipQualIdent() { |
11067 ASSERT(IsIdentifier()); | 11072 ASSERT(IsIdentifier()); |
11068 ConsumeToken(); | 11073 ConsumeToken(); |
11069 if (CurrentToken() == Token::kPERIOD) { | 11074 if (CurrentToken() == Token::kPERIOD) { |
11070 ConsumeToken(); // Consume the kPERIOD token. | 11075 ConsumeToken(); // Consume the kPERIOD token. |
11071 ExpectIdentifier("identifier expected after '.'"); | 11076 ExpectIdentifier("identifier expected after '.'"); |
11072 } | 11077 } |
11073 } | 11078 } |
11074 | 11079 |
11075 } // namespace dart | 11080 } // namespace dart |
OLD | NEW |