cvsuser     04/03/16 13:29:13

  Modified:    classes  delegate.pmc parrotobject.pmc
               include/parrot objects.h
               ops      object.ops
               src      objects.c
  Log:
  Switch over to using a buffer to hold attributes
  
  Revision  Changes    Path
  1.20      +4 -3      parrot/classes/delegate.pmc
  
  Index: delegate.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/delegate.pmc,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -w -r1.19 -r1.20
  --- delegate.pmc      13 Mar 2004 08:43:06 -0000      1.19
  +++ delegate.pmc      16 Mar 2004 21:28:56 -0000      1.20
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2003 The Perl Foundation.  All Rights Reserved.
  -$Id: delegate.pmc,v 1.19 2004/03/13 08:43:06 leo Exp $
  +$Id: delegate.pmc,v 1.20 2004/03/16 21:28:56 dan Exp $
   
   =head1 NAME
   
  @@ -115,6 +115,8 @@
   */
   
   
  +#define get_attrib_num(x, y) *((PMC **)PObj_bufstart(x)+y)
  +
   PARROT_INLINE static PMC *
   find_meth(Parrot_Interp interpreter, PMC *pmc, const char *name) {
       STRING *meth = string_from_cstring(interpreter, name, 0);
  @@ -126,8 +128,7 @@
           print_pbc_location(interpreter);
       }
       if (PObj_is_object_TEST(pmc)) {
  -        class = VTABLE_get_pmc_keyed_int(interpreter, (PMC *)PMC_data(pmc),
  -                POD_CLASS);
  +        class = get_attrib_num((Buffer *)PMC_data(pmc), POD_CLASS);
       }
       REG_STR(2) = meth;
       return Parrot_find_method_with_cache(interpreter, class, meth);
  
  
  
  1.22      +4 -3      parrot/classes/parrotobject.pmc
  
  Index: parrotobject.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/parrotobject.pmc,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -w -r1.21 -r1.22
  --- parrotobject.pmc  4 Mar 2004 17:15:59 -0000       1.21
  +++ parrotobject.pmc  16 Mar 2004 21:28:56 -0000      1.22
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: parrotobject.pmc,v 1.21 2004/03/04 17:15:59 dan Exp $
  +$Id: parrotobject.pmc,v 1.22 2004/03/16 21:28:56 dan Exp $
   
   =head1 NAME
   
  @@ -45,6 +45,7 @@
   
   #include "parrot/parrot.h"
   
  +#define get_attrib_num(x, y) *((PMC **)PObj_bufstart(x)+y)
   
   pmclass ParrotObject extends ParrotClass need_ext {
   
  @@ -95,7 +96,7 @@
   
   
       STRING* name() {
  -        return VTABLE_get_string_keyed_int(INTERP, (PMC *)PMC_data(SELF), 
POD_CLASS_NAME);
  +        return VTABLE_get_string(INTERP, (PMC *)get_attrib_num((Buffer 
*)PMC_data(SELF), POD_CLASS_NAME));
       }
   
   
  @@ -110,7 +111,7 @@
   */
   
       PMC* find_method(STRING* name) {
  -        PMC *class = VTABLE_get_pmc_keyed_int(INTERP, (PMC *)PMC_data(SELF), 0);
  +        PMC *class = get_attrib_num((PMC *)PMC_data(SELF), 0);
           return Parrot_find_method_with_cache(INTERP, class, name);
       }
   
  
  
  
  1.21      +24 -1     parrot/include/parrot/objects.h
  
  Index: objects.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/objects.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -w -r1.20 -r1.21
  --- objects.h 4 Mar 2004 18:19:38 -0000       1.20
  +++ objects.h 16 Mar 2004 21:29:01 -0000      1.21
  @@ -1,7 +1,7 @@
   /* objects.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: objects.h,v 1.20 2004/03/04 18:19:38 dan Exp $
  + *     $Id: objects.h,v 1.21 2004/03/16 21:29:01 dan Exp $
    *  Overview:
    *     Parrot class and object header stuff
    *  Data Structure and Algorithms:
  @@ -60,6 +60,29 @@
   void Parrot_set_class_destructor(Parrot_Interp, STRING *, INTVAL, STRING *);
   void Parrot_set_class_fallback(Parrot_Interp, STRING *, INTVAL, STRING *);
   
  +/* Get and set attributes. */
  +#if 0
  +/* Old way */
  +#define get_attrib_num(x, y) VTABLE_get_pmc_keyed_int(interpreter, x, y)
  +#define set_attrib_num(x, y, z) VTABLE_set_pmc_keyed_int(interpreter, x, y, z)
  +#define get_attrib_count(x) VTABLE_elements(interpreter, x)
  +#define new_attrib_array() pmc_new(interpreter, enum_class_Array)
  +#define set_attrib_array_size(x, y) VTABLE_set_integer_native(interpreter, (x), (y))
  +#define resize_attrib_array(x, y)  VTABLE_set_integer_native(interpreter, (x), (y))
  +#define set_attrib_flags(x)
  +#define SLOTTYPE PMC
  +
  +#else
  +/* These are the new way */
  +#define get_attrib_num(x, y) *((PMC **)PObj_bufstart(x)+y)
  +#define set_attrib_num(x, y, z) { PMC **foo = (PMC **)PObj_bufstart(x); foo[y] = z; 
}
  +#define get_attrib_count(x) (PObj_buflen(x) / sizeof(PMC *))
  +#define new_attrib_array() new_buffer_header(interpreter)
  +#define set_attrib_flags(x) PObj_is_buffer_of_PMCs_ptr_SET(x)
  +#define set_attrib_array_size(x, y) Parrot_allocate_zeroed(interpreter, x, 
(sizeof(PMC *)*(y)))
  +#define resize_attrib_array(x, y) Parrot_reallocate(interpreter, x, (sizeof(PMC 
*)*(y)))
  +#define SLOTTYPE Buffer
  +#endif
   #endif
   
   /*
  
  
  
  1.33      +2 -4      parrot/ops/object.ops
  
  Index: object.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/object.ops,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -w -r1.32 -r1.33
  --- object.ops        26 Feb 2004 17:10:23 -0000      1.32
  +++ object.ops        16 Mar 2004 21:29:08 -0000      1.33
  @@ -224,8 +224,7 @@
   
   inline op class(out PMC, in PMC) {
       if (PObj_is_object_TEST($2))
  -     $1 = VTABLE_get_pmc_keyed_int(interpreter,
  -             (PMC *)PMC_data($2), POD_CLASS);
  +     $1 = get_attrib_num((Buffer *)PMC_data($2), POD_CLASS);
       else
        $1 = $2;
       goto NEXT();
  @@ -240,8 +239,7 @@
   inline op classname(out STR, in PMC) {
     PMC* classname_pmc;
   
  -  classname_pmc = VTABLE_get_pmc_keyed_int(interpreter,
  -                  (PMC *)PMC_data($2), PCD_CLASS_NAME);
  +  classname_pmc = get_attrib_num((Buffer *)PMC_data($2), PCD_CLASS_NAME);
     if (classname_pmc) {
         $1 = VTABLE_get_string(interpreter, classname_pmc);
     }
  
  
  
  1.59      +13 -33    parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -w -r1.58 -r1.59
  --- objects.c 16 Mar 2004 19:02:14 -0000      1.58
  +++ objects.c 16 Mar 2004 21:29:13 -0000      1.59
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.58 2004/03/16 19:02:14 dan Exp $
  +$Id: objects.c,v 1.59 2004/03/16 21:29:13 dan Exp $
   
   =head1 NAME
   
  @@ -21,26 +21,6 @@
   #include "parrot/parrot.h"
   #include <assert.h>
   
  -/* Get and set attributes. */
  -#define get_attrib_num(x, y) VTABLE_get_pmc_keyed_int(interpreter, x, y)
  -#define set_attrib_num(x, y, z) VTABLE_set_pmc_keyed_int(interpreter, x, y, z)
  -#define get_attrib_count(x) VTABLE_elements(interpreter, x)
  -#define new_attrib_array() pmc_new(interpreter, enum_class_Array)
  -#define set_attrib_array_size(x, y) VTABLE_set_integer_native(interpreter, (x), (y))
  -#define resize_attrib_array(x, y)  VTABLE_set_integer_native(interpreter, (x), (y))
  -#define set_attrib_flags(x)
  -#define SLOTTYPE PMC
  -
  -/* These are the new way, which isn't in yet
  -#define get_attrib_num(x, y) ((PMC *)PObj_bufstart(x))+y
  -#define set_attrib_num(x, y, z) ((PMC *)PObj_bufstart(x))+y = z
  -#define get_attrib_count(x) (PObj_buflen(x) / sizeof(PMC *))
  -#define new_attrib_array() new_buffer_header(interpreter)
  -#define set_attrib_flags(x) PObj_is_buffer_of_PMCs_ptr_set(x)
  -#define set_attrib_array_size(x, y) Parrot_allocate_zeroed(interpreter, x, 
(sizeof(PMC *)*(y)))
  -#define resize_attrib_array(x, y) Parrot_reallocate(interpreter, x, (sizeof(PMC 
*)*(y)))
  -#define SLOTTYPE Buffer
  -*/
   
   static PMC *
   clone_array(Parrot_Interp interpreter, PMC *source_array) {
  @@ -263,7 +243,7 @@
       /* Hang an array off the data pointer */
       child_class_array = PMC_data(child_class) =
           new_attrib_array();
  -    set_attrib_flags(child_class_array);
  +    set_attrib_flags(child_class);
       /* We will have five entries in this array */
       set_attrib_array_size(child_class_array, PCD_MAX);
   
  @@ -344,10 +324,11 @@
       PMC *classname_pmc;
       INTVAL new_class_number;
       VTABLE *new_vtable;
  +    PMC *temp_pmc;
   
       /* Hang an array off the data pointer, empty of course */
       class_array = PMC_data(class) = new_attrib_array();
  -    set_attrib_flags(class_array);
  +    set_attrib_flags(class);
       /* We will have five entries in this array */
       set_attrib_array_size(class_array, PCD_MAX);
       /* Our parent class array has nothing in it */
  @@ -477,7 +458,7 @@
       PMC *parent_class;
       INTVAL i, nparents;
   
  -    nparents = VTABLE_get_integer(interpreter, classsearch_array);
  +    nparents = VTABLE_elements(interpreter, classsearch_array);
       for (i = nparents - 1; i >= 0; --i) {
           parent_class = VTABLE_get_pmc_keyed_int(interpreter,
                   classsearch_array, i);
  @@ -502,7 +483,7 @@
   
   void
   Parrot_instantiate_object(Parrot_Interp interpreter, PMC *object) {
  -    PMC *new_object_array;
  +    SLOTTYPE *new_object_array;
       INTVAL attrib_count;
       SLOTTYPE *class_array;
       PMC *class;
  @@ -513,7 +494,6 @@
       /*
        * put in the real vtable
        */
  -
       vtable_pmc = get_attrib_num((SLOTTYPE *)PMC_data(class), PCD_OBJECT_VTABLE);
       object->vtable = PMC_struct_val(vtable_pmc);
   
  @@ -525,7 +505,9 @@
   
       /* Build the array that hangs off the new object */
       new_object_array = new_attrib_array();
  -    set_attrib_flags(new_object_array);
  +    PMC_data(object) = new_object_array;
  +    set_attrib_flags(object);
  +
       /* Presize it */
       set_attrib_array_size(new_object_array,
                             attrib_count + POD_FIRST_ATTRIB);
  @@ -536,8 +518,6 @@
       /* Note the number of used slots */
       object->cache.int_val = POD_FIRST_ATTRIB + attrib_count;
   
  -    PMC_data(object) = new_object_array;
  -    PObj_flag_SET(is_PMC_ptr, object);
       /* We are an object now */
       PObj_is_object_SET(object);
   
  @@ -591,7 +571,7 @@
       VTABLE_set_integer_native(interpreter, current_parent_array,
                                 current_size + 1);
       VTABLE_set_pmc_keyed_int(interpreter, current_parent_array, current_size,
  -                            add_on_class);
  +                            add_on_class_obj);
   
       /* Loop through them. We can assume that we can just tack on any
          new classes to the end of the current class array. Attributes
  @@ -707,7 +687,7 @@
   Parrot_object_isa(Parrot_Interp interpreter, PMC *pmc, PMC *cl) {
       PMC * t;
       SLOTTYPE *object_array = PMC_data(pmc);
  -    SLOTTYPE *classsearch_array; /* The array of classes we're searching */
  +    PMC *classsearch_array; /* The array of classes we're searching */
       INTVAL i, classcount;
   
       /* if this is a class */
  
  
  

Reply via email to