cvsuser     04/12/07 11:48:51

  Modified:    dynclasses pybuiltin.pmc pycomplex.pmc pyfloat.pmc pyint.pmc
                        pylong.pmc
               languages/python README
               t/dynclass pyint.t
  Log:
  Complete pow, hash
  
  Revision  Changes    Path
  1.14      +4 -14     parrot/dynclasses/pybuiltin.pmc
  
  Index: pybuiltin.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pybuiltin.pmc,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- pybuiltin.pmc     7 Dec 2004 13:08:38 -0000       1.13
  +++ pybuiltin.pmc     7 Dec 2004 19:48:49 -0000       1.14
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pybuiltin.pmc,v 1.13 2004/12/07 13:08:38 leo Exp $
  +$Id: pybuiltin.pmc,v 1.14 2004/12/07 19:48:49 rubys Exp $
   
   =head1 NAME
   
  @@ -392,19 +392,9 @@
   */
   
       METHOD PMC* hash(PMC *value) {
  -        PMC *h = pmc_new_noinit(INTERP, dynclass_PyInt);
  -        INTVAL type = value->vtable->base_type;
  -        INTVAL i;
  -
  -        if (type == dynclass_PyString)
  -            i = string_hash(INTERP, PMC_str_val(value));
  -        else if (type == dynclass_PyComplex)
  -            i = (INTVAL)VTABLE_get_number_keyed_int(INTERP, value, 0);
  -        else
  -            i = VTABLE_get_integer(INTERP, value);
  -
  -        PMC_int_val(h) = i;
  -        return h;
  +        PMC *ret = pmc_new_noinit(INTERP, dynclass_PyInt);
  +        VTABLE_set_integer_native(INTERP, ret, VTABLE_hash(INTERP, value));
  +        return ret;
       }
   
   /*
  
  
  
  1.2       +16 -1     parrot/dynclasses/pycomplex.pmc
  
  Index: pycomplex.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pycomplex.pmc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pycomplex.pmc     30 Nov 2004 21:49:20 -0000      1.1
  +++ pycomplex.pmc     7 Dec 2004 19:48:49 -0000       1.2
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: pycomplex.pmc,v 1.1 2004/11/30 21:49:20 rubys Exp $
  +$Id: pycomplex.pmc,v 1.2 2004/12/07 19:48:49 rubys Exp $
   
   =head1 NAME
   
  @@ -840,6 +840,21 @@
           FLOATVAL d = sqrt(RE(SELF)*RE(SELF) + IM(SELF)*IM(SELF));
           VTABLE_set_number_native(INTERP, dest, d);
       }
  +
  +/*
  +
  +=item C<INTVAL hash()>
  +
  +Returns a unique hash for this value
  +
  +=cut
  +
  +*/
  +
  +    INTVAL hash () {
  +        return VTABLE_get_integer(INTERP, SELF);
  +    }
  +
   }
   
   /*
  
  
  
  1.5       +15 -1     parrot/dynclasses/pyfloat.pmc
  
  Index: pyfloat.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pyfloat.pmc,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- pyfloat.pmc       3 Dec 2004 17:10:04 -0000       1.4
  +++ pyfloat.pmc       7 Dec 2004 19:48:49 -0000       1.5
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pyfloat.pmc,v 1.4 2004/12/03 17:10:04 rubys Exp $
  +$Id: pyfloat.pmc,v 1.5 2004/12/07 19:48:49 rubys Exp $
   
   =head1 NAME
   
  @@ -79,6 +79,20 @@
   
   /*
   
  +=item C<INTVAL hash()>
  +
  +Returns a unique hash for this value
  +
  +=cut
  +
  +*/
  +
  +    INTVAL hash () {
  +        return VTABLE_get_integer(INTERP, SELF);
  +    }
  +
  +/*
  +
   =item C<void set_number_native(FLOATVAL value)>
   
   Sets the value of the number to C<value>.
  
  
  
  1.6       +17 -4     parrot/dynclasses/pyint.pmc
  
  Index: pyint.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pyint.pmc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- pyint.pmc 7 Dec 2004 17:24:51 -0000       1.5
  +++ pyint.pmc 7 Dec 2004 19:48:49 -0000       1.6
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pyint.pmc,v 1.5 2004/12/07 17:24:51 rubys Exp $
  +$Id: pyint.pmc,v 1.6 2004/12/07 19:48:49 rubys Exp $
   
   =head1 NAME
   
  @@ -403,7 +403,6 @@
               return -1;
           }
       }
  -
   /*
   
   =item C<void divide(PMC *value, PMC *dest)>
  @@ -543,6 +542,20 @@
   
   /*
   
  +=item C<INTVAL hash()>
  +
  +Returns a unique hash for this value
  +
  +=cut
  +
  +*/
  +
  +    INTVAL hash () {
  +        return VTABLE_get_integer(INTERP, SELF);
  +    }
  +
  +/*
  +
   =item C<INTVAL is_equal (PMC* value)>
   
   The C<==> operation.
  @@ -687,7 +700,7 @@
           }
   MMD_PyFloat: {
               FLOATVAL valf = VTABLE_get_number(INTERP, value);
  -            mmd_dispatch_v_pip(INTERP, SELF, valf, dest, MMD_POW_FLOAT);
  +            mmd_dispatch_v_pnp(INTERP, SELF, valf, dest, MMD_POW_FLOAT);
           }
       }
   
  @@ -719,7 +732,7 @@
   
       void pow_int (INTVAL value, PMC *dest) {
           if (value < 0)
  -            mmd_dispatch_v_pip(INTERP, SELF, 
  +            mmd_dispatch_v_pnp(INTERP, SELF, 
                   (FLOATVAL)value, dest, MMD_POW_FLOAT);
           else {
               int i;
  
  
  
  1.2       +16 -1     parrot/dynclasses/pylong.pmc
  
  Index: pylong.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pylong.pmc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pylong.pmc        30 Nov 2004 21:49:20 -0000      1.1
  +++ pylong.pmc        7 Dec 2004 19:48:49 -0000       1.2
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: pylong.pmc,v 1.1 2004/11/30 21:49:20 rubys Exp $
  +$Id: pylong.pmc,v 1.2 2004/12/07 19:48:49 rubys Exp $
   
   =head1 NAME
   
  @@ -706,6 +706,21 @@
       void absolute(PMC *dest) {
           bigint_abs(INTERP, SELF, dest);
       }
  +
  +/*
  +
  +=item C<INTVAL hash()>
  +
  +Returns a unique hash for this value
  +
  +=cut
  +
  +*/
  +
  +    INTVAL hash () {
  +        return VTABLE_get_integer(INTERP, SELF);
  +    }
  +
   }
   
   /*
  
  
  
  1.4       +0 -2      parrot/languages/python/README
  
  Index: README
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/README,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- README    7 Dec 2004 00:50:28 -0000       1.3
  +++ README    7 Dec 2004 19:48:50 -0000       1.4
  @@ -18,8 +18,6 @@
   Outstanding Parrot archicture/design issues:
   
     Keyword/Default arguments
  -  Hash VTABLE entry
  -  POW MMD
     MMD Inheritance
     Anonymous Classes
   
  
  
  
  1.2       +11 -9     parrot/t/dynclass/pyint.t
  
  Index: pyint.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/dynclass/pyint.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pyint.t   10 Nov 2004 01:23:24 -0000      1.1
  +++ pyint.t   7 Dec 2004 19:48:51 -0000       1.2
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: pyint.t,v 1.1 2004/11/10 01:23:24 rubys Exp $
  +# $Id: pyint.t,v 1.2 2004/12/07 19:48:51 rubys Exp $
   
   =head1 NAME
   
  @@ -454,22 +454,24 @@
       set $P2, -1 
   
       new $P3, $I0
  -    # XXX: uncomment if/when a proper op is implemented
  -    # $P2 = $P0 ** $P1
  -    # print $P2
  -    # print " "
  -    # $P2 = $P0 ** 3
  -    # print $P2
  -    # print " "
  +    $P3 = $P0 ** $P1
  +    print $P3
  +    print " "
  +    $P3 = $P0 ** 3
  +    print $P3
  +    print " "
       $P3 = $P0.__pow__($P1)
       print $P3
       print " "
       $P3 = $P1.__pow__($P2)
       print $P3
  +    print " "
  +    $P3 = $P2.__rpow__($P1)
  +    print $P3
       print "\n"
   .end
   CODE
  -961 0.5
  +961 29791 961 0.5 0.5
   OUTPUT
   
   output_is(<< 'CODE', << 'OUTPUT', "repr");
  
  
  

Reply via email to