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

Side by Side Diff: src/parsing/parser-base.h

Issue 2359513002: Remove synthetic unresolved variables from async/await desugaring (Closed)
Patch Set: Fix bug number 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/parser.cc ('k') | src/parsing/preparser.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 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_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // and PreParser methods use PreParserExpression. For any given parser 118 // and PreParser methods use PreParserExpression. For any given parser
119 // implementation class Impl, it is expected to contain the following typedefs: 119 // implementation class Impl, it is expected to contain the following typedefs:
120 // 120 //
121 // template <> 121 // template <>
122 // struct ParserTypes<Impl> { 122 // struct ParserTypes<Impl> {
123 // // Synonyms for ParserBase<Impl> and Impl, respectively. 123 // // Synonyms for ParserBase<Impl> and Impl, respectively.
124 // typedef Base; 124 // typedef Base;
125 // typedef Impl; 125 // typedef Impl;
126 // // TODO(nikolaos): this one will probably go away, as it is 126 // // TODO(nikolaos): this one will probably go away, as it is
127 // // not related to pure parsing. 127 // // not related to pure parsing.
128 // typedef GeneratorVariable; 128 // typedef Variable;
129 // // Return types for traversing functions. 129 // // Return types for traversing functions.
130 // typedef Identifier; 130 // typedef Identifier;
131 // typedef Expression; 131 // typedef Expression;
132 // typedef FunctionLiteral; 132 // typedef FunctionLiteral;
133 // typedef ObjectLiteralProperty; 133 // typedef ObjectLiteralProperty;
134 // typedef ClassLiteralProperty; 134 // typedef ClassLiteralProperty;
135 // typedef ExpressionList; 135 // typedef ExpressionList;
136 // typedef PropertyList; 136 // typedef PropertyList;
137 // typedef FormalParameters; 137 // typedef FormalParameters;
138 // typedef Statement; 138 // typedef Statement;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void AddProperty() { expected_property_count_++; } 398 void AddProperty() { expected_property_count_++; }
399 int expected_property_count() { return expected_property_count_; } 399 int expected_property_count() { return expected_property_count_; }
400 400
401 bool is_generator() const { return IsGeneratorFunction(kind_); } 401 bool is_generator() const { return IsGeneratorFunction(kind_); }
402 bool is_async_function() const { return IsAsyncFunction(kind_); } 402 bool is_async_function() const { return IsAsyncFunction(kind_); }
403 bool is_resumable() const { return is_generator() || is_async_function(); } 403 bool is_resumable() const { return is_generator() || is_async_function(); }
404 404
405 FunctionKind kind() const { return kind_; } 405 FunctionKind kind() const { return kind_; }
406 FunctionState* outer() const { return outer_function_state_; } 406 FunctionState* outer() const { return outer_function_state_; }
407 407
408 void set_generator_object_variable( 408 void set_generator_object_variable(typename Types::Variable* variable) {
409 typename Types::GeneratorVariable* variable) {
410 DCHECK(variable != NULL); 409 DCHECK(variable != NULL);
411 DCHECK(is_resumable()); 410 DCHECK(is_resumable());
412 generator_object_variable_ = variable; 411 generator_object_variable_ = variable;
413 } 412 }
414 typename Types::GeneratorVariable* generator_object_variable() const { 413 typename Types::Variable* generator_object_variable() const {
415 return generator_object_variable_; 414 return generator_object_variable_;
416 } 415 }
417 416
417 void set_promise_variable(typename Types::Variable* variable) {
418 DCHECK(variable != NULL);
419 DCHECK(is_async_function());
420 promise_variable_ = variable;
421 }
422 typename Types::Variable* promise_variable() const {
423 return promise_variable_;
424 }
425
418 const ZoneList<DestructuringAssignment>& 426 const ZoneList<DestructuringAssignment>&
419 destructuring_assignments_to_rewrite() const { 427 destructuring_assignments_to_rewrite() const {
420 return destructuring_assignments_to_rewrite_; 428 return destructuring_assignments_to_rewrite_;
421 } 429 }
422 430
423 TailCallExpressionList& tail_call_expressions() { 431 TailCallExpressionList& tail_call_expressions() {
424 return tail_call_expressions_; 432 return tail_call_expressions_;
425 } 433 }
426 void AddImplicitTailCallExpression(ExpressionT expression) { 434 void AddImplicitTailCallExpression(ExpressionT expression) {
427 if (return_expr_context() == 435 if (return_expr_context() ==
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 int next_materialized_literal_index_; 491 int next_materialized_literal_index_;
484 492
485 // Properties count estimation. 493 // Properties count estimation.
486 int expected_property_count_; 494 int expected_property_count_;
487 495
488 FunctionKind kind_; 496 FunctionKind kind_;
489 // For generators, this variable may hold the generator object. It variable 497 // For generators, this variable may hold the generator object. It variable
490 // is used by yield expressions and return statements. It is not necessary 498 // is used by yield expressions and return statements. It is not necessary
491 // for generator functions to have this variable set. 499 // for generator functions to have this variable set.
492 Variable* generator_object_variable_; 500 Variable* generator_object_variable_;
501 // For async functions, this variable holds a temporary for the Promise
502 // being created as output of the async function.
503 Variable* promise_variable_;
493 504
494 FunctionState** function_state_stack_; 505 FunctionState** function_state_stack_;
495 FunctionState* outer_function_state_; 506 FunctionState* outer_function_state_;
496 507
497 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; 508 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_;
498 TailCallExpressionList tail_call_expressions_; 509 TailCallExpressionList tail_call_expressions_;
499 ReturnExprContext return_expr_context_; 510 ReturnExprContext return_expr_context_;
500 ZoneList<ExpressionT> non_patterns_to_rewrite_; 511 ZoneList<ExpressionT> non_patterns_to_rewrite_;
501 512
502 ZoneList<typename ExpressionClassifier::Error> reported_errors_; 513 ZoneList<typename ExpressionClassifier::Error> reported_errors_;
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 }; 1433 };
1423 1434
1424 template <typename Impl> 1435 template <typename Impl>
1425 ParserBase<Impl>::FunctionState::FunctionState( 1436 ParserBase<Impl>::FunctionState::FunctionState(
1426 FunctionState** function_state_stack, ScopeState** scope_stack, 1437 FunctionState** function_state_stack, ScopeState** scope_stack,
1427 Scope* scope, FunctionKind kind) 1438 Scope* scope, FunctionKind kind)
1428 : ScopeState(scope_stack, scope), 1439 : ScopeState(scope_stack, scope),
1429 next_materialized_literal_index_(0), 1440 next_materialized_literal_index_(0),
1430 expected_property_count_(0), 1441 expected_property_count_(0),
1431 kind_(kind), 1442 kind_(kind),
1432 generator_object_variable_(NULL), 1443 generator_object_variable_(nullptr),
1444 promise_variable_(nullptr),
1433 function_state_stack_(function_state_stack), 1445 function_state_stack_(function_state_stack),
1434 outer_function_state_(*function_state_stack), 1446 outer_function_state_(*function_state_stack),
1435 destructuring_assignments_to_rewrite_(16, scope->zone()), 1447 destructuring_assignments_to_rewrite_(16, scope->zone()),
1436 tail_call_expressions_(scope->zone()), 1448 tail_call_expressions_(scope->zone()),
1437 return_expr_context_(ReturnExprContext::kInsideValidBlock), 1449 return_expr_context_(ReturnExprContext::kInsideValidBlock),
1438 non_patterns_to_rewrite_(0, scope->zone()), 1450 non_patterns_to_rewrite_(0, scope->zone()),
1439 reported_errors_(16, scope->zone()), 1451 reported_errors_(16, scope->zone()),
1440 next_function_is_parenthesized_(false), 1452 next_function_is_parenthesized_(false),
1441 this_function_is_parenthesized_(false) { 1453 this_function_is_parenthesized_(false) {
1442 *function_state_stack = this; 1454 *function_state_stack = this;
(...skipping 3584 matching lines...) Expand 10 before | Expand all | Expand 10 after
5027 has_seen_constructor_ = true; 5039 has_seen_constructor_ = true;
5028 return; 5040 return;
5029 } 5041 }
5030 } 5042 }
5031 5043
5032 5044
5033 } // namespace internal 5045 } // namespace internal
5034 } // namespace v8 5046 } // namespace v8
5035 5047
5036 #endif // V8_PARSING_PARSER_BASE_H 5048 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698