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

Side by Side Diff: src/parsing/expression-classifier.h

Issue 1928203002: [es8] More spec compliant syntactic tail calls implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Some STC tests ported for PTC 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
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_EXPRESSION_CLASSIFIER_H 5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H
6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H 6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H
7 7
8 #include "src/messages.h" 8 #include "src/messages.h"
9 #include "src/parsing/scanner.h" 9 #include "src/parsing/scanner.h"
10 #include "src/parsing/token.h" 10 #include "src/parsing/token.h"
(...skipping 21 matching lines...) Expand all
32 enum TargetProduction { 32 enum TargetProduction {
33 ExpressionProduction = 1 << 0, 33 ExpressionProduction = 1 << 0,
34 FormalParameterInitializerProduction = 1 << 1, 34 FormalParameterInitializerProduction = 1 << 1,
35 BindingPatternProduction = 1 << 2, 35 BindingPatternProduction = 1 << 2,
36 AssignmentPatternProduction = 1 << 3, 36 AssignmentPatternProduction = 1 << 3,
37 DistinctFormalParametersProduction = 1 << 4, 37 DistinctFormalParametersProduction = 1 << 4,
38 StrictModeFormalParametersProduction = 1 << 5, 38 StrictModeFormalParametersProduction = 1 << 5,
39 ArrowFormalParametersProduction = 1 << 6, 39 ArrowFormalParametersProduction = 1 << 6,
40 LetPatternProduction = 1 << 7, 40 LetPatternProduction = 1 << 7,
41 CoverInitializedNameProduction = 1 << 8, 41 CoverInitializedNameProduction = 1 << 8,
42 TailCallExpressionProduction = 1 << 9,
42 43
43 ExpressionProductions = 44 ExpressionProductions =
44 (ExpressionProduction | FormalParameterInitializerProduction), 45 (ExpressionProduction | FormalParameterInitializerProduction |
46 TailCallExpressionProduction),
45 PatternProductions = (BindingPatternProduction | 47 PatternProductions = (BindingPatternProduction |
46 AssignmentPatternProduction | LetPatternProduction), 48 AssignmentPatternProduction | LetPatternProduction),
47 FormalParametersProductions = (DistinctFormalParametersProduction | 49 FormalParametersProductions = (DistinctFormalParametersProduction |
48 StrictModeFormalParametersProduction), 50 StrictModeFormalParametersProduction),
49 StandardProductions = ExpressionProductions | PatternProductions, 51 StandardProductions = ExpressionProductions | PatternProductions,
50 AllProductions = 52 AllProductions =
51 (StandardProductions | FormalParametersProductions | 53 (StandardProductions | FormalParametersProductions |
52 ArrowFormalParametersProduction | CoverInitializedNameProduction) 54 ArrowFormalParametersProduction | CoverInitializedNameProduction)
53 }; 55 };
54 56
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 138
137 const Error& let_pattern_error() const { return let_pattern_error_; } 139 const Error& let_pattern_error() const { return let_pattern_error_; }
138 140
139 bool has_cover_initialized_name() const { 141 bool has_cover_initialized_name() const {
140 return !is_valid(CoverInitializedNameProduction); 142 return !is_valid(CoverInitializedNameProduction);
141 } 143 }
142 const Error& cover_initialized_name_error() const { 144 const Error& cover_initialized_name_error() const {
143 return cover_initialized_name_error_; 145 return cover_initialized_name_error_;
144 } 146 }
145 147
148 bool has_tail_call_expression() const {
149 return !is_valid(TailCallExpressionProduction);
150 }
151 const Error& tail_call_expression_error() const {
152 return tail_call_expression_error_;
153 }
154
146 bool is_simple_parameter_list() const { 155 bool is_simple_parameter_list() const {
147 return !(function_properties_ & NonSimpleParameter); 156 return !(function_properties_ & NonSimpleParameter);
148 } 157 }
149 158
150 void RecordNonSimpleParameter() { 159 void RecordNonSimpleParameter() {
151 function_properties_ |= NonSimpleParameter; 160 function_properties_ |= NonSimpleParameter;
152 } 161 }
153 162
154 void RecordExpressionError(const Scanner::Location& loc, 163 void RecordExpressionError(const Scanner::Location& loc,
155 MessageTemplate::Template message, 164 MessageTemplate::Template message,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void RecordCoverInitializedNameError(const Scanner::Location& loc, 262 void RecordCoverInitializedNameError(const Scanner::Location& loc,
254 MessageTemplate::Template message, 263 MessageTemplate::Template message,
255 const char* arg = nullptr) { 264 const char* arg = nullptr) {
256 if (has_cover_initialized_name()) return; 265 if (has_cover_initialized_name()) return;
257 invalid_productions_ |= CoverInitializedNameProduction; 266 invalid_productions_ |= CoverInitializedNameProduction;
258 cover_initialized_name_error_.location = loc; 267 cover_initialized_name_error_.location = loc;
259 cover_initialized_name_error_.message = message; 268 cover_initialized_name_error_.message = message;
260 cover_initialized_name_error_.arg = arg; 269 cover_initialized_name_error_.arg = arg;
261 } 270 }
262 271
272 void RecordTailCallExpressionError(const Scanner::Location& loc,
273 MessageTemplate::Template message,
274 const char* arg = nullptr) {
275 if (has_tail_call_expression()) return;
276 invalid_productions_ |= TailCallExpressionProduction;
277 tail_call_expression_error_.location = loc;
278 tail_call_expression_error_.message = message;
279 tail_call_expression_error_.arg = arg;
280 }
281
263 void ForgiveCoverInitializedNameError() { 282 void ForgiveCoverInitializedNameError() {
264 invalid_productions_ &= ~CoverInitializedNameProduction; 283 invalid_productions_ &= ~CoverInitializedNameProduction;
265 cover_initialized_name_error_ = Error(); 284 cover_initialized_name_error_ = Error();
266 } 285 }
267 286
268 void ForgiveAssignmentPatternError() { 287 void ForgiveAssignmentPatternError() {
269 invalid_productions_ &= ~AssignmentPatternProduction; 288 invalid_productions_ &= ~AssignmentPatternProduction;
270 assignment_pattern_error_ = Error(); 289 assignment_pattern_error_ = Error();
271 } 290 }
272 291
(...skipping 25 matching lines...) Expand all
298 if (errors & DistinctFormalParametersProduction) 317 if (errors & DistinctFormalParametersProduction)
299 duplicate_formal_parameter_error_ = 318 duplicate_formal_parameter_error_ =
300 inner->duplicate_formal_parameter_error_; 319 inner->duplicate_formal_parameter_error_;
301 if (errors & StrictModeFormalParametersProduction) 320 if (errors & StrictModeFormalParametersProduction)
302 strict_mode_formal_parameter_error_ = 321 strict_mode_formal_parameter_error_ =
303 inner->strict_mode_formal_parameter_error_; 322 inner->strict_mode_formal_parameter_error_;
304 if (errors & LetPatternProduction) 323 if (errors & LetPatternProduction)
305 let_pattern_error_ = inner->let_pattern_error_; 324 let_pattern_error_ = inner->let_pattern_error_;
306 if (errors & CoverInitializedNameProduction) 325 if (errors & CoverInitializedNameProduction)
307 cover_initialized_name_error_ = inner->cover_initialized_name_error_; 326 cover_initialized_name_error_ = inner->cover_initialized_name_error_;
327 if (errors & TailCallExpressionProduction)
328 tail_call_expression_error_ = inner->tail_call_expression_error_;
308 } 329 }
309 330
310 // As an exception to the above, the result continues to be a valid arrow 331 // As an exception to the above, the result continues to be a valid arrow
311 // formal parameters if the inner expression is a valid binding pattern. 332 // formal parameters if the inner expression is a valid binding pattern.
312 if (productions & ArrowFormalParametersProduction && 333 if (productions & ArrowFormalParametersProduction &&
313 is_valid_arrow_formal_parameters()) { 334 is_valid_arrow_formal_parameters()) {
314 // Also copy function properties if expecting an arrow function 335 // Also copy function properties if expecting an arrow function
315 // parameter. 336 // parameter.
316 function_properties_ |= inner->function_properties_; 337 function_properties_ |= inner->function_properties_;
317 338
(...skipping 15 matching lines...) Expand all
333 DCHECK_LE(non_pattern_begin_, inner->non_pattern_begin_); 354 DCHECK_LE(non_pattern_begin_, inner->non_pattern_begin_);
334 inner->non_pattern_begin_ = inner->non_patterns_to_rewrite_->length(); 355 inner->non_pattern_begin_ = inner->non_patterns_to_rewrite_->length();
335 } 356 }
336 357
337 private: 358 private:
338 Zone* zone_; 359 Zone* zone_;
339 ZoneList<typename Traits::Type::Expression>* non_patterns_to_rewrite_; 360 ZoneList<typename Traits::Type::Expression>* non_patterns_to_rewrite_;
340 int non_pattern_begin_; 361 int non_pattern_begin_;
341 unsigned invalid_productions_; 362 unsigned invalid_productions_;
342 unsigned function_properties_; 363 unsigned function_properties_;
364 // TODO(ishell): consider using Zone[Hash]Map<TargetProduction, Error>
365 // here to consume less stack space during parsing.
343 Error expression_error_; 366 Error expression_error_;
344 Error formal_parameter_initializer_error_; 367 Error formal_parameter_initializer_error_;
345 Error binding_pattern_error_; 368 Error binding_pattern_error_;
346 Error assignment_pattern_error_; 369 Error assignment_pattern_error_;
347 Error arrow_formal_parameters_error_; 370 Error arrow_formal_parameters_error_;
348 Error duplicate_formal_parameter_error_; 371 Error duplicate_formal_parameter_error_;
349 Error strict_mode_formal_parameter_error_; 372 Error strict_mode_formal_parameter_error_;
350 Error let_pattern_error_; 373 Error let_pattern_error_;
351 Error cover_initialized_name_error_; 374 Error cover_initialized_name_error_;
375 Error tail_call_expression_error_;
352 DuplicateFinder* duplicate_finder_; 376 DuplicateFinder* duplicate_finder_;
353 }; 377 };
354 378
355 379
356 } // namespace internal 380 } // namespace internal
357 } // namespace v8 381 } // namespace v8
358 382
359 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H 383 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698