2017-12-02 18:37:59 +01:00
|
|
|
(module
|
|
|
|
(type $ii (func (param i32) (result i32)))
|
2018-04-24 23:11:11 +02:00
|
|
|
(type $i (func (result i32)))
|
2018-02-04 07:51:40 +01:00
|
|
|
(type $iiiiv (func (param i32 i32 i32 i32)))
|
2018-01-12 15:36:17 +01:00
|
|
|
(type $v (func))
|
2018-02-04 07:51:40 +01:00
|
|
|
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
2018-02-14 09:18:43 +01:00
|
|
|
(global $HEAP_BASE i32 (i32.const 20))
|
2017-12-02 18:37:59 +01:00
|
|
|
(memory $0 1)
|
2018-02-14 09:18:43 +01:00
|
|
|
(data (i32.const 4) "\05\00\00\00i\00f\00.\00t\00s\00")
|
2017-12-02 23:33:01 +01:00
|
|
|
(export "ifThenElse" (func $if/ifThenElse))
|
|
|
|
(export "ifThen" (func $if/ifThen))
|
|
|
|
(export "ifThenElseBlock" (func $if/ifThenElseBlock))
|
2018-01-19 04:16:18 +01:00
|
|
|
(export "ifAlwaysReturns" (func $if/ifAlwaysReturns))
|
2017-12-02 18:37:59 +01:00
|
|
|
(export "memory" (memory $0))
|
2018-01-12 15:36:17 +01:00
|
|
|
(start $start)
|
2018-02-04 07:51:40 +01:00
|
|
|
(func $if/ifThenElse (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
2017-12-02 18:37:59 +01:00
|
|
|
(if
|
|
|
|
(get_local $0)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(return
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(func $if/ifThen (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
2017-12-02 18:37:59 +01:00
|
|
|
(if
|
|
|
|
(get_local $0)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(return
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(func $if/ifThenElseBlock (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
2017-12-02 18:37:59 +01:00
|
|
|
(if
|
|
|
|
(get_local $0)
|
|
|
|
(block
|
|
|
|
(nop)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(block
|
|
|
|
(nop)
|
|
|
|
(return
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(func $if/ifAlwaysReturns (; 4 ;) (type $ii) (param $0 i32) (result i32)
|
2018-01-19 04:16:18 +01:00
|
|
|
(if
|
|
|
|
(get_local $0)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
2018-04-11 23:35:19 +02:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
|
|
|
(i32.const 4)
|
|
|
|
(i32.const 37)
|
|
|
|
(i32.const 4)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-19 04:16:18 +01:00
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(func $start (; 5 ;) (type $v)
|
2018-01-12 15:36:17 +01:00
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThenElse
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 8)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThenElse
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 9)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThen
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 17)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThen
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 18)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThenElseBlock
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 30)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
(if
|
|
|
|
(i32.eqz
|
|
|
|
(i32.eq
|
|
|
|
(call $if/ifThenElseBlock
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-02-04 07:51:40 +01:00
|
|
|
(block
|
|
|
|
(call $abort
|
|
|
|
(i32.const 0)
|
2018-02-14 09:18:43 +01:00
|
|
|
(i32.const 4)
|
2018-02-04 07:51:40 +01:00
|
|
|
(i32.const 31)
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
(unreachable)
|
|
|
|
)
|
2018-01-12 15:36:17 +01:00
|
|
|
)
|
|
|
|
)
|
2017-12-02 18:37:59 +01:00
|
|
|
)
|