Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
wrapSuperCall(bareSuper, superRef, thisRef, body) {
let bareSuperNode = bareSuper.node;
if (this.isLoose) {
bareSuperNode.arguments.unshift(t.thisExpression());
if (bareSuperNode.arguments.length === 2 && t.isSpreadElement(bareSuperNode.arguments[1]) && t.isIdentifier(bareSuperNode.arguments[1].argument, { name: "arguments" })) {
// special case single arguments spread
bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument;
bareSuperNode.callee = t.memberExpression(superRef, t.identifier("apply"));
} else {
bareSuperNode.callee = t.memberExpression(superRef, t.identifier("call"));
}
} else {
bareSuperNode = optimiseCall(
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[this.classRef]
),
t.thisExpression(),
bareSuperNode.arguments
);
}
let call = t.callExpression(
this.file.addHelper("possibleConstructorReturn"),
[t.thisExpression(), bareSuperNode]
);
let bareSuperAfter = this.bareSuperAfter.map((fn) => fn(thisRef));
optimiseCall(callee, args) {
let thisNode = t.thisExpression();
thisNode[HARDCORE_THIS_REF] = true;
return optimiseCall(callee, thisNode, args);
}
}