mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
35 lines
565 B
Plaintext
35 lines
565 B
Plaintext
(module
|
|
(type $ii (func (param i32) (result i32)))
|
|
(global $HEAP_BASE i32 (i32.const 4))
|
|
(memory $0 1)
|
|
(export "fib" (func $recursive/fib))
|
|
(export "memory" (memory $0))
|
|
(func $recursive/fib (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
|
(if
|
|
(i32.le_s
|
|
(get_local $0)
|
|
(i32.const 1)
|
|
)
|
|
(return
|
|
(i32.const 1)
|
|
)
|
|
)
|
|
(return
|
|
(i32.add
|
|
(call $recursive/fib
|
|
(i32.sub
|
|
(get_local $0)
|
|
(i32.const 1)
|
|
)
|
|
)
|
|
(call $recursive/fib
|
|
(i32.sub
|
|
(get_local $0)
|
|
(i32.const 2)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|