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

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

Issue 2380663002: Revert of [parser] Refactor of ParseClass* and ParseNativeDeclaration (Closed)
Patch Set: Created 4 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
« 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 typedef v8::internal::Variable Variable; 146 typedef v8::internal::Variable Variable;
147 147
148 // Return types for traversing functions. 148 // Return types for traversing functions.
149 typedef const AstRawString* Identifier; 149 typedef const AstRawString* Identifier;
150 typedef v8::internal::Expression* Expression; 150 typedef v8::internal::Expression* Expression;
151 typedef v8::internal::FunctionLiteral* FunctionLiteral; 151 typedef v8::internal::FunctionLiteral* FunctionLiteral;
152 typedef ObjectLiteral::Property* ObjectLiteralProperty; 152 typedef ObjectLiteral::Property* ObjectLiteralProperty;
153 typedef ClassLiteral::Property* ClassLiteralProperty; 153 typedef ClassLiteral::Property* ClassLiteralProperty;
154 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 154 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
155 typedef ZoneList<ObjectLiteral::Property*>* ObjectPropertyList; 155 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
156 typedef ZoneList<ClassLiteral::Property*>* ClassPropertyList;
157 typedef ParserFormalParameters FormalParameters; 156 typedef ParserFormalParameters FormalParameters;
158 typedef v8::internal::Statement* Statement; 157 typedef v8::internal::Statement* Statement;
159 typedef ZoneList<v8::internal::Statement*>* StatementList; 158 typedef ZoneList<v8::internal::Statement*>* StatementList;
160 typedef v8::internal::Block* Block; 159 typedef v8::internal::Block* Block;
161 typedef v8::internal::BreakableStatement* BreakableStatement; 160 typedef v8::internal::BreakableStatement* BreakableStatement;
162 typedef v8::internal::IterationStatement* IterationStatement; 161 typedef v8::internal::IterationStatement* IterationStatement;
163 162
164 // For constructing objects returned by the traversing functions. 163 // For constructing objects returned by the traversing functions.
165 typedef AstNodeFactory Factory; 164 typedef AstNodeFactory Factory;
166 165
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 const AstRawString* local_name; 262 const AstRawString* local_name;
264 const Scanner::Location location; 263 const Scanner::Location location;
265 NamedImport(const AstRawString* import_name, const AstRawString* local_name, 264 NamedImport(const AstRawString* import_name, const AstRawString* local_name,
266 Scanner::Location location) 265 Scanner::Location location)
267 : import_name(import_name), 266 : import_name(import_name),
268 local_name(local_name), 267 local_name(local_name),
269 location(location) {} 268 location(location) {}
270 }; 269 };
271 ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok); 270 ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok);
272 Statement* ParseFunctionDeclaration(bool* ok); 271 Statement* ParseFunctionDeclaration(bool* ok);
272 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
273 bool default_export, bool* ok);
274 Statement* ParseNativeDeclaration(bool* ok);
273 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result, 275 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result,
274 ZoneList<const AstRawString*>* names, 276 ZoneList<const AstRawString*>* names,
275 bool* ok); 277 bool* ok);
276 void DeclareAndInitializeVariables( 278 void DeclareAndInitializeVariables(
277 Block* block, const DeclarationDescriptor* declaration_descriptor, 279 Block* block, const DeclarationDescriptor* declaration_descriptor,
278 const DeclarationParsingResult::Declaration* declaration, 280 const DeclarationParsingResult::Declaration* declaration,
279 ZoneList<const AstRawString*>* names, bool* ok); 281 ZoneList<const AstRawString*>* names, bool* ok);
280 ZoneList<const AstRawString*>* DeclareLabel( 282 ZoneList<const AstRawString*>* DeclareLabel(
281 ZoneList<const AstRawString*>* labels, VariableProxy* expr, bool* ok); 283 ZoneList<const AstRawString*>* labels, VariableProxy* expr, bool* ok);
282 bool ContainsLabel(ZoneList<const AstRawString*>* labels, 284 bool ContainsLabel(ZoneList<const AstRawString*>* labels,
283 const AstRawString* label); 285 const AstRawString* label);
284 Expression* RewriteReturn(Expression* return_value, int pos); 286 Expression* RewriteReturn(Expression* return_value, int pos);
285 Statement* RewriteSwitchStatement(Expression* tag, 287 Statement* RewriteSwitchStatement(Expression* tag,
286 SwitchStatement* switch_statement, 288 SwitchStatement* switch_statement,
287 ZoneList<CaseClause*>* cases, Scope* scope); 289 ZoneList<CaseClause*>* cases, Scope* scope);
288 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok); 290 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok);
289 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok); 291 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok);
290 Statement* RewriteTryStatement(Block* try_block, Block* catch_block, 292 Statement* RewriteTryStatement(Block* try_block, Block* catch_block,
291 Block* finally_block, 293 Block* finally_block,
292 const CatchInfo& catch_info, int pos); 294 const CatchInfo& catch_info, int pos);
293 295
294 Statement* DeclareFunction(const AstRawString* variable_name, 296 Statement* DeclareFunction(const AstRawString* variable_name,
295 FunctionLiteral* function, int pos, 297 FunctionLiteral* function, int pos,
296 bool is_generator, bool is_async, 298 bool is_generator, bool is_async,
297 ZoneList<const AstRawString*>* names, bool* ok); 299 ZoneList<const AstRawString*>* names, bool* ok);
298 V8_INLINE Statement* DeclareClass(const AstRawString* variable_name,
299 Expression* value,
300 ZoneList<const AstRawString*>* names,
301 int class_token_pos, int end_pos, bool* ok);
302 V8_INLINE void DeclareClassVariable(const AstRawString* name,
303 Scope* block_scope, ClassInfo* class_info,
304 int class_token_pos, bool* ok);
305 V8_INLINE void DeclareClassProperty(const AstRawString* class_name,
306 ClassLiteralProperty* property,
307 ClassInfo* class_info, bool* ok);
308 V8_INLINE Expression* RewriteClassLiteral(const AstRawString* name,
309 ClassInfo* class_info, int pos,
310 bool* ok);
311 V8_INLINE Statement* DeclareNative(const AstRawString* name, int pos,
312 bool* ok);
313 300
314 Expression* ParseYieldStarExpression(bool* ok); 301 Expression* ParseYieldStarExpression(bool* ok);
315 302
316 class PatternRewriter final : public AstVisitor<PatternRewriter> { 303 class PatternRewriter final : public AstVisitor<PatternRewriter> {
317 public: 304 public:
318 static void DeclareAndInitializeVariables( 305 static void DeclareAndInitializeVariables(
319 Parser* parser, Block* block, 306 Parser* parser, Block* block,
320 const DeclarationDescriptor* declaration_descriptor, 307 const DeclarationDescriptor* declaration_descriptor,
321 const DeclarationParsingResult::Declaration* declaration, 308 const DeclarationParsingResult::Declaration* declaration,
322 ZoneList<const AstRawString*>* names, bool* ok); 309 ZoneList<const AstRawString*>* names, bool* ok);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 const AstRawString* name, Scanner::Location function_name_location, 412 const AstRawString* name, Scanner::Location function_name_location,
426 FunctionNameValidity function_name_validity, FunctionKind kind, 413 FunctionNameValidity function_name_validity, FunctionKind kind,
427 int function_token_position, FunctionLiteral::FunctionType type, 414 int function_token_position, FunctionLiteral::FunctionType type,
428 LanguageMode language_mode, bool* ok); 415 LanguageMode language_mode, bool* ok);
429 416
430 Expression* InstallHomeObject(Expression* function_literal, 417 Expression* InstallHomeObject(Expression* function_literal,
431 Expression* home_object); 418 Expression* home_object);
432 FunctionLiteral* SynthesizeClassFieldInitializer(int count); 419 FunctionLiteral* SynthesizeClassFieldInitializer(int count);
433 FunctionLiteral* InsertClassFieldInitializer(FunctionLiteral* constructor); 420 FunctionLiteral* InsertClassFieldInitializer(FunctionLiteral* constructor);
434 421
422 Expression* ParseClassLiteral(const AstRawString* name,
423 Scanner::Location class_name_location,
424 bool name_is_strict_reserved, int pos,
425 bool* ok);
426
435 // Get odd-ball literals. 427 // Get odd-ball literals.
436 Literal* GetLiteralUndefined(int position); 428 Literal* GetLiteralUndefined(int position);
437 429
438 // Check if the scope has conflicting var/let declarations from different 430 // Check if the scope has conflicting var/let declarations from different
439 // scopes. This covers for example 431 // scopes. This covers for example
440 // 432 //
441 // function f() { { { var x; } let x; } } 433 // function f() { { { var x; } let x; } }
442 // function g() { { var x; let x; } } 434 // function g() { { var x; let x; } }
443 // 435 //
444 // The var declarations are hoisted to the function scope, but originate from 436 // The var declarations are hoisted to the function scope, but originate from
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } else { 732 } else {
741 fni_->PushLiteralName(ast_value_factory()->anonymous_function_string()); 733 fni_->PushLiteralName(ast_value_factory()->anonymous_function_string());
742 } 734 }
743 } 735 }
744 736
745 V8_INLINE void PushEnclosingName(const AstRawString* name) { 737 V8_INLINE void PushEnclosingName(const AstRawString* name) {
746 DCHECK_NOT_NULL(fni_); 738 DCHECK_NOT_NULL(fni_);
747 fni_->PushEnclosingName(name); 739 fni_->PushEnclosingName(name);
748 } 740 }
749 741
750 V8_INLINE void AddFunctionForNameInference(FunctionLiteral* func_to_infer) { 742 V8_INLINE void InferFunctionName(FunctionLiteral* func_to_infer) {
751 DCHECK_NOT_NULL(fni_);
752 fni_->AddFunction(func_to_infer); 743 fni_->AddFunction(func_to_infer);
753 } 744 }
754 745
755 V8_INLINE void InferFunctionName() {
756 DCHECK_NOT_NULL(fni_);
757 fni_->Infer();
758 }
759
760 // If we assign a function literal to a property we pretenure the 746 // If we assign a function literal to a property we pretenure the
761 // literal so it can be added as a constant function property. 747 // literal so it can be added as a constant function property.
762 V8_INLINE static void CheckAssigningFunctionLiteralToProperty( 748 V8_INLINE static void CheckAssigningFunctionLiteralToProperty(
763 Expression* left, Expression* right) { 749 Expression* left, Expression* right) {
764 DCHECK(left != NULL); 750 DCHECK(left != NULL);
765 if (left->IsProperty() && right->IsFunctionLiteral()) { 751 if (left->IsProperty() && right->IsFunctionLiteral()) {
766 right->AsFunctionLiteral()->set_pretenure(); 752 right->AsFunctionLiteral()->set_pretenure();
767 } 753 }
768 } 754 }
769 755
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 929
944 V8_INLINE Expression* ExpressionFromString(int pos) { 930 V8_INLINE Expression* ExpressionFromString(int pos) {
945 const AstRawString* symbol = GetSymbol(); 931 const AstRawString* symbol = GetSymbol();
946 fni_->PushLiteralName(symbol); 932 fni_->PushLiteralName(symbol);
947 return factory()->NewStringLiteral(symbol, pos); 933 return factory()->NewStringLiteral(symbol, pos);
948 } 934 }
949 935
950 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { 936 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const {
951 return new (zone()) ZoneList<Expression*>(size, zone()); 937 return new (zone()) ZoneList<Expression*>(size, zone());
952 } 938 }
953 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewObjectPropertyList( 939 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList(
954 int size) const { 940 int size) const {
955 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); 941 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
956 } 942 }
957 V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList( 943 V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList(
958 int size) const { 944 int size) const {
959 return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone()); 945 return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone());
960 } 946 }
961 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const { 947 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const {
962 return new (zone()) ZoneList<Statement*>(size, zone()); 948 return new (zone()) ZoneList<Statement*>(size, zone());
963 } 949 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 int total_preparse_skipped_; 1076 int total_preparse_skipped_;
1091 HistogramTimer* pre_parse_timer_; 1077 HistogramTimer* pre_parse_timer_;
1092 1078
1093 bool parsing_on_main_thread_; 1079 bool parsing_on_main_thread_;
1094 }; 1080 };
1095 1081
1096 } // namespace internal 1082 } // namespace internal
1097 } // namespace v8 1083 } // namespace v8
1098 1084
1099 #endif // V8_PARSING_PARSER_H_ 1085 #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