Piers Cawley <[EMAIL PROTECTED]> wrote:
> Jens Rieks <[EMAIL PROTECTED]> writes:
>> Hi,
>>
>> does the attached test use the Continuation in a correct way?
>> The test failes, what am I doing wrong?
> Without running it I'm guessing that it prints out something like
> 456=789
> 456=456
> 123=123
Why would it print 3 lines?
> Easy.
Brrr.
> One part of your problem (The state of P16-18) is, therefore, a bug in
> your program. The other part seems to be a bug in the current
> implementation of Continuation.
Yep.
> A new Continuation should grab the current P1 continuation. If you
> later invoke that Continuation, it should make the jump and reset
> P1. Until that's done, all we have is a heavyweight goto.
I don't get that. Below is a stripped down version of Jens program. There
are 2 ways of invokeing the return continuation:
invoke conti
or
conti()
The former is more or less ignored by imcc, the latter is recognized as
a regular function call: registers are preserved and a flag
"sub_calls_a_sub" is set, so that e.g. the return continuation is
preserved around the call. These variants give different output.
How schould it really work?
.sub _main
.local int a
a = 1
_func()
print a
print " main\n"
end
.end
.sub _func
.local pmc conti
.local int a
a = 4
conti = newcont _end
_do_something( conti )
_end:
print a
print " _func\n"
.end
.sub _do_something
.param pmc conti
.local int a
a = 7
# invoke conti # (1)
conti() # (2)
print "error!\n"
.end
Thanks,
leo