That's a record with 3 fields, its constructor and getters using the GC extension:
;; A `struct` with 3 fields, all immutable.
(type $testStruct
(struct
(field $first i64)
(field $foo f32)
(field $baz f64)))
;; Constructor. `ref` is a reference
(func $mkTestStruct
(param $a i64) (param $b f32) (param $c f64) (result (ref $testStruct))
(struct.new $testStruct (local.get $a) (local.get $b) (local.get $c)))
(export "mkTestStruct" (func $mkTestStruct))
;; Getter function for the three fields:
(func $getTestStruct1 (param $rs (ref $testStruct)) (result i64)
(struct.get $testStruct 0 (local.get $rs)))
(export "getTestStruct1" (func $getTestStruct1))
(func $getTestStruct2 (param $rs (ref $testStruct)) (result f32)
(struct.get $testStruct 1 (local.get $rs)))
(export "getTestStruct2" (func $getTestStruct2))
(func $getTestStruct3 (param $rs (ref $testStruct)) (result f64)
(struct.get $testStruct 2 (local.get $rs)))
(export "getTestStruct3" (func $getTestStruct3))My initial motivation to learn WASM (as someone from a primarily web background) was that I had a pretty poor understanding of WASM in general and so I had a lot of difficulty working with WASM builds in just about any capacity other than a heavy JS wrapper.
There are aspects to how WASM works that are quite different from other kinds of assembly formats that make learning the basics pretty important. e.g. how memory is requested, provided, grown. How functions are received and exported. Capabilities of tables.
A lot of this might be abstracted by massive wrappers, but you're losing a lot in perf and debugability when using them.
By limitations I mean things that a POSIX program would expect that aren't generally available from WASM, like network programming, file system access, processes and threads, pipes and signals. Emscripten and WASI help to some extent, but the replacement APIs are rarely fully compatible.
You are embedding a WASM engine and want to better grok how the import or exporting works.
You are writing a compiler that targets WASM.
Eventually I moved the whole game engine into wasm & at that point it all got ported to Rust
https://github.com/serprex/openEtG/blob/8b7069cc52ec8db3406a...