Skip to content

Conversation

@spotandjake
Copy link
Contributor

This pr adds BinaryenHasMemorySegment(module, name) to the c api and module.hasMemorySegment(name) to the js api.

While adding a test to the grain compiler to check the size of a generated memory segment, I noticed that if the segment didn't exist, any operations on that segment would throw. As we are working from OCaml, we have no way to catch this fatal C++ exception related grain pr. As far as I am aware there is no other existing way to check if a segment exists.

This function allows a user to check for the existance of a segment before trying to perform operations on it.

Related Binaryen.ml Issue
Related Grain issue

This pr adds `BinaryenHasMemorySegment(module, name)` to the c api and `module.hasMemorySegment(name)` to the js api.
@spotandjake spotandjake force-pushed the spotandjake/hasMemorySegment branch from b7f5068 to cd887c1 Compare February 11, 2026 00:48
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.

1 participant