add support for call expression abstract references and more versatile tests

This commit is contained in:
Sebastian McKenzie
2014-11-23 18:37:30 +11:00
parent 55150853b4
commit 4502aee988
9 changed files with 45 additions and 6 deletions

View File

@@ -0,0 +1 @@
PROPERTY[Symbol.referenceGet](OBJECT).call(OBJECT)

View File

@@ -3,30 +3,53 @@
var util = require("../../util");
var t = require("../../types");
var container = function (parent, call, ret) {
if (t.isExpressionStatement(parent)) {
// we don't need to worry about return values
return call;
} else {
return t.sequenceExpression([call, ret]);
}
};
exports.AssignmentExpression = function (node, parent) {
var left = node.left;
if (!t.isVirtualPropertyExpression(left)) return;
return util.template("abstract-expression-set", {
var right = node.right;
var call = util.template("abstract-expression-set", {
PROPERTY: left.property,
OBJECT: left.object,
VALUE: node.right
VALUE: right
});
return container(parent, call, right);
};
exports.UnaryExpression = function (node, parent) {
if (!t.isVirtualPropertyExpression(node.argument)) return;
var arg = node.argument;
if (!t.isVirtualPropertyExpression(arg)) return;
if (node.operator !== "delete") return;
return util.template("abstract-expression-delete", {
PROPERTY: node.property,
OBJECT: node.object
var call = util.template("abstract-expression-delete", {
PROPERTY: arg.property,
OBJECT: arg.object
});
return container(parent, call, t.literal(true));
};
exports.CallExpression = function (node, parent) {
var callee = node.callee;
if (!t.isVirtualPropertyExpression(callee)) return;
var call = util.template("abstract-expression-call", {
PROPERTY: callee.property,
OBJECT: callee.object
});
call.arguments = call.arguments.concat(node.arguments);
return call;
};
exports.VirtualPropertyExpression = function (node) {

View File

@@ -0,0 +1,2 @@
foo::bar();
foo::bar("arg");

View File

@@ -0,0 +1,4 @@
"use strict";
bar[Symbol.referenceGet](foo).call(foo);
bar[Symbol.referenceGet](foo).call(foo, "arg");

View File

@@ -1 +1,3 @@
delete foo::bar;
if (delete foo::bar);

View File

@@ -1,3 +1,5 @@
"use strict";
bar[Symbol.referenceDelete](foo);
if ((bar[Symbol.referenceDelete](foo), true)) ;

View File

@@ -0,0 +1,3 @@
{
"experimental": true
}

View File

@@ -1 +1,2 @@
foo::bar = baz;
if (foo::bar = baz);

View File

@@ -1,3 +1,4 @@
"use strict";
bar[Symbol.referenceSet](foo, baz);
if ((bar[Symbol.referenceSet](foo, baz), baz)) ;