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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 const PreParserFormalParameters& parameters, | 1594 const PreParserFormalParameters& parameters, |
1595 PreParserStatementList list, bool* ok) {} | 1595 PreParserStatementList list, bool* ok) {} |
1596 | 1596 |
1597 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, | 1597 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, |
1598 int* expected_property_count, bool* ok) { | 1598 int* expected_property_count, bool* ok) { |
1599 UNREACHABLE(); | 1599 UNREACHABLE(); |
1600 } | 1600 } |
1601 | 1601 |
1602 V8_INLINE PreParserStatementList ParseEagerFunctionBody( | 1602 V8_INLINE PreParserStatementList ParseEagerFunctionBody( |
1603 PreParserIdentifier function_name, int pos, | 1603 PreParserIdentifier function_name, int pos, |
1604 const PreParserFormalParameters& parameters, | 1604 const PreParserFormalParameters& parameters, FunctionKind kind, |
1605 Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 1605 FunctionLiteral::FunctionType function_type, bool* ok); |
1606 | 1606 |
1607 V8_INLINE void ParseArrowFunctionFormalParameters( | 1607 V8_INLINE void ParseArrowFunctionFormalParameters( |
1608 PreParserFormalParameters* parameters, | 1608 PreParserFormalParameters* parameters, |
1609 PreParserExpression expression, const Scanner::Location& params_loc, | 1609 PreParserExpression expression, const Scanner::Location& params_loc, |
1610 Scanner::Location* duplicate_loc, bool* ok); | 1610 Scanner::Location* duplicate_loc, bool* ok); |
1611 | 1611 |
1612 void ReindexLiterals(const PreParserFormalParameters& paramaters) {} | 1612 void ReindexLiterals(const PreParserFormalParameters& paramaters) {} |
1613 | 1613 |
1614 struct TemplateLiteralState {}; | 1614 struct TemplateLiteralState {}; |
1615 | 1615 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 Statement ParseForStatement(bool* ok); | 1779 Statement ParseForStatement(bool* ok); |
1780 Statement ParseThrowStatement(bool* ok); | 1780 Statement ParseThrowStatement(bool* ok); |
1781 Statement ParseTryStatement(bool* ok); | 1781 Statement ParseTryStatement(bool* ok); |
1782 Statement ParseDebuggerStatement(bool* ok); | 1782 Statement ParseDebuggerStatement(bool* ok); |
1783 Expression ParseConditionalExpression(bool accept_IN, bool* ok); | 1783 Expression ParseConditionalExpression(bool accept_IN, bool* ok); |
1784 Expression ParseObjectLiteral(bool* ok); | 1784 Expression ParseObjectLiteral(bool* ok); |
1785 Expression ParseV8Intrinsic(bool* ok); | 1785 Expression ParseV8Intrinsic(bool* ok); |
1786 | 1786 |
1787 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, | 1787 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, |
1788 int* expected_property_count, bool* ok); | 1788 int* expected_property_count, bool* ok); |
1789 V8_INLINE PreParserStatementList | 1789 V8_INLINE PreParserStatementList ParseEagerFunctionBody( |
1790 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1790 PreParserIdentifier function_name, int pos, |
1791 const PreParserFormalParameters& parameters, | 1791 const PreParserFormalParameters& parameters, FunctionKind kind, |
1792 Variable* fvar, Token::Value fvar_init_op, | 1792 FunctionLiteral::FunctionType function_type, bool* ok); |
1793 FunctionKind kind, bool* ok); | |
1794 | 1793 |
1795 Expression ParseFunctionLiteral( | 1794 Expression ParseFunctionLiteral( |
1796 Identifier name, Scanner::Location function_name_location, | 1795 Identifier name, Scanner::Location function_name_location, |
1797 FunctionNameValidity function_name_validity, FunctionKind kind, | 1796 FunctionNameValidity function_name_validity, FunctionKind kind, |
1798 int function_token_pos, FunctionLiteral::FunctionType function_type, | 1797 int function_token_pos, FunctionLiteral::FunctionType function_type, |
1799 FunctionLiteral::ArityRestriction arity_restriction, | 1798 FunctionLiteral::ArityRestriction arity_restriction, |
1800 LanguageMode language_mode, bool* ok); | 1799 LanguageMode language_mode, bool* ok); |
1801 void ParseLazyFunctionLiteralBody(bool* ok, | 1800 void ParseLazyFunctionLiteralBody(bool* ok, |
1802 Scanner::BookmarkScope* bookmark = nullptr); | 1801 Scanner::BookmarkScope* bookmark = nullptr); |
1803 | 1802 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 PreParserFormalParameters* parameters, | 1837 PreParserFormalParameters* parameters, |
1839 PreParserExpression params, const Scanner::Location& params_loc, | 1838 PreParserExpression params, const Scanner::Location& params_loc, |
1840 Scanner::Location* duplicate_loc, bool* ok) { | 1839 Scanner::Location* duplicate_loc, bool* ok) { |
1841 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter | 1840 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter |
1842 // lists that are too long. | 1841 // lists that are too long. |
1843 } | 1842 } |
1844 | 1843 |
1845 | 1844 |
1846 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1845 PreParserStatementList PreParser::ParseEagerFunctionBody( |
1847 PreParserIdentifier function_name, int pos, | 1846 PreParserIdentifier function_name, int pos, |
1848 const PreParserFormalParameters& parameters, | 1847 const PreParserFormalParameters& parameters, FunctionKind kind, |
1849 Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1848 FunctionLiteral::FunctionType function_type, bool* ok) { |
1850 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1849 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
1851 | 1850 |
1852 ParseStatementList(Token::RBRACE, ok); | 1851 ParseStatementList(Token::RBRACE, ok); |
1853 if (!*ok) return PreParserStatementList(); | 1852 if (!*ok) return PreParserStatementList(); |
1854 | 1853 |
1855 Expect(Token::RBRACE, ok); | 1854 Expect(Token::RBRACE, ok); |
1856 return PreParserStatementList(); | 1855 return PreParserStatementList(); |
1857 } | 1856 } |
1858 | 1857 |
1859 | 1858 |
1860 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1859 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
1861 PreParserIdentifier function_name, int pos, | 1860 PreParserIdentifier function_name, int pos, |
1862 const PreParserFormalParameters& parameters, | 1861 const PreParserFormalParameters& parameters, FunctionKind kind, |
1863 Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1862 FunctionLiteral::FunctionType function_type, bool* ok) { |
1864 return pre_parser_->ParseEagerFunctionBody( | 1863 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1865 function_name, pos, parameters, fvar, fvar_init_op, kind, ok); | 1864 kind, function_type, ok); |
1866 } | 1865 } |
1867 | 1866 |
1868 | 1867 |
1869 template <class Traits> | 1868 template <class Traits> |
1870 ParserBase<Traits>::FunctionState::FunctionState( | 1869 ParserBase<Traits>::FunctionState::FunctionState( |
1871 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, | 1870 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, |
1872 FunctionKind kind, typename Traits::Type::Factory* factory) | 1871 FunctionKind kind, typename Traits::Type::Factory* factory) |
1873 : next_materialized_literal_index_(0), | 1872 : next_materialized_literal_index_(0), |
1874 expected_property_count_(0), | 1873 expected_property_count_(0), |
1875 this_location_(Scanner::Location::invalid()), | 1874 this_location_(Scanner::Location::invalid()), |
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3761 Consume(Token::LBRACE); | 3760 Consume(Token::LBRACE); |
3762 bool is_lazily_parsed = | 3761 bool is_lazily_parsed = |
3763 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); | 3762 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); |
3764 if (is_lazily_parsed) { | 3763 if (is_lazily_parsed) { |
3765 body = this->NewStatementList(0, zone()); | 3764 body = this->NewStatementList(0, zone()); |
3766 this->SkipLazyFunctionBody(&materialized_literal_count, | 3765 this->SkipLazyFunctionBody(&materialized_literal_count, |
3767 &expected_property_count, CHECK_OK); | 3766 &expected_property_count, CHECK_OK); |
3768 } else { | 3767 } else { |
3769 body = this->ParseEagerFunctionBody( | 3768 body = this->ParseEagerFunctionBody( |
3770 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, | 3769 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, |
3771 NULL, Token::INIT_VAR, kArrowFunction, CHECK_OK); | 3770 kArrowFunction, FunctionLiteral::ANONYMOUS_EXPRESSION, CHECK_OK); |
3772 materialized_literal_count = | 3771 materialized_literal_count = |
3773 function_state.materialized_literal_count(); | 3772 function_state.materialized_literal_count(); |
3774 expected_property_count = function_state.expected_property_count(); | 3773 expected_property_count = function_state.expected_property_count(); |
3775 } | 3774 } |
3776 } else { | 3775 } else { |
3777 // Single-expression body | 3776 // Single-expression body |
3778 int pos = position(); | 3777 int pos = position(); |
3779 parenthesized_function_ = false; | 3778 parenthesized_function_ = false; |
3780 ExpressionClassifier classifier; | 3779 ExpressionClassifier classifier; |
3781 ExpressionT expression = | 3780 ExpressionT expression = |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 *ok = false; | 4012 *ok = false; |
4014 return; | 4013 return; |
4015 } | 4014 } |
4016 has_seen_constructor_ = true; | 4015 has_seen_constructor_ = true; |
4017 return; | 4016 return; |
4018 } | 4017 } |
4019 } | 4018 } |
4020 } } // v8::internal | 4019 } } // v8::internal |
4021 | 4020 |
4022 #endif // V8_PREPARSER_H | 4021 #endif // V8_PREPARSER_H |
OLD | NEW |