| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace dart { | 23 namespace dart { |
| 24 | 24 |
| 25 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 25 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
| 26 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 26 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
| 27 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 27 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 28 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 28 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
| 29 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 29 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
| 30 DEFINE_FLAG(bool, warn_legacy_map_literal, false, | 30 DEFINE_FLAG(bool, warn_legacy_map_literal, false, |
| 31 "Warning on legacy map literal syntax (single type argument)"); | 31 "Warning on legacy map literal syntax (single type argument)"); |
| 32 DEFINE_FLAG(bool, warn_legacy_getters, false, | |
| 33 "Warning on legacy getter syntax"); | |
| 34 DEFINE_FLAG(bool, strict_function_literals, false, | 32 DEFINE_FLAG(bool, strict_function_literals, false, |
| 35 "enforce new function literal rules"); | 33 "enforce new function literal rules"); |
| 36 DEFINE_FLAG(bool, fail_legacy_abstract, false, | 34 DEFINE_FLAG(bool, fail_legacy_abstract, false, |
| 37 "error on explicit use of abstract on class members"); | 35 "error on explicit use of abstract on class members"); |
| 38 | 36 |
| 39 static void CheckedModeHandler(bool value) { | 37 static void CheckedModeHandler(bool value) { |
| 40 FLAG_enable_asserts = value; | 38 FLAG_enable_asserts = value; |
| 41 FLAG_enable_type_checks = value; | 39 FLAG_enable_type_checks = value; |
| 42 } | 40 } |
| 43 | 41 |
| (...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 method->params.AddFinalParameter( | 2477 method->params.AddFinalParameter( |
| 2480 TokenPos(), | 2478 TokenPos(), |
| 2481 &String::ZoneHandle(Symbols::PhaseParameter()), | 2479 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 2482 &Type::ZoneHandle(Type::SmiType())); | 2480 &Type::ZoneHandle(Type::SmiType())); |
| 2483 } | 2481 } |
| 2484 if (are_implicitly_final) { | 2482 if (are_implicitly_final) { |
| 2485 method->params.SetImplicitlyFinal(); | 2483 method->params.SetImplicitlyFinal(); |
| 2486 } | 2484 } |
| 2487 if (!method->IsGetter()) { | 2485 if (!method->IsGetter()) { |
| 2488 ParseFormalParameterList(allow_explicit_default_values, &method->params); | 2486 ParseFormalParameterList(allow_explicit_default_values, &method->params); |
| 2489 } else { | |
| 2490 // TODO(hausner): Remove this once the old getter syntax with | |
| 2491 // empty parameter list is no longer supported. | |
| 2492 if (CurrentToken() == Token::kLPAREN) { | |
| 2493 if (FLAG_warn_legacy_getters) { | |
| 2494 Warning("legacy getter syntax, remove parenthesis"); | |
| 2495 } | |
| 2496 ConsumeToken(); | |
| 2497 ExpectToken(Token::kRPAREN); | |
| 2498 } | |
| 2499 } | 2487 } |
| 2500 | 2488 |
| 2501 // Now that we know the parameter list, we can distinguish between the | 2489 // Now that we know the parameter list, we can distinguish between the |
| 2502 // unary and binary operator -. | 2490 // unary and binary operator -. |
| 2503 if (method->has_operator) { | 2491 if (method->has_operator) { |
| 2504 if ((method->operator_token == Token::kSUB) && | 2492 if ((method->operator_token == Token::kSUB) && |
| 2505 (method->params.num_fixed_parameters == 1)) { | 2493 (method->params.num_fixed_parameters == 1)) { |
| 2506 // Patch up name for unary operator - so it does not clash with the | 2494 // Patch up name for unary operator - so it does not clash with the |
| 2507 // name for binary operator -. | 2495 // name for binary operator -. |
| 2508 method->operator_token = Token::kNEGATE; | 2496 method->operator_token = Token::kNEGATE; |
| (...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4003 ConsumeToken(); | 3991 ConsumeToken(); |
| 4004 } else { | 3992 } else { |
| 4005 UnexpectedToken(); | 3993 UnexpectedToken(); |
| 4006 } | 3994 } |
| 4007 } | 3995 } |
| 4008 const intptr_t name_pos = TokenPos(); | 3996 const intptr_t name_pos = TokenPos(); |
| 4009 const String* field_name = ExpectIdentifier("accessor name expected"); | 3997 const String* field_name = ExpectIdentifier("accessor name expected"); |
| 4010 | 3998 |
| 4011 const intptr_t accessor_pos = TokenPos(); | 3999 const intptr_t accessor_pos = TokenPos(); |
| 4012 ParamList params; | 4000 ParamList params; |
| 4013 if (FLAG_warn_legacy_getters && | 4001 |
| 4014 is_getter && (CurrentToken() == Token::kLPAREN)) { | 4002 if (!is_getter) { |
| 4015 Warning("legacy getter syntax, remove parenthesis"); | |
| 4016 } | |
| 4017 // TODO(hausner): Remove the kLPAREN check once we remove old getter syntax. | |
| 4018 if (!is_getter || (CurrentToken() == Token::kLPAREN)) { | |
| 4019 const bool allow_explicit_default_values = true; | 4003 const bool allow_explicit_default_values = true; |
| 4020 ParseFormalParameterList(allow_explicit_default_values, ¶ms); | 4004 ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
| 4021 } | 4005 } |
| 4022 String& accessor_name = String::ZoneHandle(); | 4006 String& accessor_name = String::ZoneHandle(); |
| 4023 int expected_num_parameters = -1; | 4007 int expected_num_parameters = -1; |
| 4024 if (is_getter) { | 4008 if (is_getter) { |
| 4025 expected_num_parameters = 0; | 4009 expected_num_parameters = 0; |
| 4026 accessor_name = Field::GetterSymbol(*field_name); | 4010 accessor_name = Field::GetterSymbol(*field_name); |
| 4027 } else { | 4011 } else { |
| 4028 expected_num_parameters = 1; | 4012 expected_num_parameters = 1; |
| (...skipping 5882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9911 void Parser::SkipQualIdent() { | 9895 void Parser::SkipQualIdent() { |
| 9912 ASSERT(IsIdentifier()); | 9896 ASSERT(IsIdentifier()); |
| 9913 ConsumeToken(); | 9897 ConsumeToken(); |
| 9914 if (CurrentToken() == Token::kPERIOD) { | 9898 if (CurrentToken() == Token::kPERIOD) { |
| 9915 ConsumeToken(); // Consume the kPERIOD token. | 9899 ConsumeToken(); // Consume the kPERIOD token. |
| 9916 ExpectIdentifier("identifier expected after '.'"); | 9900 ExpectIdentifier("identifier expected after '.'"); |
| 9917 } | 9901 } |
| 9918 } | 9902 } |
| 9919 | 9903 |
| 9920 } // namespace dart | 9904 } // namespace dart |
| OLD | NEW |