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

Unified Diff: src/parsing/parser.cc

Issue 2056993004: Parser: Desugar default derived constructor to spread/rest (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove whitespace Created 4 years, 6 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 | « no previous file | test/test262/test262.status » ('j') | 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 8164c7d3b2cda7e9dd5af74dac0883f0ff95541e..37b1ea9a6eb6edecd1703410904287bf3c49185e 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -205,7 +205,16 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
if (call_super) {
// $super_constructor = %_GetSuperConstructor(<this-function>)
- // %reflect_construct($super_constructor, arguments, new.target)
+ // %reflect_construct(
+ // $super_constructor, InternalArray(...args), new.target)
+ auto constructor_args_name = ast_value_factory()->empty_string();
+ bool is_duplicate;
+ bool is_rest = true;
+ bool is_optional = false;
+ Variable* constructor_args =
+ function_scope->DeclareParameter(constructor_args_name, TEMPORARY,
+ is_optional, is_rest, &is_duplicate);
+
ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(2, zone());
VariableProxy* this_function_proxy = scope_->NewUnresolved(
@@ -217,10 +226,12 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
Expression* super_constructor = factory()->NewCallRuntime(
Runtime::kInlineGetSuperConstructor, tmp, pos);
args->Add(super_constructor, zone());
- VariableProxy* arguments_proxy = scope_->NewUnresolved(
- factory(), ast_value_factory()->arguments_string(), Variable::NORMAL,
- pos);
- args->Add(arguments_proxy, zone());
+ Spread* spread_args = factory()->NewSpread(
+ factory()->NewVariableProxy(constructor_args), pos, pos);
+ ZoneList<Expression*>* spread_args_expr =
+ new (zone()) ZoneList<Expression*>(1, zone());
+ spread_args_expr->Add(spread_args, zone());
+ args->AddAll(*PrepareSpreadArguments(spread_args_expr), zone());
VariableProxy* new_target_proxy = scope_->NewUnresolved(
factory(), ast_value_factory()->new_target_string(), Variable::NORMAL,
pos);
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698