| 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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 // Parses a single function literal, from the opening parentheses before | 1745 // Parses a single function literal, from the opening parentheses before |
| 1746 // parameters to the closing brace after the body. | 1746 // parameters to the closing brace after the body. |
| 1747 // Returns a FunctionEntry describing the body of the function in enough | 1747 // Returns a FunctionEntry describing the body of the function in enough |
| 1748 // detail that it can be lazily compiled. | 1748 // detail that it can be lazily compiled. |
| 1749 // The scanner is expected to have matched the "function" or "function*" | 1749 // The scanner is expected to have matched the "function" or "function*" |
| 1750 // keyword and parameters, and have consumed the initial '{'. | 1750 // keyword and parameters, and have consumed the initial '{'. |
| 1751 // At return, unless an error occurred, the scanner is positioned before the | 1751 // At return, unless an error occurred, the scanner is positioned before the |
| 1752 // the final '}'. | 1752 // the final '}'. |
| 1753 PreParseResult PreParseLazyFunction(LanguageMode language_mode, | 1753 PreParseResult PreParseLazyFunction( |
| 1754 FunctionKind kind, ParserRecorder* log); | 1754 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
| 1755 Scanner::BookmarkScope* bookmark = nullptr); |
| 1755 | 1756 |
| 1756 private: | 1757 private: |
| 1757 friend class PreParserTraits; | 1758 friend class PreParserTraits; |
| 1758 | 1759 |
| 1759 // These types form an algebra over syntactic categories that is just | 1760 // These types form an algebra over syntactic categories that is just |
| 1760 // rich enough to let us recognize and propagate the constructs that | 1761 // rich enough to let us recognize and propagate the constructs that |
| 1761 // are either being counted in the preparser data, or is important | 1762 // are either being counted in the preparser data, or is important |
| 1762 // to throw the correct syntax error exceptions. | 1763 // to throw the correct syntax error exceptions. |
| 1763 | 1764 |
| 1764 // All ParseXXX functions take as the last argument an *ok parameter | 1765 // All ParseXXX functions take as the last argument an *ok parameter |
| 1765 // which is set to false if parsing failed; it is unchanged otherwise. | 1766 // which is set to false if parsing failed; it is unchanged otherwise. |
| 1766 // By making the 'exception handling' explicit, we are forced to check | 1767 // By making the 'exception handling' explicit, we are forced to check |
| 1767 // for failure at the call sites. | 1768 // for failure at the call sites. |
| 1768 Statement ParseStatementListItem(bool* ok); | 1769 Statement ParseStatementListItem(bool* ok); |
| 1769 void ParseStatementList(int end_token, bool* ok); | 1770 void ParseStatementList(int end_token, bool* ok, |
| 1771 Scanner::BookmarkScope* bookmark = nullptr); |
| 1770 Statement ParseStatement(bool* ok); | 1772 Statement ParseStatement(bool* ok); |
| 1771 Statement ParseSubStatement(bool* ok); | 1773 Statement ParseSubStatement(bool* ok); |
| 1772 Statement ParseFunctionDeclaration(bool* ok); | 1774 Statement ParseFunctionDeclaration(bool* ok); |
| 1773 Statement ParseClassDeclaration(bool* ok); | 1775 Statement ParseClassDeclaration(bool* ok); |
| 1774 Statement ParseBlock(bool* ok); | 1776 Statement ParseBlock(bool* ok); |
| 1775 Statement ParseVariableStatement(VariableDeclarationContext var_context, | 1777 Statement ParseVariableStatement(VariableDeclarationContext var_context, |
| 1776 bool* ok); | 1778 bool* ok); |
| 1777 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, | 1779 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, |
| 1778 int* num_decl, | 1780 int* num_decl, |
| 1779 Scanner::Location* first_initializer_loc, | 1781 Scanner::Location* first_initializer_loc, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1801 V8_INLINE PreParserStatementList | 1803 V8_INLINE PreParserStatementList |
| 1802 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1804 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
| 1803 Variable* fvar, Token::Value fvar_init_op, | 1805 Variable* fvar, Token::Value fvar_init_op, |
| 1804 FunctionKind kind, bool* ok); | 1806 FunctionKind kind, bool* ok); |
| 1805 | 1807 |
| 1806 Expression ParseFunctionLiteral( | 1808 Expression ParseFunctionLiteral( |
| 1807 Identifier name, Scanner::Location function_name_location, | 1809 Identifier name, Scanner::Location function_name_location, |
| 1808 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1810 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 1809 FunctionLiteral::FunctionType function_type, | 1811 FunctionLiteral::FunctionType function_type, |
| 1810 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1812 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1811 void ParseLazyFunctionLiteralBody(bool* ok); | 1813 void ParseLazyFunctionLiteralBody(bool* ok, |
| 1814 Scanner::BookmarkScope* bookmark = nullptr); |
| 1812 | 1815 |
| 1813 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1816 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
| 1814 Scanner::Location class_name_location, | 1817 Scanner::Location class_name_location, |
| 1815 bool name_is_strict_reserved, int pos, | 1818 bool name_is_strict_reserved, int pos, |
| 1816 bool* ok); | 1819 bool* ok); |
| 1817 }; | 1820 }; |
| 1818 | 1821 |
| 1819 | 1822 |
| 1820 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1823 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
| 1821 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1824 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3713 *ok = false; | 3716 *ok = false; |
| 3714 return; | 3717 return; |
| 3715 } | 3718 } |
| 3716 has_seen_constructor_ = true; | 3719 has_seen_constructor_ = true; |
| 3717 return; | 3720 return; |
| 3718 } | 3721 } |
| 3719 } | 3722 } |
| 3720 } } // v8::internal | 3723 } } // v8::internal |
| 3721 | 3724 |
| 3722 #endif // V8_PREPARSER_H | 3725 #endif // V8_PREPARSER_H |
| OLD | NEW |