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

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

Issue 2321103002: [parser] Refactor of Parse*Statement*, part 5 (Closed)
Patch Set: Rebase 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 | « src/parsing/parser-base.h ('k') | src/parsing/preparser.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_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/parsing/parser-base.h" 9 #include "src/parsing/parser-base.h"
10 10
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 bool IsNullStatement() { return code_ == kNullStatement; } 441 bool IsNullStatement() { return code_ == kNullStatement; }
442 442
443 bool IsEmptyStatement() { return code_ == kEmptyStatement; } 443 bool IsEmptyStatement() { return code_ == kEmptyStatement; }
444 444
445 // Dummy implementation for making statement->somefunc() work in both Parser 445 // Dummy implementation for making statement->somefunc() work in both Parser
446 // and PreParser. 446 // and PreParser.
447 PreParserStatement* operator->() { return this; } 447 PreParserStatement* operator->() { return this; }
448 448
449 PreParserStatementList statements() { return PreParserStatementList(); } 449 PreParserStatementList statements() { return PreParserStatementList(); }
450 void set_scope(Scope* scope) {} 450 void set_scope(Scope* scope) {}
451 void Initialize(PreParserExpression cond, PreParserStatement body) {}
451 452
452 private: 453 private:
453 enum Type { 454 enum Type {
454 kNullStatement, 455 kNullStatement,
455 kEmptyStatement, 456 kEmptyStatement,
456 kUnknownStatement, 457 kUnknownStatement,
457 kJumpStatement, 458 kJumpStatement,
458 kStringLiteralExpressionStatement, 459 kStringLiteralExpressionStatement,
459 kUseStrictExpressionStatement, 460 kUseStrictExpressionStatement,
460 kUseAsmExpressionStatement, 461 kUseAsmExpressionStatement,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 PreParserStatement NewContinueStatement(PreParserStatement target, int pos) { 634 PreParserStatement NewContinueStatement(PreParserStatement target, int pos) {
634 return PreParserStatement::Jump(); 635 return PreParserStatement::Jump();
635 } 636 }
636 637
637 PreParserStatement NewWithStatement(Scope* scope, 638 PreParserStatement NewWithStatement(Scope* scope,
638 PreParserExpression expression, 639 PreParserExpression expression,
639 PreParserStatement statement, int pos) { 640 PreParserStatement statement, int pos) {
640 return PreParserStatement::Default(); 641 return PreParserStatement::Default();
641 } 642 }
642 643
644 PreParserStatement NewDoWhileStatement(ZoneList<const AstRawString*>* labels,
645 int pos) {
646 return PreParserStatement::Default();
647 }
648
649 PreParserStatement NewWhileStatement(ZoneList<const AstRawString*>* labels,
650 int pos) {
651 return PreParserStatement::Default();
652 }
653
643 // Return the object itself as AstVisitor and implement the needed 654 // Return the object itself as AstVisitor and implement the needed
644 // dummy method right in this class. 655 // dummy method right in this class.
645 PreParserFactory* visitor() { return this; } 656 PreParserFactory* visitor() { return this; }
646 int* ast_properties() { 657 int* ast_properties() {
647 static int dummy = 42; 658 static int dummy = 42;
648 return &dummy; 659 return &dummy;
649 } 660 }
650 }; 661 };
651 662
652 663
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // By making the 'exception handling' explicit, we are forced to check 809 // By making the 'exception handling' explicit, we are forced to check
799 // for failure at the call sites. 810 // for failure at the call sites.
800 Statement ParseFunctionDeclaration(bool* ok); 811 Statement ParseFunctionDeclaration(bool* ok);
801 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, 812 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
802 bool default_export, bool* ok); 813 bool default_export, bool* ok);
803 Expression ParseAsyncFunctionExpression(bool* ok); 814 Expression ParseAsyncFunctionExpression(bool* ok);
804 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names, 815 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names,
805 bool default_export, bool* ok); 816 bool default_export, bool* ok);
806 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels, 817 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
807 bool* ok); 818 bool* ok);
808 Statement ParseDoWhileStatement(ZoneList<const AstRawString*>* labels,
809 bool* ok);
810 Statement ParseWhileStatement(ZoneList<const AstRawString*>* labels,
811 bool* ok);
812 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); 819 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
813 Statement ParseThrowStatement(bool* ok);
814 Statement ParseTryStatement(bool* ok); 820 Statement ParseTryStatement(bool* ok);
815 Expression ParseConditionalExpression(bool accept_IN, bool* ok); 821 Expression ParseConditionalExpression(bool accept_IN, bool* ok);
816 Expression ParseObjectLiteral(bool* ok); 822 Expression ParseObjectLiteral(bool* ok);
817 Expression ParseDoExpression(bool* ok);
818 823
819 V8_INLINE PreParserStatementList ParseEagerFunctionBody( 824 V8_INLINE PreParserStatementList ParseEagerFunctionBody(
820 PreParserIdentifier function_name, int pos, 825 PreParserIdentifier function_name, int pos,
821 const PreParserFormalParameters& parameters, FunctionKind kind, 826 const PreParserFormalParameters& parameters, FunctionKind kind,
822 FunctionLiteral::FunctionType function_type, bool* ok); 827 FunctionLiteral::FunctionType function_type, bool* ok);
823 828
824 V8_INLINE LazyParsingResult 829 V8_INLINE LazyParsingResult
825 SkipLazyFunctionBody(int* materialized_literal_count, 830 SkipLazyFunctionBody(int* materialized_literal_count,
826 int* expected_property_count, bool may_abort, bool* ok) { 831 int* expected_property_count, bool may_abort, bool* ok) {
827 UNREACHABLE(); 832 UNREACHABLE();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels, 927 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels,
923 PreParserIdentifier label) { 928 PreParserIdentifier label) {
924 return false; 929 return false;
925 } 930 }
926 931
927 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value, 932 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value,
928 int pos) { 933 int pos) {
929 return return_value; 934 return return_value;
930 } 935 }
931 936
937 V8_INLINE PreParserExpression RewriteDoExpression(PreParserStatement body,
938 int pos, bool* ok) {
939 return PreParserExpression::Default();
940 }
941
932 // TODO(nikolaos): The preparser currently does not keep track of labels 942 // TODO(nikolaos): The preparser currently does not keep track of labels
933 // and targets. 943 // and targets.
934 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label, 944 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label,
935 bool* ok) { 945 bool* ok) {
936 return PreParserStatement::Default(); 946 return PreParserStatement::Default();
937 } 947 }
938 V8_INLINE PreParserStatement LookupContinueTarget(PreParserIdentifier label, 948 V8_INLINE PreParserStatement LookupContinueTarget(PreParserIdentifier label,
939 bool* ok) { 949 bool* ok) {
940 return PreParserStatement::Default(); 950 return PreParserStatement::Default();
941 } 951 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 bool ignore_completion_value, int pos) { 1261 bool ignore_completion_value, int pos) {
1252 return PreParserStatement::Default(); 1262 return PreParserStatement::Default();
1253 } 1263 }
1254 1264
1255 V8_INLINE PreParserExpression 1265 V8_INLINE PreParserExpression
1256 NewV8Intrinsic(PreParserIdentifier name, PreParserExpressionList arguments, 1266 NewV8Intrinsic(PreParserIdentifier name, PreParserExpressionList arguments,
1257 int pos, bool* ok) { 1267 int pos, bool* ok) {
1258 return PreParserExpression::Default(); 1268 return PreParserExpression::Default();
1259 } 1269 }
1260 1270
1271 V8_INLINE PreParserStatement NewThrowStatement(PreParserExpression exception,
1272 int pos) {
1273 return PreParserStatement::Jump();
1274 }
1275
1261 V8_INLINE void AddParameterInitializationBlock( 1276 V8_INLINE void AddParameterInitializationBlock(
1262 const PreParserFormalParameters& parameters, PreParserStatementList body, 1277 const PreParserFormalParameters& parameters, PreParserStatementList body,
1263 bool is_async, bool* ok) {} 1278 bool is_async, bool* ok) {}
1264 1279
1265 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters, 1280 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters,
1266 PreParserExpression pattern, 1281 PreParserExpression pattern,
1267 PreParserExpression initializer, 1282 PreParserExpression initializer,
1268 int initializer_end_position, 1283 int initializer_end_position,
1269 bool is_rest) { 1284 bool is_rest) {
1270 ++parameters->arity; 1285 ++parameters->arity;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 function_state_->NextMaterializedLiteralIndex(); 1389 function_state_->NextMaterializedLiteralIndex();
1375 function_state_->NextMaterializedLiteralIndex(); 1390 function_state_->NextMaterializedLiteralIndex();
1376 } 1391 }
1377 return EmptyExpression(); 1392 return EmptyExpression();
1378 } 1393 }
1379 1394
1380 } // namespace internal 1395 } // namespace internal
1381 } // namespace v8 1396 } // namespace v8
1382 1397
1383 #endif // V8_PARSING_PREPARSER_H 1398 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698