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

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

Issue 1841543003: [esnext] implement frontend changes for async/await proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix more problems Created 4 years, 7 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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return PreParserExpression::ArrayLiteral(); 438 return PreParserExpression::ArrayLiteral();
439 } 439 }
440 PreParserExpression NewArrayLiteral(PreParserExpressionList values, 440 PreParserExpression NewArrayLiteral(PreParserExpressionList values,
441 int first_spread_index, int literal_index, 441 int first_spread_index, int literal_index,
442 int pos) { 442 int pos) {
443 return PreParserExpression::ArrayLiteral(); 443 return PreParserExpression::ArrayLiteral();
444 } 444 }
445 PreParserExpression NewObjectLiteralProperty(PreParserExpression key, 445 PreParserExpression NewObjectLiteralProperty(PreParserExpression key,
446 PreParserExpression value, 446 PreParserExpression value,
447 ObjectLiteralProperty::Kind kind, 447 ObjectLiteralProperty::Kind kind,
448 bool is_static, 448 MethodKind method_kind,
449 bool is_computed_name) { 449 bool is_computed_name) {
450 return PreParserExpression::Default(); 450 return PreParserExpression::Default();
451 } 451 }
452 PreParserExpression NewObjectLiteralProperty(PreParserExpression key, 452 PreParserExpression NewObjectLiteralProperty(PreParserExpression key,
453 PreParserExpression value, 453 PreParserExpression value,
454 bool is_static, 454 MethodKind method_kind,
455 bool is_computed_name) { 455 bool is_computed_name) {
456 return PreParserExpression::Default(); 456 return PreParserExpression::Default();
457 } 457 }
458 PreParserExpression NewObjectLiteral(PreParserExpressionList properties, 458 PreParserExpression NewObjectLiteral(PreParserExpressionList properties,
459 int literal_index, 459 int literal_index,
460 int boilerplate_properties, 460 int boilerplate_properties,
461 int pos) { 461 int pos) {
462 return PreParserExpression::ObjectLiteral(); 462 return PreParserExpression::ObjectLiteral();
463 } 463 }
464 PreParserExpression NewVariableProxy(void* variable) { 464 PreParserExpression NewVariableProxy(void* variable) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 615
616 // Helper functions for recursive descent. 616 // Helper functions for recursive descent.
617 static bool IsEval(PreParserIdentifier identifier) { 617 static bool IsEval(PreParserIdentifier identifier) {
618 return identifier.IsEval(); 618 return identifier.IsEval();
619 } 619 }
620 620
621 static bool IsArguments(PreParserIdentifier identifier) { 621 static bool IsArguments(PreParserIdentifier identifier) {
622 return identifier.IsArguments(); 622 return identifier.IsArguments();
623 } 623 }
624 624
625 static bool IsAwait(PreParserIdentifier identifier) {
626 return identifier.IsAwait();
627 }
628
625 static bool IsEvalOrArguments(PreParserIdentifier identifier) { 629 static bool IsEvalOrArguments(PreParserIdentifier identifier) {
626 return identifier.IsEvalOrArguments(); 630 return identifier.IsEvalOrArguments();
627 } 631 }
628 632
629 static bool IsUndefined(PreParserIdentifier identifier) { 633 static bool IsUndefined(PreParserIdentifier identifier) {
630 return identifier.IsUndefined(); 634 return identifier.IsUndefined();
631 } 635 }
632 636
633 static bool IsPrototype(PreParserIdentifier identifier) { 637 static bool IsPrototype(PreParserIdentifier identifier) {
634 return identifier.IsPrototype(); 638 return identifier.IsPrototype();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 V8_INLINE PreParserStatementList ParseEagerFunctionBody( 862 V8_INLINE PreParserStatementList ParseEagerFunctionBody(
859 PreParserIdentifier function_name, int pos, 863 PreParserIdentifier function_name, int pos,
860 const PreParserFormalParameters& parameters, FunctionKind kind, 864 const PreParserFormalParameters& parameters, FunctionKind kind,
861 FunctionLiteral::FunctionType function_type, bool* ok); 865 FunctionLiteral::FunctionType function_type, bool* ok);
862 866
863 V8_INLINE void ParseArrowFunctionFormalParameterList( 867 V8_INLINE void ParseArrowFunctionFormalParameterList(
864 PreParserFormalParameters* parameters, 868 PreParserFormalParameters* parameters,
865 PreParserExpression expression, const Scanner::Location& params_loc, 869 PreParserExpression expression, const Scanner::Location& params_loc,
866 Scanner::Location* duplicate_loc, bool* ok); 870 Scanner::Location* duplicate_loc, bool* ok);
867 871
872 V8_INLINE PreParserExpression ParseAsyncFunctionExpression(bool* ok);
873
868 void ReindexLiterals(const PreParserFormalParameters& paramaters) {} 874 void ReindexLiterals(const PreParserFormalParameters& paramaters) {}
869 875
870 struct TemplateLiteralState {}; 876 struct TemplateLiteralState {};
871 877
872 TemplateLiteralState OpenTemplateLiteral(int pos) { 878 TemplateLiteralState OpenTemplateLiteral(int pos) {
873 return TemplateLiteralState(); 879 return TemplateLiteralState();
874 } 880 }
875 void AddTemplateSpan(TemplateLiteralState*, bool) {} 881 void AddTemplateSpan(TemplateLiteralState*, bool) {}
876 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {} 882 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {}
877 PreParserExpression CloseTemplateLiteral(TemplateLiteralState*, int, 883 PreParserExpression CloseTemplateLiteral(TemplateLiteralState*, int,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 936
931 inline void MaterializeUnspreadArgumentsLiterals(int count); 937 inline void MaterializeUnspreadArgumentsLiterals(int count);
932 938
933 inline PreParserExpression SpreadCall(PreParserExpression function, 939 inline PreParserExpression SpreadCall(PreParserExpression function,
934 PreParserExpressionList args, int pos); 940 PreParserExpressionList args, int pos);
935 941
936 inline PreParserExpression SpreadCallNew(PreParserExpression function, 942 inline PreParserExpression SpreadCallNew(PreParserExpression function,
937 PreParserExpressionList args, 943 PreParserExpressionList args,
938 int pos); 944 int pos);
939 945
946 inline PreParserExpression ExpressionListToExpression(
947 PreParserExpressionList args) {
948 return PreParserExpression::Default();
949 }
950
940 inline void RewriteDestructuringAssignments() {} 951 inline void RewriteDestructuringAssignments() {}
941 952
942 inline PreParserExpression RewriteExponentiation(PreParserExpression left, 953 inline PreParserExpression RewriteExponentiation(PreParserExpression left,
943 PreParserExpression right, 954 PreParserExpression right,
944 int pos) { 955 int pos) {
945 return left; 956 return left;
946 } 957 }
947 inline PreParserExpression RewriteAssignExponentiation( 958 inline PreParserExpression RewriteAssignExponentiation(
948 PreParserExpression left, PreParserExpression right, int pos) { 959 PreParserExpression left, PreParserExpression right, int pos) {
949 return left; 960 return left;
950 } 961 }
951 962
952 inline void QueueDestructuringAssignmentForRewriting(PreParserExpression) {} 963 inline void QueueDestructuringAssignmentForRewriting(PreParserExpression) {}
953 inline void QueueNonPatternForRewriting(PreParserExpression) {} 964 inline void QueueNonPatternForRewriting(PreParserExpression) {}
954 965
955 void SetFunctionNameFromPropertyName(PreParserExpression, 966 void SetFunctionNameFromPropertyName(PreParserExpression,
956 PreParserIdentifier) {} 967 PreParserIdentifier) {}
957 void SetFunctionNameFromIdentifierRef(PreParserExpression, 968 void SetFunctionNameFromIdentifierRef(PreParserExpression,
958 PreParserExpression) {} 969 PreParserExpression) {}
959 970
960 inline void RewriteNonPattern(Type::ExpressionClassifier* classifier, 971 inline void RewriteNonPattern(Type::ExpressionClassifier* classifier,
961 bool* ok); 972 bool* ok);
962 973
974 inline PreParserExpression RewriteAwaitExpression(PreParserExpression value,
975 int pos);
976
963 V8_INLINE Zone* zone() const; 977 V8_INLINE Zone* zone() const;
964 V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const; 978 V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const;
965 979
966 inline PreParserExpression RewriteYieldStar( 980 inline PreParserExpression RewriteYieldStar(
967 PreParserExpression generator, PreParserExpression expr, int pos); 981 PreParserExpression generator, PreParserExpression expr, int pos);
968 inline PreParserExpression RewriteInstanceof(PreParserExpression lhs, 982 inline PreParserExpression RewriteInstanceof(PreParserExpression lhs,
969 PreParserExpression rhs, 983 PreParserExpression rhs,
970 int pos); 984 int pos);
971 985
972 private: 986 private:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 void ParseStatementList(int end_token, bool* ok, 1085 void ParseStatementList(int end_token, bool* ok,
1072 Scanner::BookmarkScope* bookmark = nullptr); 1086 Scanner::BookmarkScope* bookmark = nullptr);
1073 Statement ParseStatement(AllowLabelledFunctionStatement allow_function, 1087 Statement ParseStatement(AllowLabelledFunctionStatement allow_function,
1074 bool* ok); 1088 bool* ok);
1075 Statement ParseSubStatement(AllowLabelledFunctionStatement allow_function, 1089 Statement ParseSubStatement(AllowLabelledFunctionStatement allow_function,
1076 bool* ok); 1090 bool* ok);
1077 Statement ParseScopedStatement(bool legacy, bool* ok); 1091 Statement ParseScopedStatement(bool legacy, bool* ok);
1078 Statement ParseHoistableDeclaration(bool* ok); 1092 Statement ParseHoistableDeclaration(bool* ok);
1079 Statement ParseHoistableDeclaration(int pos, bool is_generator, bool* ok); 1093 Statement ParseHoistableDeclaration(int pos, bool is_generator, bool* ok);
1080 Statement ParseFunctionDeclaration(bool* ok); 1094 Statement ParseFunctionDeclaration(bool* ok);
1095 Statement ParseAsyncFunctionDeclaration(bool* ok);
1096 Expression ParseAsyncFunctionExpression(bool* ok);
1081 Statement ParseClassDeclaration(bool* ok); 1097 Statement ParseClassDeclaration(bool* ok);
1082 Statement ParseBlock(bool* ok); 1098 Statement ParseBlock(bool* ok);
1083 Statement ParseVariableStatement(VariableDeclarationContext var_context, 1099 Statement ParseVariableStatement(VariableDeclarationContext var_context,
1084 bool* ok); 1100 bool* ok);
1085 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, 1101 Statement ParseVariableDeclarations(VariableDeclarationContext var_context,
1086 int* num_decl, bool* is_lexical, 1102 int* num_decl, bool* is_lexical,
1087 bool* is_binding_pattern, 1103 bool* is_binding_pattern,
1088 Scanner::Location* first_initializer_loc, 1104 Scanner::Location* first_initializer_loc,
1089 Scanner::Location* bindings_loc, 1105 Scanner::Location* bindings_loc,
1090 bool* ok); 1106 bool* ok);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1175
1160 1176
1161 void PreParserTraits::ParseArrowFunctionFormalParameterList( 1177 void PreParserTraits::ParseArrowFunctionFormalParameterList(
1162 PreParserFormalParameters* parameters, 1178 PreParserFormalParameters* parameters,
1163 PreParserExpression params, const Scanner::Location& params_loc, 1179 PreParserExpression params, const Scanner::Location& params_loc,
1164 Scanner::Location* duplicate_loc, bool* ok) { 1180 Scanner::Location* duplicate_loc, bool* ok) {
1165 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter 1181 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter
1166 // lists that are too long. 1182 // lists that are too long.
1167 } 1183 }
1168 1184
1185 PreParserExpression PreParserTraits::ParseAsyncFunctionExpression(bool* ok) {
1186 return pre_parser_->ParseAsyncFunctionExpression(ok);
1187 }
1169 1188
1170 PreParserExpression PreParserTraits::ParseDoExpression(bool* ok) { 1189 PreParserExpression PreParserTraits::ParseDoExpression(bool* ok) {
1171 return pre_parser_->ParseDoExpression(ok); 1190 return pre_parser_->ParseDoExpression(ok);
1172 } 1191 }
1173 1192
1174 1193
1175 void PreParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, 1194 void PreParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier,
1176 bool* ok) { 1195 bool* ok) {
1177 pre_parser_->ValidateExpression(classifier, ok); 1196 pre_parser_->ValidateExpression(classifier, ok);
1178 } 1197 }
1179 1198
1199 PreParserExpression PreParserTraits::RewriteAwaitExpression(
1200 PreParserExpression value, int pos) {
1201 return value;
1202 }
1180 1203
1181 Zone* PreParserTraits::zone() const { 1204 Zone* PreParserTraits::zone() const {
1182 return pre_parser_->function_state_->scope()->zone(); 1205 return pre_parser_->function_state_->scope()->zone();
1183 } 1206 }
1184 1207
1185 1208
1186 ZoneList<PreParserExpression>* PreParserTraits::GetNonPatternList() const { 1209 ZoneList<PreParserExpression>* PreParserTraits::GetNonPatternList() const {
1187 return pre_parser_->function_state_->non_patterns_to_rewrite(); 1210 return pre_parser_->function_state_->non_patterns_to_rewrite();
1188 } 1211 }
1189 1212
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 const PreParserFormalParameters& parameters, FunctionKind kind, 1247 const PreParserFormalParameters& parameters, FunctionKind kind,
1225 FunctionLiteral::FunctionType function_type, bool* ok) { 1248 FunctionLiteral::FunctionType function_type, bool* ok) {
1226 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, 1249 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters,
1227 kind, function_type, ok); 1250 kind, function_type, ok);
1228 } 1251 }
1229 1252
1230 } // namespace internal 1253 } // namespace internal
1231 } // namespace v8 1254 } // namespace v8
1232 1255
1233 #endif // V8_PARSING_PREPARSER_H 1256 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« src/globals.h ('K') | « 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