[svn:parrot] r43681 - branches/pmc_freeze_with_pmcs/src/pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon Feb 1 07:10:16 UTC 2010


Author: plobsing
Date: Mon Feb  1 07:10:15 2010
New Revision: 43681
URL: https://trac.parrot.org/parrot/changeset/43681

Log:
Actually initialize id_list. also, switch to using RPA at the same time and fix typo on shift_float vtable declaration. This fixes the build and passes all tests except t/pmc/packfile*. Anyone on an i386 can fix these by bumping PBC_COMPAT and running mk_native_pbc.

Modified:
   branches/pmc_freeze_with_pmcs/src/pmc/imageio.pmc

Modified: branches/pmc_freeze_with_pmcs/src/pmc/imageio.pmc
==============================================================================
--- branches/pmc_freeze_with_pmcs/src/pmc/imageio.pmc	Mon Feb  1 06:07:05 2010	(r43680)
+++ branches/pmc_freeze_with_pmcs/src/pmc/imageio.pmc	Mon Feb  1 07:10:15 2010	(r43681)
@@ -128,12 +128,7 @@
 PARROT_INLINE
 static PMC*
 id_list_get(PARROT_INTERP, PMC *io, UINTVAL id) {
-    List * const id_list = (List *)PMC_data(PARROT_IMAGEIO(io)->id_list);
-    PMC **pos = (PMC **)Parrot_pmc_array_get(interp, id_list, id, enum_type_PMC);
-
-    if (pos && pos != ((void *)-1))
-        return *pos;
-    return NULL;
+    return VTABLE_get_pmc_keyed_int(interp, PARROT_IMAGEIO(io)->id_list, id);
 }
 
 PARROT_INLINE
@@ -162,11 +157,11 @@
             VTABLE_thaw(interp, pmc, info);
 
             {
-                List * const todo    = (List *)PMC_data(PARROT_IMAGEIO(info)->todo);
-                List * const id_list = (List *)PMC_data(PARROT_IMAGEIO(info)->id_list);
-                Parrot_pmc_array_assign(interp, id_list, id, pmc, enum_type_PMC);
+                PMC * const todo    = PARROT_IMAGEIO(info)->todo;
+                PMC * const id_list = PARROT_IMAGEIO(info)->id_list;
+                VTABLE_set_pmc_keyed_int(interp, id_list, id, pmc);
                 /* remember nested aggregates depth first */
-                Parrot_pmc_array_unshift(interp, todo, pmc, enum_type_PMC);
+                VTABLE_unshift_pmc(interp, todo, pmc);
             }
         }
         break;
@@ -212,8 +207,7 @@
         VTABLE_push_integer(interp, info,
                 PObj_is_object_TEST(pmc) ? enum_class_Object : pmc->vtable->base_type);
         parrot_hash_put(interp, hash, pmc, (void *)id);
-        Parrot_pmc_array_unshift(interp,
-            (List *)PMC_data(PARROT_IMAGEIO(info)->todo), pmc, enum_type_PMC);
+        VTABLE_unshift_pmc(interp, PARROT_IMAGEIO(info)->todo, pmc);
         VTABLE_freeze(interp, pmc, info);
     }
 }
@@ -221,15 +215,14 @@
 static void
 visit_loop_todo_list(PARROT_INTERP, PMC *current, PMC *info)
 {
-    PMC        **list_item;
-    List * const todo           = (List *)PMC_data(PARROT_IMAGEIO(info)->todo);
-    const int    thawing        = PARROT_IMAGEIO(info)->what == VISIT_THAW_NORMAL;
+    PMC * const todo     = PARROT_IMAGEIO(info)->todo;
+    const int    thawing = PARROT_IMAGEIO(info)->what == VISIT_THAW_NORMAL;
 
     (PARROT_IMAGEIO(info)->visit_pmc_now)(interp, current, info);
 
     /* can't cache upper limit, visit may append items */
-    while ((list_item = (PMC **)Parrot_pmc_array_shift(interp, todo, enum_type_PMC))) {
-        current = *list_item;
+    while (VTABLE_get_bool(interp, todo)) {
+        current = VTABLE_shift_pmc(interp, todo);
         if (!current)
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                     "NULL current PMC in visit_loop_todo_list");
@@ -247,13 +240,14 @@
 
     if (thawing) {
         /* on thawing call thawfinish for each processed PMC */
-        List        *finish_list = (List *)PMC_data(PARROT_IMAGEIO(info)->id_list);
-        const INTVAL n           = Parrot_pmc_array_length(interp, finish_list);
+        const INTVAL n = VTABLE_elements(interp, PARROT_IMAGEIO(info)->id_list);
         int          i;
 
+        /* XXX There are no younger or older pmcs in a directed graph that allows cycles. Any code that
+               requires a specific order here is likely broken. */
         /* Thaw in reverse order. We have to fully thaw younger PMCs before use them in older */
         for (i = n-1; i >= 0; --i) {
-            current = *(PMC**)Parrot_pmc_array_get(interp, finish_list, i, enum_type_PMC);
+            current = VTABLE_get_pmc_keyed_int(interp, PARROT_IMAGEIO(info)->id_list, i);
             if (!PMC_IS_NULL(current))
                 VTABLE_thawfinish(interp, current, info);
         }
@@ -296,7 +290,7 @@
     VTABLE void init() {
         PARROT_IMAGEIO(SELF)->thaw_ptr    = NULL;
         PARROT_IMAGEIO(SELF)->buffer      = NULL;
-        PARROT_IMAGEIO(SELF)->todo        = pmc_new(INTERP, enum_class_Array);
+        PARROT_IMAGEIO(SELF)->todo        = pmc_new(INTERP, enum_class_ResizablePMCArray);
         PARROT_IMAGEIO(SELF)->seen        = PMCNULL;
         PARROT_IMAGEIO(SELF)->id_list     = PMCNULL;
         PARROT_IMAGEIO(SELF)->id          = 0;
@@ -471,7 +465,7 @@
 
 /*
 
-=item C<VTABLE FLOATVAL shift_number()>
+=item C<VTABLE FLOATVAL shift_float()>
 
 Removes and returns an number from the start of the image.
 
@@ -479,7 +473,7 @@
 
 */
 
-VTABLE FLOATVAL shift_number() {
+VTABLE FLOATVAL shift_float() {
     opcode_t *pos    = GET_VISIT_CURSOR(SELF);
     const FLOATVAL f = PF_fetch_number(PARROT_IMAGEIO(SELF)->pf, (const opcode_t **)&pos);
     SET_VISIT_CURSOR(SELF, pos);
@@ -520,7 +514,7 @@
 VTABLE PMC *shift_pmc() {
     PMC *result;
     VTABLE_set_pointer(interp, SELF, &result);
-    (PARROT_IMAGEIO(SELF)->visit_pmc_now)(interp, NULL, PARROT_IMAGEIO(SELF));
+    (PARROT_IMAGEIO(SELF)->visit_pmc_now)(interp, NULL, SELF);
     return result;
 }
 
@@ -550,6 +544,7 @@
         PARROT_IMAGEIO(SELF)->what          = VISIT_THAW_NORMAL;
         PARROT_IMAGEIO(SELF)->visit_pmc_now = visit_todo_list_thaw;
         PARROT_IMAGEIO(SELF)->buffer        = (Buffer *)image;
+        PARROT_IMAGEIO(SELF)->id_list       = pmc_new(INTERP, enum_class_ResizablePMCArray);
 
         PARROT_ASSERT(image->_bufstart == image->strstart);
 


More information about the parrot-commits mailing list