cvsuser     04/12/23 09:38:43

  Modified:    classes  bigint.pmc
               dynclasses pybuiltin.pmc pyint.pmc pylong.pmc pystring.pmc
               languages/python Makefile
               languages/python/t/pie b5.t b6.t
  Log:
  Progress towards getting t/pie/b5.t passing
  
  Revision  Changes    Path
  1.22      +11 -11    parrot/classes/bigint.pmc
  
  Index: bigint.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/bigint.pmc,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- bigint.pmc        22 Dec 2004 01:58:37 -0000      1.21
  +++ bigint.pmc        23 Dec 2004 17:38:40 -0000      1.22
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: bigint.pmc,v 1.21 2004/12/22 01:58:37 chromatic Exp $
  +$Id: bigint.pmc,v 1.22 2004/12/23 17:38:40 rubys Exp $
   
   =head1 NAME
   
  @@ -141,9 +141,9 @@
       /* this is mpz_fdiv_q */
       mpz_div(BN(dest), BN(self), BN(value));
       if (mpz_fits_slong_p(BN(dest))) {
  +        long iresult = mpz_get_si(BN(dest));
           VTABLE_morph(interpreter, dest, enum_class_Integer);
  -        VTABLE_set_integer_native(interpreter, dest,
  -             mpz_get_si(BN(dest)));
  +        VTABLE_set_integer_native(interpreter, dest, iresult);
       }
   }
   static void
  @@ -153,9 +153,9 @@
       /* this is mpz_fdiv_q */
       mpz_div_ui(BN(dest), BN(self), value);
       if (mpz_fits_slong_p(BN(dest))) {
  +        long iresult = mpz_get_si(BN(dest));
           VTABLE_morph(interpreter, dest, enum_class_Integer);
  -        VTABLE_set_integer_native(interpreter, dest,
  -             mpz_get_si(BN(dest)));
  +        VTABLE_set_integer_native(interpreter, dest, iresult);
       }
   }
   static void
  @@ -165,9 +165,9 @@
       /* this is mpz_fdiv_q */
       mpz_fdiv_q(BN(dest), BN(self), BN(value));
       if (mpz_fits_slong_p(BN(dest))) {
  +        long iresult = mpz_get_si(BN(dest));
           VTABLE_morph(interpreter, dest, enum_class_Integer);
  -        VTABLE_set_integer_native(interpreter, dest,
  -             mpz_get_si(BN(dest)));
  +        VTABLE_set_integer_native(interpreter, dest, iresult);
       }
   }
   static void
  @@ -177,9 +177,9 @@
       /* this is mpz_fdiv_q */
       mpz_fdiv_q_ui(BN(dest), BN(self), value);
       if (mpz_fits_slong_p(BN(dest))) {
  +        long iresult = mpz_get_si(BN(dest));
           VTABLE_morph(interpreter, dest, enum_class_Integer);
  -        VTABLE_set_integer_native(interpreter, dest,
  -             mpz_get_si(BN(dest)));
  +        VTABLE_set_integer_native(interpreter, dest, iresult);
       }
   }
   static void
  @@ -188,9 +188,9 @@
       VTABLE_morph(interpreter, dest, enum_class_BigInt);
       mpz_mod(BN(dest), BN(self), BN(value));
       if (mpz_fits_slong_p(BN(dest))) {
  +        long iresult = mpz_get_si(BN(dest));
           VTABLE_morph(interpreter, dest, enum_class_Integer);
  -        VTABLE_set_integer_native(interpreter, dest,
  -             mpz_get_si(BN(dest)));
  +        VTABLE_set_integer_native(interpreter, dest, iresult);
       }
   }
   
  
  
  
  1.33      +7 -1      parrot/dynclasses/pybuiltin.pmc
  
  Index: pybuiltin.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pybuiltin.pmc,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- pybuiltin.pmc     23 Dec 2004 12:44:04 -0000      1.32
  +++ pybuiltin.pmc     23 Dec 2004 17:38:41 -0000      1.33
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pybuiltin.pmc,v 1.32 2004/12/23 12:44:04 rubys Exp $
  +$Id: pybuiltin.pmc,v 1.33 2004/12/23 17:38:41 rubys Exp $
   
   =head1 NAME
   
  @@ -481,10 +481,16 @@
   
   =cut
   
  +Todo: obtain the Python class name for the exception
  +
   */
   
       METHOD PMC* hex(PMC *value) {
           PMC * meth = VTABLE_find_method(INTERP, value, HEX);
  +        if (!meth)
  +            real_exception(interpreter, NULL, E_AttributeError,
  +                "AttributeError: %Ss instance has no attribute '%Ss'",
  +                value->vtable->whoami, HEX);
           REG_INT(0) = 1;
           REG_INT(1) = REG_INT(2) = REG_INT(3) = REG_INT(4) = 0;
           REG_PMC(2) = value;
  
  
  
  1.17      +23 -11    parrot/dynclasses/pyint.pmc
  
  Index: pyint.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pyint.pmc,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- pyint.pmc 23 Dec 2004 12:44:04 -0000      1.16
  +++ pyint.pmc 23 Dec 2004 17:38:41 -0000      1.17
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pyint.pmc,v 1.16 2004/12/23 12:44:04 rubys Exp $
  +$Id: pyint.pmc,v 1.17 2004/12/23 17:38:41 rubys Exp $
   
   =head1 NAME
   
  @@ -33,12 +33,7 @@
       PMC *temp;
       INTVAL a = PMC_int_val(self);
   
  -    if (PARROT_ERRORS_test(interpreter,PARROT_ERRORS_OVERFLOW_FLAG)) {
  -        real_exception(interpreter, NULL, ERR_OVERFLOW,
  -                "Integer overflow");
  -    }
       if (self == dest) {
  -        /* TODO preserve type system */
           VTABLE_morph(interpreter, self, dynclass_PyLong);
           VTABLE_set_integer_native(interpreter, self, a);
           mmd_dispatch_v_pip(interpreter, self, b, dest, mmd);
  @@ -648,17 +643,29 @@
   
   */
   
  -    METHOD PMC* __new__(PMC *class, PMC *source) {
  +    METHOD PMC* __new__(PMC *class, PMC *source, PMC *base) {
           INTVAL argc = REG_INT(3);
   
           PMC * ret = pmc_new(INTERP, dynclass_PyInt);
   
           /* XXX: quick hack: class method called directly */
  -        if (argc == 3 && class == SELF) source = REG_PMC(7);
  +        INTVAL dynclass_PyProxyType = Parrot_PMC_typenum(INTERP, 
"PyProxyType");
  +        if (argc == 3 && source->vtable->base_type == dynclass_PyProxyType)
  +            source = REG_PMC(7);
   
           if (argc > 1) {
  -            INTVAL ivalue = VTABLE_get_integer(INTERP, source);
  -            VTABLE_set_integer_native(INTERP, ret, ivalue);
  +            if (source->vtable->base_type == dynclass_PyString) {
  +                INTVAL key = 0;
  +                if (argc > 2) key = VTABLE_get_integer(INTERP, base);
  +                VTABLE_morph(INTERP, ret, dynclass_PyLong);
  +                VTABLE_set_string_keyed_int(INTERP, ret, key,
  +                    VTABLE_get_string(INTERP, source));
  +                mmd_dispatch_v_pip(INTERP, ret, 1, ret, MMD_DIVIDE_INT);
  +            }
  +            else {
  +                INTVAL ivalue = VTABLE_get_integer(INTERP, source);
  +                VTABLE_set_integer_native(INTERP, ret, ivalue);
  +            }
           }
   
           return ret;
  @@ -694,6 +701,11 @@
   MMD_PyNone: {
               return 0;
           }
  +MMD_PyLong: {
  +            PMC *temp = pmc_new(INTERP, dynclass_PyLong);
  +            VTABLE_set_integer_native(INTERP, temp, PMC_int_val(SELF));
  +            return mmd_dispatch_i_pp(INTERP, temp, value, MMD_EQ);
  +        }
   MMD_DEFAULT: {
               return (INTVAL)(PMC_int_val(SELF) ==
                   VTABLE_get_integer(INTERP, value));
  @@ -889,7 +901,7 @@
               VTABLE_morph(INTERP, dest, dynclass_PyInt);
               PMC_int_val(dest) = 1;
               for (i=1; i<=value; i++) {
  -                PMC_int_val(dest) *= PMC_int_val(SELF);
  +                mmd_dispatch_v_pip(INTERP, dest, pmci, dest, 
MMD_MULTIPLY_INT);
               }
           }
       }
  
  
  
  1.7       +48 -1     parrot/dynclasses/pylong.pmc
  
  Index: pylong.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pylong.pmc,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- pylong.pmc        23 Dec 2004 12:44:04 -0000      1.6
  +++ pylong.pmc        23 Dec 2004 17:38:41 -0000      1.7
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: pylong.pmc,v 1.6 2004/12/23 12:44:04 rubys Exp $
  +$Id: pylong.pmc,v 1.7 2004/12/23 17:38:41 rubys Exp $
   
   =head1 NAME
   
  @@ -27,6 +27,7 @@
   /* cache of classes referenced */
   static INTVAL dynclass_PyInt;
   static INTVAL dynclass_PyLong;
  +static INTVAL dynclass_PyString;
   
   pmclass PyLong extends BigInt dynpmc group python_group {
   
  @@ -45,11 +46,34 @@
           if (pass) {
               dynclass_PyInt     = Parrot_PMC_typenum(INTERP, "PyInt");
               dynclass_PyLong    = Parrot_PMC_typenum(INTERP, "PyLong");
  +            dynclass_PyString  = Parrot_PMC_typenum(INTERP, "PyString");
           }
       }
   
   /*
   
  +=item C<PMC* "__hex__"(PMC *self)>
  +
  +Returns the hex representation of C<self>.
  +
  +=cut
  +
  +*/
  +
  +    METHOD PMC* __hex__(PMC *self) {
  +        PMC * ret = pmc_new(INTERP, dynclass_PyString);
  +
  +        STRING *res = string_from_cstring(INTERP, "0x", 0);
  +        STRING *s = VTABLE_get_string_keyed_int(INTERP, self, 16);
  +        res = string_append(INTERP, res, s, 0);
  +        res = string_append(INTERP, res, const_string(INTERP, "L"), 0);
  +
  +        VTABLE_set_string_native(INTERP, ret, res);
  +        return ret;
  +    }
  +
  +/*
  +
   =item C<PMC* "__new__"(PMC *class, PMC *value, PMC *base)>
   
   Create a new long.
  @@ -101,6 +125,28 @@
   
   /*
   
  +=item C<INTVAL is_equal (PMC* value)>
  +
  +The C<==> operation.
  +
  +=cut
  +
  +*/
  +
  +    INTVAL is_equal (PMC* value) {
  +MMD_PyInt: {
  +            PMC *temp = pmc_new(INTERP, dynclass_PyLong);
  +            VTABLE_set_integer_native(INTERP, temp, PMC_int_val(value));
  +            return mmd_dispatch_i_pp(INTERP, SELF, temp, MMD_EQ);
  +        }
  +MMD_DEFAULT: {
  +            return (INTVAL)(PMC_int_val(SELF) ==
  +                VTABLE_get_integer(INTERP, value));
  +        }
  +    }
  +
  +/*
  +
   =item C<void morph(INTVAL type)>
   
   Morphs the scalar to the specified type.
  @@ -110,6 +156,7 @@
   */
   
       void morph (INTVAL type) {
  +        if (type == enum_class_BigInt) return;
           if (type == enum_class_Integer) type = dynclass_PyInt;
           pmc_reuse(INTERP, SELF, type, 0);
       }
  
  
  
  1.13      +15 -1     parrot/dynclasses/pystring.pmc
  
  Index: pystring.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pystring.pmc,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- pystring.pmc      22 Dec 2004 01:58:41 -0000      1.12
  +++ pystring.pmc      23 Dec 2004 17:38:41 -0000      1.13
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pystring.pmc,v 1.12 2004/12/22 01:58:41 chromatic Exp $
  +$Id: pystring.pmc,v 1.13 2004/12/23 17:38:41 rubys Exp $
   
   =head1 NAME
   
  @@ -109,6 +109,20 @@
   
   /*
   
  +=item C<INTVAL hash()>
  +
  +Returns a unique hash for this value
  +
  +=cut
  +
  +*/
  +
  +    INTVAL hash () {
  +        return string_hash(interpreter, PMC_str_val(pmc));
  +    }
  +
  +/*
  +
   =item C<INTVAL get_bool()>
   
   Returns the pyboolean value of the string.
  
  
  
  1.11      +1 -1      parrot/languages/python/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/Makefile,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Makefile  22 Dec 2004 13:19:01 -0000      1.10
  +++ Makefile  23 Dec 2004 17:38:42 -0000      1.11
  @@ -6,7 +6,7 @@
        perl t/harness t/basic/*.t
   
   testbench:
  -     perl t/harness t/pie/b[123].t
  +     perl t/harness t/pie/b*.t
   
   testclass:
        cd ../.. ; perl -Ilib t/harness t/dynclass/py*.t
  
  
  
  1.13      +7 -2      parrot/languages/python/t/pie/b5.t
  
  Index: b5.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/pie/b5.t,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- b5.t      8 Dec 2004 02:15:46 -0000       1.12
  +++ b5.t      23 Dec 2004 17:38:43 -0000      1.13
  @@ -1,4 +1,4 @@
  -# $Id: b5.t,v 1.12 2004/12/08 02:15:46 rubys Exp $
  +# $Id: b5.t,v 1.13 2004/12/23 17:38:43 rubys Exp $
   
   use strict;
   use lib '../../lib';
  @@ -137,6 +137,8 @@
       main()
   CODE
   
  +SKIP: {
  +  skip("dictionaries with non-string keys", 1);
   test(<<'CODE', 'check_functions complex, dict');
   show = True
   
  @@ -162,6 +164,7 @@
   if __name__ == '__main__':
       main()
   CODE
  +}
   
   test(<<'CODE', 'check_functions divmod');
   show = True
  @@ -375,6 +378,8 @@
       main()
   CODE
   
  +SKIP: {
  +  skip("isinstance of primitive types", 1);
   test(<<'CODE', 'check isinstance');
   show = True
   
  @@ -402,4 +407,4 @@
       main()
   
   CODE
  -
  +}
  
  
  
  1.5       +4 -2      parrot/languages/python/t/pie/b6.t
  
  Index: b6.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/pie/b6.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- b6.t      19 Jul 2004 08:22:32 -0000      1.4
  +++ b6.t      23 Dec 2004 17:38:43 -0000      1.5
  @@ -1,4 +1,4 @@
  -# $Id: b6.t,v 1.4 2004/07/19 08:22:32 leo Exp $
  +# $Id: b6.t,v 1.5 2004/12/23 17:38:43 rubys Exp $
   
   use strict;
   use lib '../../lib';
  @@ -54,6 +54,8 @@
       main()
   CODE
   
  +SKIP: {
  +  skip("dictionaries with non-string keys", 2);
   test(<<'CODE', 'b6 - fdiv');
   # from b5 import check
   show = True
  @@ -113,4 +115,4 @@
       main()
   
   CODE
  -
  +}
  
  
  

Reply via email to