A PASM version of the test case is:

   newclass P16, "A"
   subclass P16, P16, "B"
   subclass P16, P16, "C"
   end

 I think I've figured out what's happening here. Stepping through the
 code with gdb shows that the first subclassing works fine, but the second
 blows up in Parrot_single_subclass at line 233:

    temp_pmc =
        VTABLE_clone(interpreter,
                VTABLE_get_pmc_keyed_int(interpreter,
                    (PMC *)PMC_data(base_class), PCD_ALL_PARENTS));

 This fetches the parent class's parent array, which is an Array PMC,
 and which at this point contains a single entry -- a ParrotClass PMC
 corresponding to class "A".

 We then call the clone method of this array, in order to copy it to
 temp_pmc.

 This in turn calls list_clone in order to copy its data, and since our
 list is comprised of a single PMC, list_clone calls its clone vtable
 method.

 BUT: this PMC is a ParrotClass, and there isn't currently a clone method
 implemented for ParrotClass, so we fall back on the default option, which
 is to throw an exception and die.

 The only reason that this works the first time that we create a subclass
 is that at that point the parent's parent list is empty.

 An obvious fix for this would be to implement a clone method for
 ParrotClass, but I'm not sure if this really makes sense, as we could
 then potentially end up with multiple PMCs representing the same class.
 (Also, implies that objects in deeply nested classes would have a
  considerable memory overhead, since they'd each have to drag around PMCs
  for each of their parent classes).

 Simon



Reply via email to