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

Side by Side Diff: src/parser.h

Issue 1094653002: Revert "Factor formal argument parsing into ParserBase" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « src/messages.js ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // Return types for traversing functions. 550 // Return types for traversing functions.
551 typedef const AstRawString* Identifier; 551 typedef const AstRawString* Identifier;
552 typedef v8::internal::Expression* Expression; 552 typedef v8::internal::Expression* Expression;
553 typedef Yield* YieldExpression; 553 typedef Yield* YieldExpression;
554 typedef v8::internal::FunctionLiteral* FunctionLiteral; 554 typedef v8::internal::FunctionLiteral* FunctionLiteral;
555 typedef v8::internal::ClassLiteral* ClassLiteral; 555 typedef v8::internal::ClassLiteral* ClassLiteral;
556 typedef v8::internal::Literal* Literal; 556 typedef v8::internal::Literal* Literal;
557 typedef ObjectLiteral::Property* ObjectLiteralProperty; 557 typedef ObjectLiteral::Property* ObjectLiteralProperty;
558 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 558 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
559 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; 559 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
560 typedef const v8::internal::AstRawString* FormalParameter;
561 typedef ZoneList<const v8::internal::AstRawString*>* FormalParameterList;
562 typedef ZoneList<v8::internal::Statement*>* StatementList; 560 typedef ZoneList<v8::internal::Statement*>* StatementList;
563 561
564 // For constructing objects returned by the traversing functions. 562 // For constructing objects returned by the traversing functions.
565 typedef AstNodeFactory Factory; 563 typedef AstNodeFactory Factory;
566 }; 564 };
567 565
568 explicit ParserTraits(Parser* parser) : parser_(parser) {} 566 explicit ParserTraits(Parser* parser) : parser_(parser) {}
569 567
570 // Helper functions for recursive descent. 568 // Helper functions for recursive descent.
571 bool IsEval(const AstRawString* identifier) const; 569 bool IsEval(const AstRawString* identifier) const;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 const AstRawString* arg, 687 const AstRawString* arg,
690 ParseErrorType error_type = kSyntaxError); 688 ParseErrorType error_type = kSyntaxError);
691 689
692 // "null" return type creators. 690 // "null" return type creators.
693 static const AstRawString* EmptyIdentifier() { 691 static const AstRawString* EmptyIdentifier() {
694 return NULL; 692 return NULL;
695 } 693 }
696 static Expression* EmptyExpression() { 694 static Expression* EmptyExpression() {
697 return NULL; 695 return NULL;
698 } 696 }
697 static Expression* EmptyArrowParamList() { return NULL; }
699 static Literal* EmptyLiteral() { 698 static Literal* EmptyLiteral() {
700 return NULL; 699 return NULL;
701 } 700 }
702 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } 701 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; }
703 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } 702 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; }
704 703
705 // Used in error return values. 704 // Used in error return values.
706 static ZoneList<Expression*>* NullExpressionList() { 705 static ZoneList<Expression*>* NullExpressionList() {
707 return NULL; 706 return NULL;
708 } 707 }
709 static const AstRawString* EmptyFormalParameter() { return NULL; }
710 static ZoneList<const AstRawString*>* NullFormalParameterList() {
711 return NULL;
712 }
713 708
714 // Non-NULL empty string. 709 // Non-NULL empty string.
715 V8_INLINE const AstRawString* EmptyIdentifierString(); 710 V8_INLINE const AstRawString* EmptyIdentifierString();
716 711
717 // Odd-ball literal creators. 712 // Odd-ball literal creators.
718 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); 713 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory);
719 714
720 // Producing data during the recursive descent. 715 // Producing data during the recursive descent.
721 const AstRawString* GetSymbol(Scanner* scanner); 716 const AstRawString* GetSymbol(Scanner* scanner);
722 const AstRawString* GetNextSymbol(Scanner* scanner); 717 const AstRawString* GetNextSymbol(Scanner* scanner);
(...skipping 15 matching lines...) Expand all
738 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); 733 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory);
739 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 734 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
740 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 735 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
741 } 736 }
742 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 737 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
743 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 738 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
744 } 739 }
745 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 740 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
746 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 741 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
747 } 742 }
748 ZoneList<const v8::internal::AstRawString*>* NewFormalParameterList(
749 int size, Zone* zone) {
750 return new (zone) ZoneList<const v8::internal::AstRawString*>(size, zone);
751 }
752 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 743 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
753 FunctionKind kind = kNormalFunction); 744 FunctionKind kind = kNormalFunction);
754 745
755 void RecordArrowFunctionParameter(ZoneList<const AstRawString*>* params, 746 // Utility functions
756 VariableProxy* proxy, 747 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope,
757 FormalParameterErrorLocations* error_locs, 748 Scanner::Location* undefined_loc,
758 bool* ok); 749 Scanner::Location* dupe_loc,
759 ZoneList<const AstRawString*>* ParseArrowFunctionFormalParameterList( 750 bool* ok);
760 Expression* params, const Scanner::Location& params_loc,
761 FormalParameterErrorLocations* error_locs, bool* is_rest, bool* ok);
762 751
763 // Temporary glue; these functions will move to ParserBase. 752 // Temporary glue; these functions will move to ParserBase.
764 Expression* ParseV8Intrinsic(bool* ok); 753 Expression* ParseV8Intrinsic(bool* ok);
765 FunctionLiteral* ParseFunctionLiteral( 754 FunctionLiteral* ParseFunctionLiteral(
766 const AstRawString* name, Scanner::Location function_name_location, 755 const AstRawString* name, Scanner::Location function_name_location,
767 bool name_is_strict_reserved, FunctionKind kind, 756 bool name_is_strict_reserved, FunctionKind kind,
768 int function_token_position, FunctionLiteral::FunctionType type, 757 int function_token_position, FunctionLiteral::FunctionType type,
769 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); 758 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
770 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, 759 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name,
771 int* materialized_literal_count, 760 int* materialized_literal_count,
772 int* expected_property_count, bool* ok); 761 int* expected_property_count, bool* ok);
773 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( 762 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
774 const AstRawString* name, int pos, Variable* fvar, 763 const AstRawString* name, int pos, Variable* fvar,
775 Token::Value fvar_init_op, FunctionKind kind, bool* ok); 764 Token::Value fvar_init_op, FunctionKind kind, bool* ok);
776 765
777 ClassLiteral* ParseClassLiteral(const AstRawString* name, 766 ClassLiteral* ParseClassLiteral(const AstRawString* name,
778 Scanner::Location class_name_location, 767 Scanner::Location class_name_location,
779 bool name_is_strict_reserved, int pos, 768 bool name_is_strict_reserved, int pos,
780 bool* ok); 769 bool* ok);
781 770
782 int DeclareFormalParameters(ZoneList<const AstRawString*>* params,
783 Scope* scope, bool has_rest);
784
785 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, 771 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
786 bool* ok); 772 bool* ok);
787 773
788 class TemplateLiteral : public ZoneObject { 774 class TemplateLiteral : public ZoneObject {
789 public: 775 public:
790 TemplateLiteral(Zone* zone, int pos) 776 TemplateLiteral(Zone* zone, int pos)
791 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 777 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
792 778
793 const ZoneList<Expression*>* cooked() const { return &cooked_; } 779 const ZoneList<Expression*>* cooked() const { return &cooked_; }
794 const ZoneList<Expression*>* raw() const { return &raw_; } 780 const ZoneList<Expression*>* raw() const { return &raw_; }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 Expression* SpreadCallNew(Expression* function, 1038 Expression* SpreadCallNew(Expression* function,
1053 ZoneList<v8::internal::Expression*>* args, int pos); 1039 ZoneList<v8::internal::Expression*>* args, int pos);
1054 1040
1055 Scanner scanner_; 1041 Scanner scanner_;
1056 PreParser* reusable_preparser_; 1042 PreParser* reusable_preparser_;
1057 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1043 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1058 Target* target_stack_; // for break, continue statements 1044 Target* target_stack_; // for break, continue statements
1059 ScriptCompiler::CompileOptions compile_options_; 1045 ScriptCompiler::CompileOptions compile_options_;
1060 ParseData* cached_parse_data_; 1046 ParseData* cached_parse_data_;
1061 1047
1048 bool parsing_lazy_arrow_parameters_; // for lazily parsed arrow functions.
1049
1062 PendingCompilationErrorHandler pending_error_handler_; 1050 PendingCompilationErrorHandler pending_error_handler_;
1063 1051
1064 // Other information which will be stored in Parser and moved to Isolate after 1052 // Other information which will be stored in Parser and moved to Isolate after
1065 // parsing. 1053 // parsing.
1066 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; 1054 int use_counts_[v8::Isolate::kUseCounterFeatureCount];
1067 int total_preparse_skipped_; 1055 int total_preparse_skipped_;
1068 HistogramTimer* pre_parse_timer_; 1056 HistogramTimer* pre_parse_timer_;
1069 1057
1070 bool parsing_on_main_thread_; 1058 bool parsing_on_main_thread_;
1071 }; 1059 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 } 1162 }
1175 1163
1176 1164
1177 Expression* ParserTraits::SpreadCallNew( 1165 Expression* ParserTraits::SpreadCallNew(
1178 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1166 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1179 return parser_->SpreadCallNew(function, args, pos); 1167 return parser_->SpreadCallNew(function, args, pos);
1180 } 1168 }
1181 } } // namespace v8::internal 1169 } } // namespace v8::internal
1182 1170
1183 #endif // V8_PARSER_H_ 1171 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698