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

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

Issue 2289663002: [parser] Hide expression classifiers in parser implementation (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/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 395
396 396
397 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) { 397 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) {
398 Expect(Token::CLASS, CHECK_OK); 398 Expect(Token::CLASS, CHECK_OK);
399 399
400 int pos = position(); 400 int pos = position();
401 bool is_strict_reserved = false; 401 bool is_strict_reserved = false;
402 Identifier name = 402 Identifier name =
403 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 403 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
404 ParseClassLiteral(nullptr, name, scanner()->location(), is_strict_reserved, 404 ExpressionClassifier no_classifier(this);
405 pos, CHECK_OK); 405 ParseClassLiteral(name, scanner()->location(), is_strict_reserved, pos,
406 CHECK_OK);
406 return Statement::Default(); 407 return Statement::Default();
407 } 408 }
408 409
409 410
410 PreParser::Statement PreParser::ParseBlock(bool* ok) { 411 PreParser::Statement PreParser::ParseBlock(bool* ok) {
411 // Block :: 412 // Block ::
412 // '{' StatementList '}' 413 // '{' StatementList '}'
413 414
414 Expect(Token::LBRACE, CHECK_OK); 415 Expect(Token::LBRACE, CHECK_OK);
415 Statement final = Statement::Default(); 416 Statement final = Statement::Default();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // block. 495 // block.
495 int nvars = 0; // the number of variables declared 496 int nvars = 0; // the number of variables declared
496 int bindings_start = peek_position(); 497 int bindings_start = peek_position();
497 do { 498 do {
498 // Parse binding pattern. 499 // Parse binding pattern.
499 if (nvars > 0) Consume(Token::COMMA); 500 if (nvars > 0) Consume(Token::COMMA);
500 int decl_pos = peek_position(); 501 int decl_pos = peek_position();
501 PreParserExpression pattern = PreParserExpression::Default(); 502 PreParserExpression pattern = PreParserExpression::Default();
502 { 503 {
503 ExpressionClassifier pattern_classifier(this); 504 ExpressionClassifier pattern_classifier(this);
504 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); 505 pattern = ParsePrimaryExpression(CHECK_OK);
505 506
506 ValidateBindingPattern(&pattern_classifier, CHECK_OK); 507 ValidateBindingPattern(CHECK_OK);
507 if (lexical) { 508 if (lexical) ValidateLetPattern(CHECK_OK);
508 ValidateLetPattern(&pattern_classifier, CHECK_OK);
509 }
510 } 509 }
511 510
512 is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral(); 511 is_pattern = pattern.IsObjectLiteral() || pattern.IsArrayLiteral();
513 512
514 Scanner::Location variable_loc = scanner()->location(); 513 Scanner::Location variable_loc = scanner()->location();
515 nvars++; 514 nvars++;
516 if (Check(Token::ASSIGN)) { 515 if (Check(Token::ASSIGN)) {
517 ExpressionClassifier classifier(this); 516 ExpressionClassifier classifier(this);
518 ParseAssignmentExpression(var_context != kForStatement, &classifier, 517 ParseAssignmentExpression(var_context != kForStatement, CHECK_OK);
519 CHECK_OK); 518 ValidateExpression(CHECK_OK);
520 ValidateExpression(&classifier, CHECK_OK);
521 519
522 variable_loc.end_pos = scanner()->location().end_pos; 520 variable_loc.end_pos = scanner()->location().end_pos;
523 if (first_initializer_loc && !first_initializer_loc->IsValid()) { 521 if (first_initializer_loc && !first_initializer_loc->IsValid()) {
524 *first_initializer_loc = variable_loc; 522 *first_initializer_loc = variable_loc;
525 } 523 }
526 } else if ((require_initializer || is_pattern) && 524 } else if ((require_initializer || is_pattern) &&
527 (var_context != kForStatement || !PeekInOrOf())) { 525 (var_context != kForStatement || !PeekInOrOf())) {
528 ReportMessageAt( 526 ReportMessageAt(
529 Scanner::Location(decl_pos, scanner()->location().end_pos), 527 Scanner::Location(decl_pos, scanner()->location().end_pos),
530 MessageTemplate::kDeclarationMissingInitializer, 528 MessageTemplate::kDeclarationMissingInitializer,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 ReportUnexpectedToken(Next()); 573 ReportUnexpectedToken(Next());
576 *ok = false; 574 *ok = false;
577 return Statement::Default(); 575 return Statement::Default();
578 576
579 default: 577 default:
580 break; 578 break;
581 } 579 }
582 580
583 bool starts_with_identifier = peek_any_identifier(); 581 bool starts_with_identifier = peek_any_identifier();
584 ExpressionClassifier classifier(this); 582 ExpressionClassifier classifier(this);
585 Expression expr = ParseExpression(true, &classifier, CHECK_OK); 583 Expression expr = ParseExpressionCoverGrammar(true, CHECK_OK);
586 ValidateExpression(&classifier, CHECK_OK); 584 ValidateExpression(CHECK_OK);
587 585
588 // Even if the expression starts with an identifier, it is not necessarily an 586 // Even if the expression starts with an identifier, it is not necessarily an
589 // identifier. For example, "foo + bar" starts with an identifier but is not 587 // identifier. For example, "foo + bar" starts with an identifier but is not
590 // an identifier. 588 // an identifier.
591 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { 589 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) {
592 // Expression is a single identifier, and not, e.g., a parenthesized 590 // Expression is a single identifier, and not, e.g., a parenthesized
593 // identifier. 591 // identifier.
594 DCHECK(!expr.AsIdentifier().IsEnum()); 592 DCHECK(!expr.AsIdentifier().IsEnum());
595 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); 593 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
596 DCHECK(is_sloppy(language_mode()) || 594 DCHECK(is_sloppy(language_mode()) ||
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 834 }
837 ReportMessageAt(first_initializer_loc, 835 ReportMessageAt(first_initializer_loc,
838 MessageTemplate::kForInOfLoopInitializer, 836 MessageTemplate::kForInOfLoopInitializer,
839 ForEachStatement::VisitModeString(mode)); 837 ForEachStatement::VisitModeString(mode));
840 *ok = false; 838 *ok = false;
841 return Statement::Default(); 839 return Statement::Default();
842 } 840 }
843 841
844 if (mode == ForEachStatement::ITERATE) { 842 if (mode == ForEachStatement::ITERATE) {
845 ExpressionClassifier classifier(this); 843 ExpressionClassifier classifier(this);
846 ParseAssignmentExpression(true, &classifier, CHECK_OK); 844 ParseAssignmentExpression(true, CHECK_OK);
847 RewriteNonPattern(&classifier, CHECK_OK); 845 RewriteNonPattern(CHECK_OK);
848 } else { 846 } else {
849 ParseExpression(true, CHECK_OK); 847 ParseExpression(true, CHECK_OK);
850 } 848 }
851 849
852 Expect(Token::RPAREN, CHECK_OK); 850 Expect(Token::RPAREN, CHECK_OK);
853 { 851 {
854 ReturnExprScope no_tail_calls(function_state_, 852 ReturnExprScope no_tail_calls(function_state_,
855 ReturnExprContext::kInsideForInOfBody); 853 ReturnExprContext::kInsideForInOfBody);
856 ParseScopedStatement(true, CHECK_OK); 854 ParseScopedStatement(true, CHECK_OK);
857 } 855 }
858 return Statement::Default(); 856 return Statement::Default();
859 } 857 }
860 } else { 858 } else {
861 int lhs_beg_pos = peek_position(); 859 int lhs_beg_pos = peek_position();
862 ExpressionClassifier classifier(this); 860 ExpressionClassifier classifier(this);
863 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); 861 Expression lhs = ParseExpressionCoverGrammar(false, CHECK_OK);
864 int lhs_end_pos = scanner()->location().end_pos; 862 int lhs_end_pos = scanner()->location().end_pos;
865 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); 863 bool is_for_each = CheckInOrOf(&mode, CHECK_OK);
866 bool is_destructuring = is_for_each && 864 bool is_destructuring = is_for_each &&
867 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); 865 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral());
868 866
869 if (is_destructuring) { 867 if (is_destructuring) {
870 ValidateAssignmentPattern(&classifier, CHECK_OK); 868 ValidateAssignmentPattern(CHECK_OK);
871 } else { 869 } else {
872 ValidateExpression(&classifier, CHECK_OK); 870 ValidateExpression(CHECK_OK);
873 } 871 }
874 872
875 if (is_for_each) { 873 if (is_for_each) {
876 if (!is_destructuring) { 874 if (!is_destructuring) {
877 lhs = CheckAndRewriteReferenceExpression( 875 lhs = CheckAndRewriteReferenceExpression(
878 lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor, 876 lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
879 kSyntaxError, CHECK_OK); 877 kSyntaxError, CHECK_OK);
880 } 878 }
881 879
882 if (mode == ForEachStatement::ITERATE) { 880 if (mode == ForEachStatement::ITERATE) {
883 ExpressionClassifier classifier(this); 881 ExpressionClassifier classifier(this);
884 ParseAssignmentExpression(true, &classifier, CHECK_OK); 882 ParseAssignmentExpression(true, CHECK_OK);
885 RewriteNonPattern(&classifier, CHECK_OK); 883 RewriteNonPattern(CHECK_OK);
886 } else { 884 } else {
887 ParseExpression(true, CHECK_OK); 885 ParseExpression(true, CHECK_OK);
888 } 886 }
889 887
890 Expect(Token::RPAREN, CHECK_OK); 888 Expect(Token::RPAREN, CHECK_OK);
891 { 889 {
892 BlockState block_state(&scope_state_); 890 BlockState block_state(&scope_state_);
893 ParseScopedStatement(true, CHECK_OK); 891 ParseScopedStatement(true, CHECK_OK);
894 } 892 }
895 return Statement::Default(); 893 return Statement::Default();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 *ok = false; 965 *ok = false;
968 return Statement::Default(); 966 return Statement::Default();
969 } 967 }
970 TailCallExpressionList tail_call_expressions_in_catch_block(zone()); 968 TailCallExpressionList tail_call_expressions_in_catch_block(zone());
971 bool catch_block_exists = false; 969 bool catch_block_exists = false;
972 if (tok == Token::CATCH) { 970 if (tok == Token::CATCH) {
973 Consume(Token::CATCH); 971 Consume(Token::CATCH);
974 Expect(Token::LPAREN, CHECK_OK); 972 Expect(Token::LPAREN, CHECK_OK);
975 Scope* catch_scope = NewScope(CATCH_SCOPE); 973 Scope* catch_scope = NewScope(CATCH_SCOPE);
976 ExpressionClassifier pattern_classifier(this); 974 ExpressionClassifier pattern_classifier(this);
977 ParsePrimaryExpression(&pattern_classifier, CHECK_OK); 975 ParsePrimaryExpression(CHECK_OK);
978 ValidateBindingPattern(&pattern_classifier, CHECK_OK); 976 ValidateBindingPattern(CHECK_OK);
979 Expect(Token::RPAREN, CHECK_OK); 977 Expect(Token::RPAREN, CHECK_OK);
980 { 978 {
981 CollectExpressionsInTailPositionToListScope 979 CollectExpressionsInTailPositionToListScope
982 collect_tail_call_expressions_scope( 980 collect_tail_call_expressions_scope(
983 function_state_, &tail_call_expressions_in_catch_block); 981 function_state_, &tail_call_expressions_in_catch_block);
984 BlockState block_state(&scope_state_, catch_scope); 982 BlockState block_state(&scope_state_, catch_scope);
985 { 983 {
986 BlockState block_state(&scope_state_); 984 BlockState block_state(&scope_state_);
987 ParseBlock(CHECK_OK); 985 ParseBlock(CHECK_OK);
988 } 986 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 function_scope->SetLanguageMode(language_mode); 1041 function_scope->SetLanguageMode(language_mode);
1044 FunctionState function_state(&function_state_, &scope_state_, function_scope, 1042 FunctionState function_state(&function_state_, &scope_state_, function_scope,
1045 kind); 1043 kind);
1046 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1044 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1047 ExpressionClassifier formals_classifier(this, &duplicate_finder); 1045 ExpressionClassifier formals_classifier(this, &duplicate_finder);
1048 1046
1049 Expect(Token::LPAREN, CHECK_OK); 1047 Expect(Token::LPAREN, CHECK_OK);
1050 int start_position = scanner()->location().beg_pos; 1048 int start_position = scanner()->location().beg_pos;
1051 function_scope->set_start_position(start_position); 1049 function_scope->set_start_position(start_position);
1052 PreParserFormalParameters formals(function_scope); 1050 PreParserFormalParameters formals(function_scope);
1053 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 1051 ParseFormalParameterList(&formals, CHECK_OK);
1054 Expect(Token::RPAREN, CHECK_OK); 1052 Expect(Token::RPAREN, CHECK_OK);
1055 int formals_end_position = scanner()->location().end_pos; 1053 int formals_end_position = scanner()->location().end_pos;
1056 1054
1057 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, 1055 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position,
1058 formals_end_position, CHECK_OK); 1056 formals_end_position, CHECK_OK);
1059 1057
1060 // See Parser::ParseFunctionLiteral for more information about lazy parsing 1058 // See Parser::ParseFunctionLiteral for more information about lazy parsing
1061 // and lazy compilation. 1059 // and lazy compilation.
1062 bool is_lazily_parsed = (outer_is_script_scope && allow_lazy() && 1060 bool is_lazily_parsed = (outer_is_script_scope && allow_lazy() &&
1063 !function_state_->this_function_is_parenthesized()); 1061 !function_state_->this_function_is_parenthesized());
1064 1062
1065 Expect(Token::LBRACE, CHECK_OK); 1063 Expect(Token::LBRACE, CHECK_OK);
1066 if (is_lazily_parsed) { 1064 if (is_lazily_parsed) {
1067 ParseLazyFunctionLiteralBody(CHECK_OK); 1065 ParseLazyFunctionLiteralBody(CHECK_OK);
1068 } else { 1066 } else {
1069 ParseStatementList(Token::RBRACE, CHECK_OK); 1067 ParseStatementList(Token::RBRACE, CHECK_OK);
1070 } 1068 }
1071 Expect(Token::RBRACE, CHECK_OK); 1069 Expect(Token::RBRACE, CHECK_OK);
1072 1070
1073 // Parsing the body may change the language mode in our scope. 1071 // Parsing the body may change the language mode in our scope.
1074 language_mode = function_scope->language_mode(); 1072 language_mode = function_scope->language_mode();
1075 1073
1076 // Validate name and parameter names. We can do this only after parsing the 1074 // Validate name and parameter names. We can do this only after parsing the
1077 // function, since the function can declare itself strict. 1075 // function, since the function can declare itself strict.
1078 CheckFunctionName(language_mode, function_name, function_name_validity, 1076 CheckFunctionName(language_mode, function_name, function_name_validity,
1079 function_name_location, CHECK_OK); 1077 function_name_location, CHECK_OK);
1080 const bool allow_duplicate_parameters = 1078 const bool allow_duplicate_parameters =
1081 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); 1079 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind);
1082 ValidateFormalParameters(&formals_classifier, language_mode, 1080 ValidateFormalParameters(language_mode, allow_duplicate_parameters, CHECK_OK);
1083 allow_duplicate_parameters, CHECK_OK);
1084 1081
1085 if (is_strict(language_mode)) { 1082 if (is_strict(language_mode)) {
1086 int end_position = scanner()->location().end_pos; 1083 int end_position = scanner()->location().end_pos;
1087 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); 1084 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
1088 CheckDecimalLiteralWithLeadingZero(use_counts_, start_position, 1085 CheckDecimalLiteralWithLeadingZero(use_counts_, start_position,
1089 end_position); 1086 end_position);
1090 } 1087 }
1091 1088
1092 return Expression::Default(); 1089 return Expression::Default();
1093 } 1090 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 int body_end = scanner()->peek_location().end_pos; 1128 int body_end = scanner()->peek_location().end_pos;
1132 DeclarationScope* scope = this->scope()->AsDeclarationScope(); 1129 DeclarationScope* scope = this->scope()->AsDeclarationScope();
1133 DCHECK(scope->is_function_scope()); 1130 DCHECK(scope->is_function_scope());
1134 log_->LogFunction(body_start, body_end, 1131 log_->LogFunction(body_start, body_end,
1135 function_state_->materialized_literal_count(), 1132 function_state_->materialized_literal_count(),
1136 function_state_->expected_property_count(), language_mode(), 1133 function_state_->expected_property_count(), language_mode(),
1137 scope->uses_super_property(), scope->calls_eval()); 1134 scope->uses_super_property(), scope->calls_eval());
1138 } 1135 }
1139 1136
1140 PreParserExpression PreParser::ParseClassLiteral( 1137 PreParserExpression PreParser::ParseClassLiteral(
1141 ExpressionClassifier* classifier, PreParserIdentifier name, 1138 PreParserIdentifier name, Scanner::Location class_name_location,
1142 Scanner::Location class_name_location, bool name_is_strict_reserved, 1139 bool name_is_strict_reserved, int pos, bool* ok) {
1143 int pos, bool* ok) {
1144 // All parts of a ClassDeclaration and ClassExpression are strict code. 1140 // All parts of a ClassDeclaration and ClassExpression are strict code.
1145 if (name_is_strict_reserved) { 1141 if (name_is_strict_reserved) {
1146 ReportMessageAt(class_name_location, 1142 ReportMessageAt(class_name_location,
1147 MessageTemplate::kUnexpectedStrictReserved); 1143 MessageTemplate::kUnexpectedStrictReserved);
1148 *ok = false; 1144 *ok = false;
1149 return EmptyExpression(); 1145 return EmptyExpression();
1150 } 1146 }
1151 if (IsEvalOrArguments(name)) { 1147 if (IsEvalOrArguments(name)) {
1152 ReportMessageAt(class_name_location, MessageTemplate::kStrictEvalArguments); 1148 ReportMessageAt(class_name_location, MessageTemplate::kStrictEvalArguments);
1153 *ok = false; 1149 *ok = false;
1154 return EmptyExpression(); 1150 return EmptyExpression();
1155 } 1151 }
1156 1152
1157 LanguageMode class_language_mode = language_mode(); 1153 LanguageMode class_language_mode = language_mode();
1158 BlockState block_state(&scope_state_); 1154 BlockState block_state(&scope_state_);
1159 scope()->SetLanguageMode( 1155 scope()->SetLanguageMode(
1160 static_cast<LanguageMode>(class_language_mode | STRICT)); 1156 static_cast<LanguageMode>(class_language_mode | STRICT));
1161 // TODO(marja): Make PreParser use scope names too. 1157 // TODO(marja): Make PreParser use scope names too.
1162 // this->scope()->SetScopeName(name); 1158 // this->scope()->SetScopeName(name);
1163 1159
1164 bool has_extends = Check(Token::EXTENDS); 1160 bool has_extends = Check(Token::EXTENDS);
1165 if (has_extends) { 1161 if (has_extends) {
1166 ExpressionClassifier extends_classifier(this); 1162 ExpressionClassifier extends_classifier(this);
1167 ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); 1163 ParseLeftHandSideExpression(CHECK_OK);
1168 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); 1164 CheckNoTailCallExpressions(CHECK_OK);
1169 ValidateExpression(&extends_classifier, CHECK_OK); 1165 ValidateExpression(CHECK_OK);
1170 if (classifier != nullptr) { 1166 impl()->AccumulateFormalParameterContainmentErrors();
1171 classifier->AccumulateFormalParameterContainmentErrors(
1172 &extends_classifier);
1173 }
1174 } 1167 }
1175 1168
1176 ClassLiteralChecker checker(this); 1169 ClassLiteralChecker checker(this);
1177 bool has_seen_constructor = false; 1170 bool has_seen_constructor = false;
1178 1171
1179 Expect(Token::LBRACE, CHECK_OK); 1172 Expect(Token::LBRACE, CHECK_OK);
1180 while (peek() != Token::RBRACE) { 1173 while (peek() != Token::RBRACE) {
1181 if (Check(Token::SEMICOLON)) continue; 1174 if (Check(Token::SEMICOLON)) continue;
1182 const bool in_class = true; 1175 const bool in_class = true;
1183 bool is_computed_name = false; // Classes do not care about computed 1176 bool is_computed_name = false; // Classes do not care about computed
1184 // property names here. 1177 // property names here.
1185 Identifier name; 1178 Identifier name;
1186 ExpressionClassifier property_classifier(this); 1179 ExpressionClassifier property_classifier(this);
1187 ParsePropertyDefinition(&checker, in_class, has_extends, &is_computed_name, 1180 ParsePropertyDefinition(&checker, in_class, has_extends, &is_computed_name,
1188 &has_seen_constructor, &property_classifier, &name, 1181 &has_seen_constructor, &name, CHECK_OK);
1189 CHECK_OK); 1182 ValidateExpression(CHECK_OK);
1190 ValidateExpression(&property_classifier, CHECK_OK); 1183 impl()->AccumulateFormalParameterContainmentErrors();
1191 if (classifier != nullptr) {
1192 classifier->AccumulateFormalParameterContainmentErrors(
1193 &property_classifier);
1194 }
1195 } 1184 }
1196 1185
1197 Expect(Token::RBRACE, CHECK_OK); 1186 Expect(Token::RBRACE, CHECK_OK);
1198 1187
1199 return Expression::Default(); 1188 return Expression::Default();
1200 } 1189 }
1201 1190
1202 1191
1203 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { 1192 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
1204 // CallRuntime :: 1193 // CallRuntime ::
1205 // '%' Identifier Arguments 1194 // '%' Identifier Arguments
1206 Expect(Token::MOD, CHECK_OK); 1195 Expect(Token::MOD, CHECK_OK);
1207 if (!allow_natives()) { 1196 if (!allow_natives()) {
1208 *ok = false; 1197 *ok = false;
1209 return Expression::Default(); 1198 return Expression::Default();
1210 } 1199 }
1211 // Allow "eval" or "arguments" for backward compatibility. 1200 // Allow "eval" or "arguments" for backward compatibility.
1212 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); 1201 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
1213 Scanner::Location spread_pos; 1202 Scanner::Location spread_pos;
1214 ExpressionClassifier classifier(this); 1203 ExpressionClassifier classifier(this);
1215 ParseArguments(&spread_pos, &classifier, ok); 1204 ParseArguments(&spread_pos, ok);
1216 ValidateExpression(&classifier, CHECK_OK); 1205 ValidateExpression(CHECK_OK);
1217 1206
1218 DCHECK(!spread_pos.IsValid()); 1207 DCHECK(!spread_pos.IsValid());
1219 1208
1220 return Expression::Default(); 1209 return Expression::Default();
1221 } 1210 }
1222 1211
1223 1212
1224 PreParserExpression PreParser::ParseDoExpression(bool* ok) { 1213 PreParserExpression PreParser::ParseDoExpression(bool* ok) {
1225 // AssignmentExpression :: 1214 // AssignmentExpression ::
1226 // do '{' StatementList '}' 1215 // do '{' StatementList '}'
1227 Expect(Token::DO, CHECK_OK); 1216 Expect(Token::DO, CHECK_OK);
1228 Expect(Token::LBRACE, CHECK_OK); 1217 Expect(Token::LBRACE, CHECK_OK);
1229 while (peek() != Token::RBRACE) { 1218 while (peek() != Token::RBRACE) {
1230 ParseStatementListItem(CHECK_OK); 1219 ParseStatementListItem(CHECK_OK);
1231 } 1220 }
1232 Expect(Token::RBRACE, CHECK_OK); 1221 Expect(Token::RBRACE, CHECK_OK);
1233 return PreParserExpression::Default(); 1222 return PreParserExpression::Default();
1234 } 1223 }
1235 1224
1236 void PreParser::ParseAsyncArrowSingleExpressionBody( 1225 void PreParser::ParseAsyncArrowSingleExpressionBody(PreParserStatementList body,
1237 PreParserStatementList body, bool accept_IN, 1226 bool accept_IN, int pos,
1238 ExpressionClassifier* classifier, int pos, bool* ok) { 1227 bool* ok) {
1239 scope()->ForceContextAllocation(); 1228 scope()->ForceContextAllocation();
1240 1229
1241 PreParserExpression return_value = 1230 PreParserExpression return_value =
1242 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_CUSTOM(Void)); 1231 ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void));
1243 1232
1244 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1233 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1245 } 1234 }
1246 1235
1247 #undef CHECK_OK 1236 #undef CHECK_OK
1248 #undef CHECK_OK_CUSTOM 1237 #undef CHECK_OK_CUSTOM
1249 1238
1250 1239
1251 } // namespace internal 1240 } // namespace internal
1252 } // namespace v8 1241 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698