Skip to content

Commit 3b2f848

Browse files
committed
feat: Split out return_call_ref
1 parent c3726f6 commit 3b2f848

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/js/binaryen.js-post.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,11 +2465,17 @@ function wrapModule(module, self = {}) {
24652465
}
24662466
};
24672467

2468-
self['call_ref'] = function(target, operands, type, isReturn) {
2468+
self['call_ref'] = function(target, operands, type) {
24692469
return preserveStack(() =>
2470-
Module['_BinaryenCallRef'](module, target, i32sToStack(operands), operands.length, type, isReturn)
2470+
Module['_BinaryenCallRef'](module, target, i32sToStack(operands), operands.length, type, false)
24712471
);
24722472
};
2473+
2474+
self['return_call_ref'] = function(target, operands, type) {
2475+
return preserveStack(() =>
2476+
Module['_BinaryenCallRef'](module, target, i32sToStack(operands), operands.length, type, true)
2477+
);
2478+
}
24732479

24742480
self['any'] = {
24752481
'convert_extern'() {

test/binaryen.js/expressions.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ console.log("# CallRef");
34243424
module.i32.const(7)
34253425
];
34263426

3427-
const theCallRef = binaryen.CallRef(module.call_ref(funcRef, operands, binaryen.none, false));
3427+
const theCallRef = binaryen.CallRef(module.call_ref(funcRef, operands, binaryen.none));
34283428
assert(theCallRef instanceof binaryen.CallRef);
34293429
assert(theCallRef instanceof binaryen.Expression);
34303430
assert(theCallRef.numOperands === operands.length);
@@ -3474,6 +3474,14 @@ console.log("# CallRef");
34743474
theCallRef.setReturn(false);
34753475
assert(theCallRef.isReturn() === false);
34763476

3477+
const theReturnCallRef = binaryen.CallRef(module.return_call_ref(funcRef, operands, binaryen.none));
3478+
assert(theReturnCallRef instanceof binaryen.CallRef);
3479+
assert(theReturnCallRef instanceof binaryen.Expression);
3480+
assert(theReturnCallRef.numOperands === operands.length);
3481+
assert(theReturnCallRef.type === binaryen.none);
3482+
assert(binaryen.RefFunc(theReturnCallRef.target).func === funcName);
3483+
assert(theReturnCallRef.isReturn() === true);
3484+
34773485

34783486
const targetRef = binaryen.RefFunc(theCallRef.getTarget());
34793487
assert(theCallRef.getTarget() == theCallRef.target);

0 commit comments

Comments
 (0)