| 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 return PreParserExpression( | 749 return PreParserExpression( |
| 750 TypeField::encode(kExpression) | | 750 TypeField::encode(kExpression) | |
| 751 ExpressionTypeField::encode(kPropertyExpression)); | 751 ExpressionTypeField::encode(kPropertyExpression)); |
| 752 } | 752 } |
| 753 | 753 |
| 754 static PreParserExpression Call() { | 754 static PreParserExpression Call() { |
| 755 return PreParserExpression(TypeField::encode(kExpression) | | 755 return PreParserExpression(TypeField::encode(kExpression) | |
| 756 ExpressionTypeField::encode(kCallExpression)); | 756 ExpressionTypeField::encode(kCallExpression)); |
| 757 } | 757 } |
| 758 | 758 |
| 759 static PreParserExpression NoTemplateTag() { |
| 760 return PreParserExpression(TypeField::encode(kExpression) | |
| 761 ExpressionTypeField::encode( |
| 762 kNoTemplateTagExpression)); |
| 763 } |
| 764 |
| 759 bool IsIdentifier() const { | 765 bool IsIdentifier() const { |
| 760 return TypeField::decode(code_) == kIdentifierExpression; | 766 return TypeField::decode(code_) == kIdentifierExpression; |
| 761 } | 767 } |
| 762 | 768 |
| 763 PreParserIdentifier AsIdentifier() const { | 769 PreParserIdentifier AsIdentifier() const { |
| 764 DCHECK(IsIdentifier()); | 770 DCHECK(IsIdentifier()); |
| 765 return PreParserIdentifier(IdentifierTypeField::decode(code_)); | 771 return PreParserIdentifier(IdentifierTypeField::decode(code_)); |
| 766 } | 772 } |
| 767 | 773 |
| 768 bool IsStringLiteral() const { | 774 bool IsStringLiteral() const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 bool IsValidArrowParamList() const { | 808 bool IsValidArrowParamList() const { |
| 803 return IsValidArrowParams() && | 809 return IsValidArrowParams() && |
| 804 ParenthesizationField::decode(code_) != | 810 ParenthesizationField::decode(code_) != |
| 805 kMultiParenthesizedExpression; | 811 kMultiParenthesizedExpression; |
| 806 } | 812 } |
| 807 | 813 |
| 808 // At the moment PreParser doesn't track these expression types. | 814 // At the moment PreParser doesn't track these expression types. |
| 809 bool IsFunctionLiteral() const { return false; } | 815 bool IsFunctionLiteral() const { return false; } |
| 810 bool IsCallNew() const { return false; } | 816 bool IsCallNew() const { return false; } |
| 811 | 817 |
| 818 bool IsNoTemplateTag() const { |
| 819 return TypeField::decode(code_) == kExpression && |
| 820 ExpressionTypeField::decode(code_) == kNoTemplateTagExpression; |
| 821 } |
| 822 |
| 812 PreParserExpression AsFunctionLiteral() { return *this; } | 823 PreParserExpression AsFunctionLiteral() { return *this; } |
| 813 | 824 |
| 814 bool IsBinaryOperation() const { | 825 bool IsBinaryOperation() const { |
| 815 return TypeField::decode(code_) == kBinaryOperationExpression; | 826 return TypeField::decode(code_) == kBinaryOperationExpression; |
| 816 } | 827 } |
| 817 | 828 |
| 818 bool is_parenthesized() const { | 829 bool is_parenthesized() const { |
| 819 return ParenthesizationField::decode(code_) != kNotParenthesized; | 830 return ParenthesizationField::decode(code_) != kNotParenthesized; |
| 820 } | 831 } |
| 821 | 832 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 848 kNotParenthesized, | 859 kNotParenthesized, |
| 849 kParanthesizedExpression, | 860 kParanthesizedExpression, |
| 850 kMultiParenthesizedExpression | 861 kMultiParenthesizedExpression |
| 851 }; | 862 }; |
| 852 | 863 |
| 853 enum ExpressionType { | 864 enum ExpressionType { |
| 854 kThisExpression, | 865 kThisExpression, |
| 855 kThisPropertyExpression, | 866 kThisPropertyExpression, |
| 856 kPropertyExpression, | 867 kPropertyExpression, |
| 857 kCallExpression, | 868 kCallExpression, |
| 858 kSuperExpression | 869 kSuperExpression, |
| 870 kNoTemplateTagExpression |
| 859 }; | 871 }; |
| 860 | 872 |
| 861 explicit PreParserExpression(uint32_t expression_code) | 873 explicit PreParserExpression(uint32_t expression_code) |
| 862 : code_(expression_code) {} | 874 : code_(expression_code) {} |
| 863 | 875 |
| 864 V8_INLINE bool IsValidArrowParams() const { | 876 V8_INLINE bool IsValidArrowParams() const { |
| 865 return IsBinaryOperation() | 877 return IsBinaryOperation() |
| 866 ? IsValidArrowParamListField::decode(code_) | 878 ? IsValidArrowParamListField::decode(code_) |
| 867 : (IsIdentifier() && AsIdentifier().IsValidArrowParam()); | 879 : (IsIdentifier() && AsIdentifier().IsValidArrowParam()); |
| 868 } | 880 } |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 } | 1403 } |
| 1392 | 1404 |
| 1393 struct TemplateLiteralState {}; | 1405 struct TemplateLiteralState {}; |
| 1394 | 1406 |
| 1395 TemplateLiteralState OpenTemplateLiteral(int pos) { | 1407 TemplateLiteralState OpenTemplateLiteral(int pos) { |
| 1396 return TemplateLiteralState(); | 1408 return TemplateLiteralState(); |
| 1397 } | 1409 } |
| 1398 void AddTemplateSpan(TemplateLiteralState*, bool) {} | 1410 void AddTemplateSpan(TemplateLiteralState*, bool) {} |
| 1399 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {} | 1411 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {} |
| 1400 PreParserExpression CloseTemplateLiteral(TemplateLiteralState*, int, | 1412 PreParserExpression CloseTemplateLiteral(TemplateLiteralState*, int, |
| 1401 PreParserExpression) { | 1413 PreParserExpression tag) { |
| 1414 if (IsTaggedTemplate(tag)) { |
| 1415 // Emulate generation of array literals for tag callsite |
| 1416 // 1st is array of cooked strings, second is array of raw strings |
| 1417 MaterializeTemplateCallsiteLiterals(); |
| 1418 } |
| 1402 return EmptyExpression(); | 1419 return EmptyExpression(); |
| 1403 } | 1420 } |
| 1404 PreParserExpression NoTemplateTag() { return PreParserExpression::Default(); } | 1421 inline void MaterializeTemplateCallsiteLiterals(); |
| 1422 PreParserExpression NoTemplateTag() { |
| 1423 return PreParserExpression::NoTemplateTag(); |
| 1424 } |
| 1425 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 1426 return !tag.IsNoTemplateTag(); |
| 1427 } |
| 1405 static AstValueFactory* ast_value_factory() { return NULL; } | 1428 static AstValueFactory* ast_value_factory() { return NULL; } |
| 1406 | 1429 |
| 1407 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} | 1430 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} |
| 1408 | 1431 |
| 1409 // Temporary glue; these functions will move to ParserBase. | 1432 // Temporary glue; these functions will move to ParserBase. |
| 1410 PreParserExpression ParseV8Intrinsic(bool* ok); | 1433 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1411 PreParserExpression ParseFunctionLiteral( | 1434 PreParserExpression ParseFunctionLiteral( |
| 1412 PreParserIdentifier name, Scanner::Location function_name_location, | 1435 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1413 bool name_is_strict_reserved, FunctionKind kind, | 1436 bool name_is_strict_reserved, FunctionKind kind, |
| 1414 int function_token_position, FunctionLiteral::FunctionType type, | 1437 int function_token_position, FunctionLiteral::FunctionType type, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 | 1581 |
| 1559 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1582 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
| 1560 Scanner::Location class_name_location, | 1583 Scanner::Location class_name_location, |
| 1561 bool name_is_strict_reserved, int pos, | 1584 bool name_is_strict_reserved, int pos, |
| 1562 bool* ok); | 1585 bool* ok); |
| 1563 | 1586 |
| 1564 bool CheckInOrOf(bool accept_OF); | 1587 bool CheckInOrOf(bool accept_OF); |
| 1565 }; | 1588 }; |
| 1566 | 1589 |
| 1567 | 1590 |
| 1591 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
| 1592 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1593 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1594 } |
| 1595 |
| 1596 |
| 1568 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1597 PreParserStatementList PreParser::ParseEagerFunctionBody( |
| 1569 PreParserIdentifier function_name, int pos, Variable* fvar, | 1598 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1570 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1599 Token::Value fvar_init_op, bool is_generator, bool* ok) { |
| 1571 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1600 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| 1572 | 1601 |
| 1573 ParseSourceElements(Token::RBRACE, ok); | 1602 ParseSourceElements(Token::RBRACE, ok); |
| 1574 if (!*ok) return PreParserStatementList(); | 1603 if (!*ok) return PreParserStatementList(); |
| 1575 | 1604 |
| 1576 Expect(Token::RBRACE, ok); | 1605 Expect(Token::RBRACE, ok); |
| 1577 return PreParserStatementList(); | 1606 return PreParserStatementList(); |
| (...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2951 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
| 2923 // Both accessors of the same type. | 2952 // Both accessors of the same type. |
| 2924 parser()->ReportMessage("accessor_get_set"); | 2953 parser()->ReportMessage("accessor_get_set"); |
| 2925 } | 2954 } |
| 2926 *ok = false; | 2955 *ok = false; |
| 2927 } | 2956 } |
| 2928 } | 2957 } |
| 2929 } } // v8::internal | 2958 } } // v8::internal |
| 2930 | 2959 |
| 2931 #endif // V8_PREPARSER_H | 2960 #endif // V8_PREPARSER_H |
| OLD | NEW |