Re: parrot bug: continuations/multiple return

2003-08-14 Thread Leopold Toetsch
Michal Wallace wrote: def f(x): if x: return 1 else: return 0 print f(1), f(0) Nice coincidence. S. Togos' bug report too. Anyway, its already fixed. leo

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Leopold Toetsch
Piers Cawley <[EMAIL PROTECTED]> wrote: > Leopold Toetsch <[EMAIL PROTECTED]> writes: >> As calling conventions clearly state, that the caller has to save >> everything, its probably up to imcc/pcc.c to insert above >> statements, if another sub gets called from a sub. I'll fix that in >> a minute

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Michal Wallace
On Sun, 10 Aug 2003, Leopold Toetsch wrote: > Piers Cawley <[EMAIL PROTECTED]> wrote: > > Leopold Toetsch <[EMAIL PROTECTED]> writes: > >> As calling conventions clearly state, that the caller has to save > >> everything, its probably up to imcc/pcc.c to insert above > >> statements, if another su

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Leopold Toetsch
Benjamin Goldberg <[EMAIL PROTECTED]> wrote: > This is where .macro comes in handy :) >.macro lexical(name_in_pad, register_name) > local .register_name > find_lex .register_name, .name_in_pad >.endm Macros are currently enabled for PASM mode only. But there is no special rea

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Leopold Toetsch
Michal Wallace <[EMAIL PROTECTED]> wrote: > On Sun, 10 Aug 2003, Leopold Toetsch wrote: >> Piers Cawley <[EMAIL PROTECTED]> wrote: >> > If and only if that's not a tail call of course. >> >> Good point. But I can imagine, that's by far more simple to detect tail >> calls at the AST level > Well,

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Michal Wallace
On Sat, 9 Aug 2003, Leopold Toetsch wrote: > As calling conventions clearly state, that the caller has to save > everything, its probably up to imcc/pcc.c to insert above statements, if > another sub gets called from a sub. I'll fix that in a minute ;-) I just synced up with cvs and now everyth

Tail calls (was: parrot bug: continuations/multiple return)

2003-08-14 Thread Leopold Toetsch
Piers Cawley <[EMAIL PROTECTED]> wrote: > I'm not sure you can optimize it to a jump opcode when you're tail > calling another function can you? You could be tailcalling into a > closure so you'll need to use invoke to do the right thing with the > lexical stack etc. Argh, yes. What about: If th

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Leopold Toetsch
Michal Wallace wrote: Gosh you're quick. Thanks! Welcome Want another one? :) Always. def g(): return 0 def f(): return g() print f() This prints: 'No more I register frames to pop!' The return continuation P1 in f() isnt preserved. # f from line 3 .p

Re: parrot bug: continuations/multiple return

2003-08-14 Thread Michal Wallace
On Sat, 9 Aug 2003, Benjamin Goldberg wrote: > Michal Wallace wrote: > [snip] > > def f(): > > return g() > [snip] > > # f from line 3 > > .pcc_sub _sub1 non_prototyped > > .local object res1# (visitReturn:528) > > find_lex $P2, 'g' # (callingExpress

parrot bug: continuations/multiple return

2003-08-11 Thread Michal Wallace
Hey all, Sorry for the huge code listing here, but I don't have a simpler case. This is what pirate outputs when it compiles the following program: def f(x): if x: return 1 else: return 0 print f(1), f(0) As far as I can tell,

Re: parrot bug: continuations/multiple return

2003-08-11 Thread Piers Cawley
Leopold Toetsch <[EMAIL PROTECTED]> writes: > Piers Cawley <[EMAIL PROTECTED]> wrote: >> Leopold Toetsch <[EMAIL PROTECTED]> writes: >>> As calling conventions clearly state, that the caller has to save >>> everything, its probably up to imcc/pcc.c to insert above >>> statements, if another sub ge

Re: parrot bug: continuations/multiple return

2003-08-10 Thread Michal Wallace
On Sat, 9 Aug 2003, Leopold Toetsch wrote: > Nice coincidence. S. Togos' bug report too. > Anyway, its already fixed. Gosh you're quick. Thanks! Want another one? :) def g(): return 0 def f(): return g() print f() This prints: 'No more I register frame

Re: parrot bug: continuations/multiple return

2003-08-10 Thread Benjamin Goldberg
Michal Wallace wrote: > Benjamin Goldberg wrote: > > Michal Wallace wrote: [snip] > > Also... why is $P2 merely an imcc temporary, without a real name? > > That is, why not do: > > > > .pcc_sub _sub1 non_prototyped > > .local object sub1 > > find_lex sub1, 'g' > > .pcc_begin non_protot

Re: parrot bug: continuations/multiple return

2003-08-10 Thread Benjamin Goldberg
Michal Wallace wrote: [snip] > def f(): > return g() [snip] > # f from line 3 > .pcc_sub _sub1 non_prototyped > .local object res1# (visitReturn:528) > find_lex $P2, 'g' # (callingExpression:325) > newsub $P3, .Continuation, ret0# (callingExpressi

Re: parrot bug: continuations/multiple return

2003-08-09 Thread Piers Cawley
Leopold Toetsch <[EMAIL PROTECTED]> writes: > As calling conventions clearly state, that the caller has to save > everything, its probably up to imcc/pcc.c to insert above > statements, if another sub gets called from a sub. I'll fix that in > a minute ;-) If and only if that's not a tail call of