| 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 // Dummy implementation for making expression->somefunc() work in both Parser | 808 // Dummy implementation for making expression->somefunc() work in both Parser |
| 809 // and PreParser. | 809 // and PreParser. |
| 810 PreParserExpression* operator->() { return this; } | 810 PreParserExpression* operator->() { return this; } |
| 811 | 811 |
| 812 // More dummy implementations of things PreParser doesn't need to track: | 812 // More dummy implementations of things PreParser doesn't need to track: |
| 813 void set_index(int index) {} // For YieldExpressions | 813 void set_index(int index) {} // For YieldExpressions |
| 814 void set_parenthesized() {} | 814 void set_parenthesized() {} |
| 815 | 815 |
| 816 int position() const { return RelocInfo::kNoPosition; } | 816 int position() const { return RelocInfo::kNoPosition; } |
| 817 void set_function_token_position(int position) {} | 817 void set_function_token_position(int position) {} |
| 818 void set_ast_properties(int* ast_properties) {} | |
| 819 | 818 |
| 820 private: | 819 private: |
| 821 enum Type { | 820 enum Type { |
| 822 kExpression, | 821 kExpression, |
| 823 kIdentifierExpression, | 822 kIdentifierExpression, |
| 824 kStringLiteralExpression, | 823 kStringLiteralExpression, |
| 825 kBinaryOperationExpression | 824 kBinaryOperationExpression |
| 826 }; | 825 }; |
| 827 | 826 |
| 828 enum Parenthesization { | 827 enum Parenthesization { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 int position) { | 1090 int position) { |
| 1092 return PreParserExpression::Default(); | 1091 return PreParserExpression::Default(); |
| 1093 } | 1092 } |
| 1094 PreParserExpression NewClassLiteral(PreParserIdentifier name, | 1093 PreParserExpression NewClassLiteral(PreParserIdentifier name, |
| 1095 PreParserExpression extends, | 1094 PreParserExpression extends, |
| 1096 PreParserExpression constructor, | 1095 PreParserExpression constructor, |
| 1097 PreParserExpressionList properties, | 1096 PreParserExpressionList properties, |
| 1098 int start_position, int end_position) { | 1097 int start_position, int end_position) { |
| 1099 return PreParserExpression::Default(); | 1098 return PreParserExpression::Default(); |
| 1100 } | 1099 } |
| 1101 | |
| 1102 // Return the object itself as AstVisitor and implement the needed | |
| 1103 // dummy method right in this class. | |
| 1104 PreParserFactory* visitor() { return this; } | |
| 1105 int* ast_properties() { | |
| 1106 static int dummy = 42; | |
| 1107 return &dummy; | |
| 1108 } | |
| 1109 }; | 1100 }; |
| 1110 | 1101 |
| 1111 | 1102 |
| 1112 class PreParser; | 1103 class PreParser; |
| 1113 | 1104 |
| 1114 class PreParserTraits { | 1105 class PreParserTraits { |
| 1115 public: | 1106 public: |
| 1116 struct Type { | 1107 struct Type { |
| 1117 // TODO(marja): To be removed. The Traits object should contain all the data | 1108 // TODO(marja): To be removed. The Traits object should contain all the data |
| 1118 // it needs. | 1109 // it needs. |
| (...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 return this->EmptyExpression(); | 2616 return this->EmptyExpression(); |
| 2626 } | 2617 } |
| 2627 | 2618 |
| 2628 | 2619 |
| 2629 template <class Traits> | 2620 template <class Traits> |
| 2630 typename ParserBase<Traits>::ExpressionT ParserBase< | 2621 typename ParserBase<Traits>::ExpressionT ParserBase< |
| 2631 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, | 2622 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, |
| 2632 bool* ok) { | 2623 bool* ok) { |
| 2633 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); | 2624 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); |
| 2634 typename Traits::Type::StatementList body; | 2625 typename Traits::Type::StatementList body; |
| 2635 typename Traits::Type::AstProperties ast_properties; | |
| 2636 int num_parameters = -1; | 2626 int num_parameters = -1; |
| 2637 int materialized_literal_count = -1; | 2627 int materialized_literal_count = -1; |
| 2638 int expected_property_count = -1; | 2628 int expected_property_count = -1; |
| 2639 int handler_count = 0; | 2629 int handler_count = 0; |
| 2640 | 2630 |
| 2641 { | 2631 { |
| 2642 typename Traits::Type::Factory function_factory(this->ast_value_factory()); | 2632 typename Traits::Type::Factory function_factory(this->ast_value_factory()); |
| 2643 FunctionState function_state(&function_state_, &scope_, | 2633 FunctionState function_state(&function_state_, &scope_, |
| 2644 Traits::Type::ptr_to_scope(scope), | 2634 Traits::Type::ptr_to_scope(scope), |
| 2645 &function_factory); | 2635 &function_factory); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 function_name_loc, eval_args_error_loc, dupe_error_loc, reserved_loc, | 2697 function_name_loc, eval_args_error_loc, dupe_error_loc, reserved_loc, |
| 2708 CHECK_OK); | 2698 CHECK_OK); |
| 2709 | 2699 |
| 2710 // Validate strict mode. | 2700 // Validate strict mode. |
| 2711 if (strict_mode() == STRICT) { | 2701 if (strict_mode() == STRICT) { |
| 2712 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK); | 2702 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK); |
| 2713 } | 2703 } |
| 2714 | 2704 |
| 2715 if (allow_harmony_scoping() && strict_mode() == STRICT) | 2705 if (allow_harmony_scoping() && strict_mode() == STRICT) |
| 2716 this->CheckConflictingVarDeclarations(scope, CHECK_OK); | 2706 this->CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 2717 | |
| 2718 ast_properties = *factory()->visitor()->ast_properties(); | |
| 2719 } | 2707 } |
| 2720 | 2708 |
| 2721 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 2709 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
| 2722 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, | 2710 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, |
| 2723 materialized_literal_count, expected_property_count, handler_count, | 2711 materialized_literal_count, expected_property_count, handler_count, |
| 2724 num_parameters, FunctionLiteral::kNoDuplicateParameters, | 2712 num_parameters, FunctionLiteral::kNoDuplicateParameters, |
| 2725 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 2713 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 2726 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, | 2714 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, |
| 2727 start_pos); | 2715 start_pos); |
| 2728 | 2716 |
| 2729 function_literal->set_function_token_position(start_pos); | 2717 function_literal->set_function_token_position(start_pos); |
| 2730 function_literal->set_ast_properties(&ast_properties); | |
| 2731 | 2718 |
| 2732 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); | 2719 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); |
| 2733 | 2720 |
| 2734 return function_literal; | 2721 return function_literal; |
| 2735 } | 2722 } |
| 2736 | 2723 |
| 2737 | 2724 |
| 2738 template <class Traits> | 2725 template <class Traits> |
| 2739 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( | 2726 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( |
| 2740 IdentifierT name, Scanner::Location class_name_location, | 2727 IdentifierT name, Scanner::Location class_name_location, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2859 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2846 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
| 2860 // Both accessors of the same type. | 2847 // Both accessors of the same type. |
| 2861 parser()->ReportMessage("accessor_get_set"); | 2848 parser()->ReportMessage("accessor_get_set"); |
| 2862 } | 2849 } |
| 2863 *ok = false; | 2850 *ok = false; |
| 2864 } | 2851 } |
| 2865 } | 2852 } |
| 2866 } } // v8::internal | 2853 } } // v8::internal |
| 2867 | 2854 |
| 2868 #endif // V8_PREPARSER_H | 2855 #endif // V8_PREPARSER_H |
| OLD | NEW |