The original problem description is a little off: this works for core
Integer type, but not for the parrotObject subclass.

I was able to use gdb to break in the function called by the cmp op,
and then step through to find which actual function this was being
sent to via MMD. It was using Integer's 'cmp', in the DEFAULT branch,
which assumes things about the storage of SELF which are apparently
not true.

I suspect that if this is the right fix (see below), that we need to
replace this usage throughout the core PMCs, or subclassing is going
to break in all sorts of odd places.

$ svn diff src
Index: src/pmc/integer.pmc
===================================================================
--- src/pmc/integer.pmc (revision 27433)
+++ src/pmc/integer.pmc (working copy)
@@ -1174,7 +1174,7 @@
         }
 MMD_DEFAULT: {
             /* int or undef */
-            const INTVAL diff = PMC_int_val(SELF)
+            const INTVAL diff = VTABLE_get_integer(INTERP, SELF)
                 - VTABLE_get_integer(INTERP, value);
             return diff > 0 ? 1 : diff < 0 ? -1 : 0;
         }





On Mon, May 19, 2008 at 5:10 PM, via RT Vasily Chekalkin
<[EMAIL PROTECTED]> wrote:
> # New Ticket Created by  Vasily Chekalkin
> # Please include the string:  [perl #54474]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54474 >
>
>
> Parrot's op cmp doesn't work for integers.
>
> $ cat v.pir
> .sub main :main
>     $P99 = subclass 'Integer', 'Int'
>
>     .local pmc a, b
>     a = new 'Int'
>     a = 1
>
>     b = new 'Int'
>     b = 2
>
>     $I0 = cmp a, b
>     say $I0
>
>     $I0 = cmp b, a
>     say $I0
> .end
> $ ./parrot v.pir
> 1
> 1
> $
>
> Expected results
> -1
> 1
>
> (Thanks to pmichaud for clean version of test case)
>
>
>



-- 
Will "Coke" Coleda

Reply via email to