diff options
author | Keith Winstein <keithw@cs.stanford.edu> | 2023-02-23 13:45:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 21:45:08 +0000 |
commit | 046451f9091083148f810c5932543fb805b17f4e (patch) | |
tree | 7d45728b69612ab82186c1c5d8ee701e1e4ffc73 /wasm2c/examples/fac/main.c | |
parent | 4bf38aaefa33bcf89a8e707b406c49090c5a00e3 (diff) | |
download | wabt-046451f9091083148f810c5932543fb805b17f4e.tar.gz wabt-046451f9091083148f810c5932543fb805b17f4e.tar.bz2 wabt-046451f9091083148f810c5932543fb805b17f4e.zip |
wasm2c: prettify/change name mangling (#2142)
* wasm2c: prettify/change name-mangling
This refactors the wasm2c name-mangling in two big ways:
1) Removing the `Z_` prefix and trying to make the names somewhat
ergonomic/pretty. Previously the `factorial` export from a `fac`
module looked like this:
```
u32 Z_facZ_factorial(Z_fac_instance_t*, u32);
```
After this commit, it looks like this:
```
u32 w2c_fac_factorial(w2c_fac*, u32);
```
Symbols defined by wasm2c itself (including instantiate, free,
get_func_type and the imported memory limits) are now prefixed with
`wasm2c_` to avoid conflicting with names defined by the module.
2) Using globally unique (module-prefixed) names for functions, types,
segments, and tags, even though they are currently static
(internal-linkage) symbols in the .c output. This is preparation for
a future "multiple .c output" option where these symbols will need to
have external linkage.
Diffstat (limited to 'wasm2c/examples/fac/main.c')
-rw-r--r-- | wasm2c/examples/fac/main.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/wasm2c/examples/fac/main.c b/wasm2c/examples/fac/main.c index 37593f6e..eb85376e 100644 --- a/wasm2c/examples/fac/main.c +++ b/wasm2c/examples/fac/main.c @@ -18,19 +18,19 @@ int main(int argc, char** argv) { wasm_rt_init(); /* Declare an instance of the `fac` module. */ - Z_fac_instance_t instance; + w2c_fac fac; /* Construct the module instance. */ - Z_fac_instantiate(&instance); + wasm2c_fac_instantiate(&fac); /* Call `fac`, using the mangled name. */ - u32 result = Z_facZ_fac(&instance, x); + u32 result = w2c_fac_fac(&fac, x); /* Print the result. */ printf("fac(%u) -> %u\n", x, result); /* Free the fac module. */ - Z_fac_free(&instance); + wasm2c_fac_free(&fac); /* Free the Wasm runtime state. */ wasm_rt_free(); |