| 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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2469 member.type = &Type::ZoneHandle(Type::DynamicType()); | 2469 member.type = &Type::ZoneHandle(Type::DynamicType()); |
| 2470 } else { | 2470 } else { |
| 2471 // The type can only be already set in the factory case. | 2471 // The type can only be already set in the factory case. |
| 2472 if (!member.has_factory) { | 2472 if (!member.has_factory) { |
| 2473 ErrorMsg(member.name_pos, "constructor must not specify return type"); | 2473 ErrorMsg(member.name_pos, "constructor must not specify return type"); |
| 2474 } | 2474 } |
| 2475 } | 2475 } |
| 2476 if (CurrentToken() != Token::kLPAREN) { | 2476 if (CurrentToken() != Token::kLPAREN) { |
| 2477 ErrorMsg("left parenthesis expected"); | 2477 ErrorMsg("left parenthesis expected"); |
| 2478 } | 2478 } |
| 2479 } else if ((CurrentToken() == Token::kGET) && | 2479 } else if ((CurrentToken() == Token::kGET) && !member.has_var && |
| 2480 (LookaheadToken(1) != Token::kLPAREN) && | 2480 (LookaheadToken(1) != Token::kLPAREN) && |
| 2481 (LookaheadToken(1) != Token::kASSIGN) && | 2481 (LookaheadToken(1) != Token::kASSIGN) && |
| 2482 (LookaheadToken(1) != Token::kCOMMA) && | 2482 (LookaheadToken(1) != Token::kCOMMA) && |
| 2483 (LookaheadToken(1) != Token::kSEMICOLON)) { | 2483 (LookaheadToken(1) != Token::kSEMICOLON)) { |
| 2484 ConsumeToken(); | 2484 ConsumeToken(); |
| 2485 member.kind = RawFunction::kGetterFunction; | 2485 member.kind = RawFunction::kGetterFunction; |
| 2486 member.name_pos = this->token_index_; | 2486 member.name_pos = this->token_index_; |
| 2487 member.name = ExpectIdentifier("identifier expected"); | 2487 member.name = ExpectIdentifier("identifier expected"); |
| 2488 if (CurrentToken() != Token::kLPAREN) { |
| 2489 ErrorMsg("'(' expected"); |
| 2490 } |
| 2488 // If the result type was not specified, it will be set to DynamicType. | 2491 // If the result type was not specified, it will be set to DynamicType. |
| 2489 } else if ((CurrentToken() == Token::kSET) && | 2492 } else if ((CurrentToken() == Token::kSET) && !member.has_var && |
| 2490 (LookaheadToken(1) != Token::kLPAREN) && | 2493 (LookaheadToken(1) != Token::kLPAREN) && |
| 2491 (LookaheadToken(1) != Token::kASSIGN) && | 2494 (LookaheadToken(1) != Token::kASSIGN) && |
| 2492 (LookaheadToken(1) != Token::kCOMMA) && | 2495 (LookaheadToken(1) != Token::kCOMMA) && |
| 2493 (LookaheadToken(1) != Token::kSEMICOLON)) { | 2496 (LookaheadToken(1) != Token::kSEMICOLON)) { |
| 2494 ConsumeToken(); | 2497 ConsumeToken(); |
| 2495 member.kind = RawFunction::kSetterFunction; | 2498 member.kind = RawFunction::kSetterFunction; |
| 2496 member.name_pos = this->token_index_; | 2499 member.name_pos = this->token_index_; |
| 2497 member.name = ExpectIdentifier("identifier expected"); | 2500 member.name = ExpectIdentifier("identifier expected"); |
| 2501 if (CurrentToken() != Token::kLPAREN) { |
| 2502 ErrorMsg("'(' expected"); |
| 2503 } |
| 2498 // The grammar allows a return type, so member.type is not always NULL here. | 2504 // The grammar allows a return type, so member.type is not always NULL here. |
| 2499 // If no return type is specified, the return type of the setter is Dynamic. | 2505 // If no return type is specified, the return type of the setter is Dynamic. |
| 2500 if (member.type == NULL) { | 2506 if (member.type == NULL) { |
| 2501 member.type = &Type::ZoneHandle(Type::DynamicType()); | 2507 member.type = &Type::ZoneHandle(Type::DynamicType()); |
| 2502 } | 2508 } |
| 2503 } else if ((CurrentToken() == Token::kOPERATOR) && | 2509 } else if ((CurrentToken() == Token::kOPERATOR) && !member.has_var && |
| 2504 (LookaheadToken(1) != Token::kLPAREN) && | 2510 (LookaheadToken(1) != Token::kLPAREN) && |
| 2505 (LookaheadToken(1) != Token::kASSIGN) && | 2511 (LookaheadToken(1) != Token::kASSIGN) && |
| 2506 (LookaheadToken(1) != Token::kCOMMA) && | 2512 (LookaheadToken(1) != Token::kCOMMA) && |
| 2507 (LookaheadToken(1) != Token::kSEMICOLON)) { | 2513 (LookaheadToken(1) != Token::kSEMICOLON)) { |
| 2508 ConsumeToken(); | 2514 ConsumeToken(); |
| 2509 if (!Token::CanBeOverloaded(CurrentToken())) { | 2515 if (!Token::CanBeOverloaded(CurrentToken())) { |
| 2510 ErrorMsg("invalid operator overloading"); | 2516 ErrorMsg("invalid operator overloading"); |
| 2511 } | 2517 } |
| 2512 if (member.has_static) { | 2518 if (member.has_static) { |
| 2513 ErrorMsg("operator overloading functions cannot be static"); | 2519 ErrorMsg("operator overloading functions cannot be static"); |
| (...skipping 5745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8259 void Parser::SkipQualIdent() { | 8265 void Parser::SkipQualIdent() { |
| 8260 ASSERT(IsIdentifier()); | 8266 ASSERT(IsIdentifier()); |
| 8261 ConsumeToken(); | 8267 ConsumeToken(); |
| 8262 if (CurrentToken() == Token::kPERIOD) { | 8268 if (CurrentToken() == Token::kPERIOD) { |
| 8263 ConsumeToken(); // Consume the kPERIOD token. | 8269 ConsumeToken(); // Consume the kPERIOD token. |
| 8264 ExpectIdentifier("identifier expected after '.'"); | 8270 ExpectIdentifier("identifier expected after '.'"); |
| 8265 } | 8271 } |
| 8266 } | 8272 } |
| 8267 | 8273 |
| 8268 } // namespace dart | 8274 } // namespace dart |
| OLD | NEW |