| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 // Creates expression statement from expression. | 409 // Creates expression statement from expression. |
| 397 // Preserves being an unparenthesized string literal, possibly | 410 // Preserves being an unparenthesized string literal, possibly |
| 398 // "use strict". | 411 // "use strict". |
| 399 static PreParserStatement ExpressionStatement( | 412 static PreParserStatement ExpressionStatement( |
| 400 PreParserExpression expression) { | 413 PreParserExpression expression) { |
| 401 if (expression.IsUseStrictLiteral()) { | 414 if (expression.IsUseStrictLiteral()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 418 bool IsUseStrictLiteral() { | 431 bool IsUseStrictLiteral() { |
| 419 return code_ == kUseStrictExpressionStatement; | 432 return code_ == kUseStrictExpressionStatement; |
| 420 } | 433 } |
| 421 | 434 |
| 422 bool IsUseAsmLiteral() { return code_ == kUseAsmExpressionStatement; } | 435 bool IsUseAsmLiteral() { return code_ == kUseAsmExpressionStatement; } |
| 423 | 436 |
| 424 bool IsJumpStatement() { | 437 bool IsJumpStatement() { |
| 425 return code_ == kJumpStatement; | 438 return code_ == kJumpStatement; |
| 426 } | 439 } |
| 427 | 440 |
| 441 bool IsNullStatement() { return code_ == kNullStatement; } |
| 442 |
| 443 bool IsEmptyStatement() { return code_ == kEmptyStatement; } |
| 444 |
| 428 // Dummy implementation for making statement->somefunc() work in both Parser | 445 // Dummy implementation for making statement->somefunc() work in both Parser |
| 429 // and PreParser. | 446 // and PreParser. |
| 430 PreParserStatement* operator->() { return this; } | 447 PreParserStatement* operator->() { return this; } |
| 431 | 448 |
| 432 PreParserStatementList statements() { return PreParserStatementList(); } | 449 PreParserStatementList statements() { return PreParserStatementList(); } |
| 433 void set_scope(Scope* scope) {} | 450 void set_scope(Scope* scope) {} |
| 434 | 451 |
| 435 private: | 452 private: |
| 436 enum Type { | 453 enum Type { |
| 454 kNullStatement, |
| 455 kEmptyStatement, |
| 437 kUnknownStatement, | 456 kUnknownStatement, |
| 438 kJumpStatement, | 457 kJumpStatement, |
| 439 kStringLiteralExpressionStatement, | 458 kStringLiteralExpressionStatement, |
| 440 kUseStrictExpressionStatement, | 459 kUseStrictExpressionStatement, |
| 441 kUseAsmExpressionStatement, | 460 kUseAsmExpressionStatement, |
| 442 }; | 461 }; |
| 443 | 462 |
| 444 explicit PreParserStatement(Type code) : code_(code) {} | 463 explicit PreParserStatement(Type code) : code_(code) {} |
| 445 Type code_; | 464 Type code_; |
| 446 }; | 465 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 571 } |
| 553 return PreParserExpression::Call(); | 572 return PreParserExpression::Call(); |
| 554 } | 573 } |
| 555 PreParserExpression NewCallNew(PreParserExpression expression, | 574 PreParserExpression NewCallNew(PreParserExpression expression, |
| 556 PreParserExpressionList arguments, | 575 PreParserExpressionList arguments, |
| 557 int pos) { | 576 int pos) { |
| 558 return PreParserExpression::Default(); | 577 return PreParserExpression::Default(); |
| 559 } | 578 } |
| 560 PreParserStatement NewReturnStatement(PreParserExpression expression, | 579 PreParserStatement NewReturnStatement(PreParserExpression expression, |
| 561 int pos) { | 580 int pos) { |
| 562 return PreParserStatement::Default(); | 581 return PreParserStatement::Jump(); |
| 563 } | 582 } |
| 564 PreParserExpression NewFunctionLiteral( | 583 PreParserExpression NewFunctionLiteral( |
| 565 PreParserIdentifier name, Scope* scope, PreParserStatementList body, | 584 PreParserIdentifier name, Scope* scope, PreParserStatementList body, |
| 566 int materialized_literal_count, int expected_property_count, | 585 int materialized_literal_count, int expected_property_count, |
| 567 int parameter_count, | 586 int parameter_count, |
| 568 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 587 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 569 FunctionLiteral::FunctionType function_type, | 588 FunctionLiteral::FunctionType function_type, |
| 570 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, | 589 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, |
| 571 int position) { | 590 int position) { |
| 572 return PreParserExpression::Default(); | 591 return PreParserExpression::Default(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 588 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels, | 607 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels, |
| 589 int capacity, bool ignore_completion_value, | 608 int capacity, bool ignore_completion_value, |
| 590 int pos) { | 609 int pos) { |
| 591 return PreParserStatement::Default(); | 610 return PreParserStatement::Default(); |
| 592 } | 611 } |
| 593 | 612 |
| 594 PreParserStatement NewDebuggerStatement(int pos) { | 613 PreParserStatement NewDebuggerStatement(int pos) { |
| 595 return PreParserStatement::Default(); | 614 return PreParserStatement::Default(); |
| 596 } | 615 } |
| 597 | 616 |
| 617 PreParserStatement NewExpressionStatement(PreParserExpression expr, int pos) { |
| 618 return PreParserStatement::ExpressionStatement(expr); |
| 619 } |
| 620 |
| 621 PreParserStatement NewIfStatement(PreParserExpression condition, |
| 622 PreParserStatement then_statement, |
| 623 PreParserStatement else_statement, |
| 624 int pos) { |
| 625 // This must return a jump statement iff both clauses are jump statements. |
| 626 return else_statement.IsJumpStatement() ? then_statement : else_statement; |
| 627 } |
| 628 |
| 629 PreParserStatement NewBreakStatement(PreParserStatement target, int pos) { |
| 630 return PreParserStatement::Jump(); |
| 631 } |
| 632 |
| 633 PreParserStatement NewContinueStatement(PreParserStatement target, int pos) { |
| 634 return PreParserStatement::Jump(); |
| 635 } |
| 636 |
| 637 PreParserStatement NewWithStatement(Scope* scope, |
| 638 PreParserExpression expression, |
| 639 PreParserStatement statement, int pos) { |
| 640 return PreParserStatement::Default(); |
| 641 } |
| 642 |
| 598 // Return the object itself as AstVisitor and implement the needed | 643 // Return the object itself as AstVisitor and implement the needed |
| 599 // dummy method right in this class. | 644 // dummy method right in this class. |
| 600 PreParserFactory* visitor() { return this; } | 645 PreParserFactory* visitor() { return this; } |
| 601 int* ast_properties() { | 646 int* ast_properties() { |
| 602 static int dummy = 42; | 647 static int dummy = 42; |
| 603 return &dummy; | 648 return &dummy; |
| 604 } | 649 } |
| 605 }; | 650 }; |
| 606 | 651 |
| 607 | 652 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 typedef PreParserExpression Expression; | 686 typedef PreParserExpression Expression; |
| 642 typedef PreParserExpression FunctionLiteral; | 687 typedef PreParserExpression FunctionLiteral; |
| 643 typedef PreParserExpression ObjectLiteralProperty; | 688 typedef PreParserExpression ObjectLiteralProperty; |
| 644 typedef PreParserExpression ClassLiteralProperty; | 689 typedef PreParserExpression ClassLiteralProperty; |
| 645 typedef PreParserExpressionList ExpressionList; | 690 typedef PreParserExpressionList ExpressionList; |
| 646 typedef PreParserExpressionList PropertyList; | 691 typedef PreParserExpressionList PropertyList; |
| 647 typedef PreParserFormalParameters FormalParameters; | 692 typedef PreParserFormalParameters FormalParameters; |
| 648 typedef PreParserStatement Statement; | 693 typedef PreParserStatement Statement; |
| 649 typedef PreParserStatementList StatementList; | 694 typedef PreParserStatementList StatementList; |
| 650 typedef PreParserStatement Block; | 695 typedef PreParserStatement Block; |
| 696 typedef PreParserStatement BreakableStatementT; |
| 697 typedef PreParserStatement IterationStatementT; |
| 651 | 698 |
| 652 // For constructing objects returned by the traversing functions. | 699 // For constructing objects returned by the traversing functions. |
| 653 typedef PreParserFactory Factory; | 700 typedef PreParserFactory Factory; |
| 654 | 701 |
| 655 typedef PreParserTarget Target; | 702 typedef PreParserTarget Target; |
| 656 typedef PreParserTargetScope TargetScope; | 703 typedef PreParserTargetScope TargetScope; |
| 657 }; | 704 }; |
| 658 | 705 |
| 659 | 706 |
| 660 // Preparsing checks a JavaScript program and emits preparse-data that helps | 707 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 // All ParseXXX functions take as the last argument an *ok parameter | 796 // All ParseXXX functions take as the last argument an *ok parameter |
| 750 // which is set to false if parsing failed; it is unchanged otherwise. | 797 // which is set to false if parsing failed; it is unchanged otherwise. |
| 751 // By making the 'exception handling' explicit, we are forced to check | 798 // By making the 'exception handling' explicit, we are forced to check |
| 752 // for failure at the call sites. | 799 // for failure at the call sites. |
| 753 Statement ParseFunctionDeclaration(bool* ok); | 800 Statement ParseFunctionDeclaration(bool* ok); |
| 754 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, | 801 Statement ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 755 bool default_export, bool* ok); | 802 bool default_export, bool* ok); |
| 756 Expression ParseAsyncFunctionExpression(bool* ok); | 803 Expression ParseAsyncFunctionExpression(bool* ok); |
| 757 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 804 Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| 758 bool default_export, bool* ok); | 805 bool default_export, bool* ok); |
| 759 Statement ParseExpressionOrLabelledStatement( | |
| 760 ZoneList<const AstRawString*>* names, | |
| 761 AllowLabelledFunctionStatement allow_function, bool* ok); | |
| 762 Statement ParseIfStatement(ZoneList<const AstRawString*>* labels, bool* ok); | |
| 763 Statement ParseContinueStatement(bool* ok); | |
| 764 Statement ParseBreakStatement(ZoneList<const AstRawString*>* labels, | |
| 765 bool* ok); | |
| 766 Statement ParseReturnStatement(bool* ok); | |
| 767 Statement ParseWithStatement(ZoneList<const AstRawString*>* labels, bool* ok); | |
| 768 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels, | 806 Statement ParseSwitchStatement(ZoneList<const AstRawString*>* labels, |
| 769 bool* ok); | 807 bool* ok); |
| 770 Statement ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, | 808 Statement ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, |
| 771 bool* ok); | 809 bool* ok); |
| 772 Statement ParseWhileStatement(ZoneList<const AstRawString*>* labels, | 810 Statement ParseWhileStatement(ZoneList<const AstRawString*>* labels, |
| 773 bool* ok); | 811 bool* ok); |
| 774 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); | 812 Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); |
| 775 Statement ParseThrowStatement(bool* ok); | 813 Statement ParseThrowStatement(bool* ok); |
| 776 Statement ParseTryStatement(bool* ok); | 814 Statement ParseTryStatement(bool* ok); |
| 777 Expression ParseConditionalExpression(bool accept_IN, bool* ok); | 815 Expression ParseConditionalExpression(bool accept_IN, bool* ok); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 int pos) { | 896 int pos) { |
| 859 return PreParserExpression::Default(); | 897 return PreParserExpression::Default(); |
| 860 } | 898 } |
| 861 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } | 899 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } |
| 862 | 900 |
| 863 V8_INLINE void DeclareAndInitializeVariables( | 901 V8_INLINE void DeclareAndInitializeVariables( |
| 864 PreParserStatement block, | 902 PreParserStatement block, |
| 865 const DeclarationDescriptor* declaration_descriptor, | 903 const DeclarationDescriptor* declaration_descriptor, |
| 866 const DeclarationParsingResult::Declaration* declaration, | 904 const DeclarationParsingResult::Declaration* declaration, |
| 867 ZoneList<const AstRawString*>* names, bool* ok) {} | 905 ZoneList<const AstRawString*>* names, bool* ok) {} |
| 906 V8_INLINE ZoneList<const AstRawString*>* DeclareLabel( |
| 907 ZoneList<const AstRawString*>* labels, PreParserExpression expr, |
| 908 bool* ok) { |
| 909 DCHECK(!expr.AsIdentifier().IsEnum()); |
| 910 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); |
| 911 DCHECK(is_sloppy(language_mode()) || |
| 912 !IsFutureStrictReserved(expr.AsIdentifier())); |
| 913 return labels; |
| 914 } |
| 915 |
| 916 V8_INLINE PreParserStatement ParseNativeDeclaration(bool* ok) { |
| 917 UNREACHABLE(); |
| 918 return PreParserStatement::Default(); |
| 919 } |
| 920 |
| 921 // TODO(nikolaos): The preparser currently does not keep track of labels. |
| 922 V8_INLINE bool ContainsLabel(ZoneList<const AstRawString*>* labels, |
| 923 PreParserIdentifier label) { |
| 924 return false; |
| 925 } |
| 926 |
| 927 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value, |
| 928 int pos) { |
| 929 return return_value; |
| 930 } |
| 931 |
| 932 // TODO(nikolaos): The preparser currently does not keep track of labels |
| 933 // and targets. |
| 934 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label, |
| 935 bool* ok) { |
| 936 return PreParserStatement::Default(); |
| 937 } |
| 938 V8_INLINE PreParserStatement LookupContinueTarget(PreParserIdentifier label, |
| 939 bool* ok) { |
| 940 return PreParserStatement::Default(); |
| 941 } |
| 868 | 942 |
| 869 V8_INLINE PreParserStatement DeclareFunction( | 943 V8_INLINE PreParserStatement DeclareFunction( |
| 870 PreParserIdentifier variable_name, PreParserExpression function, int pos, | 944 PreParserIdentifier variable_name, PreParserExpression function, int pos, |
| 871 bool is_generator, bool is_async, ZoneList<const AstRawString*>* names, | 945 bool is_generator, bool is_async, ZoneList<const AstRawString*>* names, |
| 872 bool* ok) { | 946 bool* ok) { |
| 873 return Statement::Default(); | 947 return Statement::Default(); |
| 874 } | 948 } |
| 875 | 949 |
| 876 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 950 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
| 877 PreParserExpression assignment) {} | 951 PreParserExpression assignment) {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 | 984 |
| 911 V8_INLINE static bool IsIdentifier(PreParserExpression expression) { | 985 V8_INLINE static bool IsIdentifier(PreParserExpression expression) { |
| 912 return expression.IsIdentifier(); | 986 return expression.IsIdentifier(); |
| 913 } | 987 } |
| 914 | 988 |
| 915 V8_INLINE static PreParserIdentifier AsIdentifier( | 989 V8_INLINE static PreParserIdentifier AsIdentifier( |
| 916 PreParserExpression expression) { | 990 PreParserExpression expression) { |
| 917 return expression.AsIdentifier(); | 991 return expression.AsIdentifier(); |
| 918 } | 992 } |
| 919 | 993 |
| 994 V8_INLINE static PreParserExpression AsIdentifierExpression( |
| 995 PreParserExpression expression) { |
| 996 return expression; |
| 997 } |
| 998 |
| 920 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const { | 999 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const { |
| 921 return identifier.IsPrototype(); | 1000 return identifier.IsPrototype(); |
| 922 } | 1001 } |
| 923 | 1002 |
| 924 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { | 1003 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { |
| 925 return identifier.IsConstructor(); | 1004 return identifier.IsConstructor(); |
| 926 } | 1005 } |
| 927 | 1006 |
| 928 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const { | 1007 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const { |
| 929 return expression.IsDirectEvalCall(); | 1008 return expression.IsDirectEvalCall(); |
| 930 } | 1009 } |
| 931 | 1010 |
| 932 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { | 1011 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { |
| 933 // PreParser doesn't count boilerplate properties. | 1012 // PreParser doesn't count boilerplate properties. |
| 934 return false; | 1013 return false; |
| 935 } | 1014 } |
| 936 | 1015 |
| 1016 V8_INLINE bool IsNative(PreParserExpression expr) const { |
| 1017 // Preparsing is disabled for extensions (because the extension |
| 1018 // details aren't passed to lazily compiled functions), so we |
| 1019 // don't accept "native function" in the preparser and there is |
| 1020 // no need to keep track of "native". |
| 1021 return false; |
| 1022 } |
| 1023 |
| 937 V8_INLINE static bool IsArrayIndex(PreParserIdentifier string, | 1024 V8_INLINE static bool IsArrayIndex(PreParserIdentifier string, |
| 938 uint32_t* index) { | 1025 uint32_t* index) { |
| 939 return false; | 1026 return false; |
| 940 } | 1027 } |
| 941 | 1028 |
| 942 V8_INLINE bool IsUseStrictDirective(PreParserStatement statement) const { | 1029 V8_INLINE bool IsUseStrictDirective(PreParserStatement statement) const { |
| 943 return statement.IsUseStrictLiteral(); | 1030 return statement.IsUseStrictLiteral(); |
| 944 } | 1031 } |
| 945 | 1032 |
| 946 V8_INLINE bool IsUseAsmDirective(PreParserStatement statement) const { | 1033 V8_INLINE bool IsUseAsmDirective(PreParserStatement statement) const { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 V8_INLINE void ReportMessageAt(Scanner::Location source_location, | 1101 V8_INLINE void ReportMessageAt(Scanner::Location source_location, |
| 1015 MessageTemplate::Template message, | 1102 MessageTemplate::Template message, |
| 1016 const char* arg = NULL, | 1103 const char* arg = NULL, |
| 1017 ParseErrorType error_type = kSyntaxError) { | 1104 ParseErrorType error_type = kSyntaxError) { |
| 1018 log_->LogMessage(source_location.beg_pos, source_location.end_pos, message, | 1105 log_->LogMessage(source_location.beg_pos, source_location.end_pos, message, |
| 1019 arg, error_type); | 1106 arg, error_type); |
| 1020 } | 1107 } |
| 1021 | 1108 |
| 1022 V8_INLINE void ReportMessageAt(Scanner::Location source_location, | 1109 V8_INLINE void ReportMessageAt(Scanner::Location source_location, |
| 1023 MessageTemplate::Template message, | 1110 MessageTemplate::Template message, |
| 1024 const AstRawString* arg, | 1111 PreParserIdentifier arg, |
| 1025 ParseErrorType error_type = kSyntaxError) { | 1112 ParseErrorType error_type = kSyntaxError) { |
| 1026 UNREACHABLE(); | 1113 UNREACHABLE(); |
| 1027 } | 1114 } |
| 1028 | 1115 |
| 1029 // "null" return type creators. | 1116 // "null" return type creators. |
| 1030 V8_INLINE static PreParserIdentifier EmptyIdentifier() { | 1117 V8_INLINE static PreParserIdentifier EmptyIdentifier() { |
| 1031 return PreParserIdentifier::Default(); | 1118 return PreParserIdentifier::Empty(); |
| 1119 } |
| 1120 V8_INLINE static bool IsEmptyIdentifier(PreParserIdentifier name) { |
| 1121 return name.IsEmpty(); |
| 1032 } | 1122 } |
| 1033 V8_INLINE static PreParserExpression EmptyExpression() { | 1123 V8_INLINE static PreParserExpression EmptyExpression() { |
| 1034 return PreParserExpression::Empty(); | 1124 return PreParserExpression::Empty(); |
| 1035 } | 1125 } |
| 1036 V8_INLINE static PreParserExpression EmptyLiteral() { | 1126 V8_INLINE static PreParserExpression EmptyLiteral() { |
| 1037 return PreParserExpression::Default(); | 1127 return PreParserExpression::Default(); |
| 1038 } | 1128 } |
| 1039 V8_INLINE static PreParserExpression EmptyObjectLiteralProperty() { | 1129 V8_INLINE static PreParserExpression EmptyObjectLiteralProperty() { |
| 1040 return PreParserExpression::Default(); | 1130 return PreParserExpression::Default(); |
| 1041 } | 1131 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1063 } | 1153 } |
| 1064 | 1154 |
| 1065 V8_INLINE static bool IsNullStatementList(PreParserStatementList stmts) { | 1155 V8_INLINE static bool IsNullStatementList(PreParserStatementList stmts) { |
| 1066 return stmts.IsNull(); | 1156 return stmts.IsNull(); |
| 1067 } | 1157 } |
| 1068 | 1158 |
| 1069 V8_INLINE static PreParserStatement NullStatement() { | 1159 V8_INLINE static PreParserStatement NullStatement() { |
| 1070 return PreParserStatement::Default(); | 1160 return PreParserStatement::Default(); |
| 1071 } | 1161 } |
| 1072 | 1162 |
| 1073 V8_INLINE bool IsNullOrEmptyStatement(PreParserStatement stmt) { | 1163 V8_INLINE bool IsNullStatement(PreParserStatement stmt) { |
| 1074 // TODO(nikolaos): See if this needs to be consistent for the preparser. | 1164 return stmt.IsNullStatement(); |
| 1075 return false; | 1165 } |
| 1166 |
| 1167 V8_INLINE bool IsEmptyStatement(PreParserStatement stmt) { |
| 1168 return stmt.IsEmptyStatement(); |
| 1076 } | 1169 } |
| 1077 | 1170 |
| 1078 V8_INLINE static PreParserStatement NullBlock() { | 1171 V8_INLINE static PreParserStatement NullBlock() { |
| 1079 return PreParserStatement::Default(); | 1172 return PreParserStatement::Default(); |
| 1080 } | 1173 } |
| 1081 | 1174 |
| 1082 V8_INLINE PreParserIdentifier EmptyIdentifierString() const { | 1175 V8_INLINE PreParserIdentifier EmptyIdentifierString() const { |
| 1083 return PreParserIdentifier::Default(); | 1176 return PreParserIdentifier::Default(); |
| 1084 } | 1177 } |
| 1085 | 1178 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 function_state_->NextMaterializedLiteralIndex(); | 1374 function_state_->NextMaterializedLiteralIndex(); |
| 1282 function_state_->NextMaterializedLiteralIndex(); | 1375 function_state_->NextMaterializedLiteralIndex(); |
| 1283 } | 1376 } |
| 1284 return EmptyExpression(); | 1377 return EmptyExpression(); |
| 1285 } | 1378 } |
| 1286 | 1379 |
| 1287 } // namespace internal | 1380 } // namespace internal |
| 1288 } // namespace v8 | 1381 } // namespace v8 |
| 1289 | 1382 |
| 1290 #endif // V8_PARSING_PREPARSER_H | 1383 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |