| 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 11191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11202 } | 11202 } |
| 11203 PrimaryNode* primary = node->AsPrimaryNode(); | 11203 PrimaryNode* primary = node->AsPrimaryNode(); |
| 11204 if (primary->primary().IsString()) { | 11204 if (primary->primary().IsString()) { |
| 11205 if (primary->IsSuper()) { | 11205 if (primary->IsSuper()) { |
| 11206 return primary; | 11206 return primary; |
| 11207 } | 11207 } |
| 11208 // In a static method, evaluation of an unresolved identifier causes a | 11208 // In a static method, evaluation of an unresolved identifier causes a |
| 11209 // NoSuchMethodError to be thrown. | 11209 // NoSuchMethodError to be thrown. |
| 11210 // In an instance method, we convert this into a getter call | 11210 // In an instance method, we convert this into a getter call |
| 11211 // for a field (which may be defined in a subclass.) | 11211 // for a field (which may be defined in a subclass.) |
| 11212 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 11212 const String& name = |
| 11213 String::Cast(Object::ZoneHandle(primary->primary().raw())); |
| 11213 if (current_function().is_static() || | 11214 if (current_function().is_static() || |
| 11214 current_function().IsInFactoryScope()) { | 11215 current_function().IsInFactoryScope()) { |
| 11215 StaticGetterNode* getter = new(Z) StaticGetterNode( | 11216 StaticGetterNode* getter = new(Z) StaticGetterNode( |
| 11216 primary->token_pos(), | 11217 primary->token_pos(), |
| 11217 NULL, // No receiver. | 11218 NULL, // No receiver. |
| 11218 Class::ZoneHandle(Z, current_class().raw()), | 11219 Class::ZoneHandle(Z, current_class().raw()), |
| 11219 name); | 11220 name); |
| 11220 getter->set_is_deferred(primary->is_deferred_reference()); | 11221 getter->set_is_deferred(primary->is_deferred_reference()); |
| 11221 return getter; | 11222 return getter; |
| 11222 } else { | 11223 } else { |
| 11223 AstNode* receiver = LoadReceiver(primary->token_pos()); | 11224 AstNode* receiver = LoadReceiver(primary->token_pos()); |
| 11224 return CallGetter(node->token_pos(), receiver, name); | 11225 return CallGetter(node->token_pos(), receiver, name); |
| 11225 } | 11226 } |
| 11226 } | 11227 } |
| 11227 return primary; | 11228 return primary; |
| 11228 } | 11229 } |
| 11229 | 11230 |
| 11230 | 11231 |
| 11231 AstNode* Parser::LoadClosure(PrimaryNode* primary) { | 11232 AstNode* Parser::LoadClosure(PrimaryNode* primary) { |
| 11232 ASSERT(primary->primary().IsFunction()); | 11233 ASSERT(primary->primary().IsFunction()); |
| 11233 const Function& func = | 11234 const Function& func = |
| 11234 Function::CheckedZoneHandle(primary->primary().raw()); | 11235 Function::Cast(Object::ZoneHandle(primary->primary().raw())); |
| 11235 const String& funcname = String::ZoneHandle(Z, func.name()); | 11236 const String& funcname = String::ZoneHandle(Z, func.name()); |
| 11236 if (func.is_static()) { | 11237 if (func.is_static()) { |
| 11237 // Static function access. | 11238 // Static function access. |
| 11238 ClosureNode* closure = | 11239 ClosureNode* closure = |
| 11239 CreateImplicitClosureNode(func, primary->token_pos(), NULL); | 11240 CreateImplicitClosureNode(func, primary->token_pos(), NULL); |
| 11240 closure->set_is_deferred(primary->is_deferred_reference()); | 11241 closure->set_is_deferred(primary->is_deferred_reference()); |
| 11241 return closure; | 11242 return closure; |
| 11242 } else { | 11243 } else { |
| 11243 // Instance function access. | 11244 // Instance function access. |
| 11244 if (current_function().is_static() || | 11245 if (current_function().is_static() || |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11413 selector = ParseInstanceCall(LoadReceiver(primary_pos), | 11414 selector = ParseInstanceCall(LoadReceiver(primary_pos), |
| 11414 func_name, | 11415 func_name, |
| 11415 primary_pos, | 11416 primary_pos, |
| 11416 false /* is_conditional */); | 11417 false /* is_conditional */); |
| 11417 } | 11418 } |
| 11418 } else if (primary_node->primary().IsString()) { | 11419 } else if (primary_node->primary().IsString()) { |
| 11419 // Primary is an unresolved name. | 11420 // Primary is an unresolved name. |
| 11420 if (primary_node->IsSuper()) { | 11421 if (primary_node->IsSuper()) { |
| 11421 ReportError(primary_pos, "illegal use of super"); | 11422 ReportError(primary_pos, "illegal use of super"); |
| 11422 } | 11423 } |
| 11423 String& name = | 11424 const String& name = |
| 11424 String::CheckedZoneHandle(primary_node->primary().raw()); | 11425 String::Cast(Object::ZoneHandle(primary_node->primary().raw())); |
| 11425 if (current_function().is_static()) { | 11426 if (current_function().is_static()) { |
| 11426 // The static call will be converted to throwing a NSM error. | 11427 // The static call will be converted to throwing a NSM error. |
| 11427 selector = ParseStaticCall(current_class(), name, primary_pos); | 11428 selector = ParseStaticCall(current_class(), name, primary_pos); |
| 11428 } else { | 11429 } else { |
| 11429 // Treat as call to unresolved (instance) method. | 11430 // Treat as call to unresolved (instance) method. |
| 11430 selector = ParseInstanceCall(LoadReceiver(primary_pos), | 11431 selector = ParseInstanceCall(LoadReceiver(primary_pos), |
| 11431 name, | 11432 name, |
| 11432 primary_pos, | 11433 primary_pos, |
| 11433 false /* is_conditional */); | 11434 false /* is_conditional */); |
| 11434 } | 11435 } |
| (...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14282 void Parser::SkipQualIdent() { | 14283 void Parser::SkipQualIdent() { |
| 14283 ASSERT(IsIdentifier()); | 14284 ASSERT(IsIdentifier()); |
| 14284 ConsumeToken(); | 14285 ConsumeToken(); |
| 14285 if (CurrentToken() == Token::kPERIOD) { | 14286 if (CurrentToken() == Token::kPERIOD) { |
| 14286 ConsumeToken(); // Consume the kPERIOD token. | 14287 ConsumeToken(); // Consume the kPERIOD token. |
| 14287 ExpectIdentifier("identifier expected after '.'"); | 14288 ExpectIdentifier("identifier expected after '.'"); |
| 14288 } | 14289 } |
| 14289 } | 14290 } |
| 14290 | 14291 |
| 14291 } // namespace dart | 14292 } // namespace dart |
| OLD | NEW |