Skip to content

Conversation

@spotandjake
Copy link
Contributor

This is my first pr to Binaryen so I hope I did things correctly.

This pr implements the api's for working with CallRef to the js api.

  • module.call_ref
    and the related info functions:
  • getNumOperands(expr)
  • getOperandAt(expr, index)
  • setOperandAt(expr, index, operandExpr)
  • appendOperand(expr, operandExpr)
  • insertOperandAt(expr, index, operandExpr)
  • removeOperandAt(expr, index)
  • getTarget(expr)
  • setTarget(expr, targetExpr)
  • isReturn(expr)
  • setReturn(expr, isReturn)

}
};

self['call_ref'] = function(target, operands, type, isReturn) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like call_indirect handles return calls differently - there is self.return_call_indirect instead of a param. But I see we have the same difference in the C API, so this PR is following that.

I think we might want to change the C API, but for now, how about making the JS API consistent with itself? That is, add self.return_call_ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made that change. Might be smart to open an issue for tracking the change on the c api.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Good idea to open an issue, I did that here: #8110

@kripken
Copy link
Member

kripken commented Dec 9, 2025

Btw, in the future I hope we can automate the JS API bindings, perhaps using embind, though we haven't found a good way yet:

#7239
#7553

@kripken kripken merged commit 42b592d into WebAssembly:main Dec 9, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants