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

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

Issue 2271063002: Centralize and standardize logic for ExpressionClassifier accumulation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 4 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 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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // TODO(marja): Make PreParser use scope names too. 1169 // TODO(marja): Make PreParser use scope names too.
1170 // this->scope()->SetScopeName(name); 1170 // this->scope()->SetScopeName(name);
1171 1171
1172 bool has_extends = Check(Token::EXTENDS); 1172 bool has_extends = Check(Token::EXTENDS);
1173 if (has_extends) { 1173 if (has_extends) {
1174 ExpressionClassifier extends_classifier(this); 1174 ExpressionClassifier extends_classifier(this);
1175 ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); 1175 ParseLeftHandSideExpression(&extends_classifier, CHECK_OK);
1176 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); 1176 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK);
1177 ValidateExpression(&extends_classifier, CHECK_OK); 1177 ValidateExpression(&extends_classifier, CHECK_OK);
1178 if (classifier != nullptr) { 1178 if (classifier != nullptr) {
1179 classifier->Accumulate(&extends_classifier, 1179 classifier->AccumulateFormalParameterContainmentErrors(
1180 ExpressionClassifier::ExpressionProductions); 1180 &extends_classifier);
1181 } 1181 }
1182 } 1182 }
1183 1183
1184 ClassLiteralChecker checker(this); 1184 ClassLiteralChecker checker(this);
1185 bool has_seen_constructor = false; 1185 bool has_seen_constructor = false;
1186 1186
1187 Expect(Token::LBRACE, CHECK_OK); 1187 Expect(Token::LBRACE, CHECK_OK);
1188 while (peek() != Token::RBRACE) { 1188 while (peek() != Token::RBRACE) {
1189 if (Check(Token::SEMICOLON)) continue; 1189 if (Check(Token::SEMICOLON)) continue;
1190 const bool in_class = true; 1190 const bool in_class = true;
1191 bool is_computed_name = false; // Classes do not care about computed 1191 bool is_computed_name = false; // Classes do not care about computed
1192 // property names here. 1192 // property names here.
1193 Identifier name; 1193 Identifier name;
1194 ExpressionClassifier property_classifier(this); 1194 ExpressionClassifier property_classifier(this);
1195 ParsePropertyDefinition( 1195 ParsePropertyDefinition(
1196 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, 1196 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name,
1197 &has_seen_constructor, &property_classifier, &name, CHECK_OK); 1197 &has_seen_constructor, &property_classifier, &name, CHECK_OK);
1198 ValidateExpression(&property_classifier, CHECK_OK); 1198 ValidateExpression(&property_classifier, CHECK_OK);
1199 if (classifier != nullptr) { 1199 if (classifier != nullptr) {
1200 classifier->Accumulate(&property_classifier, 1200 classifier->AccumulateFormalParameterContainmentErrors(
1201 ExpressionClassifier::ExpressionProductions); 1201 &property_classifier);
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 Expect(Token::RBRACE, CHECK_OK); 1205 Expect(Token::RBRACE, CHECK_OK);
1206 1206
1207 return Expression::Default(); 1207 return Expression::Default();
1208 } 1208 }
1209 1209
1210 1210
1211 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { 1211 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1251
1252 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1252 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1253 } 1253 }
1254 1254
1255 #undef CHECK_OK 1255 #undef CHECK_OK
1256 #undef CHECK_OK_CUSTOM 1256 #undef CHECK_OK_CUSTOM
1257 1257
1258 1258
1259 } // namespace internal 1259 } // namespace internal
1260 } // namespace v8 1260 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698