wasm-lang/test.wat

44 lines
671 B
Text
Raw Normal View History

2023-10-03 01:27:33 +00:00
(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
)
)