| 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 4967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4978 const intptr_t condition_pos = token_index_; | 4978 const intptr_t condition_pos = token_index_; |
| 4979 if (!FLAG_enable_asserts && !FLAG_enable_type_checks) { | 4979 if (!FLAG_enable_asserts && !FLAG_enable_type_checks) { |
| 4980 SkipExpr(); | 4980 SkipExpr(); |
| 4981 ExpectToken(Token::kRPAREN); | 4981 ExpectToken(Token::kRPAREN); |
| 4982 return NULL; | 4982 return NULL; |
| 4983 } | 4983 } |
| 4984 AstNode* condition = ParseExpr(kAllowConst); | 4984 AstNode* condition = ParseExpr(kAllowConst); |
| 4985 const intptr_t condition_end = token_index_; | 4985 const intptr_t condition_end = token_index_; |
| 4986 ExpectToken(Token::kRPAREN); | 4986 ExpectToken(Token::kRPAREN); |
| 4987 if (condition->IsClosureNode()) { | 4987 if (condition->IsClosureNode()) { |
| 4988 EnsureExpressionTemp(); |
| 4988 // Function literal in assert implies a call. | 4989 // Function literal in assert implies a call. |
| 4989 condition = | 4990 condition = |
| 4990 new ClosureCallNode(condition_pos, | 4991 new ClosureCallNode(condition_pos, |
| 4991 condition, | 4992 condition, |
| 4992 new ArgumentListNode(condition_pos)); | 4993 new ArgumentListNode(condition_pos)); |
| 4993 } | 4994 } |
| 4994 condition = new UnaryOpNode(condition_pos, Token::kNOT, condition); | 4995 condition = new UnaryOpNode(condition_pos, Token::kNOT, condition); |
| 4995 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); | 4996 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); |
| 4996 return new IfNode(condition_pos, | 4997 return new IfNode(condition_pos, |
| 4997 condition, | 4998 condition, |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6273 String::ZoneHandle(Field::GetterName(func_name)); | 6274 String::ZoneHandle(Field::GetterName(func_name)); |
| 6274 const int kNumArguments = 0; // no arguments. | 6275 const int kNumArguments = 0; // no arguments. |
| 6275 const Array& kNoArgumentNames = Array::Handle(); | 6276 const Array& kNoArgumentNames = Array::Handle(); |
| 6276 func = Resolver::ResolveStatic(cls, | 6277 func = Resolver::ResolveStatic(cls, |
| 6277 getter_name, | 6278 getter_name, |
| 6278 kNumArguments, | 6279 kNumArguments, |
| 6279 kNoArgumentNames, | 6280 kNoArgumentNames, |
| 6280 Resolver::kIsQualified); | 6281 Resolver::kIsQualified); |
| 6281 if (!func.IsNull()) { | 6282 if (!func.IsNull()) { |
| 6282 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); | 6283 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
| 6284 EnsureExpressionTemp(); |
| 6283 closure = new StaticGetterNode(call_pos, | 6285 closure = new StaticGetterNode(call_pos, |
| 6284 Class::ZoneHandle(cls.raw()), | 6286 Class::ZoneHandle(cls.raw()), |
| 6285 func_name); | 6287 func_name); |
| 6286 return new ClosureCallNode(call_pos, closure, arguments); | 6288 return new ClosureCallNode(call_pos, closure, arguments); |
| 6287 } | 6289 } |
| 6288 } else { | 6290 } else { |
| 6291 EnsureExpressionTemp(); |
| 6289 closure = GenerateStaticFieldLookup(field, call_pos); | 6292 closure = GenerateStaticFieldLookup(field, call_pos); |
| 6290 return new ClosureCallNode(call_pos, closure, arguments); | 6293 return new ClosureCallNode(call_pos, closure, arguments); |
| 6291 } | 6294 } |
| 6292 // Could not resolve static method: throw an exception if the arguments | 6295 // Could not resolve static method: throw an exception if the arguments |
| 6293 // do not match or compile time error otherwise. | 6296 // do not match or compile time error otherwise. |
| 6294 const Function& test_func = Function::Handle( | 6297 const Function& test_func = Function::Handle( |
| 6295 Resolver::ResolveStaticByName(cls, func_name, Resolver::kIsQualified)); | 6298 Resolver::ResolveStaticByName(cls, func_name, Resolver::kIsQualified)); |
| 6296 if (test_func.IsNull()) { | 6299 if (test_func.IsNull()) { |
| 6297 ErrorMsg(ident_pos, "unresolved static method '%s'", | 6300 ErrorMsg(ident_pos, "unresolved static method '%s'", |
| 6298 func_name.ToCString()); | 6301 func_name.ToCString()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6318 } | 6321 } |
| 6319 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); | 6322 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); |
| 6320 return new InstanceCallNode(call_pos, receiver, func_name, arguments); | 6323 return new InstanceCallNode(call_pos, receiver, func_name, arguments); |
| 6321 } | 6324 } |
| 6322 | 6325 |
| 6323 | 6326 |
| 6324 AstNode* Parser::ParseClosureCall(AstNode* closure) { | 6327 AstNode* Parser::ParseClosureCall(AstNode* closure) { |
| 6325 TRACE_PARSER("ParseClosureCall"); | 6328 TRACE_PARSER("ParseClosureCall"); |
| 6326 const intptr_t call_pos = token_index_; | 6329 const intptr_t call_pos = token_index_; |
| 6327 ASSERT(CurrentToken() == Token::kLPAREN); | 6330 ASSERT(CurrentToken() == Token::kLPAREN); |
| 6331 EnsureExpressionTemp(); |
| 6328 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); | 6332 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); |
| 6329 return new ClosureCallNode(call_pos, closure, arguments); | 6333 return new ClosureCallNode(call_pos, closure, arguments); |
| 6330 } | 6334 } |
| 6331 | 6335 |
| 6332 | 6336 |
| 6333 AstNode* Parser::ParseInstanceFieldAccess(AstNode* receiver, | 6337 AstNode* Parser::ParseInstanceFieldAccess(AstNode* receiver, |
| 6334 const String& field_name) { | 6338 const String& field_name) { |
| 6335 TRACE_PARSER("ParseInstanceFieldAccess"); | 6339 TRACE_PARSER("ParseInstanceFieldAccess"); |
| 6336 AstNode* access = NULL; | 6340 AstNode* access = NULL; |
| 6337 const intptr_t call_pos = token_index_; | 6341 const intptr_t call_pos = token_index_; |
| (...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8475 void Parser::SkipQualIdent() { | 8479 void Parser::SkipQualIdent() { |
| 8476 ASSERT(IsIdentifier()); | 8480 ASSERT(IsIdentifier()); |
| 8477 ConsumeToken(); | 8481 ConsumeToken(); |
| 8478 if (CurrentToken() == Token::kPERIOD) { | 8482 if (CurrentToken() == Token::kPERIOD) { |
| 8479 ConsumeToken(); // Consume the kPERIOD token. | 8483 ConsumeToken(); // Consume the kPERIOD token. |
| 8480 ExpectIdentifier("identifier expected after '.'"); | 8484 ExpectIdentifier("identifier expected after '.'"); |
| 8481 } | 8485 } |
| 8482 } | 8486 } |
| 8483 | 8487 |
| 8484 } // namespace dart | 8488 } // namespace dart |
| OLD | NEW |