Reviewers: arv, Dmitry Lomov (chromium), rossberg,
Message:
PTAL, this ones pretty tiny
Description:
[es6] support spread-calling Super-accessing properties
BUG=v8:4105
LOG=N
[email protected], [email protected], [email protected]
Please review this at https://codereview.chromium.org/1132933003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+40, -11 lines):
M src/parser.cc
A test/mjsunit/harmony/spread-call-super-property.js
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
87a74a4c7bba3c56ae7da85c8d565dd1292c5bbf..c925cf32cddb9a424429b1681f59983adccba091
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5708,17 +5708,26 @@ Expression* Parser::SpreadCall(Expression* function,
} else {
if (function->IsProperty()) {
// Method calls
- Variable* temp =
- scope_->NewTemporary(ast_value_factory()->empty_string());
- VariableProxy* obj = factory()->NewVariableProxy(temp);
- 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());
+ if (function->AsProperty()->IsSuperAccess()) {
+ // Use super reference home object. Can we do this?
+ VariableProxy* original_home =
+ function->AsProperty()->obj()->AsSuperReference()->this_var();
+ VariableProxy* home =
factory()->NewVariableProxy(original_home->var());
+ args->InsertAt(0, function, zone());
+ args->InsertAt(1, home, zone());
+ } else {
+ Variable* temp =
+ scope_->NewTemporary(ast_value_factory()->empty_string());
+ VariableProxy* obj = factory()->NewVariableProxy(temp);
+ 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 {
// Non-method calls
args->InsertAt(0, function, zone());
Index: test/mjsunit/harmony/spread-call-super-property.js
diff --git a/test/mjsunit/harmony/spread-call-super-property.js
b/test/mjsunit/harmony/spread-call-super-property.js
new file mode 100644
index
0000000000000000000000000000000000000000..cdf6f2e242268ab6df3bf5a9c378cfc7fe67e4bf
--- /dev/null
+++ b/test/mjsunit/harmony/spread-call-super-property.js
@@ -0,0 +1,20 @@
+// 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));
+})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.