Closed Hywan closed 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
.
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 :)
What I call “name” is moduleName
in (module $moduleName)
. How does it sound?
But that is just an artefact of the text format, it is not represented in the binary format (outside custom sections).
This patch proposes 2 new functions to handle module's name:
wasm_module_name
that writes the module's name in awasm_name_t
if any,wasm_module_set_name
that sets the module's name if possible.wasm_module_set_name
returnstrue
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).