cvsuser     04/07/10 08:30:59

  Modified:    classes  complex.pmc env.pmc none.pmc null.pmc perlhash.pmc
               languages/python pie-thon.pl
               languages/python/t/basic oo_attr.t
               languages/python/t/pie b5.t
               lib/Parrot Pmc2c.pm
               ops      experimental.ops
               src      call_list.txt inter_create.c pmc.c py_func.c
               t/pmc    iter.t
  Log:
  Pie-thon 48 - singletons, Null is_equal, dict and more
  * unified singleton PMC handling
  * a singleton PMC is its own class too - only 1 instance ever
  * optimized iseq, isne for same PMCs
  * is_equal for None PMC
  * changed fromkeys to use only one param
  * new test from b5
  * is() and id()
  
  Revision  Changes    Path
  1.6       +7 -4      parrot/classes/complex.pmc
  
  Index: complex.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/complex.pmc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- complex.pmc       10 Jul 2004 09:02:26 -0000      1.5
  +++ complex.pmc       10 Jul 2004 15:30:37 -0000      1.6
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -$Id: complex.pmc,v 1.5 2004/07/10 09:02:26 leo Exp $
  +$Id: complex.pmc,v 1.6 2004/07/10 15:30:37 leo Exp $
   
   =head1 NAME
   
  @@ -289,12 +289,15 @@
       STRING* get_string () {
           STRING *s;
           if (Interp_flags_TEST(INTERP, PARROT_PYTHON_MODE)) {
  -            if (IM(SELF) >= 0)
  +            if (RE(SELF) == 0) {
  +                s = Parrot_sprintf_c(INTERP, "%.12vgj", IM(SELF));
  +            }
  +            else if (IM(SELF) >= 0)
                   s = Parrot_sprintf_c(INTERP,
  -                        "(%vg+%vgj)", RE(SELF), IM(SELF));
  +                        "(%.12vg+%.12vgj)", RE(SELF), IM(SELF));
               else
                   s = Parrot_sprintf_c(INTERP,
  -                        "(%vg-%vgj)", RE(SELF), -IM(SELF));
  +                        "(%.12vg-%.12vgj)", RE(SELF), -IM(SELF));
           }
           else {
               if (IM(SELF) >= 0)
  
  
  
  1.14      +22 -1     parrot/classes/env.pmc
  
  Index: env.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/env.pmc,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- env.pmc   26 Feb 2004 08:33:21 -0000      1.13
  +++ env.pmc   10 Jul 2004 15:30:37 -0000      1.14
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: env.pmc,v 1.13 2004/02/26 08:33:21 leo Exp $
  +$Id: env.pmc,v 1.14 2004/07/10 15:30:37 leo Exp $
   
   =head1 NAME
   
  @@ -21,8 +21,29 @@
   
   #include "parrot/parrot.h"
   
  +static PMC * Env_PMC;
   pmclass Env singleton {
   
  +    void* get_pointer() {
  +        return Env_PMC;
  +    }
  +
  +/*
  +
  +=item C<void* get_pointer()>
  +
  +=item C<void set_pointer(void *ptr)>
  +
  +These two functions are part of the singleton creation interface. For more
  +information see F<src/pmc.c>.
  +
  +=cut
  +
  +*/
  +
  +    void set_pointer(void* ptr) {
  +        Env_PMC = (PMC*) ptr;
  +    }
   /*
   
   =item C<STRING *get_string_keyed(PMC *key)>
  
  
  
  1.2       +10 -1     parrot/classes/none.pmc
  
  Index: none.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/none.pmc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- none.pmc  25 Jun 2004 17:07:09 -0000      1.1
  +++ none.pmc  10 Jul 2004 15:30:37 -0000      1.2
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: none.pmc,v 1.1 2004/06/25 17:07:09 leo Exp $
  +$Id: none.pmc,v 1.2 2004/07/10 15:30:37 leo Exp $
   
   =head1 NAME
   
  @@ -67,6 +67,15 @@
       INTVAL type () {
        return SELF->vtable->base_type;
       }
  +
  +    INTVAL is_equal(PMC* other) {
  +MMD_None: {
  +        return 1;
  +        }
  +MMD_DEFAULT: {
  +        return 0;
  +        }
  +    }
   }
   
   /*
  
  
  
  1.7       +10 -2     parrot/classes/null.pmc
  
  Index: null.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/null.pmc,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- null.pmc  22 Feb 2004 17:48:41 -0000      1.6
  +++ null.pmc  10 Jul 2004 15:30:37 -0000      1.7
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: null.pmc,v 1.6 2004/02/22 17:48:41 mikescott Exp $
  +$Id: null.pmc,v 1.7 2004/07/10 15:30:37 leo Exp $
   
   =head1 NAME
   
  @@ -21,7 +21,7 @@
   
   #include "parrot/parrot.h"
   
  -pmclass Null {
  +pmclass Null singleton {
   
   /*
   
  @@ -36,6 +36,14 @@
       void init () {
       }
   
  +    void* get_pointer() {
  +        return PMCNULL;
  +    }
  +
  +    void set_pointer(void* p) {
  +        PMCNULL = p;
  +    }
  +
   }
   
   /*
  
  
  
  1.83      +8 -7      parrot/classes/perlhash.pmc
  
  Index: perlhash.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/perlhash.pmc,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -w -r1.82 -r1.83
  --- perlhash.pmc      10 Jul 2004 11:40:48 -0000      1.82
  +++ perlhash.pmc      10 Jul 2004 15:30:37 -0000      1.83
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: perlhash.pmc,v 1.82 2004/07/10 11:40:48 leo Exp $
  +$Id: perlhash.pmc,v 1.83 2004/07/10 15:30:37 leo Exp $
   
   =head1 NAME
   
  @@ -45,13 +45,10 @@
   }
   
   static PMC*
  -fromkeys(Interp *interpreter, PMC *self, PMC *keys, PMC *value)
  +fromkeys(Interp *interpreter, PMC *self, PMC *keys)
   {
       INTVAL elems, dod_disabled, i;
  -    PMC *iter;
  -
  -    if (PMC_IS_NULL(value))
  -        value = pmc_new(interpreter, enum_class_None);
  +    PMC *iter, *value;
   
       /*
        * if the number of keys is bigger then the current PMC
  @@ -65,6 +62,8 @@
           Parrot_block_GC(interpreter);
           dod_disabled = 1;
       }
  +    value = pmc_new(interpreter, enum_class_None);
  +
       /*
        * keys should be able to iterate
        * TODO check that
  @@ -158,7 +157,7 @@
           make_bufferlike_pool(INTERP, sizeof(struct _hash));
           if (pass) {
               enter_nci_method(INTERP, enum_class_PerlHash,
  -                    F2DPTR(fromkeys), "fromkeys", "PIOPP");
  +                    F2DPTR(fromkeys), "fromkeys", "PIOP");
           }
       }
   /*
  @@ -907,6 +906,8 @@
                   return 0;
               item1 = SELF.get_pmc_keyed_str(key);
               item2 = VTABLE_get_pmc_keyed_str(INTERP, value, key);
  +            if (item1 == item2)
  +                continue;
               if (!mmd_dispatch_i_pp(INTERP, item1, item2, MMD_EQ))
                   return 0;
           }
  
  
  
  1.30      +17 -4     parrot/languages/python/pie-thon.pl
  
  Index: pie-thon.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/pie-thon.pl,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -w -r1.29 -r1.30
  --- pie-thon.pl       10 Jul 2004 11:40:52 -0000      1.29
  +++ pie-thon.pl       10 Jul 2004 15:30:40 -0000      1.30
  @@ -27,8 +27,9 @@
       callable => 1,
       chr => 1,
       dict => 'v',
  -    hash => 1,
       enumerate => 1,
  +    hash => 1,
  +    id => 1,
       filter => 1,
       list => 'v',
       long => 'v',
  @@ -731,7 +732,7 @@
       if ($opcode eq 'JUMP_IF_FALSE') {
        print "\t\t$cmt\n";
        $code_l++;
  -     JUMP_IF_TRUE($arg, $rest);
  +     JUMP_IF_TRUE($arg, $rest, "\t# JUMP_IF_FALSE");
       }
       else {
        my $tos = pop @stack;
  @@ -782,6 +783,9 @@
       my ($opcode, $rest) = ($code[$code_l]->[2],$code[$code_l]->[4]);
       my $targ = "pc_xxx";
       my $label = '';
  +    if (!defined $op) {
  +     goto plain;
  +    }
       if ($opcode eq 'Label') {
        $label = "pc_" . $code[$code_l]->[3] . ":";
        $code_l++;
  @@ -816,6 +820,7 @@
        $op = $c;
       }
       else {
  +plain:
        $code_l-- if ($label ne '');
        # plain compare, no branch
        my %is_map = (
  @@ -825,6 +830,7 @@
            '>=' => 'isge',
            '<' => 'islt',
            '<=' => 'isle',
  +         'is' => 'issame',
        );
        my $res = temp('I');
        my $pres = temp('P');
  @@ -832,7 +838,7 @@
        my $lp = promote($l);
        my $rp = promote($r);
        print <<EOC;
  -     $res = $op $lp, $rp
  +     $res = $op $lp, $rp $cmt
        $pres = new .Boolean
        $pres = $res # ugly
   EOC
  @@ -919,6 +925,7 @@
       my $a = shift;
       my %rets = (
        '__repr__' => 'S',
  +     'id'       => 'I',
       );
       return $rets{$a} if defined $rets{$a};
       return 'P';
  @@ -1010,8 +1017,14 @@
   EOC
       }
       else {
  +     my $ret_type = ret_val($func);
  +     my $ret_string = "";
  +     if ($ret_type ne 'None') {
  +         $t = temp($ret_type);
  +         $ret_string = "$t = ";
  +     }
        print <<EOC;
  -     $func($args)  $cmt
  +     $ret_string$func($args)  $cmt
   EOC
       }
       my $opcode = $code[$code_l]->[2];
  
  
  
  1.2       +21 -2     parrot/languages/python/t/basic/oo_attr.t
  
  Index: oo_attr.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/basic/oo_attr.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- oo_attr.t 10 Jul 2004 11:43:13 -0000      1.1
  +++ oo_attr.t 10 Jul 2004 15:30:43 -0000      1.2
  @@ -1,14 +1,33 @@
  -# $Id: oo_attr.t,v 1.1 2004/07/10 11:43:13 leo Exp $
  +# $Id: oo_attr.t,v 1.2 2004/07/10 15:30:43 leo Exp $
   
   use strict;
   use lib '../../lib';
   
  -use Parrot::Test tests => 1;
  +use Parrot::Test tests => 3;
   
   sub test {
       language_output_is('python', $_[0], '', $_[1]);
   }
   
  +test(<<'CODE', 'object is');
  +if __name__ == '__main__':
  +    print "a" is "b"
  +    i=5
  +    print i is i
  +    if i is i:
  +     print "ok"
  +    if not i is 2:
  +     print "ok"
  +CODE
  +
  +test(<<'CODE', 'object id');
  +if __name__ == '__main__':
  +    i=5
  +    j=6
  +    print id(i) == id(i)
  +    print id(i) != id(j)
  +CODE
  +
   test(<<'CODE', 'func attribs');
   def f(x):
       print x
  
  
  
  1.5       +27 -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.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- b5.t      9 Jul 2004 16:38:58 -0000       1.4
  +++ b5.t      10 Jul 2004 15:30:46 -0000      1.5
  @@ -1,9 +1,9 @@
  -# $Id: b5.t,v 1.4 2004/07/09 16:38:58 leo Exp $
  +# $Id: b5.t,v 1.5 2004/07/10 15:30:46 leo Exp $
   
   use strict;
   use lib '../../lib';
   
  -use Parrot::Test tests => 5;
  +use Parrot::Test tests => 6;
   
   sub test {
       language_output_is('python', $_[0], '', $_[1]);
  @@ -137,4 +137,29 @@
       main()
   CODE
   
  +test(<<'CODE', 'check_functions complex, dict');
  +show = True
  +
  +def check(a, b):
  +    if __debug__:
  +        if show:
  +            print `a`, "==", `b`
  +    if not a == b:
  +        raise AssertionError("%.30r != %.30r" % (a, b))
  +
  +def check_functions(i=0, j=0):
  +    check(complex(3*i, 4*j), 3*i+4j*j)
  +    check(dict([(1,2), (3,4)]), {1: 2, 3: 4})
  +    check(dict.fromkeys("abc"), {'a': None, 'b': None, 'c': None})
  +
  +def main():
  +    check_functions()
  +    check_functions(j=10, i=10)
  +    for i in range(0,500,249):
  +     print "i:", i
  +        check_functions(j=long(i*1000000), i=i*1000000)
  +
  +if __name__ == '__main__':
  +    main()
  +CODE
   
  
  
  
  1.33      +6 -1      parrot/lib/Parrot/Pmc2c.pm
  
  Index: Pmc2c.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/Pmc2c.pm,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -w -r1.32 -r1.33
  --- Pmc2c.pm  9 Jul 2004 11:49:29 -0000       1.32
  +++ Pmc2c.pm  10 Jul 2004 15:30:50 -0000      1.33
  @@ -1,5 +1,5 @@
   # Copyright: 2004 The Perl Foundation.  All Rights Reserved.
  -# $Id: Pmc2c.pm,v 1.32 2004/07/09 11:49:29 leo Exp $
  +# $Id: Pmc2c.pm,v 1.33 2004/07/10 15:30:50 leo Exp $
   
   =head1 NAME
   
  @@ -1063,6 +1063,11 @@
   {
       my ($self, $method, $line) = @_;
       my $meth = $method->{meth};
  +    # existing methods get emitted
  +    if ($self->SUPER::implements($meth)) {
  +        my $n = $self->{has_method}{$meth};
  +        return $self->SUPER::body($self->{methods}[$n]);
  +    }
       my $decl = $self->decl($self->{class}, $method, 0);
       my $l = "";
       my $ret = gen_ret($method);
  
  
  
  1.7       +19 -2     parrot/ops/experimental.ops
  
  Index: experimental.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/experimental.ops,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- experimental.ops  5 Jul 2004 12:14:33 -0000       1.6
  +++ experimental.ops  10 Jul 2004 15:30:53 -0000      1.7
  @@ -144,6 +144,17 @@
   
   =cut
   
  +=item B<issame>(out INT, in PMC, in PMC)
  +
  +Sets $1 to 1 or 0, dependig on the identity of the 2 objects.
  +
  +=cut
  +
  +inline op issame(out INT, in PMC, in PMC) {
  +    $1 = &$2 == &$3;
  +    goto NEXT();
  +}
  +
   inline op istrue(out INT, in PMC) {
       $1 = VTABLE_get_bool(interpreter, $2);
       goto NEXT();
  @@ -202,6 +213,9 @@
   =cut
   
   inline op iseq(out INT, in PMC, in PMC) {
  +  if (&$2 == &$3)
  +    $1 = 1;
  +  else
     $1 = mmd_dispatch_i_pp(interpreter, $2, $3, MMD_EQ);
     goto NEXT();
   }
  @@ -220,6 +234,9 @@
   =cut
   
   inline op isne(out INT, in PMC, in PMC) {
  +  if (&$2 == &$3)
  +    $1 = 0;
  +  else
     $1 = !mmd_dispatch_i_pp(interpreter, $2, $3, MMD_EQ);
     goto NEXT();
   }
  
  
  
  1.41      +2 -1      parrot/src/call_list.txt
  
  Index: call_list.txt
  ===================================================================
  RCS file: /cvs/public/parrot/src/call_list.txt,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -r1.40 -r1.41
  --- call_list.txt     10 Jul 2004 11:40:55 -0000      1.40
  +++ call_list.txt     10 Jul 2004 15:30:56 -0000      1.41
  @@ -184,6 +184,7 @@
   P    IPPP
   P    IO
   S    IO
  +i       P
   
   # the following are use by t/pmc/nci.t
   f    ff
  @@ -201,7 +202,7 @@
   P    Ii
   
   # PerlHash fromkeys
  -P    IOPP
  +P    IOP
   
   # Oddball ones for postgres
   p    ptiLTLLi
  
  
  
  1.8       +1 -9      parrot/src/inter_create.c
  
  Index: inter_create.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/inter_create.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- inter_create.c    5 Jul 2004 12:14:36 -0000       1.7
  +++ inter_create.c    10 Jul 2004 15:30:56 -0000      1.8
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: inter_create.c,v 1.7 2004/07/05 12:14:36 leo Exp $
  +$Id: inter_create.c,v 1.8 2004/07/10 15:30:56 leo Exp $
   
   =head1 NAME
   
  @@ -155,14 +155,6 @@
       /* initialize classes - this needs mmd func table */
       Parrot_init(interpreter);
   
  -#if PARROT_CATCH_NULL
  -    /* Initialize once only. For now all interpreters share the NULL PMC.
  -     * Adding to interpreter-local storage will add a deref overhead.
  -     * init_null will return the NULL PMC, but ignore for now since it is global.
  -     */
  -    pmc_init_null(interpreter);
  -#endif
  -
       /* context data */
       /* Initialize interpreter's flags */
       PARROT_WARNINGS_off(interpreter, PARROT_WARNINGS_ALL_FLAG);
  
  
  
  1.86      +25 -62    parrot/src/pmc.c
  
  Index: pmc.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/pmc.c,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -w -r1.85 -r1.86
  --- pmc.c     9 Jul 2004 05:23:45 -0000       1.85
  +++ pmc.c     10 Jul 2004 15:30:56 -0000      1.86
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pmc.c,v 1.85 2004/07/09 05:23:45 leo Exp $
  +$Id: pmc.c,v 1.86 2004/07/10 15:30:56 leo Exp $
   
   =head1 NAME
   
  @@ -22,33 +22,7 @@
   static PMC* get_new_pmc_header(Parrot_Interp, INTVAL base_type, UINTVAL flags);
   
   
  -#if PARROT_CATCH_NULL
   PMC * PMCNULL;
  -Parrot_mutex init_null_mutex;
  -
  -/*
  -
  -=item C<PMC *
  -pmc_init_null(Interp * interpreter)>
  -
  -Initializes C<PMCNULL>, C<Null> PMC.
  -
  -=cut
  -
  -*/
  -
  -PMC *
  -pmc_init_null(Interp * interpreter)
  -{
  -    LOCK(init_null_mutex);
  -    if(!PMCNULL)
  -       PMCNULL = get_new_pmc_header(interpreter, enum_class_Null,
  -               PObj_constant_FLAG);
  -    PMCNULL->vtable = Parrot_base_vtables[enum_class_Null];
  -    UNLOCK(init_null_mutex);
  -    return PMCNULL;
  -}
  -#endif
   
   /*
   
  @@ -190,6 +164,25 @@
           PANIC("Null vtable used");
       }
   
  +    /* we only have one global Env object, living in the interpreter */
  +    if (vtable->flags & VTABLE_PMC_IS_SINGLETON) {
  +        /*
  +         * singletons (monadic objects) exist only once, the interface
  +         * with the class is:
  +         * - get_pointer: return NULL or a pointer to the single instance
  +         * - set_pointer: set the only instance once
  +         *
  +         * - singletons are created in the constant pmc pool
  +         */
  +        pmc = (vtable->get_pointer)(interpreter, NULL);
  +        /* LOCK */
  +        if (!pmc) {
  +            pmc = new_pmc_header(interpreter, PObj_constant_FLAG);
  +            pmc->vtable = vtable;
  +            VTABLE_set_pointer(interpreter, pmc, pmc);
  +        }
  +        return pmc;
  +    }
       if (vtable->flags & VTABLE_IS_CONST_FLAG) {
           /* put the normal vtable in, so that the pmc can be initialized first
            * parrot or user code has to set the _ro property then,
  @@ -245,38 +238,6 @@
   pmc_new_noinit(Interp *interpreter, INTVAL base_type)
   {
       PMC *pmc;
  -    /* we only have one global Env object, living in the interpreter */
  -    if (Parrot_base_vtables[base_type]->flags & VTABLE_PMC_IS_SINGLETON) {
  -        if (base_type == enum_class_Env) {
  -            /* XXX need probably a lock around this code
  -             */
  -            pmc = VTABLE_get_pmc_keyed_int(interpreter, interpreter->iglobals,
  -                    (INTVAL)IGLOBALS_ENV_HASH);
  -            if (!pmc) {
  -                pmc = get_new_pmc_header(interpreter, base_type,
  -                        PObj_constant_FLAG);
  -                VTABLE_set_pmc_keyed_int(interpreter, interpreter->iglobals,
  -                        (INTVAL)IGLOBALS_ENV_HASH, pmc);
  -            /* UNLOCK */}
  -            return pmc;
  -        }
  -        /*
  -         * singletons (monadic objects) exist only once, the interface
  -         * with the class is:
  -         * - get_pointer: return NULL or a pointer to the single instance
  -         * - set_pointer: set the only instance once
  -         *
  -         * - singletons are created in the constant pmc pool
  -         */
  -        pmc = (Parrot_base_vtables[base_type]->get_pointer)(interpreter, NULL);
  -        /* LOCK */
  -        if (!pmc) {
  -            pmc = get_new_pmc_header(interpreter, base_type,
  -                    PObj_constant_FLAG);
  -            VTABLE_set_pointer(interpreter, pmc, pmc);
  -        }
  -        return pmc;
  -    }
       pmc = get_new_pmc_header(interpreter, base_type, 0);
       return pmc;
   }
  @@ -464,15 +425,17 @@
       VTABLE *vtable = Parrot_base_vtables[type];
       STRING *class_name;
       INTVAL pos, len, parent_type;
  +    PMC *class;
       /*
        * class interface - a PMC is it's own class
        * XXX use a separate vtable entry?
        *
        * put an instance of this PMC into data
        */
  -    PMC *class = vtable->data = new_pmc_header(interpreter,
  -            PObj_constant_FLAG);
  -    class->vtable = vtable;
  +    class = get_new_pmc_header(interpreter, type, PObj_constant_FLAG);
  +    vtable->data = class;
  +    PMC_pmc_val(class)   = (void*)0xdeadbeef;
  +    PMC_struct_val(class)= (void*)0xdeadbeef;
       /*
        * register mmds for this type
        */
  
  
  
  1.17      +10 -1     parrot/src/py_func.c
  
  Index: py_func.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/py_func.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -w -r1.16 -r1.17
  --- py_func.c 10 Jul 2004 11:40:55 -0000      1.16
  +++ py_func.c 10 Jul 2004 15:30:56 -0000      1.17
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: py_func.c,v 1.16 2004/07/10 11:40:55 leo Exp $
  +$Id: py_func.c,v 1.17 2004/07/10 15:30:56 leo Exp $
   
   =head1 NAME
   
  @@ -418,6 +418,12 @@
       return h;
   }
   
  +static INTVAL
  +parrot_py_id(PMC *pmc)
  +{
  +    return (INTVAL) pmc;
  +}
  +
   static PMC *
   parrot_py_iter(Interp *interpreter, PMC *pmc)
   {
  @@ -538,6 +544,7 @@
   static void
   parrot_py_create_funcs(Interp *interpreter)
   {
  +    STRING *ip   =     CONST_STRING(interpreter, "iP");
       STRING *pip   =    CONST_STRING(interpreter, "PIP");
       STRING *pipp   =   CONST_STRING(interpreter, "PIPP");
       STRING *pippp   =  CONST_STRING(interpreter, "PIPPP");
  @@ -549,6 +556,7 @@
       STRING *enumerate= CONST_STRING(interpreter, "enumerate");
       STRING *filter   = CONST_STRING(interpreter, "filter");
       STRING *hash     = CONST_STRING(interpreter, "hash");
  +    STRING *id       = CONST_STRING(interpreter, "id");
       STRING *list     = CONST_STRING(interpreter, "list");
       STRING *longf    = CONST_STRING(interpreter, "long");
       STRING *map      = CONST_STRING(interpreter, "map");
  @@ -565,6 +573,7 @@
       parrot_py_global(interpreter, F2DPTR(parrot_py_enumerate), enumerate, pip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_filter), filter, pipp);
       parrot_py_global(interpreter, F2DPTR(parrot_py_hash), hash, pip);
  +    parrot_py_global(interpreter, F2DPTR(parrot_py_id), id, ip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_list), list, pip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_long), longf, pip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_map), map, pipp);
  
  
  
  1.27      +6 -16     parrot/t/pmc/iter.t
  
  Index: iter.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/iter.t,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -r1.26 -r1.27
  --- iter.t    8 Jul 2004 07:57:38 -0000       1.26
  +++ iter.t    10 Jul 2004 15:30:58 -0000      1.27
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: iter.t,v 1.26 2004/07/08 07:57:38 leo Exp $
  +# $Id: iter.t,v 1.27 2004/07/10 15:30:58 leo Exp $
   
   =head1 NAME
   
  @@ -1060,13 +1060,11 @@
   .sub main @MAIN
       .include "iterator.pasm"
       .local pmc hash
  -    .local pmc value
       .local pmc str
       str = new PerlString
       str = "abcdef"
       hash = new PerlHash
  -    null value
  -    hash."fromkeys"(str, value)
  +    hash."fromkeys"(str)
       $I0 = hash
       print $I0
       print " "
  @@ -1091,7 +1089,6 @@
   .sub main @MAIN
       .include "iterator.pasm"
       .local pmc hash
  -    .local pmc value
       .local pmc ar
       ar = new PerlArray
       push ar, "a"
  @@ -1100,8 +1097,7 @@
       push ar, "d"
       push ar, "e"
       hash = new PerlHash
  -    null value
  -    hash."fromkeys"(ar, value)
  +    hash."fromkeys"(ar)
       $I0 = hash
       print $I0
       print " "
  @@ -1153,7 +1149,6 @@
   .sub main @MAIN
       .include "iterator.pasm"
       .local pmc hash
  -    .local pmc value
       .local pmc ar
       ar = new PerlArray
       push ar, "a"
  @@ -1164,8 +1159,7 @@
       .local pmc sl
       sl = slice ar[1 ..]
       hash = new PerlHash
  -    null value
  -    hash."fromkeys"(sl, value)
  +    hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  @@ -1189,14 +1183,12 @@
   .sub main @MAIN
       .include "iterator.pasm"
       .local pmc hash
  -    .local pmc value
       .local pmc xr
       xr = new Slice[0 .. 10]
       .local pmc sl
       sl = new Iterator, xr
       hash = new PerlHash
  -    null value
  -    hash."fromkeys"(sl, value)
  +    hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  @@ -1255,14 +1247,12 @@
   .sub main @MAIN
       .include "iterator.pasm"
       .local pmc hash
  -    .local pmc value
       .local pmc xr
       xr = new Slice[0 .. 10]
       .local pmc sl
       sl = new Iterator, xr
       hash = new PerlHash
  -    null value
  -    hash."fromkeys"(sl, value)
  +    hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  
  
  

Reply via email to