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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 // and PreParser. | 803 // and PreParser. |
804 PreParserExpression* operator->() { return this; } | 804 PreParserExpression* operator->() { return this; } |
805 | 805 |
806 // More dummy implementations of things PreParser doesn't need to track: | 806 // More dummy implementations of things PreParser doesn't need to track: |
807 void set_index(int index) {} // For YieldExpressions | 807 void set_index(int index) {} // For YieldExpressions |
808 void set_parenthesized() {} | 808 void set_parenthesized() {} |
809 | 809 |
810 int position() const { return RelocInfo::kNoPosition; } | 810 int position() const { return RelocInfo::kNoPosition; } |
811 void set_function_token_position(int position) {} | 811 void set_function_token_position(int position) {} |
812 void set_ast_properties(int* ast_properties) {} | 812 void set_ast_properties(int* ast_properties) {} |
813 void set_dont_optimize_reason(BailoutReason dont_optimize_reason) {} | |
814 | 813 |
815 private: | 814 private: |
816 enum Type { | 815 enum Type { |
817 kExpression, | 816 kExpression, |
818 kIdentifierExpression, | 817 kIdentifierExpression, |
819 kStringLiteralExpression, | 818 kStringLiteralExpression, |
820 kBinaryOperationExpression | 819 kBinaryOperationExpression |
821 }; | 820 }; |
822 | 821 |
823 enum Parenthesization { | 822 enum Parenthesization { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 PreParserExpression extends, | 1088 PreParserExpression extends, |
1090 PreParserExpression constructor, | 1089 PreParserExpression constructor, |
1091 PreParserExpressionList properties, | 1090 PreParserExpressionList properties, |
1092 int start_position, int end_position) { | 1091 int start_position, int end_position) { |
1093 return PreParserExpression::Default(); | 1092 return PreParserExpression::Default(); |
1094 } | 1093 } |
1095 | 1094 |
1096 // Return the object itself as AstVisitor and implement the needed | 1095 // Return the object itself as AstVisitor and implement the needed |
1097 // dummy method right in this class. | 1096 // dummy method right in this class. |
1098 PreParserFactory* visitor() { return this; } | 1097 PreParserFactory* visitor() { return this; } |
1099 BailoutReason dont_optimize_reason() { return kNoReason; } | |
1100 int* ast_properties() { | 1098 int* ast_properties() { |
1101 static int dummy = 42; | 1099 static int dummy = 42; |
1102 return &dummy; | 1100 return &dummy; |
1103 } | 1101 } |
1104 }; | 1102 }; |
1105 | 1103 |
1106 | 1104 |
1107 class PreParser; | 1105 class PreParser; |
1108 | 1106 |
1109 class PreParserTraits { | 1107 class PreParserTraits { |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 } | 2600 } |
2603 | 2601 |
2604 | 2602 |
2605 template <class Traits> | 2603 template <class Traits> |
2606 typename ParserBase<Traits>::ExpressionT ParserBase< | 2604 typename ParserBase<Traits>::ExpressionT ParserBase< |
2607 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, | 2605 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, |
2608 bool* ok) { | 2606 bool* ok) { |
2609 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); | 2607 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); |
2610 typename Traits::Type::StatementList body; | 2608 typename Traits::Type::StatementList body; |
2611 typename Traits::Type::AstProperties ast_properties; | 2609 typename Traits::Type::AstProperties ast_properties; |
2612 BailoutReason dont_optimize_reason = kNoReason; | |
2613 int num_parameters = -1; | 2610 int num_parameters = -1; |
2614 int materialized_literal_count = -1; | 2611 int materialized_literal_count = -1; |
2615 int expected_property_count = -1; | 2612 int expected_property_count = -1; |
2616 int handler_count = 0; | 2613 int handler_count = 0; |
2617 | 2614 |
2618 { | 2615 { |
2619 typename Traits::Type::Factory function_factory(this->ast_value_factory()); | 2616 typename Traits::Type::Factory function_factory(this->ast_value_factory()); |
2620 FunctionState function_state(&function_state_, &scope_, | 2617 FunctionState function_state(&function_state_, &scope_, |
2621 Traits::Type::ptr_to_scope(scope), | 2618 Traits::Type::ptr_to_scope(scope), |
2622 &function_factory); | 2619 &function_factory); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 | 2683 |
2687 // Validate strict mode. | 2684 // Validate strict mode. |
2688 if (strict_mode() == STRICT) { | 2685 if (strict_mode() == STRICT) { |
2689 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK); | 2686 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK); |
2690 } | 2687 } |
2691 | 2688 |
2692 if (allow_harmony_scoping() && strict_mode() == STRICT) | 2689 if (allow_harmony_scoping() && strict_mode() == STRICT) |
2693 this->CheckConflictingVarDeclarations(scope, CHECK_OK); | 2690 this->CheckConflictingVarDeclarations(scope, CHECK_OK); |
2694 | 2691 |
2695 ast_properties = *factory()->visitor()->ast_properties(); | 2692 ast_properties = *factory()->visitor()->ast_properties(); |
2696 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); | |
2697 } | 2693 } |
2698 | 2694 |
2699 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 2695 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
2700 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, | 2696 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, |
2701 materialized_literal_count, expected_property_count, handler_count, | 2697 materialized_literal_count, expected_property_count, handler_count, |
2702 num_parameters, FunctionLiteral::kNoDuplicateParameters, | 2698 num_parameters, FunctionLiteral::kNoDuplicateParameters, |
2703 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 2699 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
2704 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, | 2700 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, |
2705 start_pos); | 2701 start_pos); |
2706 | 2702 |
2707 function_literal->set_function_token_position(start_pos); | 2703 function_literal->set_function_token_position(start_pos); |
2708 function_literal->set_ast_properties(&ast_properties); | 2704 function_literal->set_ast_properties(&ast_properties); |
2709 function_literal->set_dont_optimize_reason(dont_optimize_reason); | |
2710 | 2705 |
2711 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); | 2706 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); |
2712 | 2707 |
2713 return function_literal; | 2708 return function_literal; |
2714 } | 2709 } |
2715 | 2710 |
2716 | 2711 |
2717 template <class Traits> | 2712 template <class Traits> |
2718 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( | 2713 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( |
2719 IdentifierT name, Scanner::Location class_name_location, | 2714 IdentifierT name, Scanner::Location class_name_location, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2826 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2832 // Both accessors of the same type. | 2827 // Both accessors of the same type. |
2833 parser()->ReportMessage("accessor_get_set"); | 2828 parser()->ReportMessage("accessor_get_set"); |
2834 } | 2829 } |
2835 *ok = false; | 2830 *ok = false; |
2836 } | 2831 } |
2837 } | 2832 } |
2838 } } // v8::internal | 2833 } } // v8::internal |
2839 | 2834 |
2840 #endif // V8_PREPARSER_H | 2835 #endif // V8_PREPARSER_H |
OLD | NEW |