cvsuser     04/03/04 07:28:41

  Modified:    src      objects.c
  Log:
  Fix sub-subclassing bug
  
  Revision  Changes    Path
  1.48      +27 -11    parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -w -r1.47 -r1.48
  --- objects.c 3 Mar 2004 14:17:27 -0000       1.47
  +++ objects.c 4 Mar 2004 15:28:41 -0000       1.48
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.47 2004/03/03 14:17:27 leo Exp $
  +$Id: objects.c,v 1.48 2004/03/04 15:28:41 dan Exp $
   
   =head1 NAME
   
  @@ -21,6 +21,21 @@
   #include "parrot/parrot.h"
   #include <assert.h>
   
  +static PMC *
  +clone_array(Parrot_Interp interpreter, PMC *source_array) {
  +    PMC *new_array;
  +    INTVAL count;
  +    INTVAL i;
  +    count = VTABLE_elements(interpreter, source_array);
  +    new_array = pmc_new(interpreter, enum_class_Array);
  +    VTABLE_set_integer_native(interpreter, new_array, count);
  +    for (i = 0; i < count; i++) {
  +        VTABLE_set_pmc_keyed_int(interpreter, new_array, i,
  +                                 VTABLE_get_pmc_keyed_int(interpreter, 
source_array, i));
  +    }
  +    return new_array;
  +}
  +
   /*
   
   =item C<static PMC *
  @@ -231,7 +246,7 @@
       /* Our penultimate parent list is a clone of our parent's parent
          list, with our parent unshifted onto the beginning */
       temp_pmc =
  -        VTABLE_clone(interpreter,
  +        clone_array(interpreter,
                   VTABLE_get_pmc_keyed_int(interpreter,
                       (PMC *)PMC_data(base_class), PCD_ALL_PARENTS));
       VTABLE_unshift_pmc(interpreter, temp_pmc, base_class);
  @@ -239,14 +254,14 @@
               temp_pmc);
   
       /* Our attribute list is our parent's attribute list */
  -    temp_pmc = VTABLE_clone(interpreter,
  +    temp_pmc = clone_array(interpreter,
               VTABLE_get_pmc_keyed_int(interpreter,
                   (PMC *)PMC_data(base_class), PCD_ATTRIB_OFFS));
       VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIB_OFFS,
               temp_pmc);
   
       /* And our full keyed attribute list is our parent's */
  -    temp_pmc = VTABLE_clone(interpreter,
  +    temp_pmc = clone_array(interpreter,
               VTABLE_get_pmc_keyed_int(interpreter,
                   (PMC *)PMC_data(base_class), PCD_ATTRIBUTES));
       VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIBUTES,
  @@ -415,6 +430,7 @@
       /* put in the real vtable
        * XXX we are leaking ths vtable
        */
  +    /*    object->vtable = Parrot_base_vtables[class_enum];*/
       object->vtable = Parrot_clone_vtable(interpreter,
                   Parrot_base_vtables[enum_class_ParrotObject]);
       /* and set type of class */
  
  
  

Reply via email to