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 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 ExpressionClassifier* classifier, bool is_rest) {} | 1620 ExpressionClassifier* classifier, bool is_rest) {} |
1621 | 1621 |
1622 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} | 1622 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
1623 | 1623 |
1624 // Temporary glue; these functions will move to ParserBase. | 1624 // Temporary glue; these functions will move to ParserBase. |
1625 PreParserExpression ParseV8Intrinsic(bool* ok); | 1625 PreParserExpression ParseV8Intrinsic(bool* ok); |
1626 PreParserExpression ParseFunctionLiteral( | 1626 PreParserExpression ParseFunctionLiteral( |
1627 PreParserIdentifier name, Scanner::Location function_name_location, | 1627 PreParserIdentifier name, Scanner::Location function_name_location, |
1628 FunctionNameValidity function_name_validity, FunctionKind kind, | 1628 FunctionNameValidity function_name_validity, FunctionKind kind, |
1629 int function_token_position, FunctionLiteral::FunctionType type, | 1629 int function_token_position, FunctionLiteral::FunctionType type, |
1630 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1630 FunctionLiteral::ArityRestriction arity_restriction, |
| 1631 LanguageMode language_mode, bool* ok); |
1631 | 1632 |
1632 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1633 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
1633 Scanner::Location class_name_location, | 1634 Scanner::Location class_name_location, |
1634 bool name_is_strict_reserved, int pos, | 1635 bool name_is_strict_reserved, int pos, |
1635 bool* ok); | 1636 bool* ok); |
1636 | 1637 |
1637 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) { | 1638 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) { |
1638 return list; | 1639 return list; |
1639 } | 1640 } |
1640 | 1641 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 V8_INLINE PreParserStatementList | 1769 V8_INLINE PreParserStatementList |
1769 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1770 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
1770 const FormalParameterParsingStateT& formal_parameters, | 1771 const FormalParameterParsingStateT& formal_parameters, |
1771 Variable* fvar, Token::Value fvar_init_op, | 1772 Variable* fvar, Token::Value fvar_init_op, |
1772 FunctionKind kind, bool* ok); | 1773 FunctionKind kind, bool* ok); |
1773 | 1774 |
1774 Expression ParseFunctionLiteral( | 1775 Expression ParseFunctionLiteral( |
1775 Identifier name, Scanner::Location function_name_location, | 1776 Identifier name, Scanner::Location function_name_location, |
1776 FunctionNameValidity function_name_validity, FunctionKind kind, | 1777 FunctionNameValidity function_name_validity, FunctionKind kind, |
1777 int function_token_pos, FunctionLiteral::FunctionType function_type, | 1778 int function_token_pos, FunctionLiteral::FunctionType function_type, |
1778 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1779 FunctionLiteral::ArityRestriction arity_restriction, |
| 1780 LanguageMode language_mode, bool* ok); |
1779 void ParseLazyFunctionLiteralBody(bool* ok, | 1781 void ParseLazyFunctionLiteralBody(bool* ok, |
1780 Scanner::BookmarkScope* bookmark = nullptr); | 1782 Scanner::BookmarkScope* bookmark = nullptr); |
1781 | 1783 |
1782 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1784 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
1783 Scanner::Location class_name_location, | 1785 Scanner::Location class_name_location, |
1784 bool name_is_strict_reserved, int pos, | 1786 bool name_is_strict_reserved, int pos, |
1785 bool* ok); | 1787 bool* ok); |
1786 }; | 1788 }; |
1787 | 1789 |
1788 | 1790 |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 *has_seen_constructor = true; | 2545 *has_seen_constructor = true; |
2544 kind = has_extends ? FunctionKind::kSubclassConstructor | 2546 kind = has_extends ? FunctionKind::kSubclassConstructor |
2545 : FunctionKind::kBaseConstructor; | 2547 : FunctionKind::kBaseConstructor; |
2546 } | 2548 } |
2547 | 2549 |
2548 if (!in_class) kind = WithObjectLiteralBit(kind); | 2550 if (!in_class) kind = WithObjectLiteralBit(kind); |
2549 | 2551 |
2550 value = this->ParseFunctionLiteral( | 2552 value = this->ParseFunctionLiteral( |
2551 name, scanner()->location(), kSkipFunctionNameCheck, kind, | 2553 name, scanner()->location(), kSkipFunctionNameCheck, kind, |
2552 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 2554 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, |
2553 FunctionLiteral::NORMAL_ARITY, | 2555 FunctionLiteral::NORMAL_ARITY, language_mode(), |
2554 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2556 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2555 | 2557 |
2556 return factory()->NewObjectLiteralProperty(name_expression, value, | 2558 return factory()->NewObjectLiteralProperty(name_expression, value, |
2557 ObjectLiteralProperty::COMPUTED, | 2559 ObjectLiteralProperty::COMPUTED, |
2558 is_static, *is_computed_name); | 2560 is_static, *is_computed_name); |
2559 | 2561 |
2560 } else if (in_class && name_is_static && !is_static) { | 2562 } else if (in_class && name_is_static && !is_static) { |
2561 // static MethodDefinition | 2563 // static MethodDefinition |
2562 return ParsePropertyDefinition(checker, true, has_extends, true, | 2564 return ParsePropertyDefinition(checker, true, has_extends, true, |
2563 is_computed_name, nullptr, classifier, ok); | 2565 is_computed_name, nullptr, classifier, ok); |
(...skipping 12 matching lines...) Expand all Loading... |
2576 is_generator, | 2578 is_generator, |
2577 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2579 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2578 } | 2580 } |
2579 | 2581 |
2580 FunctionKind kind = FunctionKind::kAccessorFunction; | 2582 FunctionKind kind = FunctionKind::kAccessorFunction; |
2581 if (!in_class) kind = WithObjectLiteralBit(kind); | 2583 if (!in_class) kind = WithObjectLiteralBit(kind); |
2582 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( | 2584 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( |
2583 name, scanner()->location(), kSkipFunctionNameCheck, kind, | 2585 name, scanner()->location(), kSkipFunctionNameCheck, kind, |
2584 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 2586 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, |
2585 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY, | 2587 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY, |
2586 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2588 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2587 | 2589 |
2588 // Make sure the name expression is a string since we need a Name for | 2590 // Make sure the name expression is a string since we need a Name for |
2589 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this | 2591 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this |
2590 // statically we can skip the extra runtime check. | 2592 // statically we can skip the extra runtime check. |
2591 if (!*is_computed_name) { | 2593 if (!*is_computed_name) { |
2592 name_expression = | 2594 name_expression = |
2593 factory()->NewStringLiteral(name, name_expression->position()); | 2595 factory()->NewStringLiteral(name, name_expression->position()); |
2594 } | 2596 } |
2595 | 2597 |
2596 return factory()->NewObjectLiteralProperty( | 2598 return factory()->NewObjectLiteralProperty( |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3295 function_name_location = scanner()->location(); | 3297 function_name_location = scanner()->location(); |
3296 function_type = FunctionLiteral::NAMED_EXPRESSION; | 3298 function_type = FunctionLiteral::NAMED_EXPRESSION; |
3297 } | 3299 } |
3298 result = this->ParseFunctionLiteral( | 3300 result = this->ParseFunctionLiteral( |
3299 name, function_name_location, | 3301 name, function_name_location, |
3300 is_strict_reserved_name ? kFunctionNameIsStrictReserved | 3302 is_strict_reserved_name ? kFunctionNameIsStrictReserved |
3301 : kFunctionNameValidityUnknown, | 3303 : kFunctionNameValidityUnknown, |
3302 is_generator ? FunctionKind::kGeneratorFunction | 3304 is_generator ? FunctionKind::kGeneratorFunction |
3303 : FunctionKind::kNormalFunction, | 3305 : FunctionKind::kNormalFunction, |
3304 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, | 3306 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, |
3305 CHECK_OK); | 3307 language_mode(), CHECK_OK); |
3306 } else if (peek() == Token::SUPER) { | 3308 } else if (peek() == Token::SUPER) { |
3307 const bool is_new = false; | 3309 const bool is_new = false; |
3308 result = ParseSuperExpression(is_new, classifier, CHECK_OK); | 3310 result = ParseSuperExpression(is_new, classifier, CHECK_OK); |
3309 } else { | 3311 } else { |
3310 result = ParsePrimaryExpression(classifier, CHECK_OK); | 3312 result = ParsePrimaryExpression(classifier, CHECK_OK); |
3311 } | 3313 } |
3312 | 3314 |
3313 result = ParseMemberExpressionContinuation(result, classifier, CHECK_OK); | 3315 result = ParseMemberExpressionContinuation(result, classifier, CHECK_OK); |
3314 return result; | 3316 return result; |
3315 } | 3317 } |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3980 *ok = false; | 3982 *ok = false; |
3981 return; | 3983 return; |
3982 } | 3984 } |
3983 has_seen_constructor_ = true; | 3985 has_seen_constructor_ = true; |
3984 return; | 3986 return; |
3985 } | 3987 } |
3986 } | 3988 } |
3987 } } // v8::internal | 3989 } } // v8::internal |
3988 | 3990 |
3989 #endif // V8_PREPARSER_H | 3991 #endif // V8_PREPARSER_H |
OLD | NEW |