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 3311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3322 } | 3322 } |
3323 ExpectToken(Token::kRPAREN); | 3323 ExpectToken(Token::kRPAREN); |
3324 ExpectToken(Token::kSEMICOLON); | 3324 ExpectToken(Token::kSEMICOLON); |
3325 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl, | 3325 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl, |
3326 import_pos, | 3326 import_pos, |
3327 url); | 3327 url); |
3328 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); | 3328 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); |
3329 // Lookup the library URL. | 3329 // Lookup the library URL. |
3330 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); | 3330 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); |
3331 if (library.IsNull()) { | 3331 if (library.IsNull()) { |
3332 // Create a new library object and call the library tag handler. | 3332 // Call the library tag handler to load the library. |
3333 library = Library::New(canon_url); | |
3334 library.Register(); | |
Mads Ager (google)
2012/01/23 11:35:38
I changed the handling of this. Registering an emp
| |
3335 // The tag handler expects the importing library as a parameter. | |
3336 CallLibraryTagHandler(kImportTag, import_pos, canon_url); | 3333 CallLibraryTagHandler(kImportTag, import_pos, canon_url); |
3334 // If the library tag handler succeded without registering the | |
3335 // library we create an empty library to import. | |
3336 library = Library::LookupLibrary(canon_url); | |
3337 if (library.IsNull()) { | |
3338 library = Library::New(canon_url); | |
3339 library.Register(); | |
3340 } | |
3337 } | 3341 } |
3338 // Add the import to the library. | 3342 // Add the import to the library. |
3339 if (prefix.IsNull() || (prefix.Length() == 0)) { | 3343 if (prefix.IsNull() || (prefix.Length() == 0)) { |
3340 library_.AddImport(library); | 3344 library_.AddImport(library); |
3341 } else { | 3345 } else { |
3342 if (library_.LookupLocalObject(prefix) != Object::null()) { | 3346 if (library_.LookupLocalObject(prefix) != Object::null()) { |
3343 ErrorMsg(token_index_, "'%s' is already defined", prefix.ToCString()); | 3347 ErrorMsg(token_index_, "'%s' is already defined", prefix.ToCString()); |
3344 } | 3348 } |
3345 const LibraryPrefix& library_prefix = | 3349 const LibraryPrefix& library_prefix = |
3346 LibraryPrefix::Handle(LibraryPrefix::New(prefix, library)); | 3350 LibraryPrefix::Handle(LibraryPrefix::New(prefix, library)); |
(...skipping 4423 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 |