WebAssembly / wasm-c-api

Wasm C API prototype
Apache License 2.0
534 stars 77 forks source link

feat: Add `wasm_module_name` and `wasm_module_set_name`. #157

Closed Hywan closed 3 years ago

Hywan commented 3 years ago

This patch proposes 2 new functions to handle module's name:

wasm_module_set_name returns true if the module's name has been updated succesfully, false otherwise, e.g. if the name is invalid, or if it's not possible to update it (e.g. if the module is already instantiated).

rossberg commented 3 years ago

Hm, there is no such concept as a module's name in Wasm. So this would be a custom notion. But if you want to attach custom data to a module object, you already can by using wasm_module_set_host_info.

syrusakbary commented 3 years ago

Some context:

We use Wasm names to identify the wasm modules when debugging. Perhaps this is not useful for all VMs, but just throwing some context before closing the PR :)

Hywan commented 3 years ago

What I call “name” is moduleName in (module $moduleName). How does it sound?

rossberg commented 3 years ago

But that is just an artefact of the text format, it is not represented in the binary format (outside custom sections).