I am compiling my Rust code which has a linked in C++ static library to wasm32-unknown-emcc. Out of curiosity, I converted the generated wasm file to a .wat file for better readability and saw this at the top. I understand the last line, as I can see the invoke_viii
being defined in the accompanying .js file. Where can I find the function definitions/documentation about the top 18 function declarations?
(module
(type (;0;) (func (param i32 i32) (result i32)))
(type (;1;) (func (param i32) (result i32)))
(type (;2;) (func (param i32 i32)))
(type (;3;) (func (param i32 i32 i32) (result i32)))
(type (;4;) (func (param i32)))
(type (;5;) (func (param i32 i32 i32)))
(type (;6;) (func (param i32 i32 i32 i32)))
(type (;7;) (func))
(type (;8;) (func (param i32 i32 i32 i32 i32)))
(type (;9;) (func (result i32)))
(type (;10;) (func (param i32 i32 i32 i32) (result i32)))
(type (;11;) (func (param i32) (result i64)))
(type (;12;) (func (param i32 i32 i32 i32 i32 i32)))
(type (;13;) (func (param i32 i32 i32 i32 i32 i32) (result i32)))
(type (;14;) (func (param i32 i32 i32 i32 i32 i32 i32)))
(type (;15;) (func (param i32 i32 i32 i32 i32) (result i32)))
(type (;16;) (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
(type (;17;) (func (param i64 i32 i32) (result i32)))
(type (;18;) (func (param i32 i32 i32 i32 i32 i32 i32 i32)))
(import "env" "invoke_viii" (func $invoke_viii (type 6)))
// More stuff below
Those aren't function declarations, they're type declarations declaring the types of functions.
(import "env" "invoke_viii" (func $invoke_viii (type 6)))
This is importing the function named "invoke_viii" and the type of that function is type 6, this one:
(type (;6;) (func (param i32 i32 i32 i32)))
In your .wat file the (func ...)
declarations (whether inside an import
or not) are your function declarations and definitions.