v2 / examples / wasm_codegen / add.v
13 lines · 12 sloc · 249 bytes · eeaaff218bbe695c655a6380963e2f82deadcb94
Raw
1import wasm
2
3fn main() {
4 mut m := wasm.Module{}
5 mut func := m.new_function('add', [.i32_t, .i32_t], [.i32_t])
6 {
7 func.local_get(0)
8 func.local_get(1)
9 func.add(.i32_t)
10 }
11 m.commit(func, true) // `export: true`
12 print(m.compile().bytestr())
13}
14