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

Unified Diff: src/parsing/parser.cc

Issue 2220363004: Redirect Scope::NewTemporary over parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index b7761564f26abe1031a68d1f486f4843d14f61e8..c920c9c87fe78ed50c0ada65bf85ddd35630a486 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2741,8 +2741,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
// %_IsJSReceiver(temp) ? temp : 1;
// temp = expr
- Variable* temp =
- scope()->NewTemporary(ast_value_factory()->empty_string());
+ Variable* temp = NewTemporary(ast_value_factory()->empty_string());
Assignment* assign = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos);
@@ -2884,7 +2883,7 @@ Statement* Parser::ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
Expect(Token::RPAREN, CHECK_OK);
Variable* tag_variable =
- scope()->NewTemporary(ast_value_factory()->dot_switch_tag_string());
+ NewTemporary(ast_value_factory()->dot_switch_tag_string());
Assignment* tag_assign = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(tag_variable), tag,
tag->position());
@@ -3245,8 +3244,7 @@ Statement* Parser::InitializeForEachStatement(ForEachStatement* stmt,
each_keyword_pos);
} else {
if (each->IsArrayLiteral() || each->IsObjectLiteral()) {
- Variable* temp =
- scope()->NewTemporary(ast_value_factory()->empty_string());
+ Variable* temp = NewTemporary(ast_value_factory()->empty_string());
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment(
this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy,
@@ -3279,11 +3277,9 @@ Statement* Parser::InitializeForOfStatement(ForOfStatement* for_of,
const int nopos = kNoSourcePosition;
auto avfactory = ast_value_factory();
- Variable* iterator =
- scope()->NewTemporary(ast_value_factory()->dot_iterator_string());
- Variable* result =
- scope()->NewTemporary(ast_value_factory()->dot_result_string());
- Variable* completion = scope()->NewTemporary(avfactory->empty_string());
+ Variable* iterator = NewTemporary(ast_value_factory()->dot_iterator_string());
+ Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
+ Variable* completion = NewTemporary(avfactory->empty_string());
// iterator = iterable[Symbol.iterator]()
Expression* assign_iterator;
@@ -3339,7 +3335,7 @@ Statement* Parser::InitializeForOfStatement(ForOfStatement* for_of,
// do { let tmp = #result_value; #set_completion_abrupt; tmp }
// Expression* result_value (gets overwritten)
if (finalize) {
- Variable* var_tmp = scope()->NewTemporary(avfactory->empty_string());
+ Variable* var_tmp = NewTemporary(avfactory->empty_string());
Expression* tmp = factory()->NewVariableProxy(var_tmp);
Expression* assignment =
factory()->NewAssignment(Token::ASSIGN, tmp, result_value, nopos);
@@ -3449,7 +3445,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
// make statement: temp_x = x.
for (int i = 0; i < names->length(); i++) {
VariableProxy* proxy = NewUnresolved(names->at(i), LET);
- Variable* temp = scope()->NewTemporary(temp_name);
+ Variable* temp = NewTemporary(temp_name);
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy,
proxy, kNoSourcePosition);
@@ -3462,7 +3458,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Variable* first = NULL;
// Make statement: first = 1.
if (next) {
- first = scope()->NewTemporary(temp_name);
+ first = NewTemporary(temp_name);
VariableProxy* first_proxy = factory()->NewVariableProxy(first);
Expression* const1 = factory()->NewSmiLiteral(1, kNoSourcePosition);
Assignment* assignment = factory()->NewAssignment(
@@ -3537,7 +3533,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
ignore_completion_block->statements()->Add(clear_first_or_next, zone());
}
- Variable* flag = scope()->NewTemporary(temp_name);
+ Variable* flag = NewTemporary(temp_name);
// Make statement: flag = 1.
{
VariableProxy* flag_proxy = factory()->NewVariableProxy(flag);
@@ -3746,8 +3742,7 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
// let x; // for TDZ
// }
- Variable* temp =
- scope()->NewTemporary(ast_value_factory()->dot_for_string());
+ Variable* temp = NewTemporary(ast_value_factory()->dot_for_string());
ForEachStatement* loop =
factory()->NewForEachStatement(mode, labels, stmt_pos);
Target target(&this->target_stack_, loop);
@@ -4139,8 +4134,8 @@ void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
// }
// }
scope->ForceContextAllocation();
- Variable* temp = this->scope()->NewTemporary(
- ast_value_factory()->dot_generator_object_string());
+ Variable* temp =
+ NewTemporary(ast_value_factory()->dot_generator_object_string());
function_state_->set_generator_object_variable(temp);
Expression* init_generator_variable = factory()->NewAssignment(
@@ -4178,8 +4173,7 @@ DoExpression* Parser::ParseDoExpression(bool* ok) {
int pos = peek_position();
Expect(Token::DO, CHECK_OK);
- Variable* result =
- scope()->NewTemporary(ast_value_factory()->dot_result_string());
+ Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
Block* block = ParseBlock(nullptr, CHECK_OK);
DoExpression* expr = factory()->NewDoExpression(block, result, pos);
if (!Rewriter::Rewrite(this, GetClosureScope(), expr, ast_value_factory())) {
@@ -4382,8 +4376,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// Calling a generator returns a generator object. That object is stored
// in a temporary variable, a definition that is used by "yield"
// expressions. This also marks the FunctionState as a generator.
- Variable* temp = this->scope()->NewTemporary(
- ast_value_factory()->dot_generator_object_string());
+ Variable* temp =
+ NewTemporary(ast_value_factory()->dot_generator_object_string());
function_state.set_generator_object_variable(temp);
}
@@ -5105,8 +5099,7 @@ Expression* Parser::ParseClassLiteral(ExpressionClassifier* classifier,
}
Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
- Variable* result_var =
- scope()->NewTemporary(ast_value_factory()->empty_string());
+ Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
do_block->set_scope(block_state.FinalizedBlockScope());
DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
@@ -5711,8 +5704,7 @@ Expression* Parser::SpreadCall(Expression* function,
args->InsertAt(0, function, zone());
args->InsertAt(1, home, zone());
} else {
- Variable* temp =
- scope()->NewTemporary(ast_value_factory()->empty_string());
+ Variable* temp = NewTemporary(ast_value_factory()->empty_string());
VariableProxy* obj = factory()->NewVariableProxy(temp);
Assignment* assign_obj = factory()->NewAssignment(
Token::ASSIGN, obj, function->AsProperty()->obj(),
@@ -5817,8 +5809,8 @@ Expression* ParserTraits::RewriteAwaitExpression(Expression* value,
auto factory = parser_->factory();
const int nopos = kNoSourcePosition;
- Variable* temp_var = parser_->scope()->NewTemporary(
- parser_->ast_value_factory()->empty_string());
+ Variable* temp_var =
+ parser_->NewTemporary(parser_->ast_value_factory()->empty_string());
VariableProxy* temp_proxy = factory->NewVariableProxy(temp_var);
Block* do_block = factory->NewBlock(nullptr, 2, false, nopos);
@@ -5961,8 +5953,8 @@ Expression* Parser::RewriteAssignExponentiation(Expression* left,
return factory()->NewAssignment(Token::ASSIGN, result, call, pos);
} else if (left->IsProperty()) {
Property* prop = left->AsProperty();
- auto temp_obj = scope()->NewTemporary(ast_value_factory()->empty_string());
- auto temp_key = scope()->NewTemporary(ast_value_factory()->empty_string());
+ auto temp_obj = NewTemporary(ast_value_factory()->empty_string());
+ auto temp_key = NewTemporary(ast_value_factory()->empty_string());
Expression* assign_obj = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(temp_obj), prop->obj(),
kNoSourcePosition);
@@ -6005,8 +5997,7 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
// where $R, $i and $j are fresh temporary variables.
ZoneList<Expression*>::iterator s = lit->FirstSpread();
if (s == lit->EndValue()) return nullptr; // no spread, no rewriting...
- Variable* result =
- scope()->NewTemporary(ast_value_factory()->dot_result_string());
+ Variable* result = NewTemporary(ast_value_factory()->dot_result_string());
// NOTE: The value assigned to R is the whole original array literal,
// spreads included. This will be fixed before the rewritten AST is returned.
// $R = lit
@@ -6034,8 +6025,7 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
zone());
} else {
// If it's a spread, we're adding a for/of loop iterating through it.
- Variable* each =
- scope()->NewTemporary(ast_value_factory()->dot_for_string());
+ Variable* each = NewTemporary(ast_value_factory()->dot_for_string());
Expression* subject = spread->expression();
// %AppendElement($R, each)
Statement* append_body;
@@ -6220,7 +6210,6 @@ Expression* ParserTraits::RewriteYieldStar(
auto factory = parser_->factory();
auto avfactory = parser_->ast_value_factory();
- auto scope = parser_->scope();
auto zone = parser_->zone();
@@ -6229,7 +6218,7 @@ Expression* ParserTraits::RewriteYieldStar(
// let input = undefined;
- Variable* var_input = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_input = parser_->NewTemporary(avfactory->empty_string());
Statement* initialize_input;
{
Expression* input_proxy = factory->NewVariableProxy(var_input);
@@ -6240,7 +6229,7 @@ Expression* ParserTraits::RewriteYieldStar(
// let mode = kNext;
- Variable* var_mode = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_mode = parser_->NewTemporary(avfactory->empty_string());
Statement* initialize_mode;
{
Expression* mode_proxy = factory->NewVariableProxy(var_mode);
@@ -6252,7 +6241,7 @@ Expression* ParserTraits::RewriteYieldStar(
// let output = undefined;
- Variable* var_output = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_output = parser_->NewTemporary(avfactory->empty_string());
Statement* initialize_output;
{
Expression* output_proxy = factory->NewVariableProxy(var_output);
@@ -6264,7 +6253,7 @@ Expression* ParserTraits::RewriteYieldStar(
// let iterator = iterable[Symbol.iterator];
- Variable* var_iterator = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_iterator = parser_->NewTemporary(avfactory->empty_string());
Statement* get_iterator;
{
Expression* iterator = GetIterator(iterable, factory, nopos);
@@ -6344,7 +6333,7 @@ Expression* ParserTraits::RewriteYieldStar(
// let iteratorThrow = iterator.throw;
- Variable* var_throw = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_throw = parser_->NewTemporary(avfactory->empty_string());
Statement* get_throw;
{
Expression* iterator_proxy = factory->NewVariableProxy(var_iterator);
@@ -6539,7 +6528,7 @@ Expression* ParserTraits::RewriteYieldStar(
Block* catch_block = factory->NewBlock(nullptr, 1, false, nopos);
catch_block->statements()->Add(set_mode_throw, zone);
- Scope* catch_scope = NewScopeWithParent(scope, CATCH_SCOPE);
+ Scope* catch_scope = NewScope(CATCH_SCOPE);
catch_scope->set_is_hidden();
const AstRawString* name = avfactory->dot_catch_string();
Variable* catch_variable =
@@ -6631,9 +6620,11 @@ Expression* ParserTraits::RewriteYieldStar(
do_block->statements()->Add(do_block_, zone);
do_block->statements()->Add(get_value, zone);
- Variable* dot_result = scope->NewTemporary(avfactory->dot_result_string());
+ Variable* dot_result =
+ parser_->NewTemporary(avfactory->dot_result_string());
yield_star = factory->NewDoExpression(do_block, dot_result, nopos);
- Rewriter::Rewrite(parser_, scope->GetClosureScope(), yield_star, avfactory);
+ Rewriter::Rewrite(parser_, parser_->GetClosureScope(), yield_star,
+ avfactory);
}
return yield_star;
@@ -6904,12 +6895,11 @@ void ParserTraits::BuildIteratorCloseForCompletion(
const int nopos = kNoSourcePosition;
auto factory = parser_->factory();
auto avfactory = parser_->ast_value_factory();
- auto scope = parser_->scope();
auto zone = parser_->zone();
// let iteratorReturn = iterator.return;
- Variable* var_return = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_return = parser_->NewTemporary(avfactory->empty_string());
Statement* get_return;
{
Expression* iterator_proxy = factory->NewVariableProxy(iterator);
@@ -6950,7 +6940,7 @@ void ParserTraits::BuildIteratorCloseForCompletion(
Block* catch_block = factory->NewBlock(nullptr, 0, false, nopos);
- Scope* catch_scope = NewScopeWithParent(scope, CATCH_SCOPE);
+ Scope* catch_scope = NewScope(CATCH_SCOPE);
Variable* catch_variable = catch_scope->DeclareLocal(
avfactory->dot_catch_string(), VAR, kCreatedInitialized,
Variable::NORMAL);
@@ -6966,7 +6956,7 @@ void ParserTraits::BuildIteratorCloseForCompletion(
// }
Block* validate_return;
{
- Variable* var_output = scope->NewTemporary(avfactory->empty_string());
+ Variable* var_output = parser_->NewTemporary(avfactory->empty_string());
Statement* call_return;
{
auto args = new (zone) ZoneList<Expression*>(2, zone);
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698