On 5/17/07, Klaas-Jan Stol <[EMAIL PROTECTED]> wrote:


On 5/17/07, Mehmet Yavuz Selim Soyturk <[EMAIL PROTECTED]> wrote:
> On 5/17/07, via RT Jerry Gay
<[EMAIL PROTECTED]> wrote:
> > # New Ticket Created by  Jerry Gay
> > # Please include the string:  [perl #42974]
> > # in the subject line of all future correspondence about this issue.
> > # <URL:
http://rt.perl.org/rt3/Ticket/Display.html?id=42974 >
> >
> >
> > it looks like the register alligator is eating integers in this code:
> >
> > .const int TESTS = 2
> >
> > .sub 'main' :main
> >     load_bytecode 'Test/More.pir'
> >     .local pmc exp, test_ns
> >     test_ns = get_namespace ['Test::More']
> >     exp     = new 'Exporter'
> >     exp.'source'(test_ns)
> >     exp.'import'('plan ok is diag isa_ok' :named('globals'))
> >
> >     plan(TESTS)
> >
> >     .local pmc attrs
> >     attrs = new 'Hash'
> >
> >     .local pmc red, green, blue
> >     attrs['name'] = 'Red'
> >     red           = new 'Role', attrs
> >
> >     attrs['name'] = 'Green'
> >     green         = new 'Role', attrs
> >
> >     attrs['name'] = 'Blue'
> >     blue          = new 'Role', attrs
> >
> >     green.'add_role'( blue )
> >
> >     .local pmc color
> >     color = new 'Class'
> >
> >     $S0 = 'Red'
> >     $I0 = color.'does'($S0)
> >     is($I0, 0, 'does not Red')
> >
> >     color.'add_role'( red )
> >     $I0 = color.'does'($S0)
> >     is($I0, 1, 'does Red')
> > .end
> >
> >
> > which produces:
> >
> > 1..2
> > ok 1 - does not Red
> > not ok 2 - does Red
> > # Received: -888
> > # Expected: 1
> >
> >
> > either something's fishy in the PCCRETURN code, or the register
> > allocator. the -888 is a dead giveaway that an integer register has
> > been eaten. it's possible it's isolated in code called from the
> > 'add_role' method in the Class PMC... this bug is preventing me from
> > testing that code.
> >
> > ~jerry
> >
>
> The following patch solves that issue.
>
> --- src/pmc/class.pmc   (revision 18568)
> +++ src/pmc/class.pmc   (working copy)
> @@ -1111,8 +1111,9 @@
>              PMC    *role     =
VTABLE_get_pmc_keyed_int(interp, role_list, i);
>              (STRING *r_name) = PCCINVOKE(interp, role, "name");
>
> -            if (string_compare(interp, role_name, r_name))
> +            if (string_compare(interp, role_name, r_name) == 0) {
>                  PCCRETURN(INTVAL 1);
> +            }
>          }
>
>          PCCRETURN(INTVAL 0);
>
>
> --
> Mehmet
>


Mmmm, is string_compare a wrapper for strcmp() ? Or is it a wrapper that
reverses the result? (so return true if they're equal). In /that/ case,
!string_compare() would be nicer. (my point being, if string_compare() is
part of parrot source code, why not try and make it more sensible/readable).
(I understand why the result values are the way they are for strcmp, but i
never liked them)

kjs

I think that it's analogous to strcmp, but for the STRING* type. I
looked now at string_funcs.h, there is in fact a string_equal
function.

By the way, that wasn't the only issue. PCCRETURN expands to multiple
statements, so the curly braces are needed after the if test. Would it
not be better if PCCRETURN did it itself?


--
Mehmet

Reply via email to