| 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 4969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4980 } else if ((CurrentToken() == Token::kDOUBLE) && | 4980 } else if ((CurrentToken() == Token::kDOUBLE) && |
| 4981 (no_check || type.IsDoubleType() || type.IsNumberType())) { | 4981 (no_check || type.IsDoubleType() || type.IsNumberType())) { |
| 4982 *value = CurrentDoubleLiteral(); | 4982 *value = CurrentDoubleLiteral(); |
| 4983 return true; | 4983 return true; |
| 4984 } else if ((CurrentToken() == Token::kSTRING) && | 4984 } else if ((CurrentToken() == Token::kSTRING) && |
| 4985 (no_check || type.IsStringType())) { | 4985 (no_check || type.IsStringType())) { |
| 4986 *value = CurrentLiteral()->raw(); | 4986 *value = CurrentLiteral()->raw(); |
| 4987 return true; | 4987 return true; |
| 4988 } else if ((CurrentToken() == Token::kTRUE) && | 4988 } else if ((CurrentToken() == Token::kTRUE) && |
| 4989 (no_check || type.IsBoolType())) { | 4989 (no_check || type.IsBoolType())) { |
| 4990 *value = Bool::True(); | 4990 *value = Bool::True().raw(); |
| 4991 return true; | 4991 return true; |
| 4992 } else if ((CurrentToken() == Token::kFALSE) && | 4992 } else if ((CurrentToken() == Token::kFALSE) && |
| 4993 (no_check || type.IsBoolType())) { | 4993 (no_check || type.IsBoolType())) { |
| 4994 *value = Bool::False(); | 4994 *value = Bool::False().raw(); |
| 4995 return true; | 4995 return true; |
| 4996 } else if (CurrentToken() == Token::kNULL) { | 4996 } else if (CurrentToken() == Token::kNULL) { |
| 4997 *value = Instance::null(); | 4997 *value = Instance::null(); |
| 4998 return true; | 4998 return true; |
| 4999 } | 4999 } |
| 5000 return false; | 5000 return false; |
| 5001 } | 5001 } |
| 5002 | 5002 |
| 5003 | 5003 |
| 5004 // Returns true if the current token is kIDENT or a pseudo-keyword. | 5004 // Returns true if the current token is kIDENT or a pseudo-keyword. |
| (...skipping 4212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9217 String* ident = ExpectIdentifier("parameter name expected"); | 9217 String* ident = ExpectIdentifier("parameter name expected"); |
| 9218 Function& owner_function = Function::Handle(); | 9218 Function& owner_function = Function::Handle(); |
| 9219 LocalScope* owner_scope; | 9219 LocalScope* owner_scope; |
| 9220 intptr_t param_index; | 9220 intptr_t param_index; |
| 9221 if (!IsFormalParameter(*ident, &owner_function, &owner_scope, ¶m_index)) { | 9221 if (!IsFormalParameter(*ident, &owner_function, &owner_scope, ¶m_index)) { |
| 9222 ErrorMsg(ident_pos, "formal parameter name expected"); | 9222 ErrorMsg(ident_pos, "formal parameter name expected"); |
| 9223 } | 9223 } |
| 9224 if (param_index < owner_function.num_fixed_parameters()) { | 9224 if (param_index < owner_function.num_fixed_parameters()) { |
| 9225 // The formal parameter is not optional, therefore the corresponding | 9225 // The formal parameter is not optional, therefore the corresponding |
| 9226 // argument is always passed and defined. | 9226 // argument is always passed and defined. |
| 9227 return new LiteralNode(test_pos, Bool::ZoneHandle(Bool::True())); | 9227 return new LiteralNode(test_pos, Bool::True()); |
| 9228 } | 9228 } |
| 9229 char name[64]; | 9229 char name[64]; |
| 9230 OS::SNPrint(name, 64, "%s_%"Pd"", | 9230 OS::SNPrint(name, 64, "%s_%"Pd"", |
| 9231 Symbols::Name(Symbols::kSavedArgDescVarPrefixId), | 9231 Symbols::Name(Symbols::kSavedArgDescVarPrefixId), |
| 9232 owner_function.token_pos()); | 9232 owner_function.token_pos()); |
| 9233 const String& saved_args_desc_name = String::ZoneHandle(Symbols::New(name)); | 9233 const String& saved_args_desc_name = String::ZoneHandle(Symbols::New(name)); |
| 9234 LocalVariable* saved_args_desc_var = LookupLocalScope(saved_args_desc_name); | 9234 LocalVariable* saved_args_desc_var = LookupLocalScope(saved_args_desc_name); |
| 9235 if (saved_args_desc_var == NULL) { | 9235 if (saved_args_desc_var == NULL) { |
| 9236 ASSERT(owner_scope != NULL); | 9236 ASSERT(owner_scope != NULL); |
| 9237 saved_args_desc_var = | 9237 saved_args_desc_var = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9311 if (local == NULL) { | 9311 if (local == NULL) { |
| 9312 ErrorMsg("receiver 'this' is not in scope"); | 9312 ErrorMsg("receiver 'this' is not in scope"); |
| 9313 } | 9313 } |
| 9314 primary = new LoadLocalNode(TokenPos(), local); | 9314 primary = new LoadLocalNode(TokenPos(), local); |
| 9315 ConsumeToken(); | 9315 ConsumeToken(); |
| 9316 } else if (CurrentToken() == Token::kINTEGER) { | 9316 } else if (CurrentToken() == Token::kINTEGER) { |
| 9317 const Integer& literal = Integer::ZoneHandle(CurrentIntegerLiteral()); | 9317 const Integer& literal = Integer::ZoneHandle(CurrentIntegerLiteral()); |
| 9318 primary = new LiteralNode(TokenPos(), literal); | 9318 primary = new LiteralNode(TokenPos(), literal); |
| 9319 ConsumeToken(); | 9319 ConsumeToken(); |
| 9320 } else if (CurrentToken() == Token::kTRUE) { | 9320 } else if (CurrentToken() == Token::kTRUE) { |
| 9321 primary = new LiteralNode(TokenPos(), Bool::ZoneHandle(Bool::True())); | 9321 primary = new LiteralNode(TokenPos(), Bool::True()); |
| 9322 ConsumeToken(); | 9322 ConsumeToken(); |
| 9323 } else if (CurrentToken() == Token::kFALSE) { | 9323 } else if (CurrentToken() == Token::kFALSE) { |
| 9324 primary = new LiteralNode(TokenPos(), Bool::ZoneHandle(Bool::False())); | 9324 primary = new LiteralNode(TokenPos(), Bool::False()); |
| 9325 ConsumeToken(); | 9325 ConsumeToken(); |
| 9326 } else if (CurrentToken() == Token::kNULL) { | 9326 } else if (CurrentToken() == Token::kNULL) { |
| 9327 primary = new LiteralNode(TokenPos(), Instance::ZoneHandle()); | 9327 primary = new LiteralNode(TokenPos(), Instance::ZoneHandle()); |
| 9328 ConsumeToken(); | 9328 ConsumeToken(); |
| 9329 } else if (CurrentToken() == Token::kLPAREN) { | 9329 } else if (CurrentToken() == Token::kLPAREN) { |
| 9330 ConsumeToken(); | 9330 ConsumeToken(); |
| 9331 const bool saved_mode = SetAllowFunctionLiterals(true); | 9331 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 9332 primary = ParseExpr(kAllowConst, kConsumeCascades); | 9332 primary = ParseExpr(kAllowConst, kConsumeCascades); |
| 9333 SetAllowFunctionLiterals(saved_mode); | 9333 SetAllowFunctionLiterals(saved_mode); |
| 9334 ExpectToken(Token::kRPAREN); | 9334 ExpectToken(Token::kRPAREN); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9698 void Parser::SkipQualIdent() { | 9698 void Parser::SkipQualIdent() { |
| 9699 ASSERT(IsIdentifier()); | 9699 ASSERT(IsIdentifier()); |
| 9700 ConsumeToken(); | 9700 ConsumeToken(); |
| 9701 if (CurrentToken() == Token::kPERIOD) { | 9701 if (CurrentToken() == Token::kPERIOD) { |
| 9702 ConsumeToken(); // Consume the kPERIOD token. | 9702 ConsumeToken(); // Consume the kPERIOD token. |
| 9703 ExpectIdentifier("identifier expected after '.'"); | 9703 ExpectIdentifier("identifier expected after '.'"); |
| 9704 } | 9704 } |
| 9705 } | 9705 } |
| 9706 | 9706 |
| 9707 } // namespace dart | 9707 } // namespace dart |
| OLD | NEW |