Commit e681eea1 authored by gsathya's avatar gsathya Committed by Commit bot

Parser: Desugar default derived constructor to spread/rest

This patch declares a new rest parameter for the derived constructor,
and passes it to base constructor after calling PrepareSpreadArguments.

This patch also updates the test262.status to account for
the now passing test.

BUG=v8:4890

Review-Url: https://codereview.chromium.org/2056993004
Cr-Commit-Position: refs/heads/master@{#36939}
parent 1a308662
...@@ -205,7 +205,16 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, ...@@ -205,7 +205,16 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
if (call_super) { if (call_super) {
// $super_constructor = %_GetSuperConstructor(<this-function>) // $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 = ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(2, zone()); new (zone()) ZoneList<Expression*>(2, zone());
VariableProxy* this_function_proxy = scope_->NewUnresolved( VariableProxy* this_function_proxy = scope_->NewUnresolved(
...@@ -217,10 +226,12 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, ...@@ -217,10 +226,12 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
Expression* super_constructor = factory()->NewCallRuntime( Expression* super_constructor = factory()->NewCallRuntime(
Runtime::kInlineGetSuperConstructor, tmp, pos); Runtime::kInlineGetSuperConstructor, tmp, pos);
args->Add(super_constructor, zone()); args->Add(super_constructor, zone());
VariableProxy* arguments_proxy = scope_->NewUnresolved( Spread* spread_args = factory()->NewSpread(
factory(), ast_value_factory()->arguments_string(), Variable::NORMAL, factory()->NewVariableProxy(constructor_args), pos, pos);
pos); ZoneList<Expression*>* spread_args_expr =
args->Add(arguments_proxy, zone()); 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( VariableProxy* new_target_proxy = scope_->NewUnresolved(
factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, factory(), ast_value_factory()->new_target_string(), Variable::NORMAL,
pos); pos);
......
...@@ -173,9 +173,6 @@ ...@@ -173,9 +173,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=4784 # https://bugs.chromium.org/p/v8/issues/detail?id=4784
'built-ins/TypedArrays/buffer-arg-defined-negative-length': [FAIL], 'built-ins/TypedArrays/buffer-arg-defined-negative-length': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4890
'language/statements/class/subclass/default-constructor-spread-override': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4901 # https://bugs.chromium.org/p/v8/issues/detail?id=4901
'built-ins/TypedArrays/internals/DefineOwnProperty/key-is-greater-than-last-index': [FAIL], 'built-ins/TypedArrays/internals/DefineOwnProperty/key-is-greater-than-last-index': [FAIL],
'built-ins/TypedArrays/internals/DefineOwnProperty/key-is-lower-than-zero': [FAIL], 'built-ins/TypedArrays/internals/DefineOwnProperty/key-is-lower-than-zero': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment