A better fix is to update pmc_reuse in src/pmc.c so it correctly handles
morphing to object types. See pmc_new in the same file for an example of
instantiating an object from a type ID (by looking up the class object).
As Jonathan started to ponder in his message "Morphing to high level
classes", this may mean having the 'instantiate' vtable function check
the hash parameter for a 'reuse' key, a PMC header to reuse. (50/50 on
whether we want to expose that as an option from the PIR-level interface
or block it.)
Allison
[EMAIL PROTECTED] wrote:
Author: chromatic
Date: Tue Nov 20 20:42:22 2007
New Revision: 22924
Modified:
trunk/src/pmc/undef.pmc
Log:
[PMC] assign $P0, $P1 failed with badness when $P0 was an Undef PMC and $P1 was
an Object, because the assign_pmc vtable entry first morphed the Undef PMC into
a like Object and then tried to instantiate it with the init vtable entry.
This does not work on Objects, as you must instantiate them from their Classes.
Now there's no morph into an Object; the Undef PMC morphs into a Ref and points
to the Object instead.
Modified: trunk/src/pmc/undef.pmc
==============================================================================
--- trunk/src/pmc/undef.pmc (original)
+++ trunk/src/pmc/undef.pmc Tue Nov 20 20:42:22 2007
@@ -48,7 +48,7 @@
=item C<void assign_pmc(PMC *other)>
-Assigns the PMC to the value of C<*other>by first changing the PMC to the
+Assigns the PMC to the value of C<*other> by first changing the PMC to the
appropriate type.
=cut
@@ -56,7 +56,8 @@
*/
void assign_pmc(PMC *other) {
- VTABLE_morph(INTERP, SELF, other->vtable->base_type);
+ if (!PObj_is_object_TEST(other))
+ VTABLE_morph(INTERP, SELF, other->vtable->base_type);
/* don't want to call set_pmc if we're assigning an Undef to an Undef */
if (other->vtable->base_type != enum_class_Undef)