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

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

Issue 11190009: Add warning flag for legacy getter syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 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 15 matching lines...) Expand all
26 "Named constructors may not clash with other members"); 26 "Named constructors may not clash with other members");
27 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); 27 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements.");
28 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); 28 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
29 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); 29 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
30 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); 30 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors.");
31 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); 31 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings.");
32 DEFINE_FLAG(bool, warn_legacy_map_literal, false, 32 DEFINE_FLAG(bool, warn_legacy_map_literal, false,
33 "Warning on legacy map literal syntax (single type argument)"); 33 "Warning on legacy map literal syntax (single type argument)");
34 DEFINE_FLAG(bool, warn_legacy_dynamic, false, 34 DEFINE_FLAG(bool, warn_legacy_dynamic, false,
35 "Warning on legacy type Dynamic)"); 35 "Warning on legacy type Dynamic)");
36 DEFINE_FLAG(bool, warn_legacy_getters, false,
37 "Warning on legacy getter syntax");
36 38
37 static void CheckedModeHandler(bool value) { 39 static void CheckedModeHandler(bool value) {
38 FLAG_enable_asserts = value; 40 FLAG_enable_asserts = value;
39 FLAG_enable_type_checks = value; 41 FLAG_enable_type_checks = value;
40 } 42 }
41 43
42 // --enable-checked-mode and --checked both enable checked mode which is 44 // --enable-checked-mode and --checked both enable checked mode which is
43 // equivalent to setting --enable-asserts and --enable-type-checks. 45 // equivalent to setting --enable-asserts and --enable-type-checks.
44 DEFINE_FLAG_HANDLER(CheckedModeHandler, 46 DEFINE_FLAG_HANDLER(CheckedModeHandler,
45 enable_checked_mode, 47 enable_checked_mode,
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 } 2435 }
2434 if (are_implicitly_final) { 2436 if (are_implicitly_final) {
2435 method->params.SetImplicitlyFinal(); 2437 method->params.SetImplicitlyFinal();
2436 } 2438 }
2437 if (!method->IsGetter()) { 2439 if (!method->IsGetter()) {
2438 ParseFormalParameterList(allow_explicit_default_values, &method->params); 2440 ParseFormalParameterList(allow_explicit_default_values, &method->params);
2439 } else { 2441 } else {
2440 // TODO(hausner): Remove this once the old getter syntax with 2442 // TODO(hausner): Remove this once the old getter syntax with
2441 // empty parameter list is no longer supported. 2443 // empty parameter list is no longer supported.
2442 if (CurrentToken() == Token::kLPAREN) { 2444 if (CurrentToken() == Token::kLPAREN) {
2445 if (FLAG_warn_legacy_getters) {
2446 Warning("legacy getter syntax, remove parenthesis");
2447 }
2443 ConsumeToken(); 2448 ConsumeToken();
2444 ExpectToken(Token::kRPAREN); 2449 ExpectToken(Token::kRPAREN);
2445 } 2450 }
2446 } 2451 }
2447 2452
2448 // Now that we know the parameter list, we can distinguish between the 2453 // Now that we know the parameter list, we can distinguish between the
2449 // unary and binary operator -. 2454 // unary and binary operator -.
2450 if (method->has_operator) { 2455 if (method->has_operator) {
2451 if ((method->operator_token == Token::kSUB) && 2456 if ((method->operator_token == Token::kSUB) &&
2452 (method->params.num_fixed_parameters == 1)) { 2457 (method->params.num_fixed_parameters == 1)) {
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3991 ConsumeToken(); 3996 ConsumeToken();
3992 } else { 3997 } else {
3993 UnexpectedToken(); 3998 UnexpectedToken();
3994 } 3999 }
3995 } 4000 }
3996 const intptr_t name_pos = TokenPos(); 4001 const intptr_t name_pos = TokenPos();
3997 const String* field_name = ExpectIdentifier("accessor name expected"); 4002 const String* field_name = ExpectIdentifier("accessor name expected");
3998 4003
3999 const intptr_t accessor_pos = TokenPos(); 4004 const intptr_t accessor_pos = TokenPos();
4000 ParamList params; 4005 ParamList params;
4001 // TODO(hausner): Remove the ( check once we remove old getter syntax. 4006 if (FLAG_warn_legacy_getters &&
4007 is_getter && (CurrentToken() == Token::kLPAREN)) {
4008 Warning("legacy getter syntax, remove parenthesis");
4009 }
4010 // TODO(hausner): Remove the kLPAREN check once we remove old getter syntax.
4002 if (!is_getter || (CurrentToken() == Token::kLPAREN)) { 4011 if (!is_getter || (CurrentToken() == Token::kLPAREN)) {
4003 const bool allow_explicit_default_values = true; 4012 const bool allow_explicit_default_values = true;
4004 ParseFormalParameterList(allow_explicit_default_values, &params); 4013 ParseFormalParameterList(allow_explicit_default_values, &params);
4005 } 4014 }
4006 String& accessor_name = String::ZoneHandle(); 4015 String& accessor_name = String::ZoneHandle();
4007 int expected_num_parameters = -1; 4016 int expected_num_parameters = -1;
4008 if (is_getter) { 4017 if (is_getter) {
4009 expected_num_parameters = 0; 4018 expected_num_parameters = 0;
4010 accessor_name = Field::GetterSymbol(*field_name); 4019 accessor_name = Field::GetterSymbol(*field_name);
4011 } else { 4020 } else {
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
5868 condition = InsertClosureCallNodes(condition); 5877 condition = InsertClosureCallNodes(condition);
5869 condition = new UnaryOpNode(condition_pos, Token::kNOT, condition); 5878 condition = new UnaryOpNode(condition_pos, Token::kNOT, condition);
5870 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); 5879 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end);
5871 return new IfNode(condition_pos, 5880 return new IfNode(condition_pos,
5872 condition, 5881 condition,
5873 NodeAsSequenceNode(condition_pos, assert_throw, NULL), 5882 NodeAsSequenceNode(condition_pos, assert_throw, NULL),
5874 NULL); 5883 NULL);
5875 } 5884 }
5876 5885
5877 5886
5878 // TODO(hausner): This structure can be simplified once the old catch
5879 // syntax is removed. All catch parameters in the new syntax are final.
5880 struct CatchParamDesc { 5887 struct CatchParamDesc {
5881 CatchParamDesc() 5888 CatchParamDesc()
5882 : token_pos(0), type(NULL), var(NULL) { } 5889 : token_pos(0), type(NULL), var(NULL) { }
5883 intptr_t token_pos; 5890 intptr_t token_pos;
5884 const AbstractType* type; 5891 const AbstractType* type;
5885 const String* var; 5892 const String* var;
5886 }; 5893 };
5887 5894
5888 5895
5889 // Populate local scope of the catch block with the catch parameters. 5896 // Populate local scope of the catch block with the catch parameters.
(...skipping 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after
9734 void Parser::SkipQualIdent() { 9741 void Parser::SkipQualIdent() {
9735 ASSERT(IsIdentifier()); 9742 ASSERT(IsIdentifier());
9736 ConsumeToken(); 9743 ConsumeToken();
9737 if (CurrentToken() == Token::kPERIOD) { 9744 if (CurrentToken() == Token::kPERIOD) {
9738 ConsumeToken(); // Consume the kPERIOD token. 9745 ConsumeToken(); // Consume the kPERIOD token.
9739 ExpectIdentifier("identifier expected after '.'"); 9746 ExpectIdentifier("identifier expected after '.'");
9740 } 9747 }
9741 } 9748 }
9742 9749
9743 } // namespace dart 9750 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698