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 5145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5156 } | 5156 } |
5157 if (hide_list.Length() > 0) { | 5157 if (hide_list.Length() > 0) { |
5158 hide_names = Array::MakeArray(hide_list); | 5158 hide_names = Array::MakeArray(hide_list); |
5159 } | 5159 } |
5160 } | 5160 } |
5161 ExpectSemicolon(); | 5161 ExpectSemicolon(); |
5162 | 5162 |
5163 // Canonicalize library URL. | 5163 // Canonicalize library URL. |
5164 const String& canon_url = String::CheckedHandle( | 5164 const String& canon_url = String::CheckedHandle( |
5165 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url)); | 5165 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url)); |
5166 // Lookup the library URL. | 5166 |
5167 Library& library = Library::Handle(isolate(), | 5167 // Create a new library if it does not exist yet. |
5168 Library::LookupLibrary(canon_url)); | 5168 Library& library = |
| 5169 Library::Handle(isolate(), Library::LookupLibrary(canon_url)); |
5169 if (library.IsNull()) { | 5170 if (library.IsNull()) { |
5170 // Create an empty library to mark that we have initiated loading of this | |
5171 // library. | |
5172 library = Library::New(canon_url); | 5171 library = Library::New(canon_url); |
5173 library.Register(); | 5172 library.Register(); |
5174 // Call the library tag handler to load the library. | 5173 } |
5175 // TODO(hausner): do not load eagerly if import is deferred. | 5174 |
| 5175 // If loading hasn't been requested yet, and if this is not a deferred |
| 5176 // library import, call the library tag handler to request loading |
| 5177 // the library. |
| 5178 if (library.LoadNotStarted() && !is_deferred_import) { |
| 5179 library.SetLoadRequested(); |
5176 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); | 5180 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); |
5177 } | 5181 } |
5178 | 5182 |
5179 Namespace& ns = Namespace::Handle(isolate(), | 5183 Namespace& ns = Namespace::Handle(isolate(), |
5180 Namespace::New(library, show_names, hide_names)); | 5184 Namespace::New(library, show_names, hide_names)); |
5181 if (metadata_pos >= 0) { | 5185 if (metadata_pos >= 0) { |
5182 ns.AddMetadata(metadata_pos, current_class()); | 5186 ns.AddMetadata(metadata_pos, current_class()); |
5183 } | 5187 } |
5184 | 5188 |
5185 if (is_import) { | 5189 if (is_import) { |
(...skipping 16 matching lines...) Expand all Loading... |
5202 if (!is_deferred_import && library_prefix.is_deferred_load()) { | 5206 if (!is_deferred_import && library_prefix.is_deferred_load()) { |
5203 ErrorMsg(prefix_pos, | 5207 ErrorMsg(prefix_pos, |
5204 "prefix '%s' already used in a deferred import clause", | 5208 "prefix '%s' already used in a deferred import clause", |
5205 prefix.ToCString()); | 5209 prefix.ToCString()); |
5206 } | 5210 } |
5207 if (is_deferred_import) { | 5211 if (is_deferred_import) { |
5208 ErrorMsg(prefix_pos, "prefix of deferred import must be uniqe"); | 5212 ErrorMsg(prefix_pos, "prefix of deferred import must be uniqe"); |
5209 } | 5213 } |
5210 library_prefix.AddImport(ns); | 5214 library_prefix.AddImport(ns); |
5211 } else { | 5215 } else { |
5212 library_prefix = LibraryPrefix::New(prefix, ns, is_deferred_import); | 5216 library_prefix = |
| 5217 LibraryPrefix::New(prefix, ns, is_deferred_import, library_); |
5213 library_.AddObject(library_prefix, prefix); | 5218 library_.AddObject(library_prefix, prefix); |
5214 } | 5219 } |
5215 } | 5220 } |
5216 } else { | 5221 } else { |
5217 ASSERT(is_export); | 5222 ASSERT(is_export); |
5218 library_.AddExport(ns); | 5223 library_.AddExport(ns); |
5219 } | 5224 } |
5220 } | 5225 } |
5221 | 5226 |
5222 | 5227 |
(...skipping 5856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11079 void Parser::SkipQualIdent() { | 11084 void Parser::SkipQualIdent() { |
11080 ASSERT(IsIdentifier()); | 11085 ASSERT(IsIdentifier()); |
11081 ConsumeToken(); | 11086 ConsumeToken(); |
11082 if (CurrentToken() == Token::kPERIOD) { | 11087 if (CurrentToken() == Token::kPERIOD) { |
11083 ConsumeToken(); // Consume the kPERIOD token. | 11088 ConsumeToken(); // Consume the kPERIOD token. |
11084 ExpectIdentifier("identifier expected after '.'"); | 11089 ExpectIdentifier("identifier expected after '.'"); |
11085 } | 11090 } |
11086 } | 11091 } |
11087 | 11092 |
11088 } // namespace dart | 11093 } // namespace dart |
OLD | NEW |