Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: src/preparser.h

Issue 660083005: AstNumberingVisitor does the work of AstConstructionVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // Dummy implementation for making expression->somefunc() work in both Parser 798 // Dummy implementation for making expression->somefunc() work in both Parser
799 // and PreParser. 799 // and PreParser.
800 PreParserExpression* operator->() { return this; } 800 PreParserExpression* operator->() { return this; }
801 801
802 // More dummy implementations of things PreParser doesn't need to track: 802 // More dummy implementations of things PreParser doesn't need to track:
803 void set_index(int index) {} // For YieldExpressions 803 void set_index(int index) {} // For YieldExpressions
804 void set_parenthesized() {} 804 void set_parenthesized() {}
805 805
806 int position() const { return RelocInfo::kNoPosition; } 806 int position() const { return RelocInfo::kNoPosition; }
807 void set_function_token_position(int position) {} 807 void set_function_token_position(int position) {}
808 void set_ast_properties(int* ast_properties) {}
809 void set_dont_optimize_reason(BailoutReason dont_optimize_reason) {}
810 808
811 private: 809 private:
812 enum Type { 810 enum Type {
813 kExpression, 811 kExpression,
814 kIdentifierExpression, 812 kIdentifierExpression,
815 kStringLiteralExpression, 813 kStringLiteralExpression,
816 kBinaryOperationExpression 814 kBinaryOperationExpression
817 }; 815 };
818 816
819 enum Parenthesization { 817 enum Parenthesization {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 int position) { 1079 int position) {
1082 return PreParserExpression::Default(); 1080 return PreParserExpression::Default();
1083 } 1081 }
1084 PreParserExpression NewClassLiteral(PreParserIdentifier name, 1082 PreParserExpression NewClassLiteral(PreParserIdentifier name,
1085 PreParserExpression extends, 1083 PreParserExpression extends,
1086 PreParserExpression constructor, 1084 PreParserExpression constructor,
1087 PreParserExpressionList properties, 1085 PreParserExpressionList properties,
1088 int start_position, int end_position) { 1086 int start_position, int end_position) {
1089 return PreParserExpression::Default(); 1087 return PreParserExpression::Default();
1090 } 1088 }
1091
1092 // Return the object itself as AstVisitor and implement the needed
1093 // dummy method right in this class.
1094 PreParserFactory* visitor() { return this; }
1095 BailoutReason dont_optimize_reason() { return kNoReason; }
1096 int* ast_properties() {
1097 static int dummy = 42;
1098 return &dummy;
1099 }
1100 }; 1089 };
1101 1090
1102 1091
1103 class PreParser; 1092 class PreParser;
1104 1093
1105 class PreParserTraits { 1094 class PreParserTraits {
1106 public: 1095 public:
1107 struct Type { 1096 struct Type {
1108 // TODO(marja): To be removed. The Traits object should contain all the data 1097 // TODO(marja): To be removed. The Traits object should contain all the data
1109 // it needs. 1098 // it needs.
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 return this->EmptyExpression(); 2586 return this->EmptyExpression();
2598 } 2587 }
2599 2588
2600 2589
2601 template <class Traits> 2590 template <class Traits>
2602 typename ParserBase<Traits>::ExpressionT ParserBase< 2591 typename ParserBase<Traits>::ExpressionT ParserBase<
2603 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, 2592 Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
2604 bool* ok) { 2593 bool* ok) {
2605 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); 2594 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE);
2606 typename Traits::Type::StatementList body; 2595 typename Traits::Type::StatementList body;
2607 typename Traits::Type::AstProperties ast_properties;
2608 BailoutReason dont_optimize_reason = kNoReason;
2609 int num_parameters = -1; 2596 int num_parameters = -1;
2610 int materialized_literal_count = -1; 2597 int materialized_literal_count = -1;
2611 int expected_property_count = -1; 2598 int expected_property_count = -1;
2612 int handler_count = 0; 2599 int handler_count = 0;
2613 2600
2614 { 2601 {
2615 typename Traits::Type::Factory function_factory(this->ast_value_factory()); 2602 typename Traits::Type::Factory function_factory(this->ast_value_factory());
2616 FunctionState function_state(&function_state_, &scope_, 2603 FunctionState function_state(&function_state_, &scope_,
2617 Traits::Type::ptr_to_scope(scope), 2604 Traits::Type::ptr_to_scope(scope),
2618 &function_factory); 2605 &function_factory);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 function_name_loc, eval_args_error_loc, dupe_error_loc, reserved_loc, 2667 function_name_loc, eval_args_error_loc, dupe_error_loc, reserved_loc,
2681 CHECK_OK); 2668 CHECK_OK);
2682 2669
2683 // Validate strict mode. 2670 // Validate strict mode.
2684 if (strict_mode() == STRICT) { 2671 if (strict_mode() == STRICT) {
2685 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK); 2672 CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK);
2686 } 2673 }
2687 2674
2688 if (allow_harmony_scoping() && strict_mode() == STRICT) 2675 if (allow_harmony_scoping() && strict_mode() == STRICT)
2689 this->CheckConflictingVarDeclarations(scope, CHECK_OK); 2676 this->CheckConflictingVarDeclarations(scope, CHECK_OK);
2690
2691 ast_properties = *factory()->visitor()->ast_properties();
2692 dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
2693 } 2677 }
2694 2678
2695 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( 2679 FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
2696 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, 2680 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body,
2697 materialized_literal_count, expected_property_count, handler_count, 2681 materialized_literal_count, expected_property_count, handler_count,
2698 num_parameters, FunctionLiteral::kNoDuplicateParameters, 2682 num_parameters, FunctionLiteral::kNoDuplicateParameters,
2699 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, 2683 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
2700 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, 2684 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction,
2701 start_pos); 2685 start_pos);
2702 2686
2703 function_literal->set_function_token_position(start_pos); 2687 function_literal->set_function_token_position(start_pos);
2704 function_literal->set_ast_properties(&ast_properties);
2705 function_literal->set_dont_optimize_reason(dont_optimize_reason);
2706 2688
2707 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); 2689 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
2708 2690
2709 return function_literal; 2691 return function_literal;
2710 } 2692 }
2711 2693
2712 2694
2713 template <class Traits> 2695 template <class Traits>
2714 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral( 2696 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseClassLiteral(
2715 IdentifierT name, Scanner::Location class_name_location, 2697 IdentifierT name, Scanner::Location class_name_location,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2809 DCHECK(IsAccessorAccessorConflict(old_type, type));
2828 // Both accessors of the same type. 2810 // Both accessors of the same type.
2829 parser()->ReportMessage("accessor_get_set"); 2811 parser()->ReportMessage("accessor_get_set");
2830 } 2812 }
2831 *ok = false; 2813 *ok = false;
2832 } 2814 }
2833 } 2815 }
2834 } } // v8::internal 2816 } } // v8::internal
2835 2817
2836 #endif // V8_PREPARSER_H 2818 #endif // V8_PREPARSER_H
OLDNEW
« src/ast-numbering.cc ('K') | « src/parser.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698