cvsuser     04/07/13 09:28:31

  Modified:    classes  iterator.pmc
               languages/python pie-thon.pl
               src      py_func.c
               t/pmc    iter.t
  Log:
  Pie-thon 63 - Python iter converted; fixed fromkeys tests
  
  Revision  Changes    Path
  1.27      +11 -1     parrot/classes/iterator.pmc
  
  Index: iterator.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/iterator.pmc,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -r1.26 -r1.27
  --- iterator.pmc      8 Jul 2004 07:57:26 -0000       1.26
  +++ iterator.pmc      13 Jul 2004 16:28:15 -0000      1.27
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: iterator.pmc,v 1.26 2004/07/08 07:57:26 leo Exp $
  +$Id: iterator.pmc,v 1.27 2004/07/13 16:28:15 leo Exp $
   
   =head1 NAME
   
  @@ -456,6 +456,16 @@
           PMC *agg, *key, *res;
           INTVAL ires;
   
  +        if (REG_INT(3) == 1) {       /* iterator constructor */
  +            PMC *iter;
  +            REG_PMC(5) = iter = pmc_new_init(INTERP,
  +                    enum_class_Iterator, REG_PMC(5));
  +            VTABLE_set_integer_native(INTERP, iter, 0);
  +            return next;
  +        }
  +        else if (REG_INT(3) == 2)   /* TODO function+sentinel */
  +            internal_exception(1, "Iterator: invoke 2 args");
  +
           REG_INT(1) = REG_INT(2) = REG_INT(3) = REG_INT(4) = 0;
           key = PMC_struct_val(SELF);
           agg = PMC_pmc_val(SELF);
  
  
  
  1.41      +3 -55     parrot/languages/python/pie-thon.pl
  
  Index: pie-thon.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/pie-thon.pl,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -r1.40 -r1.41
  --- pie-thon.pl       13 Jul 2004 15:21:35 -0000      1.40
  +++ pie-thon.pl       13 Jul 2004 16:28:21 -0000      1.41
  @@ -18,7 +18,6 @@
   
   my %builtin_ops = (
       abs => 'o',
  -    iter => 'o',
   );
   
   my %builtins = (
  @@ -34,6 +33,7 @@
       hash => 1,
       hex => 1,
       id => 1,
  +    iter => 1,
       filter => 1,
       list => 1,
       long => 1,
  @@ -59,6 +59,8 @@
       dict  => 'Py_dict',
       list  => 'Py_list',
       tuple => 'Py_tuple',
  +
  +    iter  => 'Py_iter',
   );
   
   
  @@ -908,59 +910,6 @@
       }
   }
   
  -# python func to opcode translations
  -sub OPC_bool {
  -    my ($n, $c, $cmt) = @_;
  -    my $b = temp('I');
  -    my $p = temp('P');
  -    my $arg = promote(pop @stack);
  -    my $self = pop @stack;
  -    print <<EOC;
  -     $b = istrue $arg $cmt
  -     # TODO create true P, false P opcodes
  -     $p = new .Boolean
  -     $p = $b
  -EOC
  -    push @stack, [-1, $p, 'I'];
  -}
  -
  -sub OPC_complex {
  -    my ($n, $c, $cmt) = @_;
  -    my $p = temp('P');
  -    my $im = pop @stack;
  -    my $re = pop @stack; # TODO 1 argument only
  -    my $self = pop @stack;
  -    print "\t# stack messed $c ne $self->[1]\n" if ($c ne $self->[1]);
  -    print <<EOC;
  -     # cmplx($re->[1], $im->[1]) $cmt
  -     $p = new .Complex
  -EOC
  -    if ($re->[2] eq 'P') {
  -     my $n = temp('N');
  -     print <<EOC;
  -     $n = $re->[1]
  -     $p = $n
  -EOC
  -    }
  -    else {
  -     print <<EOC;
  -     $p = $re->[1]
  -EOC
  -    }
  -    if ($im->[2] eq 'P') {
  -     my $n = temp('N');
  -     print <<EOC;
  -     $n = $im->[1]
  -     $p\["imag"\] = $n
  -EOC
  -    }
  -    else {
  -     print <<EOC;
  -     $p\["imag"\] = $im->[1]
  -EOC
  -    }
  -    push @stack, [-1, $p, 'I'];
  -}
   
   sub ret_val {
       my $a = shift;
  @@ -1150,7 +1099,6 @@
   sub BUILD_TUPLE
   {
       my ($n, $c, $cmt, $type) = @_;
  -    # TODO iter for FixedPMCArray
       $type = "FixedPMCArray" unless defined $type;
       my ($opcode, $rest) = ($code[$code_l]->[2],$code[$code_l]->[4]);
       if ($opcode eq 'UNPACK_SEQUENCE') {
  
  
  
  1.28      +7 -1      parrot/src/py_func.c
  
  Index: py_func.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/py_func.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -r1.27 -r1.28
  --- py_func.c 13 Jul 2004 15:21:38 -0000      1.27
  +++ py_func.c 13 Jul 2004 16:28:26 -0000      1.28
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: py_func.c,v 1.27 2004/07/13 15:21:38 leo Exp $
  +$Id: py_func.c,v 1.28 2004/07/13 16:28:26 leo Exp $
   
   =head1 NAME
   
  @@ -566,6 +566,9 @@
       STRING *Py_dict  = CONST_STRING(interpreter, "Py_dict");
       STRING *Py_list  = CONST_STRING(interpreter, "Py_list");
       STRING *Py_tuple = CONST_STRING(interpreter, "Py_tuple");
  +
  +    STRING *Py_iter  = CONST_STRING(interpreter, "Py_iter");
  +
       PMC* class;
       /*
        * new types interface, just place a class object as global
  @@ -591,6 +594,9 @@
       class = Parrot_base_vtables[enum_class_PerlHash]->data;
       Parrot_store_global(interpreter, NULL, Py_dict, class);
   
  +    class = Parrot_base_vtables[enum_class_Iterator]->data;
  +    Parrot_store_global(interpreter, NULL, Py_iter, class);
  +
       parrot_py_global(interpreter, F2DPTR(parrot_py_assert_e), assert_e, pip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_callable), callable, pip);
       parrot_py_global(interpreter, F2DPTR(parrot_py_chr), chr, pip);
  
  
  
  1.28      +6 -6      parrot/t/pmc/iter.t
  
  Index: iter.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/iter.t,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -r1.27 -r1.28
  --- iter.t    10 Jul 2004 15:30:58 -0000      1.27
  +++ iter.t    13 Jul 2004 16:28:31 -0000      1.28
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: iter.t,v 1.27 2004/07/10 15:30:58 leo Exp $
  +# $Id: iter.t,v 1.28 2004/07/13 16:28:31 leo Exp $
   
   =head1 NAME
   
  @@ -1064,7 +1064,7 @@
       str = new PerlString
       str = "abcdef"
       hash = new PerlHash
  -    hash."fromkeys"(str)
  +    hash = hash."fromkeys"(str)
       $I0 = hash
       print $I0
       print " "
  @@ -1097,7 +1097,7 @@
       push ar, "d"
       push ar, "e"
       hash = new PerlHash
  -    hash."fromkeys"(ar)
  +    hash = hash."fromkeys"(ar)
       $I0 = hash
       print $I0
       print " "
  @@ -1159,7 +1159,7 @@
       .local pmc sl
       sl = slice ar[1 ..]
       hash = new PerlHash
  -    hash."fromkeys"(sl)
  +    hash = hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  @@ -1188,7 +1188,7 @@
       .local pmc sl
       sl = new Iterator, xr
       hash = new PerlHash
  -    hash."fromkeys"(sl)
  +    hash = hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  @@ -1252,7 +1252,7 @@
       .local pmc sl
       sl = new Iterator, xr
       hash = new PerlHash
  -    hash."fromkeys"(sl)
  +    hash = hash."fromkeys"(sl)
       $I0 = hash
       print $I0
       print " "
  
  
  

Reply via email to