| 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 3924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 | 3935 |
| 3936 AstNode* Parser::LoadReceiver(intptr_t token_pos) { | 3936 AstNode* Parser::LoadReceiver(intptr_t token_pos) { |
| 3937 // A nested function may access 'this', referring to the receiver of the | 3937 // A nested function may access 'this', referring to the receiver of the |
| 3938 // outermost enclosing function. | 3938 // outermost enclosing function. |
| 3939 // We should not be loading the receiver from a static scope. | 3939 // We should not be loading the receiver from a static scope. |
| 3940 ASSERT(!current_function().is_static() || | 3940 ASSERT(!current_function().is_static() || |
| 3941 current_function().IsInFactoryScope()); | 3941 current_function().IsInFactoryScope()); |
| 3942 const bool kTestOnly = false; | 3942 const bool kTestOnly = false; |
| 3943 LocalVariable* receiver = LookupReceiver(current_block_->scope, kTestOnly); | 3943 LocalVariable* receiver = LookupReceiver(current_block_->scope, kTestOnly); |
| 3944 if (receiver == NULL) { | 3944 if (receiver == NULL) { |
| 3945 ErrorMsg(token_pos, "illegal access to 'this'"); | 3945 ErrorMsg(token_pos, "illegal implicit access to receiver 'this'"); |
| 3946 } | 3946 } |
| 3947 return new LoadLocalNode(token_index_, *receiver); | 3947 return new LoadLocalNode(token_index_, *receiver); |
| 3948 } | 3948 } |
| 3949 | 3949 |
| 3950 | 3950 |
| 3951 AstNode* Parser::CallGetter(intptr_t token_index, | 3951 AstNode* Parser::CallGetter(intptr_t token_index, |
| 3952 AstNode* object, | 3952 AstNode* object, |
| 3953 const String& name) { | 3953 const String& name) { |
| 3954 return new InstanceGetterNode(token_index_, object, name); | 3954 return new InstanceGetterNode(token_index_, object, name); |
| 3955 } | 3955 } |
| (...skipping 4200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8156 // the identifier locally in that library (we do not include the | 8156 // the identifier locally in that library (we do not include the |
| 8157 // libraries imported by that library). | 8157 // libraries imported by that library). |
| 8158 primary = ResolveIdentInLibraryPrefixScope(*(qual_ident.lib_prefix), | 8158 primary = ResolveIdentInLibraryPrefixScope(*(qual_ident.lib_prefix), |
| 8159 qual_ident); | 8159 qual_ident); |
| 8160 } | 8160 } |
| 8161 ASSERT(primary != NULL); | 8161 ASSERT(primary != NULL); |
| 8162 } else if (CurrentToken() == Token::kTHIS) { | 8162 } else if (CurrentToken() == Token::kTHIS) { |
| 8163 const String& this_name = String::Handle(String::NewSymbol(kThisName)); | 8163 const String& this_name = String::Handle(String::NewSymbol(kThisName)); |
| 8164 LocalVariable* local = LookupLocalScope(this_name); | 8164 LocalVariable* local = LookupLocalScope(this_name); |
| 8165 if (local == NULL) { | 8165 if (local == NULL) { |
| 8166 ErrorMsg("unexpected use of 'this' in primary expression"); | 8166 ErrorMsg("receiver 'this' is not in scope"); |
| 8167 } | 8167 } |
| 8168 primary = new LoadLocalNode(token_index_, *local); | 8168 primary = new LoadLocalNode(token_index_, *local); |
| 8169 ConsumeToken(); | 8169 ConsumeToken(); |
| 8170 } else if (CurrentToken() == Token::kINTEGER) { | 8170 } else if (CurrentToken() == Token::kINTEGER) { |
| 8171 const Integer& literal = Integer::ZoneHandle(CurrentIntegerLiteral()); | 8171 const Integer& literal = Integer::ZoneHandle(CurrentIntegerLiteral()); |
| 8172 primary = new LiteralNode(token_index_, literal); | 8172 primary = new LiteralNode(token_index_, literal); |
| 8173 ConsumeToken(); | 8173 ConsumeToken(); |
| 8174 } else if (CurrentToken() == Token::kTRUE) { | 8174 } else if (CurrentToken() == Token::kTRUE) { |
| 8175 primary = new LiteralNode(token_index_, Bool::ZoneHandle(Bool::True())); | 8175 primary = new LiteralNode(token_index_, Bool::ZoneHandle(Bool::True())); |
| 8176 ConsumeToken(); | 8176 ConsumeToken(); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8516 void Parser::SkipQualIdent() { | 8516 void Parser::SkipQualIdent() { |
| 8517 ASSERT(IsIdentifier()); | 8517 ASSERT(IsIdentifier()); |
| 8518 ConsumeToken(); | 8518 ConsumeToken(); |
| 8519 if (CurrentToken() == Token::kPERIOD) { | 8519 if (CurrentToken() == Token::kPERIOD) { |
| 8520 ConsumeToken(); // Consume the kPERIOD token. | 8520 ConsumeToken(); // Consume the kPERIOD token. |
| 8521 ExpectIdentifier("identifier expected after '.'"); | 8521 ExpectIdentifier("identifier expected after '.'"); |
| 8522 } | 8522 } |
| 8523 } | 8523 } |
| 8524 | 8524 |
| 8525 } // namespace dart | 8525 } // namespace dart |
| OLD | NEW |