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

Side by Side Diff: src/parsing/parser.h

Issue 2297563007: Move ParseVariableDeclarations to ParserBase. (Closed)
Patch Set: rebased Created 4 years, 3 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 | « no previous file | src/parsing/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_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/parsing/parser-base.h" 10 #include "src/parsing/parser-base.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 typedef Yield* YieldExpression; 152 typedef Yield* YieldExpression;
153 typedef v8::internal::FunctionLiteral* FunctionLiteral; 153 typedef v8::internal::FunctionLiteral* FunctionLiteral;
154 typedef v8::internal::ClassLiteral* ClassLiteral; 154 typedef v8::internal::ClassLiteral* ClassLiteral;
155 typedef v8::internal::Literal* Literal; 155 typedef v8::internal::Literal* Literal;
156 typedef ObjectLiteral::Property* ObjectLiteralProperty; 156 typedef ObjectLiteral::Property* ObjectLiteralProperty;
157 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 157 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
158 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; 158 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
159 typedef ParserFormalParameters::Parameter FormalParameter; 159 typedef ParserFormalParameters::Parameter FormalParameter;
160 typedef ParserFormalParameters FormalParameters; 160 typedef ParserFormalParameters FormalParameters;
161 typedef ZoneList<v8::internal::Statement*>* StatementList; 161 typedef ZoneList<v8::internal::Statement*>* StatementList;
162 typedef v8::internal::Block* Block;
162 163
163 // For constructing objects returned by the traversing functions. 164 // For constructing objects returned by the traversing functions.
164 typedef AstNodeFactory Factory; 165 typedef AstNodeFactory Factory;
165 }; 166 };
166 167
167 class Parser : public ParserBase<Parser> { 168 class Parser : public ParserBase<Parser> {
168 public: 169 public:
169 explicit Parser(ParseInfo* info); 170 explicit Parser(ParseInfo* info);
170 ~Parser() { 171 ~Parser() {
171 delete reusable_preparser_; 172 delete reusable_preparser_;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, 289 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
289 bool default_export, bool* ok); 290 bool default_export, bool* ok);
290 Expression* ParseAsyncFunctionExpression(bool* ok); 291 Expression* ParseAsyncFunctionExpression(bool* ok);
291 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, 292 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
292 bool default_export, bool* ok); 293 bool default_export, bool* ok);
293 Statement* ParseNativeDeclaration(bool* ok); 294 Statement* ParseNativeDeclaration(bool* ok);
294 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); 295 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
295 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result, 296 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result,
296 ZoneList<const AstRawString*>* names, 297 ZoneList<const AstRawString*>* names,
297 bool* ok); 298 bool* ok);
299 void DeclareAndInitializeVariables(
300 Block* block, const DeclarationDescriptor* declaration_descriptor,
301 const DeclarationParsingResult::Declaration* declaration,
302 ZoneList<const AstRawString*>* names, bool* ok);
298 303
299 Block* ParseVariableStatement(VariableDeclarationContext var_context, 304 Block* ParseVariableStatement(VariableDeclarationContext var_context,
300 ZoneList<const AstRawString*>* names, 305 ZoneList<const AstRawString*>* names,
301 bool* ok); 306 bool* ok);
302 DoExpression* ParseDoExpression(bool* ok); 307 DoExpression* ParseDoExpression(bool* ok);
303 Expression* ParseYieldStarExpression(bool* ok); 308 Expression* ParseYieldStarExpression(bool* ok);
304 309
305 class PatternRewriter final : public AstVisitor<PatternRewriter> { 310 class PatternRewriter final : public AstVisitor<PatternRewriter> {
306 public: 311 public:
307 static void DeclareAndInitializeVariables( 312 static void DeclareAndInitializeVariables(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 Block* block_; 381 Block* block_;
377 const DeclarationDescriptor* descriptor_; 382 const DeclarationDescriptor* descriptor_;
378 ZoneList<const AstRawString*>* names_; 383 ZoneList<const AstRawString*>* names_;
379 Expression* current_value_; 384 Expression* current_value_;
380 int recursion_level_; 385 int recursion_level_;
381 bool* ok_; 386 bool* ok_;
382 387
383 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() 388 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW()
384 }; 389 };
385 390
386 Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
387 DeclarationParsingResult* parsing_result,
388 ZoneList<const AstRawString*>* names,
389 bool* ok);
390 Statement* ParseExpressionOrLabelledStatement( 391 Statement* ParseExpressionOrLabelledStatement(
391 ZoneList<const AstRawString*>* labels, 392 ZoneList<const AstRawString*>* labels,
392 AllowLabelledFunctionStatement allow_function, bool* ok); 393 AllowLabelledFunctionStatement allow_function, bool* ok);
393 IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels, 394 IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels,
394 bool* ok); 395 bool* ok);
395 Statement* ParseContinueStatement(bool* ok); 396 Statement* ParseContinueStatement(bool* ok);
396 Statement* ParseBreakStatement(ZoneList<const AstRawString*>* labels, 397 Statement* ParseBreakStatement(ZoneList<const AstRawString*>* labels,
397 bool* ok); 398 bool* ok);
398 Statement* ParseReturnStatement(bool* ok); 399 Statement* ParseReturnStatement(bool* ok);
399 Statement* ParseWithStatement(ZoneList<const AstRawString*>* labels, 400 Statement* ParseWithStatement(ZoneList<const AstRawString*>* labels,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return property->value(); 713 return property->value();
713 } 714 }
714 715
715 // Functions for encapsulating the differences between parsing and preparsing; 716 // Functions for encapsulating the differences between parsing and preparsing;
716 // operations interleaved with the recursive descent. 717 // operations interleaved with the recursive descent.
717 V8_INLINE static void PushLiteralName(FuncNameInferrer* fni, 718 V8_INLINE static void PushLiteralName(FuncNameInferrer* fni,
718 const AstRawString* id) { 719 const AstRawString* id) {
719 fni->PushLiteralName(id); 720 fni->PushLiteralName(id);
720 } 721 }
721 722
723 V8_INLINE static void PushVariableName(FuncNameInferrer* fni,
724 const AstRawString* id) {
725 fni->PushVariableName(id);
726 }
727
722 V8_INLINE void PushPropertyName(FuncNameInferrer* fni, 728 V8_INLINE void PushPropertyName(FuncNameInferrer* fni,
723 Expression* expression) { 729 Expression* expression) {
724 if (expression->IsPropertyName()) { 730 if (expression->IsPropertyName()) {
725 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); 731 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
726 } else { 732 } else {
727 fni->PushLiteralName(ast_value_factory()->anonymous_function_string()); 733 fni->PushLiteralName(ast_value_factory()->anonymous_function_string());
728 } 734 }
729 } 735 }
730 736
731 V8_INLINE static void InferFunctionName(FuncNameInferrer* fni, 737 V8_INLINE static void InferFunctionName(FuncNameInferrer* fni,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 837 }
832 838
833 // "null" return type creators. 839 // "null" return type creators.
834 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; } 840 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; }
835 V8_INLINE static Expression* EmptyExpression() { return nullptr; } 841 V8_INLINE static Expression* EmptyExpression() { return nullptr; }
836 V8_INLINE static Literal* EmptyLiteral() { return nullptr; } 842 V8_INLINE static Literal* EmptyLiteral() { return nullptr; }
837 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() { 843 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() {
838 return nullptr; 844 return nullptr;
839 } 845 }
840 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; } 846 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; }
847 V8_INLINE static Block* NullBlock() { return nullptr; }
841 848
842 V8_INLINE static bool IsEmptyExpression(Expression* expr) { 849 V8_INLINE static bool IsEmptyExpression(Expression* expr) {
843 return expr == nullptr; 850 return expr == nullptr;
844 } 851 }
845 852
846 // Used in error return values. 853 // Used in error return values.
847 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { 854 V8_INLINE static ZoneList<Expression*>* NullExpressionList() {
848 return nullptr; 855 return nullptr;
849 } 856 }
850 V8_INLINE static ZoneList<Statement*>* NullStatementList() { return nullptr; } 857 V8_INLINE static ZoneList<Statement*>* NullStatementList() { return nullptr; }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 return new (zone()) ZoneList<Expression*>(size, zone()); 915 return new (zone()) ZoneList<Expression*>(size, zone());
909 } 916 }
910 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList( 917 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList(
911 int size) const { 918 int size) const {
912 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); 919 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
913 } 920 }
914 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const { 921 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const {
915 return new (zone()) ZoneList<Statement*>(size, zone()); 922 return new (zone()) ZoneList<Statement*>(size, zone());
916 } 923 }
917 924
925 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
926 bool ignore_completion_value, int pos) {
927 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos);
928 }
929
918 V8_INLINE void AddParameterInitializationBlock( 930 V8_INLINE void AddParameterInitializationBlock(
919 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, 931 const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
920 bool is_async, bool* ok) { 932 bool is_async, bool* ok) {
921 if (parameters.is_simple) return; 933 if (parameters.is_simple) return;
922 auto* init_block = BuildParameterInitializationBlock(parameters, ok); 934 auto* init_block = BuildParameterInitializationBlock(parameters, ok);
923 if (!*ok) return; 935 if (!*ok) return;
924 if (is_async) { 936 if (is_async) {
925 init_block = BuildRejectPromiseOnException(init_block, ok); 937 init_block = BuildRejectPromiseOnException(init_block, ok);
926 if (!*ok) return; 938 if (!*ok) return;
927 } 939 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 static const int kLiteralTypeSlot = 0; 1061 static const int kLiteralTypeSlot = 0;
1050 static const int kElementsSlot = 1; 1062 static const int kElementsSlot = 1;
1051 1063
1052 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 1064 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
1053 }; 1065 };
1054 1066
1055 } // namespace internal 1067 } // namespace internal
1056 } // namespace v8 1068 } // namespace v8
1057 1069
1058 #endif // V8_PARSING_PARSER_H_ 1070 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698