develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35607 - in branches/morph_pmc_type/src: . pmc

From:
Whiteknight
Date:
January 15, 2009 15:54
Subject:
[svn:parrot] r35607 - in branches/morph_pmc_type/src: . pmc
Message ID:
20090115235259.87BB4CB9AE@x12.develooper.com
Author: Whiteknight
Date: Thu Jan 15 15:52:58 2009
New Revision: 35607

Modified:
   branches/morph_pmc_type/src/pmc/default.pmc
   branches/morph_pmc_type/src/pmc/object.pmc
   branches/morph_pmc_type/src/pmc/pointer.pmc
   branches/morph_pmc_type/src/pmc/ref.pmc
   branches/morph_pmc_type/src/pmc/scalar.pmc
   branches/morph_pmc_type/src/vtable.tbl

Log:
[morph_pmc_type] add morph_string vtable methods to PMCs that had morphs. These should act identically, but they take strings instead of intvals. Now I can start switching the old VTABLE_morph to VTABLE_morph_string

Modified: branches/morph_pmc_type/src/pmc/default.pmc
==============================================================================
--- branches/morph_pmc_type/src/pmc/default.pmc	(original)
+++ branches/morph_pmc_type/src/pmc/default.pmc	Thu Jan 15 15:52:58 2009
@@ -635,6 +635,11 @@
         pmc_reuse(INTERP, SELF, type, 0);
     }
 
+    VTABLE void morph_string(STRING * type) {
+        const INTVAL typenum = pmc_type(interp, type);
+        pmc_reuse(INTERP, SELF, typenum, 0);
+    }
+
 /*
 
 =item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>

Modified: branches/morph_pmc_type/src/pmc/object.pmc
==============================================================================
--- branches/morph_pmc_type/src/pmc/object.pmc	(original)
+++ branches/morph_pmc_type/src/pmc/object.pmc	Thu Jan 15 15:52:58 2009
@@ -848,19 +848,34 @@
 */
 
     VTABLE void morph(INTVAL type) {
-		PMC    * const classobj = VTABLE_get_class(interp, SELF);
+        PMC    * const classobj = VTABLE_get_class(interp, SELF);
         STRING * meth_name      = CONST_STRING(interp, "morph");
         /* If there's a vtable override for 'morph' run that instead. */
         PMC * const method = Parrot_oo_find_vtable_override(interp,
                 classobj, meth_name);
 
         if (!PMC_IS_NULL(method)) {
-            STRING *typename = string_copy(interp, interp->vtables[type]->whoami);
+            STRING * typename = string_copy(interp, interp->vtables[type]->whoami);
             Parrot_run_meth_fromc_args(interp, method, SELF, meth_name, "vS", typename);
         }
         else
             SUPER(type);
     }
+
+    VTABLE void morph_string(STRING * type) {
+        PMC * const classobj = VTABLE_get_class(interp, SELF);
+
+        /* PIR morph vtable overrides already take a string argument, so we
+           can use those transparently. Once everything gets switched to
+           "morph_string", we delete the old one and rename this to "morph". */
+        STRING * meth_name = CONST_STRING(interp, "morph");
+        PMC * const method = Parrot_oo_find_vtable_override(interp,
+            classobj, meth_name);
+        if (!PMC_IS_NULL(method))
+            Parrot_run_meth_fromc_args(interp, method, SELF, meth_name, "vS", type);
+        else
+            SUPER(type);
+    }
 }
 
 /*

Modified: branches/morph_pmc_type/src/pmc/pointer.pmc
==============================================================================
--- branches/morph_pmc_type/src/pmc/pointer.pmc	(original)
+++ branches/morph_pmc_type/src/pmc/pointer.pmc	Thu Jan 15 15:52:58 2009
@@ -51,6 +51,9 @@
     VTABLE void morph(INTVAL type) {
     }
 
+    VTABLE void morph_string(STRING type) {
+    }
+
 /*
 
 =item C<void mark()>

Modified: branches/morph_pmc_type/src/pmc/ref.pmc
==============================================================================
--- branches/morph_pmc_type/src/pmc/ref.pmc	(original)
+++ branches/morph_pmc_type/src/pmc/ref.pmc	Thu Jan 15 15:52:58 2009
@@ -149,10 +149,15 @@
 =cut
 
 */
+
     VTABLE void morph(INTVAL type) {
         SUPER(type);
     }
 
+    VTABLE void morph_string(STRING * type) {
+        SUPER(type);
+    }
+
 }
 
 /*

Modified: branches/morph_pmc_type/src/pmc/scalar.pmc
==============================================================================
--- branches/morph_pmc_type/src/pmc/scalar.pmc	(original)
+++ branches/morph_pmc_type/src/pmc/scalar.pmc	Thu Jan 15 15:52:58 2009
@@ -101,6 +101,13 @@
             return;
         pmc_reuse(INTERP, SELF, type, 0);
     }
+
+    VTABLE void morph_string(STRING * type) {
+        const INTVAL t = pmc_type(INTERP, type);
+        if (SELF->vtable->base_type == t)
+            return;
+        pmc_reuse(INTERP, SELF, t, 0);
+    }
 /*
 
 =item C<void assign_pmc(PMC *value)>

Modified: branches/morph_pmc_type/src/vtable.tbl
==============================================================================
--- branches/morph_pmc_type/src/vtable.tbl	(original)
+++ branches/morph_pmc_type/src/vtable.tbl	Thu Jan 15 15:52:58 2009
@@ -12,7 +12,7 @@
 PMC* instantiate(PMC* sig)
 PMC* new_from_string(STRING* rep, INTVAL flags)
 void morph(INTVAL type) :write
-void morph_string(STRING type) :write
+void morph_string(STRING* type) :write
 void mark()
 void destroy()
 PMC* get_namespace()



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About