I try to refactor runtime/parrot/library/TAP/parser.pir with a generator (see attached patch)
this naive implementation :
.sub '_get_results'
.param pmc parser
.local pmc result
result = new 'ResizablePMCArray'
L1:
$P0 = parser.'next'()
if null $P0 goto L2
diag($P0)
push result, $P0
goto L1
L2:
.return (result)
.end
cannot work with more than 1 file.
And fails at the beginning of second file with the message :
Cannot resume dead coroutine.
this other implementation with a Coroutine PMC :
.sub '_get_results'
.param pmc parser
.local pmc result
result = new 'ResizablePMCArray'
$P0 = get_hll_global ['TAP';'Parser'], 'next'
.local pmc coro
coro = new 'Coroutine', $P0
L1:
$P0 = coro(parser)
if null $P0 goto L2
diag($P0)
push result, $P0
goto L1
L2:
.return (result)
.end
fails with the message :
exists_keyed_str() not implemented in class 'Coroutine'
Something seems to be broken and parrot lacks of tests for this part.
Any idea or help is welcome.
François
generator.patch
Description: Binary data
_______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev
