On Fri, Sep 26, 2008 at 9:11 AM, Patrick R. Michaud (via RT)
<[EMAIL PROTECTED]> wrote:
> # New Ticket Created by  Patrick R. Michaud
> # Please include the string:  [perl #59374]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59374 >
>
>
> Summary:  pmc2c produces incorrect code for returning negative
> integer constants, as in RETURN(INTVAL -1)
>
>
> Longer description:  In the set_readline_interactive method of the
> ParrotIO PMC line 200 reads
>
>        RETURN(INTVAL -1);
>
> This is supposed to return a value of -1 when the method is called
> and the readline library is not present.  However, when run this is
> actually returning 1 (readline is not present in the example below):
>
>    $ cat z.pir
>    .sub main :main
>        .local pmc stdin
>
>        stdin = getstdin
>        $I0 = stdin.'set_readline_interactive'(1)
>        say $I0
>    .end
>    $ ./parrot z.pir
>    1
>
> Looking at the code generated in src/pmc/parrotio.c (line 775 on my
> system), we see:
>
>    /*BEGIN RETURN INTVAL -1 */
>    /*BEGIN GENERATED ACCESSORS */
> #line 777 "./src/pmc/parrotio.pmc"
>    CTX_REG_INT(_ctx, 0) = 1;
>
> I think somewhere the minus sign is being lost when the code is being
> generated.  This also occurs earlier in the method for a couple
> of instances of RETURN(INTVAL -2):
>
>    /*BEGIN RETURN INTVAL -2 */
>    /*BEGIN GENERATED ACCESSORS */
> #line 722 "./src/pmc/parrotio.pmc"
>    CTX_REG_INT(_ctx, 0) = 2;
>
> Pm
>

indeed. the code in parse_p_args_string in
lib/Parrot/Pmc2c/PCCMETHOD.pm was losing the minus sign. i've
committed a fix in r31441.

after the change:
  [EMAIL PROTECTED]:~/parrot/trunk$ ./parrot z.pir
  -1

~jerry

Reply via email to