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.

@spotandjake spotandjake force-pushed the spotandjake-js-callref branch from 3b2f848 to 07f5a59 Compare December 8, 2025 17:55
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