Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: runtime/vm/parser.cc

Issue 2911333002: Allow a function named 'get' to be generic (fixes #29746). (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 5524 matching lines...) Expand 10 before | Expand all | Expand 10 after
5535 Token::Kind token = CurrentToken(); 5535 Token::Kind token = CurrentToken();
5536 if ((token == Token::kGT) || (token == Token::kSHR)) { 5536 if ((token == Token::kGT) || (token == Token::kSHR)) {
5537 ConsumeRightAngleBracket(); 5537 ConsumeRightAngleBracket();
5538 } else { 5538 } else {
5539 ReportError("right angle bracket expected"); 5539 ReportError("right angle bracket expected");
5540 } 5540 }
5541 } 5541 }
5542 } 5542 }
5543 5543
5544 5544
5545 void Parser::SkipTypeParameters() {
5546 // Function already parsed, no need to check FLAG_generic_method_syntax.
5547 if (IsTypeParameters()) {
5548 const bool skipped = TryParseTypeParameters();
5549 ASSERT(skipped);
5550 }
5551 }
5552
5553
5545 void Parser::SkipType(bool allow_void) { 5554 void Parser::SkipType(bool allow_void) {
5546 if (CurrentToken() == Token::kVOID) { 5555 if (CurrentToken() == Token::kVOID) {
5547 if (!allow_void) { 5556 if (!allow_void) {
5548 ReportError("'void' not allowed here"); 5557 ReportError("'void' not allowed here");
5549 } 5558 }
5550 ConsumeToken(); 5559 ConsumeToken();
5551 } else { 5560 } else {
5552 ExpectIdentifier("type name expected"); 5561 ExpectIdentifier("type name expected");
5553 if (CurrentToken() == Token::kPERIOD) { 5562 if (CurrentToken() == Token::kPERIOD) {
5554 ConsumeToken(); 5563 ConsumeToken();
(...skipping 9295 matching lines...) Expand 10 before | Expand all | Expand 10 after
14850 SkipExpr(); 14859 SkipExpr();
14851 } 14860 }
14852 } 14861 }
14853 14862
14854 14863
14855 // Skips function/method/constructor/getter/setter preambles until the formal 14864 // Skips function/method/constructor/getter/setter preambles until the formal
14856 // parameter list. It is enough to skip the tokens, since we have already 14865 // parameter list. It is enough to skip the tokens, since we have already
14857 // previously parsed the function. 14866 // previously parsed the function.
14858 void Parser::SkipFunctionPreamble() { 14867 void Parser::SkipFunctionPreamble() {
14859 while (true) { 14868 while (true) {
14860 const Token::Kind token = CurrentToken();
14861 if (IsFunctionTypeSymbol()) { 14869 if (IsFunctionTypeSymbol()) {
14862 ConsumeToken(); 14870 ConsumeToken();
14863 SkipTypeArguments(); 14871 SkipTypeParameters();
14864 SkipToMatchingParenthesis(); 14872 SkipToMatchingParenthesis();
14865 continue; 14873 continue;
14866 } 14874 }
14875 const Token::Kind token = CurrentToken();
14867 if (token == Token::kLPAREN) { 14876 if (token == Token::kLPAREN) {
14868 return; 14877 return;
14869 } 14878 }
14870 if (token == Token::kGET) { 14879 if (token == Token::kGET) {
14880 if (LookaheadToken(1) == Token::kLT) {
14881 // Case: Generic Function/method named get.
14882 ConsumeToken(); // Parse away 'get' (the function's name).
14883 SkipTypeParameters();
14884 continue;
14885 }
14871 if (LookaheadToken(1) == Token::kLPAREN) { 14886 if (LookaheadToken(1) == Token::kLPAREN) {
14872 // Case: Function/method named get. 14887 // Case: Function/method named get.
14873 ConsumeToken(); // Parse away 'get' (the function's name). 14888 ConsumeToken(); // Parse away 'get' (the function's name).
14874 return; 14889 return;
14875 } 14890 }
14876 // Case: Getter. 14891 // Case: Getter.
14877 ConsumeToken(); // Parse away 'get'. 14892 ConsumeToken(); // Parse away 'get'.
14878 ConsumeToken(); // Parse away the getter name. 14893 ConsumeToken(); // Parse away the getter name.
14879 return; 14894 return;
14880 } 14895 }
14881 ConsumeToken(); 14896 ConsumeToken(); // Can be static, factory, operator, void, ident, etc...
14882 } 14897 }
14883 } 14898 }
14884 14899
14885 14900
14886 void Parser::SkipListLiteral() { 14901 void Parser::SkipListLiteral() {
14887 if (CurrentToken() == Token::kINDEX) { 14902 if (CurrentToken() == Token::kINDEX) {
14888 // Empty list literal. 14903 // Empty list literal.
14889 ConsumeToken(); 14904 ConsumeToken();
14890 return; 14905 return;
14891 } 14906 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
15298 TokenPosition* start, 15313 TokenPosition* start,
15299 TokenPosition* end) { 15314 TokenPosition* end) {
15300 UNREACHABLE(); 15315 UNREACHABLE();
15301 return false; 15316 return false;
15302 } 15317 }
15303 15318
15304 15319
15305 } // namespace dart 15320 } // namespace dart
15306 15321
15307 #endif // DART_PRECOMPILED_RUNTIME 15322 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698