wasm2c generates functions that construct and free a w2c_fac instance: wasm2c_fac_instantiate and wasm2c_fac_free. The first is w2c_fac, a type that represents an instance of the fac module. Wasm2c generates a few C symbols based on the fac.wasm module. To actually use our fac module, we'll use create a new file, main.c, that include fac.h, initializes the module, and calls fac. We‘ll take a closer look at these files below, but first let’s show a simple example of how to use these files. This generates two files, fac.c and fac.h. We can then convert it to a C source and header by using the wasm2c tool: $ wasm2c fac. wasm file by using the wat2wasm tool: $ wat2wasm fac. ( memory $mem 1 ) ( func ( export "fac" ) ( param $x i32 ) ( result i32 ) ( if ( result i32 ) ( i32. Let's look at a simple example of a factorial function. # parse test.wasm, write test.c and test.h, but ignore the debug names, if any Some examples: # parse binary file test.wasm and write test.c and test.h Wasm2c takes a WebAssembly module and produces an equivalent C source and header. Wasm2c: Convert wasm files to C source and header
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |