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 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 } | 1814 } |
1815 | 1815 |
1816 // Parses a single function literal, from the opening parentheses before | 1816 // Parses a single function literal, from the opening parentheses before |
1817 // parameters to the closing brace after the body. | 1817 // parameters to the closing brace after the body. |
1818 // Returns a FunctionEntry describing the body of the function in enough | 1818 // Returns a FunctionEntry describing the body of the function in enough |
1819 // detail that it can be lazily compiled. | 1819 // detail that it can be lazily compiled. |
1820 // The scanner is expected to have matched the "function" or "function*" | 1820 // The scanner is expected to have matched the "function" or "function*" |
1821 // keyword and parameters, and have consumed the initial '{'. | 1821 // keyword and parameters, and have consumed the initial '{'. |
1822 // At return, unless an error occurred, the scanner is positioned before the | 1822 // At return, unless an error occurred, the scanner is positioned before the |
1823 // the final '}'. | 1823 // the final '}'. |
1824 PreParseResult PreParseLazyFunction(LanguageMode language_mode, | 1824 PreParseResult PreParseLazyFunction( |
1825 FunctionKind kind, ParserRecorder* log); | 1825 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
| 1826 Scanner::BookmarkScope* bookmark = nullptr); |
1826 | 1827 |
1827 private: | 1828 private: |
1828 friend class PreParserTraits; | 1829 friend class PreParserTraits; |
1829 | 1830 |
1830 // These types form an algebra over syntactic categories that is just | 1831 // These types form an algebra over syntactic categories that is just |
1831 // rich enough to let us recognize and propagate the constructs that | 1832 // rich enough to let us recognize and propagate the constructs that |
1832 // are either being counted in the preparser data, or is important | 1833 // are either being counted in the preparser data, or is important |
1833 // to throw the correct syntax error exceptions. | 1834 // to throw the correct syntax error exceptions. |
1834 | 1835 |
1835 // All ParseXXX functions take as the last argument an *ok parameter | 1836 // All ParseXXX functions take as the last argument an *ok parameter |
1836 // which is set to false if parsing failed; it is unchanged otherwise. | 1837 // which is set to false if parsing failed; it is unchanged otherwise. |
1837 // By making the 'exception handling' explicit, we are forced to check | 1838 // By making the 'exception handling' explicit, we are forced to check |
1838 // for failure at the call sites. | 1839 // for failure at the call sites. |
1839 Statement ParseStatementListItem(bool* ok); | 1840 Statement ParseStatementListItem(bool* ok); |
1840 void ParseStatementList(int end_token, bool* ok); | 1841 void ParseStatementList(int end_token, bool* ok, |
| 1842 Scanner::BookmarkScope* bookmark = nullptr); |
1841 Statement ParseStatement(bool* ok); | 1843 Statement ParseStatement(bool* ok); |
1842 Statement ParseSubStatement(bool* ok); | 1844 Statement ParseSubStatement(bool* ok); |
1843 Statement ParseFunctionDeclaration(bool* ok); | 1845 Statement ParseFunctionDeclaration(bool* ok); |
1844 Statement ParseClassDeclaration(bool* ok); | 1846 Statement ParseClassDeclaration(bool* ok); |
1845 Statement ParseBlock(bool* ok); | 1847 Statement ParseBlock(bool* ok); |
1846 Statement ParseVariableStatement(VariableDeclarationContext var_context, | 1848 Statement ParseVariableStatement(VariableDeclarationContext var_context, |
1847 bool* ok); | 1849 bool* ok); |
1848 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, | 1850 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, |
1849 int* num_decl, | 1851 int* num_decl, |
1850 Scanner::Location* first_initializer_loc, | 1852 Scanner::Location* first_initializer_loc, |
(...skipping 21 matching lines...) Expand all Loading... |
1872 V8_INLINE PreParserStatementList | 1874 V8_INLINE PreParserStatementList |
1873 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1875 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
1874 Variable* fvar, Token::Value fvar_init_op, | 1876 Variable* fvar, Token::Value fvar_init_op, |
1875 FunctionKind kind, bool* ok); | 1877 FunctionKind kind, bool* ok); |
1876 | 1878 |
1877 Expression ParseFunctionLiteral( | 1879 Expression ParseFunctionLiteral( |
1878 Identifier name, Scanner::Location function_name_location, | 1880 Identifier name, Scanner::Location function_name_location, |
1879 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1881 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
1880 FunctionLiteral::FunctionType function_type, | 1882 FunctionLiteral::FunctionType function_type, |
1881 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1883 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
1882 void ParseLazyFunctionLiteralBody(bool* ok); | 1884 void ParseLazyFunctionLiteralBody(bool* ok, |
| 1885 Scanner::BookmarkScope* bookmark = nullptr); |
1883 | 1886 |
1884 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1887 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
1885 Scanner::Location class_name_location, | 1888 Scanner::Location class_name_location, |
1886 bool name_is_strict_reserved, int pos, | 1889 bool name_is_strict_reserved, int pos, |
1887 bool* ok); | 1890 bool* ok); |
1888 }; | 1891 }; |
1889 | 1892 |
1890 | 1893 |
1891 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1894 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
1892 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1895 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 *ok = false; | 3843 *ok = false; |
3841 return; | 3844 return; |
3842 } | 3845 } |
3843 has_seen_constructor_ = true; | 3846 has_seen_constructor_ = true; |
3844 return; | 3847 return; |
3845 } | 3848 } |
3846 } | 3849 } |
3847 } } // v8::internal | 3850 } } // v8::internal |
3848 | 3851 |
3849 #endif // V8_PREPARSER_H | 3852 #endif // V8_PREPARSER_H |
OLD | NEW |