| 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 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 } else { | 2394 } else { |
| 2395 // The type can only be already set in the factory case. | 2395 // The type can only be already set in the factory case. |
| 2396 if (!member.has_factory) { | 2396 if (!member.has_factory) { |
| 2397 ErrorMsg(member.name_pos, "constructor must not specify return type"); | 2397 ErrorMsg(member.name_pos, "constructor must not specify return type"); |
| 2398 } | 2398 } |
| 2399 } | 2399 } |
| 2400 if (CurrentToken() != Token::kLPAREN) { | 2400 if (CurrentToken() != Token::kLPAREN) { |
| 2401 ErrorMsg("left parenthesis expected"); | 2401 ErrorMsg("left parenthesis expected"); |
| 2402 } | 2402 } |
| 2403 } else if ((CurrentToken() == Token::kGET) && | 2403 } else if ((CurrentToken() == Token::kGET) && |
| 2404 (LookaheadToken(1) != Token::kLPAREN) && !member.has_var) { | 2404 (LookaheadToken(1) != Token::kLPAREN) && |
| 2405 !member.has_var && !member.has_final) { |
| 2405 ConsumeToken(); | 2406 ConsumeToken(); |
| 2406 member.kind = RawFunction::kGetterFunction; | 2407 member.kind = RawFunction::kGetterFunction; |
| 2407 member.name_pos = this->token_index_; | 2408 member.name_pos = this->token_index_; |
| 2408 member.name = ExpectIdentifier("identifier expected"); | 2409 member.name = ExpectIdentifier("identifier expected"); |
| 2409 // If the result type was not specified, it will be set to DynamicType. | 2410 // If the result type was not specified, it will be set to DynamicType. |
| 2410 } else if ((CurrentToken() == Token::kSET) && | 2411 } else if ((CurrentToken() == Token::kSET) && |
| 2411 (LookaheadToken(1) != Token::kLPAREN) && !member.has_var) { | 2412 (LookaheadToken(1) != Token::kLPAREN) && |
| 2413 !member.has_var && !member.has_final) { |
| 2412 ConsumeToken(); | 2414 ConsumeToken(); |
| 2413 member.kind = RawFunction::kSetterFunction; | 2415 member.kind = RawFunction::kSetterFunction; |
| 2414 member.name_pos = this->token_index_; | 2416 member.name_pos = this->token_index_; |
| 2415 member.name = ExpectIdentifier("identifier expected"); | 2417 member.name = ExpectIdentifier("identifier expected"); |
| 2416 // The grammar allows a return type, so member.type is not always NULL here. | 2418 // The grammar allows a return type, so member.type is not always NULL here. |
| 2417 // If no return type is specified, the return type of the setter is Dynamic. | 2419 // If no return type is specified, the return type of the setter is Dynamic. |
| 2418 if (member.type == NULL) { | 2420 if (member.type == NULL) { |
| 2419 member.type = &Type::ZoneHandle(Type::DynamicType()); | 2421 member.type = &Type::ZoneHandle(Type::DynamicType()); |
| 2420 } | 2422 } |
| 2421 } else if ((CurrentToken() == Token::kOPERATOR) && | 2423 } else if ((CurrentToken() == Token::kOPERATOR) && |
| 2422 (LookaheadToken(1) != Token::kLPAREN) && !member.has_var) { | 2424 (LookaheadToken(1) != Token::kLPAREN) && |
| 2425 !member.has_var && !member.has_final) { |
| 2423 ConsumeToken(); | 2426 ConsumeToken(); |
| 2424 if (!Token::CanBeOverloaded(CurrentToken())) { | 2427 if (!Token::CanBeOverloaded(CurrentToken())) { |
| 2425 ErrorMsg("invalid operator overloading"); | 2428 ErrorMsg("invalid operator overloading"); |
| 2426 } | 2429 } |
| 2427 if (member.has_static) { | 2430 if (member.has_static) { |
| 2428 ErrorMsg("operator overloading functions cannot be static"); | 2431 ErrorMsg("operator overloading functions cannot be static"); |
| 2429 } | 2432 } |
| 2430 member.kind = RawFunction::kFunction; | 2433 member.kind = RawFunction::kFunction; |
| 2431 member.name_pos = this->token_index_; | 2434 member.name_pos = this->token_index_; |
| 2432 member.name = | 2435 member.name = |
| (...skipping 5297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7730 } | 7733 } |
| 7731 | 7734 |
| 7732 | 7735 |
| 7733 void Parser::SkipNestedExpr() { | 7736 void Parser::SkipNestedExpr() { |
| 7734 const bool saved_mode = SetAllowFunctionLiterals(true); | 7737 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7735 SkipExpr(); | 7738 SkipExpr(); |
| 7736 SetAllowFunctionLiterals(saved_mode); | 7739 SetAllowFunctionLiterals(saved_mode); |
| 7737 } | 7740 } |
| 7738 | 7741 |
| 7739 } // namespace dart | 7742 } // namespace dart |
| OLD | NEW |