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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 3302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3313 } | 3313 } |
3314 ExpectToken(Token::kRPAREN); | 3314 ExpectToken(Token::kRPAREN); |
3315 ExpectToken(Token::kSEMICOLON); | 3315 ExpectToken(Token::kSEMICOLON); |
3316 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl, | 3316 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl, |
3317 import_pos, | 3317 import_pos, |
3318 url); | 3318 url); |
3319 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); | 3319 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); |
3320 // Lookup the library URL. | 3320 // Lookup the library URL. |
3321 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); | 3321 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); |
3322 if (library.IsNull()) { | 3322 if (library.IsNull()) { |
3323 // Create a new library object and call the library tag handler. | 3323 // Call the library tag handler to load the library. |
3324 library = Library::New(canon_url); | |
3325 library.Register(); | |
3326 // The tag handler expects the importing library as a parameter. | |
3327 CallLibraryTagHandler(kImportTag, import_pos, canon_url); | 3324 CallLibraryTagHandler(kImportTag, import_pos, canon_url); |
| 3325 // If the library tag handler succeded without registering the |
| 3326 // library we create an empty library to import. |
| 3327 library = Library::LookupLibrary(canon_url); |
| 3328 if (library.IsNull()) { |
| 3329 library = Library::New(canon_url); |
| 3330 library.Register(); |
| 3331 } |
3328 } | 3332 } |
3329 // Add the import to the library. | 3333 // Add the import to the library. |
3330 if (prefix.IsNull() || (prefix.Length() == 0)) { | 3334 if (prefix.IsNull() || (prefix.Length() == 0)) { |
3331 library_.AddImport(library); | 3335 library_.AddImport(library); |
3332 } else { | 3336 } else { |
3333 if (library_.LookupLocalObject(prefix) != Object::null()) { | 3337 if (library_.LookupLocalObject(prefix) != Object::null()) { |
3334 ErrorMsg(token_index_, "'%s' is already defined", prefix.ToCString()); | 3338 ErrorMsg(token_index_, "'%s' is already defined", prefix.ToCString()); |
3335 } | 3339 } |
3336 const LibraryPrefix& library_prefix = | 3340 const LibraryPrefix& library_prefix = |
3337 LibraryPrefix::Handle(LibraryPrefix::New(prefix, library)); | 3341 LibraryPrefix::Handle(LibraryPrefix::New(prefix, library)); |
(...skipping 4432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7770 void Parser::SkipQualIdent() { | 7774 void Parser::SkipQualIdent() { |
7771 ASSERT(IsIdentifier()); | 7775 ASSERT(IsIdentifier()); |
7772 ConsumeToken(); | 7776 ConsumeToken(); |
7773 if (CurrentToken() == Token::kPERIOD) { | 7777 if (CurrentToken() == Token::kPERIOD) { |
7774 ConsumeToken(); // Consume the kPERIOD token. | 7778 ConsumeToken(); // Consume the kPERIOD token. |
7775 ExpectIdentifier("identifier expected after '.'"); | 7779 ExpectIdentifier("identifier expected after '.'"); |
7776 } | 7780 } |
7777 } | 7781 } |
7778 | 7782 |
7779 } // namespace dart | 7783 } // namespace dart |
OLD | NEW |