[svn:parrot] r43122 - in branches/pmc_freeze_cleanup: include/parrot src/pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Thu Dec 17 05:37:57 UTC 2009


Author: plobsing
Date: Thu Dec 17 05:37:56 2009
New Revision: 43122
URL: https://trac.parrot.org/parrot/changeset/43122

Log:
add VISIT_PMC_ATTR macro to visit an attribute easily
need to pass in the class because of pmc2c--

Modified:
   branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h
   branches/pmc_freeze_cleanup/src/pmc/class.pmc

Modified: branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h
==============================================================================
--- branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h	Thu Dec 17 05:29:25 2009	(r43121)
+++ branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h	Thu Dec 17 05:37:56 2009	(r43122)
@@ -74,6 +74,21 @@
 
 #define IMAGE_IO visit_info
 
+#define VISIT_PMC_ATTR(interp, visit, self, pmclass, attr_name) do {\
+    PMC *_visit_pmc_attr; \
+    switch (VTABLE_get_integer((interp), (visit))) { \
+      case VISIT_FREEZE_NORMAL: \
+        GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
+        VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \
+        break; \
+      case VISIT_THAW_NORMAL: \
+      case VISIT_THAW_CONSTANTS: \
+        _visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \
+        SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
+        break; \
+    } \
+} while (0)
+
 /*
  * public interfaces
  */

Modified: branches/pmc_freeze_cleanup/src/pmc/class.pmc
==============================================================================
--- branches/pmc_freeze_cleanup/src/pmc/class.pmc	Thu Dec 17 05:29:25 2009	(r43121)
+++ branches/pmc_freeze_cleanup/src/pmc/class.pmc	Thu Dec 17 05:37:56 2009	(r43122)
@@ -1432,38 +1432,23 @@
 */
 
     VTABLE void visit(visit_info *info) {
-        Parrot_Class_attributes * const class_data = PARROT_CLASS(SELF);
-        PMC **pos;
-
         /* 1) visit the attribute description hash */
-        pos            = &class_data->attrib_metadata;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, attrib_metadata);
 
         /* 2) visit list of parents */
-        pos            = &class_data->parents;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, parents);
 
         /* 3) visit list of roles */
-        pos            = &class_data->roles;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, roles);
 
         /* 4) visit hash of methods */
-        pos            = &class_data->methods;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, methods);
 
         /* 5) visit hash of vtable overrides */
-        pos            = &class_data->vtable_overrides;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, vtable_overrides);
 
         /* 6) visit list of resolve methods */
-        pos            = &class_data->resolve_method;
-        info->thaw_ptr = pos;
-        (info->visit_pmc_now)(INTERP, *pos, info);
+        VISIT_PMC_ATTR(INTERP, info, SELF, Class, resolve_method);
     }
 
 /*


More information about the parrot-commits mailing list