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, I'm doing exactly the same thing
for the return 1 and return 0 branches... But the output
of this program is: 

   "1 get_string() not implemented in class 'Continuation'\n"

Calling f(0) causes the bug even if f(1) isn't called first.
I think this is a bug in parrot's register allocation scheme.

Or am I just doing something stupid? :)


BTW: It would be SO nice if parrot could print a line 
number for ALL its error messages. (Or if the debugger
didn't segfault <g>)


######################################

.sub __main__
    new_pad 0
    setline 1
    newsub $P0, .Sub, _sub0
    store_lex -1, 'f', $P0
    .local object arg0
    arg0 = new PerlInt
    arg0 = 1
    find_lex $P2, 'f'
    newsub $P3, .Continuation, ret0
    .pcc_begin non_prototyped
    .arg arg0
    .pcc_call $P2, $P3
ret0:
    .result $P1
    .pcc_end
    .arg $P1
    call __py__print
    print " "
    .local object arg1
    arg1 = new PerlInt
    arg1 = 0
    find_lex $P5, 'f'
    newsub $P6, .Continuation, ret1
    .pcc_begin non_prototyped
    .arg arg1
    .pcc_call $P5, $P6
ret1:
    .result $P4
    .pcc_end
    .arg $P4
    call __py__print
    print "\n"
    end
.end
.include 'pirate.imc'

# f from line 1
.pcc_sub _sub0 non_prototyped
    .param object x
    setline 2
    .local object test0
    test0 = new PerlInt
    test0 = x
    unless test0 goto elif0  ### if x return 1
    .local object res0       
    res0 = new PerlInt
    res0 = 1
    .pcc_begin_return
    .return res0
    .pcc_end_return
    goto endif0
elif0:                       ### else return 0
    .local object res1
    res1 = new PerlInt
    res1 = 0
    .pcc_begin_return
    .return res1
    .pcc_end_return
endif0:
.end

######################################


Sincerely,
 
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: [EMAIL PROTECTED]
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
--------------------------------------


Reply via email to