| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } | 862 } |
| 863 return false; | 863 return false; |
| 864 } | 864 } |
| 865 | 865 |
| 866 bool PeekInOrOf() { | 866 bool PeekInOrOf() { |
| 867 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); | 867 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); |
| 868 } | 868 } |
| 869 | 869 |
| 870 // Checks whether an octal literal was last seen between beg_pos and end_pos. | 870 // Checks whether an octal literal was last seen between beg_pos and end_pos. |
| 871 // If so, reports an error. Only called for strict mode and template strings. | 871 // If so, reports an error. Only called for strict mode and template strings. |
| 872 void CheckOctalLiteral(int beg_pos, int end_pos, | 872 void CheckOctalLiteral(int beg_pos, int end_pos, bool is_template, bool* ok) { |
| 873 MessageTemplate::Template message, bool* ok) { | |
| 874 Scanner::Location octal = scanner()->octal_position(); | 873 Scanner::Location octal = scanner()->octal_position(); |
| 875 if (octal.IsValid() && beg_pos <= octal.beg_pos && | 874 if (octal.IsValid() && beg_pos <= octal.beg_pos && |
| 876 octal.end_pos <= end_pos) { | 875 octal.end_pos <= end_pos) { |
| 876 MessageTemplate::Template message = |
| 877 is_template ? MessageTemplate::kTemplateOctalLiteral |
| 878 : scanner()->octal_message(); |
| 879 DCHECK_NE(message, MessageTemplate::kNone); |
| 877 impl()->ReportMessageAt(octal, message); | 880 impl()->ReportMessageAt(octal, message); |
| 878 scanner()->clear_octal_position(); | 881 scanner()->clear_octal_position(); |
| 879 *ok = false; | 882 *ok = false; |
| 880 } | 883 } |
| 881 } | 884 } |
| 882 // for now, this check just collects statistics. | 885 // for now, this check just collects statistics. |
| 883 void CheckDecimalLiteralWithLeadingZero(int beg_pos, int end_pos) { | 886 void CheckDecimalLiteralWithLeadingZero(int beg_pos, int end_pos) { |
| 884 Scanner::Location token_location = | 887 Scanner::Location token_location = |
| 885 scanner()->decimal_with_leading_zero_position(); | 888 scanner()->decimal_with_leading_zero_position(); |
| 886 if (token_location.IsValid() && beg_pos <= token_location.beg_pos && | 889 if (token_location.IsValid() && beg_pos <= token_location.beg_pos && |
| 887 token_location.end_pos <= end_pos) { | 890 token_location.end_pos <= end_pos) { |
| 888 scanner()->clear_decimal_with_leading_zero_position(); | 891 scanner()->clear_decimal_with_leading_zero_position(); |
| 889 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); | 892 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); |
| 890 } | 893 } |
| 891 } | 894 } |
| 892 | 895 |
| 893 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { | 896 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
| 894 CheckOctalLiteral(beg_pos, end_pos, MessageTemplate::kStrictOctalLiteral, | 897 CheckOctalLiteral(beg_pos, end_pos, false, ok); |
| 895 ok); | |
| 896 } | 898 } |
| 897 | 899 |
| 898 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { | 900 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
| 899 CheckOctalLiteral(beg_pos, end_pos, MessageTemplate::kTemplateOctalLiteral, | 901 CheckOctalLiteral(beg_pos, end_pos, true, ok); |
| 900 ok); | |
| 901 } | 902 } |
| 902 | 903 |
| 903 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); | 904 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); |
| 904 | 905 |
| 905 // Checking the name of a function literal. This has to be done after parsing | 906 // Checking the name of a function literal. This has to be done after parsing |
| 906 // the function, since the function can declare itself strict. | 907 // the function, since the function can declare itself strict. |
| 907 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, | 908 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, |
| 908 FunctionNameValidity function_name_validity, | 909 FunctionNameValidity function_name_validity, |
| 909 const Scanner::Location& function_name_loc, bool* ok) { | 910 const Scanner::Location& function_name_loc, bool* ok) { |
| 910 if (function_name_validity == kSkipFunctionNameCheck) return; | 911 if (function_name_validity == kSkipFunctionNameCheck) return; |
| (...skipping 4584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5495 has_seen_constructor_ = true; | 5496 has_seen_constructor_ = true; |
| 5496 return; | 5497 return; |
| 5497 } | 5498 } |
| 5498 } | 5499 } |
| 5499 | 5500 |
| 5500 | 5501 |
| 5501 } // namespace internal | 5502 } // namespace internal |
| 5502 } // namespace v8 | 5503 } // namespace v8 |
| 5503 | 5504 |
| 5504 #endif // V8_PARSING_PARSER_BASE_H | 5505 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |