(module $scheduler (type $func (;0;) (func)) (type $cont (;1;) (cont $func)) (type $cont-func (;2;) (func (param (ref $cont)))) (type $cont-cont (;3;) (cont $cont-func)) (type $func-cont-func-func (;4;) (func (param (ref $func) (ref $cont-func)))) (type $func-cont-func-cont (;5;) (cont $func-cont-func-func)) (type $func-cont-cont (;6;) (func (param (ref $cont) (ref $cont)))) (type $cont-cont-func (;7;) (cont $func-cont-cont)) (type (;8;) (func (param i32))) (type (;9;) (func (result i32))) (type (;10;) (func (result (ref null $cont)))) (type (;11;) (func (param (ref $cont-cont)))) (type (;12;) (func (param (ref null $cont)))) (type (;13;) (func (param (ref $func-cont-func-cont)))) (import "spectest" "print_i32" (func $log (;0;) (type 8))) (import "queue" "queue-empty" (func $queue-empty (;1;) (type 9))) (import "queue" "dequeue" (func $dequeue (;2;) (type 10))) (import "queue" "enqueue" (func $enqueue (;3;) (type $cont-func))) (import "control" "control" (tag $control (;0;) (type 11) (param (ref $cont-cont)))) (import "control" "prompt" (func $prompt (;4;) (type 12))) (export "sync" (func $sync)) (export "kt" (func $kt)) (export "tk" (func $tk)) (export "ykt" (func $ykt)) (export "ytk" (func $ytk)) (elem (;0;) declare func $handle-yield-sync $handle-yield $handle-fork-sync $handle-fork-kt $handle-fork-tk $handle-fork-ykt $handle-fork-ytk $yield $fork-sync $fork-kt $fork-tk $fork-ykt $fork-ytk) (func $scheduler (;5;) (type 12) (param $nextk (ref null $cont)) loop $loop local.get $nextk ref.is_null if ;; label = @2 return end local.get $nextk call $prompt call $dequeue local.set $nextk br $loop end ) (func $handle-yield-sync (;6;) (type $cont-func) (param $k (ref $cont)) local.get $k call $scheduler ) (func $yield-sync (;7;) (type $func) ref.func $handle-yield cont.new $cont-cont suspend $control ) (func $handle-fork-sync (;8;) (type $func-cont-cont) (param $t (ref $cont)) (param $k (ref $cont)) local.get $t call $enqueue local.get $k call $scheduler ) (func $fork-sync (;9;) (type $cont-func) (param $t (ref $cont)) local.get $t ref.func $handle-fork-sync cont.new $cont-cont-func cont.bind $cont-cont-func $cont-cont suspend $control ) (func $sync (;10;) (type 13) (param $k (ref $func-cont-func-cont)) ref.func $yield ref.func $fork-sync local.get $k cont.bind $func-cont-func-cont $cont call $scheduler ) (func $handle-yield (;11;) (type $cont-func) (param $k (ref $cont)) local.get $k call $enqueue call $dequeue call $scheduler ) (func $yield (;12;) (type $func) ref.func $handle-yield cont.new $cont-cont suspend $control ) (func $handle-fork-kt (;13;) (type $func-cont-cont) (param $t (ref $cont)) (param $k (ref $cont)) local.get $t call $enqueue local.get $k call $scheduler ) (func $fork-kt (;14;) (type $cont-func) (param $t (ref $cont)) local.get $t ref.func $handle-fork-kt cont.new $cont-cont-func cont.bind $cont-cont-func $cont-cont suspend $control ) (func $kt (;15;) (type 13) (param $k (ref $func-cont-func-cont)) ref.func $yield ref.func $fork-kt local.get $k cont.bind $func-cont-func-cont $cont call $scheduler ) (func $handle-fork-tk (;16;) (type $func-cont-cont) (param $t (ref $cont)) (param $k (ref $cont)) local.get $k call $enqueue local.get $t call $scheduler ) (func $fork-tk (;17;) (type $cont-func) (param $t (ref $cont)) local.get $t ref.func $handle-fork-tk cont.new $cont-cont-func cont.bind $cont-cont-func $cont-cont suspend $control ) (func $tk (;18;) (type 13) (param $k (ref $func-cont-func-cont)) ref.func $yield ref.func $fork-tk local.get $k cont.bind $func-cont-func-cont $cont call $scheduler ) (func $handle-fork-ykt (;19;) (type $func-cont-cont) (param $t (ref $cont)) (param $k (ref $cont)) local.get $k call $enqueue local.get $t call $enqueue call $dequeue call $scheduler ) (func $fork-ykt (;20;) (type $cont-func) (param $t (ref $cont)) local.get $t ref.func $handle-fork-ykt cont.new $cont-cont-func cont.bind $cont-cont-func $cont-cont suspend $control ) (func $ykt (;21;) (type 13) (param $k (ref $func-cont-func-cont)) ref.func $yield ref.func $fork-ykt local.get $k cont.bind $func-cont-func-cont $cont call $scheduler ) (func $handle-fork-ytk (;22;) (type $func-cont-cont) (param $t (ref $cont)) (param $k (ref $cont)) local.get $t call $enqueue local.get $k call $enqueue call $dequeue call $scheduler ) (func $fork-ytk (;23;) (type $cont-func) (param $t (ref $cont)) local.get $t ref.func $handle-fork-ytk cont.new $cont-cont-func cont.bind $cont-cont-func $cont-cont suspend $control ) (func $ytk (;24;) (type 13) (param $k (ref $func-cont-func-cont)) ref.func $yield ref.func $fork-ytk local.get $k cont.bind $func-cont-func-cont $cont call $scheduler ) )