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 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 } | 1647 } |
1648 | 1648 |
1649 // Parses a single function literal, from the opening parentheses before | 1649 // Parses a single function literal, from the opening parentheses before |
1650 // parameters to the closing brace after the body. | 1650 // parameters to the closing brace after the body. |
1651 // Returns a FunctionEntry describing the body of the function in enough | 1651 // Returns a FunctionEntry describing the body of the function in enough |
1652 // detail that it can be lazily compiled. | 1652 // detail that it can be lazily compiled. |
1653 // The scanner is expected to have matched the "function" or "function*" | 1653 // The scanner is expected to have matched the "function" or "function*" |
1654 // keyword and parameters, and have consumed the initial '{'. | 1654 // keyword and parameters, and have consumed the initial '{'. |
1655 // At return, unless an error occurred, the scanner is positioned before the | 1655 // At return, unless an error occurred, the scanner is positioned before the |
1656 // the final '}'. | 1656 // the final '}'. |
1657 PreParseResult PreParseLazyFunction(LanguageMode language_mode, | 1657 PreParseResult PreParseLazyFunction( |
1658 FunctionKind kind, ParserRecorder* log); | 1658 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
| 1659 Scanner::BookmarkScope* bookmark = nullptr); |
1659 | 1660 |
1660 private: | 1661 private: |
1661 friend class PreParserTraits; | 1662 friend class PreParserTraits; |
1662 | 1663 |
1663 // These types form an algebra over syntactic categories that is just | 1664 // These types form an algebra over syntactic categories that is just |
1664 // rich enough to let us recognize and propagate the constructs that | 1665 // rich enough to let us recognize and propagate the constructs that |
1665 // are either being counted in the preparser data, or is important | 1666 // are either being counted in the preparser data, or is important |
1666 // to throw the correct syntax error exceptions. | 1667 // to throw the correct syntax error exceptions. |
1667 | 1668 |
1668 // All ParseXXX functions take as the last argument an *ok parameter | 1669 // All ParseXXX functions take as the last argument an *ok parameter |
1669 // which is set to false if parsing failed; it is unchanged otherwise. | 1670 // which is set to false if parsing failed; it is unchanged otherwise. |
1670 // By making the 'exception handling' explicit, we are forced to check | 1671 // By making the 'exception handling' explicit, we are forced to check |
1671 // for failure at the call sites. | 1672 // for failure at the call sites. |
1672 Statement ParseStatementListItem(bool* ok); | 1673 Statement ParseStatementListItem(bool* ok); |
1673 void ParseStatementList(int end_token, bool* ok); | 1674 void ParseStatementList(int end_token, bool* ok, |
| 1675 Scanner::BookmarkScope* bookmark = nullptr); |
1674 Statement ParseStatement(bool* ok); | 1676 Statement ParseStatement(bool* ok); |
1675 Statement ParseSubStatement(bool* ok); | 1677 Statement ParseSubStatement(bool* ok); |
1676 Statement ParseFunctionDeclaration(bool* ok); | 1678 Statement ParseFunctionDeclaration(bool* ok); |
1677 Statement ParseClassDeclaration(bool* ok); | 1679 Statement ParseClassDeclaration(bool* ok); |
1678 Statement ParseBlock(bool* ok); | 1680 Statement ParseBlock(bool* ok); |
1679 Statement ParseVariableStatement(VariableDeclarationContext var_context, | 1681 Statement ParseVariableStatement(VariableDeclarationContext var_context, |
1680 bool* ok); | 1682 bool* ok); |
1681 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, | 1683 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, |
1682 int* num_decl, | 1684 int* num_decl, |
1683 Scanner::Location* first_initializer_loc, | 1685 Scanner::Location* first_initializer_loc, |
(...skipping 22 matching lines...) Expand all Loading... |
1706 V8_INLINE PreParserStatementList | 1708 V8_INLINE PreParserStatementList |
1707 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1709 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
1708 Variable* fvar, Token::Value fvar_init_op, | 1710 Variable* fvar, Token::Value fvar_init_op, |
1709 FunctionKind kind, bool* ok); | 1711 FunctionKind kind, bool* ok); |
1710 | 1712 |
1711 Expression ParseFunctionLiteral( | 1713 Expression ParseFunctionLiteral( |
1712 Identifier name, Scanner::Location function_name_location, | 1714 Identifier name, Scanner::Location function_name_location, |
1713 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1715 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
1714 FunctionLiteral::FunctionType function_type, | 1716 FunctionLiteral::FunctionType function_type, |
1715 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1717 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
1716 void ParseLazyFunctionLiteralBody(bool* ok); | 1718 void ParseLazyFunctionLiteralBody(bool* ok, |
| 1719 Scanner::BookmarkScope* bookmark = nullptr); |
1717 | 1720 |
1718 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1721 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
1719 Scanner::Location class_name_location, | 1722 Scanner::Location class_name_location, |
1720 bool name_is_strict_reserved, int pos, | 1723 bool name_is_strict_reserved, int pos, |
1721 bool* ok); | 1724 bool* ok); |
1722 }; | 1725 }; |
1723 | 1726 |
1724 | 1727 |
1725 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1728 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
1726 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1729 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3341 *ok = false; | 3344 *ok = false; |
3342 return; | 3345 return; |
3343 } | 3346 } |
3344 has_seen_constructor_ = true; | 3347 has_seen_constructor_ = true; |
3345 return; | 3348 return; |
3346 } | 3349 } |
3347 } | 3350 } |
3348 } } // v8::internal | 3351 } } // v8::internal |
3349 | 3352 |
3350 #endif // V8_PREPARSER_H | 3353 #endif // V8_PREPARSER_H |
OLD | NEW |