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

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

Issue 2323763002: [parser] Refactor of Parse*Statement*, part 4 (Closed)
Patch Set: The real patch 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
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
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 // Whereas the Parser generates AST during the recursive descent, 14 // Whereas the Parser generates AST during the recursive descent,
15 // the PreParser doesn't create a tree. Instead, it passes around minimal 15 // the PreParser doesn't create a tree. Instead, it passes around minimal
16 // data objects (PreParserExpression, PreParserIdentifier etc.) which contain 16 // data objects (PreParserExpression, PreParserIdentifier etc.) which contain
17 // just enough data for the upper layer functions. PreParserFactory is 17 // just enough data for the upper layer functions. PreParserFactory is
18 // responsible for creating these dummy objects. It provides a similar kind of 18 // responsible for creating these dummy objects. It provides a similar kind of
19 // interface as AstNodeFactory, so ParserBase doesn't need to care which one is 19 // interface as AstNodeFactory, so ParserBase doesn't need to care which one is
20 // used. 20 // used.
21 21
22 class PreParserIdentifier { 22 class PreParserIdentifier {
23 public: 23 public:
24 PreParserIdentifier() : type_(kUnknownIdentifier) {} 24 PreParserIdentifier() : type_(kUnknownIdentifier) {}
25 static PreParserIdentifier Default() { 25 static PreParserIdentifier Default() {
26 return PreParserIdentifier(kUnknownIdentifier); 26 return PreParserIdentifier(kUnknownIdentifier);
27 } 27 }
28 static PreParserIdentifier Empty() {
29 return PreParserIdentifier(kEmptyIdentifier);
30 }
28 static PreParserIdentifier Eval() { 31 static PreParserIdentifier Eval() {
29 return PreParserIdentifier(kEvalIdentifier); 32 return PreParserIdentifier(kEvalIdentifier);
30 } 33 }
31 static PreParserIdentifier Arguments() { 34 static PreParserIdentifier Arguments() {
32 return PreParserIdentifier(kArgumentsIdentifier); 35 return PreParserIdentifier(kArgumentsIdentifier);
33 } 36 }
34 static PreParserIdentifier Undefined() { 37 static PreParserIdentifier Undefined() {
35 return PreParserIdentifier(kUndefinedIdentifier); 38 return PreParserIdentifier(kUndefinedIdentifier);
36 } 39 }
37 static PreParserIdentifier FutureReserved() { 40 static PreParserIdentifier FutureReserved() {
(...skipping 19 matching lines...) Expand all
57 } 60 }
58 static PreParserIdentifier Enum() { 61 static PreParserIdentifier Enum() {
59 return PreParserIdentifier(kEnumIdentifier); 62 return PreParserIdentifier(kEnumIdentifier);
60 } 63 }
61 static PreParserIdentifier Await() { 64 static PreParserIdentifier Await() {
62 return PreParserIdentifier(kAwaitIdentifier); 65 return PreParserIdentifier(kAwaitIdentifier);
63 } 66 }
64 static PreParserIdentifier Async() { 67 static PreParserIdentifier Async() {
65 return PreParserIdentifier(kAsyncIdentifier); 68 return PreParserIdentifier(kAsyncIdentifier);
66 } 69 }
70 bool IsEmpty() const { return type_ == kEmptyIdentifier; }
67 bool IsEval() const { return type_ == kEvalIdentifier; } 71 bool IsEval() const { return type_ == kEvalIdentifier; }
68 bool IsArguments() const { return type_ == kArgumentsIdentifier; } 72 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
69 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } 73 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); }
70 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } 74 bool IsUndefined() const { return type_ == kUndefinedIdentifier; }
71 bool IsLet() const { return type_ == kLetIdentifier; } 75 bool IsLet() const { return type_ == kLetIdentifier; }
72 bool IsStatic() const { return type_ == kStaticIdentifier; } 76 bool IsStatic() const { return type_ == kStaticIdentifier; }
73 bool IsYield() const { return type_ == kYieldIdentifier; } 77 bool IsYield() const { return type_ == kYieldIdentifier; }
74 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } 78 bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
75 bool IsConstructor() const { return type_ == kConstructorIdentifier; } 79 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
76 bool IsEnum() const { return type_ == kEnumIdentifier; } 80 bool IsEnum() const { return type_ == kEnumIdentifier; }
77 bool IsAwait() const { return type_ == kAwaitIdentifier; } 81 bool IsAwait() const { return type_ == kAwaitIdentifier; }
78 bool IsFutureStrictReserved() const { 82 bool IsFutureStrictReserved() const {
79 return type_ == kFutureStrictReservedIdentifier || 83 return type_ == kFutureStrictReservedIdentifier ||
80 type_ == kLetIdentifier || type_ == kStaticIdentifier || 84 type_ == kLetIdentifier || type_ == kStaticIdentifier ||
81 type_ == kYieldIdentifier; 85 type_ == kYieldIdentifier;
82 } 86 }
83 87
84 // Allow identifier->name()[->length()] to work. The preparser 88 // Allow identifier->name()[->length()] to work. The preparser
85 // does not need the actual positions/lengths of the identifiers. 89 // does not need the actual positions/lengths of the identifiers.
86 const PreParserIdentifier* operator->() const { return this; } 90 const PreParserIdentifier* operator->() const { return this; }
87 const PreParserIdentifier raw_name() const { return *this; } 91 const PreParserIdentifier raw_name() const { return *this; }
88 92
89 int position() const { return 0; } 93 int position() const { return 0; }
90 int length() const { return 0; } 94 int length() const { return 0; }
91 95
92 private: 96 private:
93 enum Type { 97 enum Type {
98 kEmptyIdentifier,
94 kUnknownIdentifier, 99 kUnknownIdentifier,
95 kFutureReservedIdentifier, 100 kFutureReservedIdentifier,
96 kFutureStrictReservedIdentifier, 101 kFutureStrictReservedIdentifier,
97 kLetIdentifier, 102 kLetIdentifier,
98 kStaticIdentifier, 103 kStaticIdentifier,
99 kYieldIdentifier, 104 kYieldIdentifier,
100 kEvalIdentifier, 105 kEvalIdentifier,
101 kArgumentsIdentifier, 106 kArgumentsIdentifier,
102 kUndefinedIdentifier, 107 kUndefinedIdentifier,
103 kPrototypeIdentifier, 108 kPrototypeIdentifier,
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 387
383 class PreParserStatement; 388 class PreParserStatement;
384 typedef PreParserList<PreParserStatement> PreParserStatementList; 389 typedef PreParserList<PreParserStatement> PreParserStatementList;
385 390
386 class PreParserStatement { 391 class PreParserStatement {
387 public: 392 public:
388 static PreParserStatement Default() { 393 static PreParserStatement Default() {
389 return PreParserStatement(kUnknownStatement); 394 return PreParserStatement(kUnknownStatement);
390 } 395 }
391 396
397 static PreParserStatement Null() {
398 return PreParserStatement(kNullStatement);
399 }
400
401 static PreParserStatement Empty() {
402 return PreParserStatement(kEmptyStatement);
403 }
404
392 static PreParserStatement Jump() { 405 static PreParserStatement Jump() {
393 return PreParserStatement(kJumpStatement); 406 return PreParserStatement(kJumpStatement);
394 } 407 }
395 408
396 static PreParserStatement FunctionDeclaration() { 409 static PreParserStatement FunctionDeclaration() {
397 return PreParserStatement(kFunctionDeclaration); 410 return PreParserStatement(kFunctionDeclaration);
398 } 411 }
399 412
400 // Creates expression statement from expression. 413 // Creates expression statement from expression.
401 // Preserves being an unparenthesized string literal, possibly 414 // Preserves being an unparenthesized string literal, possibly
(...skipping 24 matching lines...) Expand all
426 bool IsUseAsmLiteral() { return code_ == kUseAsmExpressionStatement; } 439 bool IsUseAsmLiteral() { return code_ == kUseAsmExpressionStatement; }
427 440
428 bool IsFunctionDeclaration() { 441 bool IsFunctionDeclaration() {
429 return code_ == kFunctionDeclaration; 442 return code_ == kFunctionDeclaration;
430 } 443 }
431 444
432 bool IsJumpStatement() { 445 bool IsJumpStatement() {
433 return code_ == kJumpStatement; 446 return code_ == kJumpStatement;
434 } 447 }
435 448
449 bool IsNullStatement() { return code_ == kNullStatement; }
450
451 bool IsEmptyStatement() { return code_ == kEmptyStatement; }
adamk 2016/09/08 18:33:19 Is this only called by IsNullOrEmptyStatement()? T
nickie 2016/09/09 09:42:27 I think the confusion was originally created by "E
452
436 // Dummy implementation for making statement->somefunc() work in both Parser 453 // Dummy implementation for making statement->somefunc() work in both Parser
437 // and PreParser. 454 // and PreParser.
438 PreParserStatement* operator->() { return this; } 455 PreParserStatement* operator->() { return this; }
439 456
440 PreParserStatementList statements() { return PreParserStatementList(); } 457 PreParserStatementList statements() { return PreParserStatementList(); }
441 void set_scope(Scope* scope) {} 458 void set_scope(Scope* scope) {}
442 459
443 private: 460 private:
444 enum Type { 461 enum Type {
462 kNullStatement,
463 kEmptyStatement,
445 kUnknownStatement, 464 kUnknownStatement,
446 kJumpStatement, 465 kJumpStatement,
447 kStringLiteralExpressionStatement, 466 kStringLiteralExpressionStatement,
448 kUseStrictExpressionStatement, 467 kUseStrictExpressionStatement,
449 kUseAsmExpressionStatement, 468 kUseAsmExpressionStatement,
450 kFunctionDeclaration 469 kFunctionDeclaration
451 }; 470 };
452 471
453 explicit PreParserStatement(Type code) : code_(code) {} 472 explicit PreParserStatement(Type code) : code_(code) {}
454 Type code_; 473 Type code_;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 585 }
567 return PreParserExpression::Call(); 586 return PreParserExpression::Call();
568 } 587 }
569 PreParserExpression NewCallNew(PreParserExpression expression, 588 PreParserExpression NewCallNew(PreParserExpression expression,
570 PreParserExpressionList arguments, 589 PreParserExpressionList arguments,
571 int pos) { 590 int pos) {
572 return PreParserExpression::Default(); 591 return PreParserExpression::Default();
573 } 592 }
574 PreParserStatement NewReturnStatement(PreParserExpression expression, 593 PreParserStatement NewReturnStatement(PreParserExpression expression,
575 int pos) { 594 int pos) {
576 return PreParserStatement::Default(); 595 return PreParserStatement::Jump();
577 } 596 }
578 PreParserExpression NewFunctionLiteral( 597 PreParserExpression NewFunctionLiteral(
579 PreParserIdentifier name, Scope* scope, PreParserStatementList body, 598 PreParserIdentifier name, Scope* scope, PreParserStatementList body,
580 int materialized_literal_count, int expected_property_count, 599 int materialized_literal_count, int expected_property_count,
581 int parameter_count, 600 int parameter_count,
582 FunctionLiteral::ParameterFlag has_duplicate_parameters, 601 FunctionLiteral::ParameterFlag has_duplicate_parameters,
583 FunctionLiteral::FunctionType function_type, 602 FunctionLiteral::FunctionType function_type,
584 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, 603 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
585 int position) { 604 int position) {
586 return PreParserExpression::Default(); 605 return PreParserExpression::Default();
(...skipping 15 matching lines...) Expand all
602 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels, 621 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels,
603 int capacity, bool ignore_completion_value, 622 int capacity, bool ignore_completion_value,
604 int pos) { 623 int pos) {
605 return PreParserStatement::Default(); 624 return PreParserStatement::Default();
606 } 625 }
607 626
608 PreParserStatement NewDebuggerStatement(int pos) { 627 PreParserStatement NewDebuggerStatement(int pos) {
609 return PreParserStatement::Default(); 628 return PreParserStatement::Default();
610 } 629 }
611 630
631 PreParserStatement NewExpressionStatement(PreParserExpression expr, int pos) {
632 return PreParserStatement::ExpressionStatement(expr);
633 }
634
635 PreParserStatement NewIfStatement(PreParserExpression condition,
636 PreParserStatement then_statement,
637 PreParserStatement else_statement,
638 int pos) {
639 // This must return a jump statement iff both clauses are jump statements.
640 return else_statement.IsJumpStatement() ? then_statement : else_statement;
641 }
642
643 PreParserStatement NewBreakStatement(PreParserStatement target, int pos) {
644 return PreParserStatement::Jump();
645 }
646
647 PreParserStatement NewContinueStatement(PreParserStatement target, int pos) {
648 return PreParserStatement::Jump();
649 }
650
651 PreParserStatement NewWithStatement(Scope* scope,
652 PreParserExpression expression,
653 PreParserStatement statement, int pos) {
654 return PreParserStatement::Default();
655 }
656
612 // Return the object itself as AstVisitor and implement the needed 657 // Return the object itself as AstVisitor and implement the needed
613 // dummy method right in this class. 658 // dummy method right in this class.
614 PreParserFactory* visitor() { return this; } 659 PreParserFactory* visitor() { return this; }
615 int* ast_properties() { 660 int* ast_properties() {
616 static int dummy = 42; 661 static int dummy = 42;
617 return &dummy; 662 return &dummy;
618 } 663 }
619 }; 664 };
620 665
621 666
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 typedef PreParserExpression Expression; 700 typedef PreParserExpression Expression;
656 typedef PreParserExpression FunctionLiteral; 701 typedef PreParserExpression FunctionLiteral;
657 typedef PreParserExpression ObjectLiteralProperty; 702 typedef PreParserExpression ObjectLiteralProperty;
658 typedef PreParserExpression ClassLiteralProperty; 703 typedef PreParserExpression ClassLiteralProperty;
659 typedef PreParserExpressionList ExpressionList; 704 typedef PreParserExpressionList ExpressionList;
660 typedef PreParserExpressionList PropertyList; 705 typedef PreParserExpressionList PropertyList;
661 typedef PreParserFormalParameters FormalParameters; 706 typedef PreParserFormalParameters FormalParameters;
662 typedef PreParserStatement Statement; 707 typedef PreParserStatement Statement;
663 typedef PreParserStatementList StatementList; 708 typedef PreParserStatementList StatementList;
664 typedef PreParserStatement Block; 709 typedef PreParserStatement Block;
710 typedef PreParserStatement BreakableStatementT;
711 typedef PreParserStatement IterationStatementT;
665 712
666 // For constructing objects returned by the traversing functions. 713 // For constructing objects returned by the traversing functions.
667 typedef PreParserFactory Factory; 714 typedef PreParserFactory Factory;
668 715
669 typedef PreParserTarget Target; 716 typedef PreParserTarget Target;
670 typedef PreParserTargetScope TargetScope; 717 typedef PreParserTargetScope TargetScope;
671 }; 718 };
672 719
673 720
674 // Preparsing checks a JavaScript program and emits preparse-data that helps 721 // Preparsing checks a JavaScript program and emits preparse-data that helps
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 bool default_export, bool* ok); 815 bool default_export, bool* ok);
769 Statement ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, 816 Statement ParseHoistableDeclaration(int pos, ParseFunctionFlags flags,
770 ZoneList<const AstRawString*>* names, 817 ZoneList<const AstRawString*>* names,
771 bool default_export, bool* ok); 818 bool default_export, bool* ok);
772 Statement ParseFunctionDeclaration(bool* ok); 819 Statement ParseFunctionDeclaration(bool* ok);
773 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, 820 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
774 bool default_export, bool* ok); 821 bool default_export, bool* ok);
775 Expression ParseAsyncFunctionExpression(bool* ok); 822 Expression ParseAsyncFunctionExpression(bool* ok);
776 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names, 823 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names,
777 bool default_export, bool* ok); 824 bool default_export, bool* ok);
778 Statement ParseExpressionOrLabelledStatement(
779 ZoneList<const AstRawString*>* names,
780 AllowLabelledFunctionStatement allow_function, bool* ok);
781 Statement ParseIfStatement(ZoneList<const AstRawString*>* labels, bool* ok);
782 Statement ParseContinueStatement(bool* ok);
783 Statement ParseBreakStatement(ZoneList<const AstRawString*>* labels,
784 bool* ok);
785 Statement ParseReturnStatement(bool* ok);
786 Statement ParseWithStatement(ZoneList<const AstRawString*>* labels, bool* ok);
787 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels, 825 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
788 bool* ok); 826 bool* ok);
789 Statement ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, 827 Statement ParseDoWhileStatement(ZoneList<const AstRawString*>* labels,
790 bool* ok); 828 bool* ok);
791 Statement ParseWhileStatement(ZoneList<const AstRawString*>* labels, 829 Statement ParseWhileStatement(ZoneList<const AstRawString*>* labels,
792 bool* ok); 830 bool* ok);
793 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); 831 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
794 Statement ParseThrowStatement(bool* ok); 832 Statement ParseThrowStatement(bool* ok);
795 Statement ParseTryStatement(bool* ok); 833 Statement ParseTryStatement(bool* ok);
796 Expression ParseConditionalExpression(bool accept_IN, bool* ok); 834 Expression ParseConditionalExpression(bool accept_IN, bool* ok);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 int pos) { 915 int pos) {
878 return PreParserExpression::Default(); 916 return PreParserExpression::Default();
879 } 917 }
880 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } 918 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); }
881 919
882 V8_INLINE void DeclareAndInitializeVariables( 920 V8_INLINE void DeclareAndInitializeVariables(
883 PreParserStatement block, 921 PreParserStatement block,
884 const DeclarationDescriptor* declaration_descriptor, 922 const DeclarationDescriptor* declaration_descriptor,
885 const DeclarationParsingResult::Declaration* declaration, 923 const DeclarationParsingResult::Declaration* declaration,
886 ZoneList<const AstRawString*>* names, bool* ok) {} 924 ZoneList<const AstRawString*>* names, bool* ok) {}
925 V8_INLINE ZoneList<const AstRawString*>* DeclareLabel(
926 ZoneList<const AstRawString*>* labels, PreParserExpression expr,
927 bool* ok) {
928 DCHECK(!expr.AsIdentifier().IsEnum());
929 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
930 DCHECK(is_sloppy(language_mode()) ||
931 !IsFutureStrictReserved(expr.AsIdentifier()));
932 return labels;
933 }
934
935 V8_INLINE PreParserStatement ParseNativeDeclaration(bool* ok) {
936 UNREACHABLE();
937 return PreParserStatement::Default();
938 }
939
940 // TODO(nikolaos): The preparser currently does not keep track of labels.
941 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels,
942 PreParserIdentifier label) {
943 return false;
944 }
945
946 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value,
947 int pos) {
948 return return_value;
949 }
950
951 // TODO(nikolaos): The preparser currently does not keep track of labels
952 // and targets.
953 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label,
954 bool* ok) {
955 return PreParserStatement::Default();
956 }
957 V8_INLINE PreParserStatement LookupContinueTarget(PreParserIdentifier label,
958 bool* ok) {
959 return PreParserStatement::Default();
960 }
887 961
888 V8_INLINE void QueueDestructuringAssignmentForRewriting( 962 V8_INLINE void QueueDestructuringAssignmentForRewriting(
889 PreParserExpression assignment) {} 963 PreParserExpression assignment) {}
890 V8_INLINE void QueueNonPatternForRewriting(PreParserExpression expr, 964 V8_INLINE void QueueNonPatternForRewriting(PreParserExpression expr,
891 bool* ok) {} 965 bool* ok) {}
892 966
893 // Helper functions for recursive descent. 967 // Helper functions for recursive descent.
894 V8_INLINE bool IsEval(PreParserIdentifier identifier) const { 968 V8_INLINE bool IsEval(PreParserIdentifier identifier) const {
895 return identifier.IsEval(); 969 return identifier.IsEval();
896 } 970 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 1013
940 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const { 1014 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const {
941 return expression.IsDirectEvalCall(); 1015 return expression.IsDirectEvalCall();
942 } 1016 }
943 1017
944 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { 1018 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) {
945 // PreParser doesn't count boilerplate properties. 1019 // PreParser doesn't count boilerplate properties.
946 return false; 1020 return false;
947 } 1021 }
948 1022
1023 V8_INLINE bool IsNative(PreParserExpression expr) const {
1024 // Preparsing is disabled for extensions (because the extension
1025 // details aren't passed to lazily compiled functions), so we
1026 // don't accept "native function" in the preparser and there is
1027 // no need to keep track of "native".
1028 return false;
1029 }
1030
949 V8_INLINE static bool IsArrayIndex(PreParserIdentifier string, 1031 V8_INLINE static bool IsArrayIndex(PreParserIdentifier string,
950 uint32_t* index) { 1032 uint32_t* index) {
951 return false; 1033 return false;
952 } 1034 }
953 1035
954 V8_INLINE bool IsUseStrictDirective(PreParserStatement statement) const { 1036 V8_INLINE bool IsUseStrictDirective(PreParserStatement statement) const {
955 return statement.IsUseStrictLiteral(); 1037 return statement.IsUseStrictLiteral();
956 } 1038 }
957 1039
958 V8_INLINE bool IsUseAsmDirective(PreParserStatement statement) const { 1040 V8_INLINE bool IsUseAsmDirective(PreParserStatement statement) const {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 V8_INLINE void ReportMessageAt(Scanner::Location source_location, 1103 V8_INLINE void ReportMessageAt(Scanner::Location source_location,
1022 MessageTemplate::Template message, 1104 MessageTemplate::Template message,
1023 const char* arg = NULL, 1105 const char* arg = NULL,
1024 ParseErrorType error_type = kSyntaxError) { 1106 ParseErrorType error_type = kSyntaxError) {
1025 log_->LogMessage(source_location.beg_pos, source_location.end_pos, message, 1107 log_->LogMessage(source_location.beg_pos, source_location.end_pos, message,
1026 arg, error_type); 1108 arg, error_type);
1027 } 1109 }
1028 1110
1029 V8_INLINE void ReportMessageAt(Scanner::Location source_location, 1111 V8_INLINE void ReportMessageAt(Scanner::Location source_location,
1030 MessageTemplate::Template message, 1112 MessageTemplate::Template message,
1031 const AstRawString* arg, 1113 PreParserIdentifier arg,
1032 ParseErrorType error_type = kSyntaxError) { 1114 ParseErrorType error_type = kSyntaxError) {
1033 UNREACHABLE(); 1115 UNREACHABLE();
1034 } 1116 }
1035 1117
1036 // "null" return type creators. 1118 // "null" return type creators.
1037 V8_INLINE static PreParserIdentifier EmptyIdentifier() { 1119 V8_INLINE static PreParserIdentifier EmptyIdentifier() {
1038 return PreParserIdentifier::Default(); 1120 return PreParserIdentifier::Empty();
1121 }
1122 V8_INLINE static bool IsEmptyIdentifier(PreParserIdentifier name) {
1123 return name.IsEmpty();
1039 } 1124 }
1040 V8_INLINE static PreParserExpression EmptyExpression() { 1125 V8_INLINE static PreParserExpression EmptyExpression() {
1041 return PreParserExpression::Empty(); 1126 return PreParserExpression::Empty();
1042 } 1127 }
1043 V8_INLINE static PreParserExpression EmptyLiteral() { 1128 V8_INLINE static PreParserExpression EmptyLiteral() {
1044 return PreParserExpression::Default(); 1129 return PreParserExpression::Default();
1045 } 1130 }
1046 V8_INLINE static PreParserExpression EmptyObjectLiteralProperty() { 1131 V8_INLINE static PreParserExpression EmptyObjectLiteralProperty() {
1047 return PreParserExpression::Default(); 1132 return PreParserExpression::Default();
1048 } 1133 }
(...skipping 21 matching lines...) Expand all
1070 } 1155 }
1071 1156
1072 V8_INLINE static bool IsNullStatementList(PreParserStatementList stmts) { 1157 V8_INLINE static bool IsNullStatementList(PreParserStatementList stmts) {
1073 return stmts.IsNull(); 1158 return stmts.IsNull();
1074 } 1159 }
1075 1160
1076 V8_INLINE static PreParserStatement NullStatement() { 1161 V8_INLINE static PreParserStatement NullStatement() {
1077 return PreParserStatement::Default(); 1162 return PreParserStatement::Default();
1078 } 1163 }
1079 1164
1165 V8_INLINE bool IsNullStatement(PreParserStatement stmt) {
1166 return stmt.IsNullStatement();
1167 }
1168
1080 V8_INLINE bool IsNullOrEmptyStatement(PreParserStatement stmt) { 1169 V8_INLINE bool IsNullOrEmptyStatement(PreParserStatement stmt) {
1081 // TODO(nikolaos): See if this needs to be consistent for the preparser. 1170 return stmt.IsNullStatement() || stmt.IsEmptyStatement();
1082 return false;
1083 } 1171 }
1084 1172
1085 V8_INLINE static PreParserStatement NullBlock() { 1173 V8_INLINE static PreParserStatement NullBlock() {
1086 return PreParserStatement::Default(); 1174 return PreParserStatement::Default();
1087 } 1175 }
1088 1176
1089 V8_INLINE PreParserIdentifier EmptyIdentifierString() const { 1177 V8_INLINE PreParserIdentifier EmptyIdentifierString() const {
1090 return PreParserIdentifier::Default(); 1178 return PreParserIdentifier::Default();
1091 } 1179 }
1092 1180
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 function_state_->NextMaterializedLiteralIndex(); 1376 function_state_->NextMaterializedLiteralIndex();
1289 function_state_->NextMaterializedLiteralIndex(); 1377 function_state_->NextMaterializedLiteralIndex();
1290 } 1378 }
1291 return EmptyExpression(); 1379 return EmptyExpression();
1292 } 1380 }
1293 1381
1294 } // namespace internal 1382 } // namespace internal
1295 } // namespace v8 1383 } // namespace v8
1296 1384
1297 #endif // V8_PARSING_PREPARSER_H 1385 #endif // V8_PARSING_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698