You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(module$generator
(type$ft (func))
;; Types of continuations used by the generator:;; No need for param or result types: No data passed back to the;; generator when resuming it, and $generator function has no return;; values.
(type$ct (cont $ft))
(func$print (import"spectest""print_i32") (parami32))
;; Tag used to coordinate between generator and consumer: The i32 param;; corresponds to the generated values passed; no values passed back from;; generator to consumer.
(tag $gen (parami32))
;; Simple generator yielding values from 100 down to 1
(func$generator
(local$ii32)
(local.set$i (i32.const100))
(loop$l;; Suspend execution, pass current value of $i to consumer
(suspend $gen (local.get$i))
;; Decrement $i and exit loop once $i reaches 0
(local.tee$i (i32.sub (local.get$i) (i32.const1)))
(br_if$l)
)
)
(elemdeclarefunc$generator)
(func$consumer
(local$c (ref$ct))
;; Create continuation executing function $generator.;; Execution only starts when resumed for the first time.
(local.set$c (cont.new $ct (ref.func$generator)))
;; (call $print (i32.const 42))
(loop$loop
(block$on_gen (resulti32 (ref$ct))
;; Resume continuation $c
(resume $ct (on $gen$on_gen) (local.get$c))
(call$print (i32.const42))
;; $generator returned: no more data
(return)
)
;; Generator suspended, stack now contains [i32 (ref $ct)];; Save continuation to resume it in the next iteration
(local.set$c)
;; Stack now contains the i32 value produced by $generator
(call$print)
(br$loop)
)
)
(start$consumer)
)
The text was updated successfully, but these errors were encountered:
Thanks for the report. I think this is an instance of the same issue as wasmfx/wasmfx-tools#96 -- I'll eventually get around to fixing it. Just to check, is it blocking progress for whatever you are working on (I suppose the workaround is to rewrite everything to folded form)?
Thanks for the report. I think this is an instance of the same issue as wasmfx/wasmfx-tools#96 -- I'll eventually get around to fixing it. Just to check, is it blocking progress for whatever you are working on (I suppose the workaround is to rewrite everything to folded form)?
Thanks for the pointer. I believe it's a parsing issue in the reference interpreter. It's not blocking progress on my side. A workaround is to wrap resume 1 (on 0 0 (;@2;)) with another pair of brackets.
Hi,
The following
gen.wast
taken from stack-switching explainer can't be parsed in the reference interpreter when unfoldedIt gives me the following syntax error:
Here's the working folded version
The text was updated successfully, but these errors were encountered: