develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34064 - trunk/src/pmc

From:
chromatic
Date:
December 18, 2008 01:19
Subject:
[svn:parrot] r34064 - trunk/src/pmc
Message ID:
20081218091953.09DD1CBA12@x12.develooper.com
Author: chromatic
Date: Thu Dec 18 01:19:52 2008
New Revision: 34064

Modified:
   trunk/src/pmc/multisub.pmc

Log:
[PMC] Reverting r34063 temporarily, as it slows down Rakudo tremendously and
breaks Pheme.  This patch needs a branch (and probably freeze/thaw).

Modified: trunk/src/pmc/multisub.pmc
==============================================================================
--- trunk/src/pmc/multisub.pmc	(original)
+++ trunk/src/pmc/multisub.pmc	Thu Dec 18 01:19:52 2008
@@ -8,8 +8,8 @@
 
 =head1 DESCRIPTION
 
-This class contains an Array of Sub PMCs with the same short name, but
-different long names.
+This class inherits from ResizablePMCArray and provides an Array of
+Sub PMCs with the same short name, but different long names.
 
 =head2 Functions
 
@@ -22,70 +22,26 @@
 #include "parrot/parrot.h"
 
 
-pmclass MultiSub need_ext provides array {
-    ATTR PMC *subs;
+pmclass MultiSub extends ResizablePMCArray need_ext provides array {
 
-    VTABLE void init() {
-        Parrot_MultiSub_attributes * const ms =
-            mem_allocate_zeroed_typed(Parrot_MultiSub_attributes);
-
-        /* no mark() necessary; everything is constant */
-        PObj_active_destroy_SET(SELF);
-
-        PMC_data(SELF) = ms;
-        ms->subs       = constant_pmc_new(interp, enum_class_ResizablePMCArray);
-    }
-
-    VTABLE void destroy() {
-        Parrot_MultiSub_attributes * const ms = PARROT_MULTISUB(SELF);
-
-        if (ms)
-            mem_sys_free(ms);
-
-        PMC_data(SELF) = NULL;
-    }
-
-    VTABLE INTVAL elements() {
-        Parrot_MultiSub_attributes * const ms = PARROT_MULTISUB(SELF);
-        return VTABLE_elements(interp, ms->subs);
-    }
-
-    VTABLE PMC *get_attr_str(STRING *name) {
-        Parrot_MultiSub_attributes * const ms = PARROT_MULTISUB(SELF);
-
-        if (string_equal(interp, name, CONST_STRING(interp, "candidates")) ==0 )
-            return ms->subs;
-
-        return PMCNULL;
-    }
-
-    VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
-        Parrot_MultiSub_attributes * const ms = PARROT_MULTISUB(SELF);
-        return VTABLE_get_pmc_keyed_int(interp, ms->subs, key);
-    }
-
-    VTABLE void push_pmc(PMC *value) {
-        STRING                     * const _sub = CONST_STRING(interp, "Sub");
-        STRING                     * const _nci = CONST_STRING(interp, "NCI");
-        Parrot_MultiSub_attributes * const ms   = PARROT_MULTISUB(SELF);
+    void push_pmc(PMC *value) {
+        STRING * const _sub = CONST_STRING(interp, "Sub");
+        STRING * const _nci = CONST_STRING(interp, "NCI");
 
         if (!VTABLE_isa(interp, value, _sub)
         &&  !VTABLE_isa(interp, value, _nci))
-            Parrot_ex_throw_from_c_args(interp, NULL,
-                EXCEPTION_INVALID_OPERATION, "attempt to push non Sub PMC");
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                    "attempt to push non Sub PMC");
 
-        VTABLE_push_pmc(interp, ms->subs, value);
+        SUPER(value);
     }
 
     VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
-        STRING                     * const _sub = CONST_STRING(interp, "Sub");
-        Parrot_MultiSub_attributes * const ms   = PARROT_MULTISUB(SELF);
-
+        STRING *_sub = CONST_STRING(interp, "Sub");
         if (!VTABLE_isa(interp, value, _sub))
-            Parrot_ex_throw_from_c_args(interp, NULL,
-                EXCEPTION_INVALID_OPERATION, "attempt to set non Sub PMC");
-
-        VTABLE_set_pmc_keyed_int(interp, ms->subs, key, value);
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                    "attempt to set non Sub PMC");
+        SUPER(key, value);
     }
 
     VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
@@ -104,27 +60,20 @@
     }
 
     VTABLE opcode_t *invoke(void *next) {
-        Parrot_MultiSub_attributes * const ms   = PARROT_MULTISUB(SELF);
-        PMC                        * const func =
-                                    Parrot_mmd_sort_manhattan(interp, ms->subs);
+        PMC * const func = Parrot_mmd_sort_manhattan(interp, SELF);
 
         if (PMC_IS_NULL(func))
-            Parrot_ex_throw_from_c_args(INTERP, NULL,
-                EXCEPTION_METH_NOT_FOUND, "No applicable methods.\n");
+            Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
 
         return VTABLE_invoke(INTERP, func, next);
     }
 
     VTABLE PMC *get_iter() {
-        Parrot_MultiSub_attributes * const ms  = PARROT_MULTISUB(SELF);
-        PMC                        * const sub =
-                                    Parrot_mmd_sort_manhattan(INTERP, ms->subs);
+        PMC * const sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
 
         if (PMC_IS_NULL(sub))
-            Parrot_ex_throw_from_c_args(INTERP, NULL,
-                EXCEPTION_METH_NOT_FOUND, "No applicable methods.\n");
-
-        return VTABLE_get_iter(interp, ms->subs);
+            Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
+        return SUPER();
     }
 
     /* I don't really know how to implement these if they need something
@@ -132,27 +81,17 @@
        ResizablePMCArray's VTABLE methods of the same names. Hopefully we
        don't need anything beyond that. */
     VTABLE PMC *get_pmc_keyed(PMC *key) {
-        Parrot_MultiSub_attributes * const ms  = PARROT_MULTISUB(SELF);
-        PMC                        * const sub =
-                                    Parrot_mmd_sort_manhattan(INTERP, ms->subs);
-
+        PMC *sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
         if (PMC_IS_NULL(sub))
-            Parrot_ex_throw_from_c_args(INTERP, NULL,
-                EXCEPTION_METH_NOT_FOUND, "No applicable methods.\n");
-
-        return VTABLE_get_pmc_keyed(interp, ms->subs, key);
+            Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
+        return SUPER(key);
     }
 
     VTABLE PMC *get_pmc_keyed_string(STRING *s) {
-        Parrot_MultiSub_attributes * const ms  = PARROT_MULTISUB(SELF);
-        PMC                        * const sub =
-                                    Parrot_mmd_sort_manhattan(INTERP, ms->subs);
-
+        PMC *sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
         if (PMC_IS_NULL(sub))
-            Parrot_ex_throw_from_c_args(INTERP, NULL,
-                EXCEPTION_METH_NOT_FOUND, "No applicable methods.\n");
-
-        return VTABLE_get_pmc_keyed_string(interp, ms->subs, s);
+            Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
+        return SUPER(s);
     }
 
     /* get_iter method should take one of two inputs: either an array of
@@ -172,8 +111,7 @@
             /* TODO: What goes here? */
         }
         else
-            Parrot_ex_throw_from_c_args(interp, NULL,
-                EXCEPTION_INVALID_OPERATION,
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
                     "attempt to call get_iter method with invalid arg type.\n");
     }
 }



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