| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 private: | 189 private: |
| 190 typename Traits::Type::Scope** scope_stack_; | 190 typename Traits::Type::Scope** scope_stack_; |
| 191 typename Traits::Type::Scope* outer_scope_; | 191 typename Traits::Type::Scope* outer_scope_; |
| 192 typename Traits::Type::Scope* scope_; | 192 typename Traits::Type::Scope* scope_; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class FunctionState BASE_EMBEDDED { | 195 class FunctionState BASE_EMBEDDED { |
| 196 public: | 196 public: |
| 197 FunctionState(FunctionState** function_state_stack, | 197 FunctionState(FunctionState** function_state_stack, |
| 198 typename Traits::Type::Scope** scope_stack, | 198 typename Traits::Type::Scope** scope_stack, |
| 199 typename Traits::Type::Scope* scope, | 199 typename Traits::Type::Scope* scope, FunctionKind kind, |
| 200 typename Traits::Type::Factory* factory); | 200 typename Traits::Type::Factory* factory); |
| 201 ~FunctionState(); | 201 ~FunctionState(); |
| 202 | 202 |
| 203 int NextMaterializedLiteralIndex() { | 203 int NextMaterializedLiteralIndex() { |
| 204 return next_materialized_literal_index_++; | 204 return next_materialized_literal_index_++; |
| 205 } | 205 } |
| 206 int materialized_literal_count() { | 206 int materialized_literal_count() { |
| 207 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; | 207 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
| 208 } | 208 } |
| 209 | 209 |
| 210 int NextHandlerIndex() { return next_handler_index_++; } | 210 int NextHandlerIndex() { return next_handler_index_++; } |
| 211 int handler_count() { return next_handler_index_; } | 211 int handler_count() { return next_handler_index_; } |
| 212 | 212 |
| 213 void AddProperty() { expected_property_count_++; } | 213 void AddProperty() { expected_property_count_++; } |
| 214 int expected_property_count() { return expected_property_count_; } | 214 int expected_property_count() { return expected_property_count_; } |
| 215 | 215 |
| 216 void set_is_generator(bool is_generator) { is_generator_ = is_generator; } | 216 bool is_generator() const { return IsGeneratorFunction(kind_); } |
| 217 bool is_generator() const { return is_generator_; } | 217 |
| 218 FunctionKind kind() const { return kind_; } |
| 218 | 219 |
| 219 void set_generator_object_variable( | 220 void set_generator_object_variable( |
| 220 typename Traits::Type::GeneratorVariable* variable) { | 221 typename Traits::Type::GeneratorVariable* variable) { |
| 221 DCHECK(variable != NULL); | 222 DCHECK(variable != NULL); |
| 222 DCHECK(!is_generator()); | 223 DCHECK(is_generator()); |
| 223 generator_object_variable_ = variable; | 224 generator_object_variable_ = variable; |
| 224 is_generator_ = true; | |
| 225 } | 225 } |
| 226 typename Traits::Type::GeneratorVariable* generator_object_variable() | 226 typename Traits::Type::GeneratorVariable* generator_object_variable() |
| 227 const { | 227 const { |
| 228 return generator_object_variable_; | 228 return generator_object_variable_; |
| 229 } | 229 } |
| 230 | 230 |
| 231 typename Traits::Type::Factory* factory() { return factory_; } | 231 typename Traits::Type::Factory* factory() { return factory_; } |
| 232 | 232 |
| 233 private: | 233 private: |
| 234 // Used to assign an index to each literal that needs materialization in | 234 // Used to assign an index to each literal that needs materialization in |
| 235 // the function. Includes regexp literals, and boilerplate for object and | 235 // the function. Includes regexp literals, and boilerplate for object and |
| 236 // array literals. | 236 // array literals. |
| 237 int next_materialized_literal_index_; | 237 int next_materialized_literal_index_; |
| 238 | 238 |
| 239 // Used to assign a per-function index to try and catch handlers. | 239 // Used to assign a per-function index to try and catch handlers. |
| 240 int next_handler_index_; | 240 int next_handler_index_; |
| 241 | 241 |
| 242 // Properties count estimation. | 242 // Properties count estimation. |
| 243 int expected_property_count_; | 243 int expected_property_count_; |
| 244 | 244 |
| 245 // Whether the function is a generator. | 245 FunctionKind kind_; |
| 246 bool is_generator_; | |
| 247 // For generators, this variable may hold the generator object. It variable | 246 // For generators, this variable may hold the generator object. It variable |
| 248 // is used by yield expressions and return statements. It is not necessary | 247 // is used by yield expressions and return statements. It is not necessary |
| 249 // for generator functions to have this variable set. | 248 // for generator functions to have this variable set. |
| 250 Variable* generator_object_variable_; | 249 Variable* generator_object_variable_; |
| 251 | 250 |
| 251 |
| 252 FunctionState** function_state_stack_; | 252 FunctionState** function_state_stack_; |
| 253 FunctionState* outer_function_state_; | 253 FunctionState* outer_function_state_; |
| 254 typename Traits::Type::Scope** scope_stack_; | 254 typename Traits::Type::Scope** scope_stack_; |
| 255 typename Traits::Type::Scope* outer_scope_; | 255 typename Traits::Type::Scope* outer_scope_; |
| 256 typename Traits::Type::Zone* extra_param_; | 256 typename Traits::Type::Zone* extra_param_; |
| 257 typename Traits::Type::Factory* factory_; | 257 typename Traits::Type::Factory* factory_; |
| 258 | 258 |
| 259 friend class ParserTraits; | 259 friend class ParserTraits; |
| 260 friend class Checkpoint; | 260 friend class Checkpoint; |
| 261 }; | 261 }; |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 return PreParserExpressionList(); | 1423 return PreParserExpressionList(); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1426 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, |
| 1427 int* materialized_literal_count, | 1427 int* materialized_literal_count, |
| 1428 int* expected_property_count, bool* ok) { | 1428 int* expected_property_count, bool* ok) { |
| 1429 UNREACHABLE(); | 1429 UNREACHABLE(); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 V8_INLINE PreParserStatementList | 1432 V8_INLINE PreParserStatementList |
| 1433 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1433 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
| 1434 Variable* fvar, Token::Value fvar_init_op, | 1434 Variable* fvar, Token::Value fvar_init_op, |
| 1435 bool is_generator, bool* ok); | 1435 FunctionKind kind, bool* ok); |
| 1436 | 1436 |
| 1437 // Utility functions | 1437 // Utility functions |
| 1438 int DeclareArrowParametersFromExpression(PreParserExpression expression, | 1438 int DeclareArrowParametersFromExpression(PreParserExpression expression, |
| 1439 PreParserScope* scope, | 1439 PreParserScope* scope, |
| 1440 Scanner::Location* dupe_loc, | 1440 Scanner::Location* dupe_loc, |
| 1441 bool* ok) { | 1441 bool* ok) { |
| 1442 // TODO(aperez): Detect duplicated identifiers in paramlists. | 1442 // TODO(aperez): Detect duplicated identifiers in paramlists. |
| 1443 *ok = expression.IsValidArrowParamList(); | 1443 *ok = expression.IsValidArrowParamList(); |
| 1444 return 0; | 1444 return 0; |
| 1445 } | 1445 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 : ParserBase<PreParserTraits>(isolate, NULL, scanner, stack_limit, NULL, | 1517 : ParserBase<PreParserTraits>(isolate, NULL, scanner, stack_limit, NULL, |
| 1518 log, this) {} | 1518 log, this) {} |
| 1519 | 1519 |
| 1520 // Pre-parse the program from the character stream; returns true on | 1520 // Pre-parse the program from the character stream; returns true on |
| 1521 // success (even if parsing failed, the pre-parse data successfully | 1521 // success (even if parsing failed, the pre-parse data successfully |
| 1522 // captured the syntax error), and false if a stack-overflow happened | 1522 // captured the syntax error), and false if a stack-overflow happened |
| 1523 // during parsing. | 1523 // during parsing. |
| 1524 PreParseResult PreParseProgram(int* materialized_literals = 0) { | 1524 PreParseResult PreParseProgram(int* materialized_literals = 0) { |
| 1525 PreParserScope scope(scope_, SCRIPT_SCOPE); | 1525 PreParserScope scope(scope_, SCRIPT_SCOPE); |
| 1526 PreParserFactory factory(NULL); | 1526 PreParserFactory factory(NULL); |
| 1527 FunctionState top_scope(&function_state_, &scope_, &scope, &factory); | 1527 FunctionState top_scope(&function_state_, &scope_, &scope, kNormalFunction, |
| 1528 &factory); |
| 1528 bool ok = true; | 1529 bool ok = true; |
| 1529 int start_position = scanner()->peek_location().beg_pos; | 1530 int start_position = scanner()->peek_location().beg_pos; |
| 1530 ParseSourceElements(Token::EOS, &ok); | 1531 ParseSourceElements(Token::EOS, &ok); |
| 1531 if (stack_overflow()) return kPreParseStackOverflow; | 1532 if (stack_overflow()) return kPreParseStackOverflow; |
| 1532 if (!ok) { | 1533 if (!ok) { |
| 1533 ReportUnexpectedToken(scanner()->current_token()); | 1534 ReportUnexpectedToken(scanner()->current_token()); |
| 1534 } else if (is_strict(scope_->language_mode())) { | 1535 } else if (is_strict(scope_->language_mode())) { |
| 1535 CheckStrictOctalLiteral(start_position, scanner()->location().end_pos, | 1536 CheckStrictOctalLiteral(start_position, scanner()->location().end_pos, |
| 1536 &ok); | 1537 &ok); |
| 1537 } | 1538 } |
| 1538 if (materialized_literals) { | 1539 if (materialized_literals) { |
| 1539 *materialized_literals = function_state_->materialized_literal_count(); | 1540 *materialized_literals = function_state_->materialized_literal_count(); |
| 1540 } | 1541 } |
| 1541 return kPreParseSuccess; | 1542 return kPreParseSuccess; |
| 1542 } | 1543 } |
| 1543 | 1544 |
| 1544 // Parses a single function literal, from the opening parentheses before | 1545 // Parses a single function literal, from the opening parentheses before |
| 1545 // parameters to the closing brace after the body. | 1546 // parameters to the closing brace after the body. |
| 1546 // Returns a FunctionEntry describing the body of the function in enough | 1547 // Returns a FunctionEntry describing the body of the function in enough |
| 1547 // detail that it can be lazily compiled. | 1548 // detail that it can be lazily compiled. |
| 1548 // The scanner is expected to have matched the "function" or "function*" | 1549 // The scanner is expected to have matched the "function" or "function*" |
| 1549 // keyword and parameters, and have consumed the initial '{'. | 1550 // keyword and parameters, and have consumed the initial '{'. |
| 1550 // At return, unless an error occurred, the scanner is positioned before the | 1551 // At return, unless an error occurred, the scanner is positioned before the |
| 1551 // the final '}'. | 1552 // the final '}'. |
| 1552 PreParseResult PreParseLazyFunction(LanguageMode language_mode, | 1553 PreParseResult PreParseLazyFunction(LanguageMode language_mode, |
| 1553 bool is_generator, ParserRecorder* log); | 1554 FunctionKind kind, ParserRecorder* log); |
| 1554 | 1555 |
| 1555 private: | 1556 private: |
| 1556 friend class PreParserTraits; | 1557 friend class PreParserTraits; |
| 1557 | 1558 |
| 1558 // These types form an algebra over syntactic categories that is just | 1559 // These types form an algebra over syntactic categories that is just |
| 1559 // rich enough to let us recognize and propagate the constructs that | 1560 // rich enough to let us recognize and propagate the constructs that |
| 1560 // are either being counted in the preparser data, or is important | 1561 // are either being counted in the preparser data, or is important |
| 1561 // to throw the correct syntax error exceptions. | 1562 // to throw the correct syntax error exceptions. |
| 1562 | 1563 |
| 1563 enum VariableDeclarationContext { | 1564 enum VariableDeclarationContext { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 Statement ParseTryStatement(bool* ok); | 1608 Statement ParseTryStatement(bool* ok); |
| 1608 Statement ParseDebuggerStatement(bool* ok); | 1609 Statement ParseDebuggerStatement(bool* ok); |
| 1609 Expression ParseConditionalExpression(bool accept_IN, bool* ok); | 1610 Expression ParseConditionalExpression(bool accept_IN, bool* ok); |
| 1610 Expression ParseObjectLiteral(bool* ok); | 1611 Expression ParseObjectLiteral(bool* ok); |
| 1611 Expression ParseV8Intrinsic(bool* ok); | 1612 Expression ParseV8Intrinsic(bool* ok); |
| 1612 | 1613 |
| 1613 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1614 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, |
| 1614 int* materialized_literal_count, | 1615 int* materialized_literal_count, |
| 1615 int* expected_property_count, bool* ok); | 1616 int* expected_property_count, bool* ok); |
| 1616 V8_INLINE PreParserStatementList | 1617 V8_INLINE PreParserStatementList |
| 1617 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1618 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
| 1618 Variable* fvar, Token::Value fvar_init_op, | 1619 Variable* fvar, Token::Value fvar_init_op, |
| 1619 bool is_generator, bool* ok); | 1620 FunctionKind kind, bool* ok); |
| 1620 | 1621 |
| 1621 Expression ParseFunctionLiteral( | 1622 Expression ParseFunctionLiteral( |
| 1622 Identifier name, Scanner::Location function_name_location, | 1623 Identifier name, Scanner::Location function_name_location, |
| 1623 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1624 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 1624 FunctionLiteral::FunctionType function_type, | 1625 FunctionLiteral::FunctionType function_type, |
| 1625 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1626 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1626 void ParseLazyFunctionLiteralBody(bool* ok); | 1627 void ParseLazyFunctionLiteralBody(bool* ok); |
| 1627 | 1628 |
| 1628 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1629 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
| 1629 Scanner::Location class_name_location, | 1630 Scanner::Location class_name_location, |
| 1630 bool name_is_strict_reserved, int pos, | 1631 bool name_is_strict_reserved, int pos, |
| 1631 bool* ok); | 1632 bool* ok); |
| 1632 | 1633 |
| 1633 bool CheckInOrOf(bool accept_OF); | 1634 bool CheckInOrOf(bool accept_OF); |
| 1634 }; | 1635 }; |
| 1635 | 1636 |
| 1636 | 1637 |
| 1637 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1638 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
| 1638 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1639 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1639 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1640 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 | 1643 |
| 1643 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1644 PreParserStatementList PreParser::ParseEagerFunctionBody( |
| 1644 PreParserIdentifier function_name, int pos, Variable* fvar, | 1645 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1645 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1646 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
| 1646 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1647 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| 1647 | 1648 |
| 1648 ParseSourceElements(Token::RBRACE, ok); | 1649 ParseSourceElements(Token::RBRACE, ok); |
| 1649 if (!*ok) return PreParserStatementList(); | 1650 if (!*ok) return PreParserStatementList(); |
| 1650 | 1651 |
| 1651 Expect(Token::RBRACE, ok); | 1652 Expect(Token::RBRACE, ok); |
| 1652 return PreParserStatementList(); | 1653 return PreParserStatementList(); |
| 1653 } | 1654 } |
| 1654 | 1655 |
| 1655 | 1656 |
| 1656 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1657 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
| 1657 PreParserIdentifier function_name, int pos, Variable* fvar, | 1658 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1658 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1659 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
| 1659 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, | 1660 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, |
| 1660 fvar_init_op, is_generator, ok); | 1661 fvar_init_op, kind, ok); |
| 1661 } | 1662 } |
| 1662 | 1663 |
| 1663 | 1664 |
| 1664 template <class Traits> | 1665 template <class Traits> |
| 1665 ParserBase<Traits>::FunctionState::FunctionState( | 1666 ParserBase<Traits>::FunctionState::FunctionState( |
| 1666 FunctionState** function_state_stack, | 1667 FunctionState** function_state_stack, |
| 1667 typename Traits::Type::Scope** scope_stack, | 1668 typename Traits::Type::Scope** scope_stack, |
| 1668 typename Traits::Type::Scope* scope, | 1669 typename Traits::Type::Scope* scope, FunctionKind kind, |
| 1669 typename Traits::Type::Factory* factory) | 1670 typename Traits::Type::Factory* factory) |
| 1670 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1671 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1671 next_handler_index_(0), | 1672 next_handler_index_(0), |
| 1672 expected_property_count_(0), | 1673 expected_property_count_(0), |
| 1673 is_generator_(false), | 1674 kind_(kind), |
| 1674 generator_object_variable_(NULL), | 1675 generator_object_variable_(NULL), |
| 1675 function_state_stack_(function_state_stack), | 1676 function_state_stack_(function_state_stack), |
| 1676 outer_function_state_(*function_state_stack), | 1677 outer_function_state_(*function_state_stack), |
| 1677 scope_stack_(scope_stack), | 1678 scope_stack_(scope_stack), |
| 1678 outer_scope_(*scope_stack), | 1679 outer_scope_(*scope_stack), |
| 1679 factory_(factory) { | 1680 factory_(factory) { |
| 1680 *scope_stack_ = scope; | 1681 *scope_stack_ = scope; |
| 1681 *function_state_stack = this; | 1682 *function_state_stack = this; |
| 1682 } | 1683 } |
| 1683 | 1684 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 is_generator, | 2130 is_generator, |
| 2130 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2131 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2131 } | 2132 } |
| 2132 | 2133 |
| 2133 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod | 2134 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod |
| 2134 : FunctionKind::kConciseMethod; | 2135 : FunctionKind::kConciseMethod; |
| 2135 | 2136 |
| 2136 if (in_class && !is_static && this->IsConstructor(name)) { | 2137 if (in_class && !is_static && this->IsConstructor(name)) { |
| 2137 *has_seen_constructor = true; | 2138 *has_seen_constructor = true; |
| 2138 kind = has_extends ? FunctionKind::kSubclassConstructor | 2139 kind = has_extends ? FunctionKind::kSubclassConstructor |
| 2139 : FunctionKind::kNormalFunction; | 2140 : FunctionKind::kBaseConstructor; |
| 2140 } | 2141 } |
| 2141 | 2142 |
| 2142 value = this->ParseFunctionLiteral( | 2143 value = this->ParseFunctionLiteral( |
| 2143 name, scanner()->location(), | 2144 name, scanner()->location(), |
| 2144 false, // reserved words are allowed here | 2145 false, // reserved words are allowed here |
| 2145 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 2146 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, |
| 2146 FunctionLiteral::NORMAL_ARITY, | 2147 FunctionLiteral::NORMAL_ARITY, |
| 2147 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2148 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2148 | 2149 |
| 2149 return factory()->NewObjectLiteralProperty(name_expression, value, | 2150 return factory()->NewObjectLiteralProperty(name_expression, value, |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 typename Traits::Type::StatementList body; | 2811 typename Traits::Type::StatementList body; |
| 2811 int num_parameters = -1; | 2812 int num_parameters = -1; |
| 2812 int materialized_literal_count = -1; | 2813 int materialized_literal_count = -1; |
| 2813 int expected_property_count = -1; | 2814 int expected_property_count = -1; |
| 2814 int handler_count = 0; | 2815 int handler_count = 0; |
| 2815 | 2816 |
| 2816 { | 2817 { |
| 2817 typename Traits::Type::Factory function_factory(this->ast_value_factory()); | 2818 typename Traits::Type::Factory function_factory(this->ast_value_factory()); |
| 2818 FunctionState function_state(&function_state_, &scope_, | 2819 FunctionState function_state(&function_state_, &scope_, |
| 2819 Traits::Type::ptr_to_scope(scope), | 2820 Traits::Type::ptr_to_scope(scope), |
| 2820 &function_factory); | 2821 kArrowFunction, &function_factory); |
| 2821 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 2822 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
| 2822 num_parameters = Traits::DeclareArrowParametersFromExpression( | 2823 num_parameters = Traits::DeclareArrowParametersFromExpression( |
| 2823 params_ast, scope_, &dupe_error_loc, ok); | 2824 params_ast, scope_, &dupe_error_loc, ok); |
| 2824 if (!*ok) { | 2825 if (!*ok) { |
| 2825 ReportMessageAt( | 2826 ReportMessageAt( |
| 2826 Scanner::Location(start_pos, scanner()->location().beg_pos), | 2827 Scanner::Location(start_pos, scanner()->location().beg_pos), |
| 2827 "malformed_arrow_function_parameter_list"); | 2828 "malformed_arrow_function_parameter_list"); |
| 2828 return this->EmptyExpression(); | 2829 return this->EmptyExpression(); |
| 2829 } | 2830 } |
| 2830 | 2831 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2843 bool is_lazily_parsed = | 2844 bool is_lazily_parsed = |
| 2844 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); | 2845 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); |
| 2845 if (is_lazily_parsed) { | 2846 if (is_lazily_parsed) { |
| 2846 body = this->NewStatementList(0, zone()); | 2847 body = this->NewStatementList(0, zone()); |
| 2847 this->SkipLazyFunctionBody(this->EmptyIdentifier(), | 2848 this->SkipLazyFunctionBody(this->EmptyIdentifier(), |
| 2848 &materialized_literal_count, | 2849 &materialized_literal_count, |
| 2849 &expected_property_count, CHECK_OK); | 2850 &expected_property_count, CHECK_OK); |
| 2850 } else { | 2851 } else { |
| 2851 body = this->ParseEagerFunctionBody( | 2852 body = this->ParseEagerFunctionBody( |
| 2852 this->EmptyIdentifier(), RelocInfo::kNoPosition, NULL, | 2853 this->EmptyIdentifier(), RelocInfo::kNoPosition, NULL, |
| 2853 Token::INIT_VAR, false, // Not a generator. | 2854 Token::INIT_VAR, kArrowFunction, CHECK_OK); |
| 2854 CHECK_OK); | |
| 2855 materialized_literal_count = | 2855 materialized_literal_count = |
| 2856 function_state.materialized_literal_count(); | 2856 function_state.materialized_literal_count(); |
| 2857 expected_property_count = function_state.expected_property_count(); | 2857 expected_property_count = function_state.expected_property_count(); |
| 2858 handler_count = function_state.handler_count(); | 2858 handler_count = function_state.handler_count(); |
| 2859 } | 2859 } |
| 2860 } else { | 2860 } else { |
| 2861 // Single-expression body | 2861 // Single-expression body |
| 2862 int pos = position(); | 2862 int pos = position(); |
| 2863 parenthesized_function_ = false; | 2863 parenthesized_function_ = false; |
| 2864 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); | 2864 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3076 *ok = false; | 3076 *ok = false; |
| 3077 return; | 3077 return; |
| 3078 } | 3078 } |
| 3079 has_seen_constructor_ = true; | 3079 has_seen_constructor_ = true; |
| 3080 return; | 3080 return; |
| 3081 } | 3081 } |
| 3082 } | 3082 } |
| 3083 } } // v8::internal | 3083 } } // v8::internal |
| 3084 | 3084 |
| 3085 #endif // V8_PREPARSER_H | 3085 #endif // V8_PREPARSER_H |
| OLD | NEW |