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/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 11608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11619 if (current_block_ != NULL) { | 11619 if (current_block_ != NULL) { |
11620 current_block_->scope->AddReferencedName(ident_pos, ident); | 11620 current_block_->scope->AddReferencedName(ident_pos, ident); |
11621 } | 11621 } |
11622 if (local != NULL) { | 11622 if (local != NULL) { |
11623 if (node != NULL) { | 11623 if (node != NULL) { |
11624 *node = new(Z) LoadLocalNode(ident_pos, local); | 11624 *node = new(Z) LoadLocalNode(ident_pos, local); |
11625 } | 11625 } |
11626 return true; | 11626 return true; |
11627 } | 11627 } |
11628 | 11628 |
| 11629 // If we are compiling top-level code, we don't need to look for |
| 11630 // the identifier in the current (top-level) class. The class scope |
| 11631 // of the top-level class is part of the library scope. |
| 11632 if (current_class().IsTopLevel()) { |
| 11633 if (node != NULL) { |
| 11634 *node = NULL; |
| 11635 } |
| 11636 return false; |
| 11637 } |
| 11638 |
11629 // Try to find the identifier in the class scope of the current class. | 11639 // Try to find the identifier in the class scope of the current class. |
11630 // If the current class is the result of a mixin application, we must | 11640 // If the current class is the result of a mixin application, we must |
11631 // use the class scope of the class from which the function originates. | 11641 // use the class scope of the class from which the function originates. |
11632 Class& cls = Class::Handle(Z); | 11642 Class& cls = Class::Handle(Z); |
11633 if (!current_class().IsMixinApplication()) { | 11643 if (!current_class().IsMixinApplication()) { |
11634 cls = current_class().raw(); | 11644 cls = current_class().raw(); |
11635 } else { | 11645 } else { |
11636 cls = parsed_function()->function().origin(); | 11646 cls = parsed_function()->function().origin(); |
11637 } | 11647 } |
11638 Function& func = Function::Handle(Z, Function::null()); | 11648 Function& func = Function::Handle(Z, Function::null()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11707 ident); | 11717 ident); |
11708 } | 11718 } |
11709 return true; | 11719 return true; |
11710 } | 11720 } |
11711 } | 11721 } |
11712 | 11722 |
11713 // Nothing found in scope of current class. | 11723 // Nothing found in scope of current class. |
11714 if (node != NULL) { | 11724 if (node != NULL) { |
11715 *node = NULL; | 11725 *node = NULL; |
11716 } | 11726 } |
11717 return false; // Not an unqualified identifier. | 11727 return false; |
11718 } | 11728 } |
11719 | 11729 |
11720 | 11730 |
11721 RawClass* Parser::ResolveClassInCurrentLibraryScope(const String& name) { | 11731 RawClass* Parser::ResolveClassInCurrentLibraryScope(const String& name) { |
11722 HANDLESCOPE(I); | 11732 HANDLESCOPE(I); |
11723 const Object& obj = Object::Handle(Z, library_.ResolveName(name)); | 11733 const Object& obj = Object::Handle(Z, library_.ResolveName(name)); |
11724 if (obj.IsClass()) { | 11734 if (obj.IsClass()) { |
11725 return Class::Cast(obj).raw(); | 11735 return Class::Cast(obj).raw(); |
11726 } | 11736 } |
11727 return Class::null(); | 11737 return Class::null(); |
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13502 void Parser::SkipQualIdent() { | 13512 void Parser::SkipQualIdent() { |
13503 ASSERT(IsIdentifier()); | 13513 ASSERT(IsIdentifier()); |
13504 ConsumeToken(); | 13514 ConsumeToken(); |
13505 if (CurrentToken() == Token::kPERIOD) { | 13515 if (CurrentToken() == Token::kPERIOD) { |
13506 ConsumeToken(); // Consume the kPERIOD token. | 13516 ConsumeToken(); // Consume the kPERIOD token. |
13507 ExpectIdentifier("identifier expected after '.'"); | 13517 ExpectIdentifier("identifier expected after '.'"); |
13508 } | 13518 } |
13509 } | 13519 } |
13510 | 13520 |
13511 } // namespace dart | 13521 } // namespace dart |
OLD | NEW |