Dan,

 I've been playing about with the new object stuff you added today, and
 I've noticed a couple of problems.

 Firstly, when your doing the initialization for a new ParrotClass PMC,
 you create an Array to hold various other PMCs, but you don't size the
 array; this means that when you later try to put things in it in
 Parrot_new_class, it dies with:

  Array index out of bounds!

 The simplest solution is just to specify the size, as in the patch below.

 ------------

 The other problem I noticed was that in a bunch of the ops you're using
 code like:

     PMC *class = VTABLE_get_pmc_keyed(interpreter,
            interpreter->class_hash, key_new_string(interpreter, $2));

 to get the ParrotClass PMC, and then seeing whether it's a valid class
 by checking whether class is NULL. For instance, in findclass, you have:

  if (VTABLE_get_pmc_keyed(interpreter, interpreter->class_hash,
                           key_new_string(interpreter, $2))) {
    $1 = 1;
  } else {
    $1 = 0;
  }

 Unfortunately, this doesn't do what you intend. When you look up a
 non-existent entry in a PerlHash, it creates and returns a PerlUndef PMC,
 so the class pointer that you get is always non-NULL, even though it
 isn't necessarily a ParrotClass. Consequently, in the example above,
 findclass always returns true.

 I'm not sure what the best fix is here.

 Simon


--- classes/parrotclass.pmc     Wed Jul 16 22:28:40 2003
+++ classes/parrotclass.pmc.new Wed Jul 16 22:28:35 2003
@@ -32,6 +32,8 @@
   void init () {
     /* Hang an array off the data pointer, empty of course */
     PMC_data(SELF) = pmc_new(interpreter, enum_class_Array);
+    /* We will have five entries in this array */
+    VTABLE_set_integer_native(interpreter, (PMC*)PMC_data(SELF), (INTVAL)5);
     /* No attributes to start with */
     SELF->obj.u.int_val = 0;
     /* But we are a class, really */




Reply via email to