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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 } | 847 } |
848 return false; | 848 return false; |
849 } | 849 } |
850 | 850 |
851 bool PeekInOrOf() { | 851 bool PeekInOrOf() { |
852 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); | 852 return peek() == Token::IN || PeekContextualKeyword(CStrVector("of")); |
853 } | 853 } |
854 | 854 |
855 // Checks whether an octal literal was last seen between beg_pos and end_pos. | 855 // Checks whether an octal literal was last seen between beg_pos and end_pos. |
856 // If so, reports an error. Only called for strict mode and template strings. | 856 // If so, reports an error. Only called for strict mode and template strings. |
857 void CheckOctalLiteral(int beg_pos, int end_pos, | 857 void CheckOctalLiteral(int beg_pos, int end_pos, bool is_template_escape, |
858 MessageTemplate::Template message, bool* ok) { | 858 bool* ok) { |
859 Scanner::Location octal = scanner()->octal_position(); | 859 Scanner::Location octal = scanner()->octal_position(); |
860 if (octal.IsValid() && beg_pos <= octal.beg_pos && | 860 if (octal.IsValid() && beg_pos <= octal.beg_pos && |
861 octal.end_pos <= end_pos) { | 861 octal.end_pos <= end_pos) { |
862 MessageTemplate::Template message = | |
863 is_template_escape ? MessageTemplate::kTemplateOctalLiteral | |
864 : scanner()->octal_message(); | |
865 DCHECK_NE(message, MessageTemplate::kNone); | |
Dan Ehrenberg
2016/11/18 17:13:51
IMO it wouldn't hurt to continue updating the UseC
| |
862 impl()->ReportMessageAt(octal, message); | 866 impl()->ReportMessageAt(octal, message); |
863 scanner()->clear_octal_position(); | 867 scanner()->clear_octal_position(); |
864 *ok = false; | 868 *ok = false; |
865 } | 869 } |
866 } | 870 } |
867 // for now, this check just collects statistics. | |
868 void CheckDecimalLiteralWithLeadingZero(int beg_pos, int end_pos) { | |
869 Scanner::Location token_location = | |
870 scanner()->decimal_with_leading_zero_position(); | |
871 if (token_location.IsValid() && beg_pos <= token_location.beg_pos && | |
872 token_location.end_pos <= end_pos) { | |
873 scanner()->clear_decimal_with_leading_zero_position(); | |
874 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); | |
875 } | |
876 } | |
877 | 871 |
878 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { | 872 inline void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
879 CheckOctalLiteral(beg_pos, end_pos, MessageTemplate::kStrictOctalLiteral, | 873 CheckOctalLiteral(beg_pos, end_pos, false, ok); |
880 ok); | |
881 } | 874 } |
882 | 875 |
883 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { | 876 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
884 CheckOctalLiteral(beg_pos, end_pos, MessageTemplate::kTemplateOctalLiteral, | 877 CheckOctalLiteral(beg_pos, end_pos, true, ok); |
885 ok); | |
886 } | 878 } |
887 | 879 |
888 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); | 880 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); |
889 | 881 |
890 // Checking the name of a function literal. This has to be done after parsing | 882 // Checking the name of a function literal. This has to be done after parsing |
891 // the function, since the function can declare itself strict. | 883 // the function, since the function can declare itself strict. |
892 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, | 884 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, |
893 FunctionNameValidity function_name_validity, | 885 FunctionNameValidity function_name_validity, |
894 const Scanner::Location& function_name_loc, bool* ok) { | 886 const Scanner::Location& function_name_loc, bool* ok) { |
895 if (function_name_validity == kSkipFunctionNameCheck) return; | 887 if (function_name_validity == kSkipFunctionNameCheck) return; |
(...skipping 4550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5446 has_seen_constructor_ = true; | 5438 has_seen_constructor_ = true; |
5447 return; | 5439 return; |
5448 } | 5440 } |
5449 } | 5441 } |
5450 | 5442 |
5451 | 5443 |
5452 } // namespace internal | 5444 } // namespace internal |
5453 } // namespace v8 | 5445 } // namespace v8 |
5454 | 5446 |
5455 #endif // V8_PARSING_PARSER_BASE_H | 5447 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |