(module $actor-as-lwt (type $func (;0;) (func)) (type $cont (;1;) (cont $func)) (type $i-func (;2;) (func (param i32))) (type $i-cont (;3;) (cont $i-func)) (type $icont-func (;4;) (func (param i32 (ref $cont)))) (type $icont-cont (;5;) (cont $icont-func)) (type (;6;) (func (param (ref $cont)))) (type (;7;) (func (param i32) (result i32))) (type (;8;) (func (result i32))) (type (;9;) (func (param i32 i32))) (type (;10;) (func (param (ref $cont)) (result i32))) (type (;11;) (func (param i32 i32 (ref $i-cont)))) (type (;12;) (func (result (ref $cont) (ref $i-cont)))) (type (;13;) (func (result i32 i32 (ref $cont)))) (import "spectest" "print_i32" (func $log (;0;) (type $i-func))) (import "lwt" "yield" (tag $yield (;0;) (type $func))) (import "lwt" "fork" (tag $fork (;1;) (type 6) (param (ref $cont)))) (import "mailboxes" "init" (func $init (;1;) (type $func))) (import "mailboxes" "empty-mb" (func $empty-mb (;2;) (type 7))) (import "mailboxes" "new-mb" (func $new-mb (;3;) (type 8))) (import "mailboxes" "send-to-mb" (func $send-to-mb (;4;) (type 9))) (import "mailboxes" "recv-from-mb" (func $recv-from-mb (;5;) (type 7))) (import "actor" "self" (tag $self (;2;) (type 8) (result i32))) (import "actor" "spawn" (tag $spawn (;3;) (type 10) (param (ref $cont)) (result i32))) (import "actor" "send" (tag $send (;4;) (type 9) (param i32 i32))) (import "actor" "recv" (tag $recv (;5;) (type 8) (result i32))) (export "act" (func $act)) (elem (;0;) declare func $act-nullary $act-res) (func $act-res (;6;) (type 11) (param $mine i32) (param $res i32) (param $ik (ref $i-cont)) (local $yours i32) (local $k (ref $cont)) (local $you (ref $cont)) block $on_self (result (ref $i-cont)) block $on_spawn (type 12) (result (ref $cont) (ref $i-cont)) block $on_send (type 13) (result i32 i32 (ref $cont)) block $on_recv (result (ref $i-cont)) local.get $res local.get $ik resume $i-cont (on $self $on_self) (on $spawn $on_spawn) (on $send $on_send) (on $recv $on_recv) return end local.set $ik loop $l local.get $mine call $empty-mb if ;; label = @5 suspend $yield br $l end end local.get $mine call $recv-from-mb local.set $res local.get $mine local.get $res local.get $ik return_call $act-res end local.set $k call $send-to-mb local.get $mine local.get $k return_call $act-nullary end local.set $ik local.set $you call $new-mb local.set $yours local.get $yours local.get $you ref.func $act-nullary cont.new $icont-cont cont.bind $icont-cont $cont suspend $fork local.get $mine local.get $yours local.get $ik return_call $act-res end local.set $ik local.get $mine local.get $mine local.get $ik return_call $act-res ) (func $act-nullary (;7;) (type $icont-func) (param $mine i32) (param $k (ref $cont)) (local $res i32) (local $ik (ref $i-cont)) (local $you (ref $cont)) (local $yours i32) block $on_self (result (ref $i-cont)) block $on_spawn (type 12) (result (ref $cont) (ref $i-cont)) block $on_send (type 13) (result i32 i32 (ref $cont)) block $on_recv (result (ref $i-cont)) local.get $k resume $cont (on $self $on_self) (on $spawn $on_spawn) (on $send $on_send) (on $recv $on_recv) return end local.set $ik loop $l local.get $mine call $empty-mb if ;; label = @5 suspend $yield br $l end end local.get $mine call $recv-from-mb local.set $res local.get $mine local.get $res local.get $ik return_call $act-res end local.set $k call $send-to-mb local.get $mine local.get $k return_call $act-nullary end local.set $ik local.set $you call $new-mb local.set $yours local.get $yours local.get $you ref.func $act-nullary cont.new $icont-cont cont.bind $icont-cont $cont suspend $fork local.get $mine local.get $yours local.get $ik return_call $act-res end local.set $ik local.get $mine local.get $mine local.get $ik return_call $act-res ) (func $act (;8;) (type 6) (param $k (ref $cont)) call $init call $new-mb local.get $k call $act-nullary ) )