[svn:parrot] r41373 - in trunk: src/pmc t/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sun Sep 20 00:02:58 UTC 2009


Author: chromatic
Date: Sun Sep 20 00:02:56 2009
New Revision: 41373
URL: https://trac.parrot.org/parrot/changeset/41373

Log:
[PMC] Fixed Undef's set_pmc() VTABLE: when assigning an Object to an Undef, the
Undef PMC ended up getting the Object's *Class*'s vtable, not the Object's
vtable.  Understandably this causes confusion, especially as the attribute
structs of Class and Object are very different.

Added Undef morph to Object test to ensure that the morph gets the right

Modified:
   trunk/src/pmc/undef.pmc
   trunk/t/pmc/undef.t

Modified: trunk/src/pmc/undef.pmc
==============================================================================
--- trunk/src/pmc/undef.pmc	Sat Sep 19 22:38:15 2009	(r41372)
+++ trunk/src/pmc/undef.pmc	Sun Sep 20 00:02:56 2009	(r41373)
@@ -49,11 +49,11 @@
             PMC        *clone   = VTABLE_clone(interp, other);
             void       *attrs   = PMC_data(clone);
             PMC        *meta    = PMC_metadata(clone);
-            pmc_reuse_by_class(INTERP, SELF, class_, PObj_is_object_FLAG);
 
             /* now swap memory without leaking it */
             PMC_data(clone)     = PMC_data(SELF);
             PMC_data(SELF)      = attrs;
+            SELF->vtable        = clone->vtable;
 
             /* Restore metadata. */
             if (!PMC_IS_NULL(meta)) {

Modified: trunk/t/pmc/undef.t
==============================================================================
--- trunk/t/pmc/undef.t	Sat Sep 19 22:38:15 2009	(r41372)
+++ trunk/t/pmc/undef.t	Sun Sep 20 00:02:56 2009	(r41373)
@@ -1,5 +1,5 @@
 #! parrot
-# Copyright (C) 2001-2008, Parrot Foundation.
+# Copyright (C) 2001-2009, Parrot Foundation.
 # $Id$
 
 =head1 NAME
@@ -19,7 +19,7 @@
 .sub main :main
     .include 'test_more.pir'
 
-    plan(23)
+    plan(24)
 
     morph_to_string()
     undef_pmc_is_false()
@@ -191,6 +191,9 @@
     $I0 = isa $P0, $P1
     ok( $I0, 'Assign Object to Undef' )
 
+    $S0 = $P0
+    is( $S0, 'A string', '... and the right object' )
+
     $P0 = new "Undef"
     $P1 = subclass 'ResizablePMCArray', 'FooRPA'
     $P2 = new $P1
@@ -202,6 +205,12 @@
     #       across the assignment
 .end
 
+.namespace [ 'HI' ]
+
+.sub get_string :vtable :method
+    .return( 'A string' )
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list