(module (type $func (;0;) (func)) (type $cont (;1;) (cont $func)) (type (;2;) (func (param i32))) (type (;3;) (func (param i32 (ref $cont)))) (type (;4;) (func (param i32 (ref $cont)) (result i32))) (type (;5;) (func (param (ref $cont)) (result i32))) (type (;6;) (func (param i32) (result i32))) (type (;7;) (func (param i32 i32))) (import "spectest" "print_i32" (func $log (;0;) (type 2))) (import "examples" "naturals" (func $naturals (;1;) (type $func))) (import "examples" "fibonacci" (func $fibonacci (;2;) (type $func))) (import "examples" "one-two-three" (func $one-two-three (;3;) (type $func))) (import "examples" "print-first" (func $print-first (;4;) (type 3))) (import "examples" "sum-first" (func $sum-first (;5;) (type 4))) (import "manager" "init" (func $init (;6;) (type 5))) (import "manager" "next" (func $next (;7;) (type 6))) (export "main" (func $main)) (elem (;0;) declare func $naturals $fibonacci $one-two-three) (func $print-with-next (;8;) (type 7) (param $n i32) (param $gen i32) loop $l local.get $n i32.eqz if ;; label = @2 return end local.get $gen call $next call $log local.get $n i32.const -1 i32.add local.set $n br $l end ) (func $interleave-naturals-and-fib (;9;) (type $func) (local $gen1 i32) (local $gen2 i32) ref.func $naturals cont.new $cont call $init local.set $gen1 ref.func $fibonacci cont.new $cont call $init local.set $gen2 i32.const 5 local.get $gen1 call $print-with-next i32.const 5 local.get $gen2 call $print-with-next i32.const 5 local.get $gen1 call $print-with-next i32.const 5 local.get $gen2 call $print-with-next i32.const 5 local.get $gen1 call $print-with-next i32.const 5 local.get $gen2 call $print-with-next i32.const 5 local.get $gen1 call $print-with-next i32.const 5 local.get $gen2 call $print-with-next ) (func $main (;10;) (type $func) call $interleave-naturals-and-fib i32.const 42 ref.func $naturals cont.new $cont call $print-first i32.const 42 ref.func $fibonacci cont.new $cont call $print-first i32.const 101 ref.func $naturals cont.new $cont call $sum-first call $log i32.const 10 ref.func $one-two-three cont.new $cont call $sum-first call $log ) )