-
Notifications
You must be signed in to change notification settings - Fork 4
/
sample.wat
34 lines (30 loc) · 906 Bytes
/
sample.wat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(module (type $return_true? (func (param $x i32) (result i32)))
(func $true_QMARK_ (param $x i32) (result i32)
(i32.eq
(i32.const 1)
(local.get $x)))
(export "$true_QMARK_" (func $true_QMARK_))(type $return_false? (func (param $x i32) (result i32)))
(func $false_QMARK_ (param $x i32) (result i32)
(i32.eq
(i32.const 0)
(local.get $x)))
(export "$false_QMARK_" (func $false_QMARK_))(type $return_add (func (param $a i32) (param $b i32) (result i32)))
(func $add (param $a i32) (param $b i32) (result i32)(local $x i32)
(block (result i32)
(local.set $x
(i32.const 1))
(if (result i32) (i32.eq
(local.get $x)
(local.get $a))
(then (i32.add
(local.get $x)
(local.get $a)))
(else (i32.add
(local.get $b)
(local.get $a))))))
(export "$add" (func $add))(type $return_main (func (result i32)))
(func $main (result i32)
(call $add
(i32.const 9)
(i32.const 8)))
(export "main" (func $main)))