Commit 3a18b9b7 authored by caitpotter88's avatar caitpotter88 Committed by Commit bot

[es6] support spread-calling Super-accessing properties

BUG=v8:4105, v8:3018
LOG=N
R=arv@chromium.org

Review URL: https://codereview.chromium.org/1132933003

Cr-Commit-Position: refs/heads/master@{#28405}
parent d090469c
...@@ -5708,17 +5708,25 @@ Expression* Parser::SpreadCall(Expression* function, ...@@ -5708,17 +5708,25 @@ Expression* Parser::SpreadCall(Expression* function,
} else { } else {
if (function->IsProperty()) { if (function->IsProperty()) {
// Method calls // Method calls
Variable* temp = if (function->AsProperty()->IsSuperAccess()) {
scope_->NewTemporary(ast_value_factory()->empty_string()); VariableProxy* original_home =
VariableProxy* obj = factory()->NewVariableProxy(temp); function->AsProperty()->obj()->AsSuperReference()->this_var();
Assignment* assign_obj = factory()->NewAssignment( VariableProxy* home = factory()->NewVariableProxy(original_home->var());
Token::ASSIGN, obj, function->AsProperty()->obj(), args->InsertAt(0, function, zone());
RelocInfo::kNoPosition); args->InsertAt(1, home, zone());
function = factory()->NewProperty( } else {
assign_obj, function->AsProperty()->key(), RelocInfo::kNoPosition); Variable* temp =
args->InsertAt(0, function, zone()); scope_->NewTemporary(ast_value_factory()->empty_string());
obj = factory()->NewVariableProxy(temp); VariableProxy* obj = factory()->NewVariableProxy(temp);
args->InsertAt(1, obj, zone()); Assignment* assign_obj = factory()->NewAssignment(
Token::ASSIGN, obj, function->AsProperty()->obj(),
RelocInfo::kNoPosition);
function = factory()->NewProperty(
assign_obj, function->AsProperty()->key(), RelocInfo::kNoPosition);
args->InsertAt(0, function, zone());
obj = factory()->NewVariableProxy(temp);
args->InsertAt(1, obj, zone());
}
} else { } else {
// Non-method calls // Non-method calls
args->InsertAt(0, function, zone()); args->InsertAt(0, function, zone());
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-spreadcalls --harmony-sloppy --harmony-rest-parameters
(function testCallSuperProperty() {
class BaseClass {
strict_method(...args) { "use strict"; return [this].concat(args); }
sloppy_method(...args) { return [this].concat(args); }
}
class SubClass extends BaseClass {
strict_m(...args) { return super.strict_method(...args); }
sloppy_m(...args) { return super.sloppy_method(...args); }
}
var c = new SubClass();
assertEquals([c, 1, 2, 3, 4, 5], c.strict_m(1, 2, 3, 4, 5));
assertEquals([c, 1, 2, 3, 4, 5], c.sloppy_m(1, 2, 3, 4, 5));
})();
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