(module $scheduler (type $func (;0;) (func)) (type $cont (;1;) (cont $func)) (type (;2;) (func (param (ref $cont)))) (type (;3;) (func (result i32))) (type (;4;) (func (result (ref null $cont)))) (type (;5;) (func (param (ref null $cont)))) (type (;6;) (func (result (ref $cont) (ref $cont)))) (import "lwt" "yield" (tag $yield (;0;) (type $func))) (import "lwt" "fork" (tag $fork (;1;) (type 2) (param (ref $cont)))) (import "queue" "queue-empty" (func $queue-empty (;0;) (type 3))) (import "queue" "dequeue" (func $dequeue (;1;) (type 4))) (import "queue" "enqueue" (func $enqueue (;2;) (type 2))) (export "sync" (func $sync)) (export "kt" (func $kt)) (export "tk" (func $tk)) (export "ykt" (func $ykt)) (export "ytk" (func $ytk)) (func $sync (;3;) (type 5) (param $nextk (ref null $cont)) local.get $nextk ref.is_null if ;; label = @1 return end block $on_yield (result (ref $cont)) block $on_fork (type 6) (result (ref $cont) (ref $cont)) local.get $nextk resume $cont (on $yield $on_yield) (on $fork $on_fork) call $dequeue return_call $sync end local.set $nextk call $enqueue local.get $nextk return_call $sync end return_call $sync ) (func $kt (;4;) (type 5) (param $nextk (ref null $cont)) local.get $nextk ref.is_null if ;; label = @1 return end block $on_yield (result (ref $cont)) block $on_fork (type 6) (result (ref $cont) (ref $cont)) local.get $nextk resume $cont (on $yield $on_yield) (on $fork $on_fork) call $dequeue return_call $tk end local.set $nextk call $enqueue local.get $nextk return_call $tk end call $enqueue call $dequeue return_call $tk ) (func $tk (;5;) (type 5) (param $nextk (ref null $cont)) local.get $nextk ref.is_null if ;; label = @1 return end block $on_yield (result (ref $cont)) block $on_fork (type 6) (result (ref $cont) (ref $cont)) local.get $nextk resume $cont (on $yield $on_yield) (on $fork $on_fork) call $dequeue return_call $kt end call $enqueue return_call $kt end call $enqueue call $dequeue return_call $kt ) (func $ykt (;6;) (type 5) (param $nextk (ref null $cont)) local.get $nextk ref.is_null if ;; label = @1 return end block $on_yield (result (ref $cont)) block $on_fork (type 6) (result (ref $cont) (ref $cont)) local.get $nextk resume $cont (on $yield $on_yield) (on $fork $on_fork) call $dequeue return_call $ykt end call $enqueue call $enqueue call $dequeue return_call $ykt end call $enqueue call $dequeue return_call $ykt ) (func $ytk (;7;) (type 5) (param $nextk (ref null $cont)) (local $k (ref $cont)) local.get $nextk ref.is_null if ;; label = @1 return end block $on_yield (result (ref $cont)) block $on_fork (type 6) (result (ref $cont) (ref $cont)) local.get $nextk resume $cont (on $yield $on_yield) (on $fork $on_fork) call $dequeue return_call $ytk end local.set $k call $enqueue local.get $k call $enqueue call $dequeue return_call $ytk end call $enqueue call $dequeue return_call $ytk ) )