wasm-lang/test.wat
2023-10-02 18:27:33 -07:00

43 lines
671 B
Text

(module
(func $main (export "_start") (result i32)
(local $match i32)
(local $n i32)
i32.const -1
local.set $n
local.get $n
call $add_four
call $is_three
local.set $match
i32.const 1
local.get $match
i32.eq
(if (result i32) (then
i32.const 20
) (else
i32.const 0
local.get $match
i32.eq
(if (result i32) (then
i32.const 30
) (else unreachable
))))
)
(func $add_four (export "add_four") (param $n i32) (result i32)
(local $match i32)
local.get $n
i32.const 4
i32.add
)
(func $is_three (param $n i32) (result i32)
(local $match i32)
local.get $n
i32.const 3
i32.eq
)
(func $add_four_float (param $n f64) (result f64)
(local $match i32)
local.get $n
f64.const 4
f64.add
)
)