| 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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 impl()->ReportMessageAt(octal, message); | 828 impl()->ReportMessageAt(octal, message); |
| 829 scanner()->clear_octal_position(); | 829 scanner()->clear_octal_position(); |
| 830 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) { | 830 if (message == MessageTemplate::kStrictDecimalWithLeadingZero) { |
| 831 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); | 831 impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode); |
| 832 } | 832 } |
| 833 *ok = false; | 833 *ok = false; |
| 834 } | 834 } |
| 835 } | 835 } |
| 836 | 836 |
| 837 // Checks if an octal literal or an invalid hex or unicode escape sequence | 837 // Checks if an octal literal or an invalid hex or unicode escape sequence |
| 838 // appears in a template literal. In the presence of such, either | 838 // appears in the current template literal token. In the presence of such, |
| 839 // returns false or reports an error, depending on should_throw. Otherwise | 839 // either returns false or reports an error, depending on should_throw. |
| 840 // returns true. | 840 // Otherwise returns true. |
| 841 inline bool CheckTemplateEscapes(bool should_throw, bool* ok) { | 841 inline bool CheckTemplateEscapes(bool should_throw, bool* ok) { |
| 842 DCHECK(scanner()->current_token() == Token::TEMPLATE_SPAN || |
| 843 scanner()->current_token() == Token::TEMPLATE_TAIL); |
| 842 if (!scanner()->has_invalid_template_escape()) { | 844 if (!scanner()->has_invalid_template_escape()) { |
| 843 return true; | 845 return true; |
| 844 } | 846 } |
| 845 | 847 |
| 846 // Handle error case(s) | 848 // Handle error case(s) |
| 847 if (should_throw) { | 849 if (should_throw) { |
| 848 impl()->ReportMessageAt(scanner()->invalid_template_escape_location(), | 850 impl()->ReportMessageAt(scanner()->invalid_template_escape_location(), |
| 849 scanner()->invalid_template_escape_message()); | 851 scanner()->invalid_template_escape_message()); |
| 850 *ok = false; | 852 *ok = false; |
| 851 } | 853 } |
| 852 scanner()->clear_invalid_template_escape(); | |
| 853 return false; | 854 return false; |
| 854 } | 855 } |
| 855 | 856 |
| 856 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); | 857 void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos); |
| 857 | 858 |
| 858 // Checking the name of a function literal. This has to be done after parsing | 859 // Checking the name of a function literal. This has to be done after parsing |
| 859 // the function, since the function can declare itself strict. | 860 // the function, since the function can declare itself strict. |
| 860 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, | 861 void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name, |
| 861 FunctionNameValidity function_name_validity, | 862 FunctionNameValidity function_name_validity, |
| 862 const Scanner::Location& function_name_loc, bool* ok) { | 863 const Scanner::Location& function_name_loc, bool* ok) { |
| (...skipping 4983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5846 } | 5847 } |
| 5847 | 5848 |
| 5848 #undef CHECK_OK | 5849 #undef CHECK_OK |
| 5849 #undef CHECK_OK_CUSTOM | 5850 #undef CHECK_OK_CUSTOM |
| 5850 #undef CHECK_OK_VOID | 5851 #undef CHECK_OK_VOID |
| 5851 | 5852 |
| 5852 } // namespace internal | 5853 } // namespace internal |
| 5853 } // namespace v8 | 5854 } // namespace v8 |
| 5854 | 5855 |
| 5855 #endif // V8_PARSING_PARSER_BASE_H | 5856 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |