| 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 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 typedef PreParserExpression YieldExpression; | 607 typedef PreParserExpression YieldExpression; |
| 608 typedef PreParserExpression FunctionLiteral; | 608 typedef PreParserExpression FunctionLiteral; |
| 609 typedef PreParserExpression ClassLiteral; | 609 typedef PreParserExpression ClassLiteral; |
| 610 typedef PreParserExpression Literal; | 610 typedef PreParserExpression Literal; |
| 611 typedef PreParserExpression ObjectLiteralProperty; | 611 typedef PreParserExpression ObjectLiteralProperty; |
| 612 typedef PreParserExpressionList ExpressionList; | 612 typedef PreParserExpressionList ExpressionList; |
| 613 typedef PreParserExpressionList PropertyList; | 613 typedef PreParserExpressionList PropertyList; |
| 614 typedef PreParserIdentifier FormalParameter; | 614 typedef PreParserIdentifier FormalParameter; |
| 615 typedef PreParserFormalParameters FormalParameters; | 615 typedef PreParserFormalParameters FormalParameters; |
| 616 typedef PreParserStatementList StatementList; | 616 typedef PreParserStatementList StatementList; |
| 617 typedef PreParserStatement Block; |
| 617 | 618 |
| 618 // For constructing objects returned by the traversing functions. | 619 // For constructing objects returned by the traversing functions. |
| 619 typedef PreParserFactory Factory; | 620 typedef PreParserFactory Factory; |
| 620 }; | 621 }; |
| 621 | 622 |
| 622 | 623 |
| 623 // Preparsing checks a JavaScript program and emits preparse-data that helps | 624 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| 624 // a later parsing to be faster. | 625 // a later parsing to be faster. |
| 625 // See preparse-data-format.h for the data format. | 626 // See preparse-data-format.h for the data format. |
| 626 | 627 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 Statement ParseHoistableDeclaration(bool* ok); | 730 Statement ParseHoistableDeclaration(bool* ok); |
| 730 Statement ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, | 731 Statement ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, |
| 731 bool* ok); | 732 bool* ok); |
| 732 Statement ParseFunctionDeclaration(bool* ok); | 733 Statement ParseFunctionDeclaration(bool* ok); |
| 733 Statement ParseAsyncFunctionDeclaration(bool* ok); | 734 Statement ParseAsyncFunctionDeclaration(bool* ok); |
| 734 Expression ParseAsyncFunctionExpression(bool* ok); | 735 Expression ParseAsyncFunctionExpression(bool* ok); |
| 735 Statement ParseClassDeclaration(bool* ok); | 736 Statement ParseClassDeclaration(bool* ok); |
| 736 Statement ParseBlock(bool* ok); | 737 Statement ParseBlock(bool* ok); |
| 737 Statement ParseVariableStatement(VariableDeclarationContext var_context, | 738 Statement ParseVariableStatement(VariableDeclarationContext var_context, |
| 738 bool* ok); | 739 bool* ok); |
| 739 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, | |
| 740 int* num_decl, bool* is_lexical, | |
| 741 bool* is_binding_pattern, | |
| 742 Scanner::Location* first_initializer_loc, | |
| 743 Scanner::Location* bindings_loc, | |
| 744 bool* ok); | |
| 745 Statement ParseExpressionOrLabelledStatement( | 740 Statement ParseExpressionOrLabelledStatement( |
| 746 AllowLabelledFunctionStatement allow_function, bool* ok); | 741 AllowLabelledFunctionStatement allow_function, bool* ok); |
| 747 Statement ParseIfStatement(bool* ok); | 742 Statement ParseIfStatement(bool* ok); |
| 748 Statement ParseContinueStatement(bool* ok); | 743 Statement ParseContinueStatement(bool* ok); |
| 749 Statement ParseBreakStatement(bool* ok); | 744 Statement ParseBreakStatement(bool* ok); |
| 750 Statement ParseReturnStatement(bool* ok); | 745 Statement ParseReturnStatement(bool* ok); |
| 751 Statement ParseWithStatement(bool* ok); | 746 Statement ParseWithStatement(bool* ok); |
| 752 Statement ParseSwitchStatement(bool* ok); | 747 Statement ParseSwitchStatement(bool* ok); |
| 753 Statement ParseDoWhileStatement(bool* ok); | 748 Statement ParseDoWhileStatement(bool* ok); |
| 754 Statement ParseWhileStatement(bool* ok); | 749 Statement ParseWhileStatement(bool* ok); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 RewriteAwaitExpression(PreParserExpression value, int pos) { | 826 RewriteAwaitExpression(PreParserExpression value, int pos) { |
| 832 return value; | 827 return value; |
| 833 } | 828 } |
| 834 V8_INLINE PreParserExpression RewriteYieldStar(PreParserExpression generator, | 829 V8_INLINE PreParserExpression RewriteYieldStar(PreParserExpression generator, |
| 835 PreParserExpression expression, | 830 PreParserExpression expression, |
| 836 int pos) { | 831 int pos) { |
| 837 return PreParserExpression::Default(); | 832 return PreParserExpression::Default(); |
| 838 } | 833 } |
| 839 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } | 834 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } |
| 840 | 835 |
| 836 V8_INLINE void DeclareAndInitializeVariables( |
| 837 PreParserStatement block, |
| 838 const DeclarationDescriptor* declaration_descriptor, |
| 839 const DeclarationParsingResult::Declaration* declaration, |
| 840 ZoneList<const AstRawString*>* names, bool* ok) {} |
| 841 |
| 841 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 842 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
| 842 PreParserExpression assignment) {} | 843 PreParserExpression assignment) {} |
| 843 V8_INLINE void QueueNonPatternForRewriting(PreParserExpression expr, | 844 V8_INLINE void QueueNonPatternForRewriting(PreParserExpression expr, |
| 844 bool* ok) {} | 845 bool* ok) {} |
| 845 | 846 |
| 846 // Helper functions for recursive descent. | 847 // Helper functions for recursive descent. |
| 847 V8_INLINE bool IsEval(PreParserIdentifier identifier) const { | 848 V8_INLINE bool IsEval(PreParserIdentifier identifier) const { |
| 848 return identifier.IsEval(); | 849 return identifier.IsEval(); |
| 849 } | 850 } |
| 850 | 851 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 } | 911 } |
| 911 | 912 |
| 912 // Functions for encapsulating the differences between parsing and preparsing; | 913 // Functions for encapsulating the differences between parsing and preparsing; |
| 913 // operations interleaved with the recursive descent. | 914 // operations interleaved with the recursive descent. |
| 914 V8_INLINE static void PushLiteralName(FuncNameInferrer* fni, | 915 V8_INLINE static void PushLiteralName(FuncNameInferrer* fni, |
| 915 PreParserIdentifier id) { | 916 PreParserIdentifier id) { |
| 916 // PreParser should not use FuncNameInferrer. | 917 // PreParser should not use FuncNameInferrer. |
| 917 UNREACHABLE(); | 918 UNREACHABLE(); |
| 918 } | 919 } |
| 919 | 920 |
| 921 V8_INLINE static void PushVariableName(FuncNameInferrer* fni, |
| 922 PreParserIdentifier id) { |
| 923 // PreParser should not use FuncNameInferrer. |
| 924 UNREACHABLE(); |
| 925 } |
| 926 |
| 920 V8_INLINE void PushPropertyName(FuncNameInferrer* fni, | 927 V8_INLINE void PushPropertyName(FuncNameInferrer* fni, |
| 921 PreParserExpression expression) { | 928 PreParserExpression expression) { |
| 922 // PreParser should not use FuncNameInferrer. | 929 // PreParser should not use FuncNameInferrer. |
| 923 UNREACHABLE(); | 930 UNREACHABLE(); |
| 924 } | 931 } |
| 925 | 932 |
| 926 V8_INLINE static void InferFunctionName(FuncNameInferrer* fni, | 933 V8_INLINE static void InferFunctionName(FuncNameInferrer* fni, |
| 927 PreParserExpression expression) { | 934 PreParserExpression expression) { |
| 928 // PreParser should not use FuncNameInferrer. | 935 // PreParser should not use FuncNameInferrer. |
| 929 UNREACHABLE(); | 936 UNREACHABLE(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 return PreParserExpression::Default(); | 1011 return PreParserExpression::Default(); |
| 1005 } | 1012 } |
| 1006 | 1013 |
| 1007 V8_INLINE static bool IsEmptyExpression(PreParserExpression expr) { | 1014 V8_INLINE static bool IsEmptyExpression(PreParserExpression expr) { |
| 1008 return expr.IsEmpty(); | 1015 return expr.IsEmpty(); |
| 1009 } | 1016 } |
| 1010 | 1017 |
| 1011 V8_INLINE static PreParserExpressionList NullExpressionList() { | 1018 V8_INLINE static PreParserExpressionList NullExpressionList() { |
| 1012 return PreParserExpressionList(); | 1019 return PreParserExpressionList(); |
| 1013 } | 1020 } |
| 1021 |
| 1014 V8_INLINE static PreParserStatementList NullStatementList() { | 1022 V8_INLINE static PreParserStatementList NullStatementList() { |
| 1015 return PreParserStatementList(); | 1023 return PreParserStatementList(); |
| 1016 } | 1024 } |
| 1025 |
| 1026 V8_INLINE static PreParserStatement NullBlock() { |
| 1027 return PreParserStatement::Default(); |
| 1028 } |
| 1029 |
| 1017 V8_INLINE PreParserIdentifier EmptyIdentifierString() const { | 1030 V8_INLINE PreParserIdentifier EmptyIdentifierString() const { |
| 1018 return PreParserIdentifier::Default(); | 1031 return PreParserIdentifier::Default(); |
| 1019 } | 1032 } |
| 1020 | 1033 |
| 1021 // Odd-ball literal creators. | 1034 // Odd-ball literal creators. |
| 1022 V8_INLINE PreParserExpression GetLiteralTheHole(int position) { | 1035 V8_INLINE PreParserExpression GetLiteralTheHole(int position) { |
| 1023 return PreParserExpression::Default(); | 1036 return PreParserExpression::Default(); |
| 1024 } | 1037 } |
| 1025 | 1038 |
| 1039 V8_INLINE PreParserExpression GetLiteralUndefined(int position) { |
| 1040 return PreParserExpression::Default(); |
| 1041 } |
| 1042 |
| 1026 // Producing data during the recursive descent. | 1043 // Producing data during the recursive descent. |
| 1027 PreParserIdentifier GetSymbol() const; | 1044 PreParserIdentifier GetSymbol() const; |
| 1028 | 1045 |
| 1029 V8_INLINE PreParserIdentifier GetNextSymbol() const { | 1046 V8_INLINE PreParserIdentifier GetNextSymbol() const { |
| 1030 return PreParserIdentifier::Default(); | 1047 return PreParserIdentifier::Default(); |
| 1031 } | 1048 } |
| 1032 | 1049 |
| 1033 V8_INLINE PreParserIdentifier GetNumberAsSymbol() const { | 1050 V8_INLINE PreParserIdentifier GetNumberAsSymbol() const { |
| 1034 return PreParserIdentifier::Default(); | 1051 return PreParserIdentifier::Default(); |
| 1035 } | 1052 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 } | 1094 } |
| 1078 | 1095 |
| 1079 V8_INLINE PreParserExpressionList NewPropertyList(int size) const { | 1096 V8_INLINE PreParserExpressionList NewPropertyList(int size) const { |
| 1080 return PreParserExpressionList(); | 1097 return PreParserExpressionList(); |
| 1081 } | 1098 } |
| 1082 | 1099 |
| 1083 V8_INLINE PreParserStatementList NewStatementList(int size) const { | 1100 V8_INLINE PreParserStatementList NewStatementList(int size) const { |
| 1084 return PreParserStatementList(); | 1101 return PreParserStatementList(); |
| 1085 } | 1102 } |
| 1086 | 1103 |
| 1104 V8_INLINE static PreParserStatement NewBlock( |
| 1105 ZoneList<const AstRawString*>* labels, int capacity, |
| 1106 bool ignore_completion_value, int pos) { |
| 1107 return PreParserStatement::Default(); |
| 1108 } |
| 1109 |
| 1087 V8_INLINE void AddParameterInitializationBlock( | 1110 V8_INLINE void AddParameterInitializationBlock( |
| 1088 const PreParserFormalParameters& parameters, PreParserStatementList body, | 1111 const PreParserFormalParameters& parameters, PreParserStatementList body, |
| 1089 bool is_async, bool* ok) {} | 1112 bool is_async, bool* ok) {} |
| 1090 | 1113 |
| 1091 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters, | 1114 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters, |
| 1092 PreParserExpression pattern, | 1115 PreParserExpression pattern, |
| 1093 PreParserExpression initializer, | 1116 PreParserExpression initializer, |
| 1094 int initializer_end_position, | 1117 int initializer_end_position, |
| 1095 bool is_rest) { | 1118 bool is_rest) { |
| 1096 ++parameters->arity; | 1119 ++parameters->arity; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 function_state_->NextMaterializedLiteralIndex(); | 1215 function_state_->NextMaterializedLiteralIndex(); |
| 1193 function_state_->NextMaterializedLiteralIndex(); | 1216 function_state_->NextMaterializedLiteralIndex(); |
| 1194 } | 1217 } |
| 1195 return EmptyExpression(); | 1218 return EmptyExpression(); |
| 1196 } | 1219 } |
| 1197 | 1220 |
| 1198 } // namespace internal | 1221 } // namespace internal |
| 1199 } // namespace v8 | 1222 } // namespace v8 |
| 1200 | 1223 |
| 1201 #endif // V8_PARSING_PREPARSER_H | 1224 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |