Author: allison
Date: Wed Oct  3 22:56:27 2007
New Revision: 21810

Modified:
   branches/pdd15oo/include/parrot/oo.h
   branches/pdd15oo/src/mmd.c
   branches/pdd15oo/src/oo.c

Log:
[pdd15oo] Fix MMD so it looks in the correct namespace for multi subs defined
for a particular class.


Modified: branches/pdd15oo/include/parrot/oo.h
==============================================================================
--- branches/pdd15oo/include/parrot/oo.h        (original)
+++ branches/pdd15oo/include/parrot/oo.h        Wed Oct  3 22:56:27 2007
@@ -17,8 +17,10 @@
 
 /* HEADERIZER BEGIN: src/oo.c */
 
-void Parrot_oo_extract_methods_from_namespace(PARROT_INTERP, PMC *self)
-        __attribute__nonnull__(1);
+void Parrot_oo_extract_methods_from_namespace(PARROT_INTERP,
+    NOTNULL(PMC *self))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
@@ -43,6 +45,12 @@
 
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
+PMC * Parrot_oo_get_namespace(PARROT_INTERP, NOTNULL(PMC *classobj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_CAN_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
 PMC * Parrot_oo_newclass_from_str(PARROT_INTERP, NOTNULL(STRING *name))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);

Modified: branches/pdd15oo/src/mmd.c
==============================================================================
--- branches/pdd15oo/src/mmd.c  (original)
+++ branches/pdd15oo/src/mmd.c  Wed Oct  3 22:56:27 2007
@@ -444,7 +444,7 @@
 
     left = mmd_deref(interp, left);
 
-    left_type = left->vtable->base_type;
+    left_type = VTABLE_type(interp, left);
 
     real_function =
         (mmd_f_p_pip)get_mmd_dispatch_type(interp, func_nr,
@@ -477,7 +477,7 @@
 
     left = mmd_deref(interp, left);
 
-    left_type = left->vtable->base_type;
+    left_type = VTABLE_type(interp, left);
     real_function = (mmd_f_p_pnp)get_mmd_dispatch_type(interp,
             func_nr, left_type, enum_type_FLOATVAL, &is_pmc);
     if (is_pmc) {
@@ -502,7 +502,7 @@
 {
     mmd_f_p_psp real_function;
     int is_pmc;
-    const UINTVAL left_type = left->vtable->base_type;
+    const UINTVAL left_type = VTABLE_type(interp, left);
 
     real_function = (mmd_f_p_psp)get_mmd_dispatch_type(interp,
             func_nr, left_type, enum_type_STRING, &is_pmc);
@@ -560,7 +560,7 @@
     left = mmd_deref(interp, left);
     mmd_ensure_writable(interp, func_nr, left);
 
-    left_type = left->vtable->base_type;
+    left_type = VTABLE_type(interp, left);
     real_function = (mmd_f_v_pi)get_mmd_dispatch_type(interp,
             func_nr, left_type, enum_type_INTVAL, &is_pmc);
     if (is_pmc) {
@@ -584,7 +584,7 @@
     left = mmd_deref(interp, left);
     mmd_ensure_writable(interp, func_nr, left);
 
-    left_type = left->vtable->base_type;
+    left_type = VTABLE_type(interp, left);
     real_function = (mmd_f_v_pn)get_mmd_dispatch_type(interp,
             func_nr, left_type, enum_type_FLOATVAL, &is_pmc);
     if (is_pmc) {
@@ -1266,14 +1266,15 @@
 
         for (i = start_at_parent; i < n; ++i) {
             PMC * const _class = VTABLE_get_pmc_keyed_int(interp, mro, i);
-            PMC * const pmc = Parrot_find_method_with_cache(interp, _class, 
meth);
-            if (!PMC_IS_NULL(pmc)) {
+            PMC * const ns = Parrot_oo_get_namespace(interp, _class);
+            PMC * const methodobj = VTABLE_get_pmc_keyed_str(interp, ns, meth);
+            if (!PMC_IS_NULL(methodobj)) {
                 /*
                  * mmd_is_hidden would consider all previous candidates
                  * XXX pass current n so that only candidates from this
                  *     mro are used?
                  */
-                if (mmd_maybe_candidate(interp, pmc, cl))
+                if (mmd_maybe_candidate(interp, methodobj, cl))
                     break;
             }
         }

Modified: branches/pdd15oo/src/oo.c
==============================================================================
--- branches/pdd15oo/src/oo.c   (original)
+++ branches/pdd15oo/src/oo.c   Wed Oct  3 22:56:27 2007
@@ -90,6 +90,28 @@
 
 /*
 
+=item C<Parrot_oo_get_namespace>
+
+Lookup a namespace object from a class PMC.
+
+=cut
+
+*/
+
+PARROT_CAN_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+PMC *
+Parrot_oo_get_namespace(PARROT_INTERP, NOTNULL(PMC *classobj))
+{
+    Parrot_Class * const  _class     = PARROT_CLASS(classobj);
+    PMC                  *_namespace = _class->_namespace;
+    if (PMC_IS_NULL(_namespace))
+        return PMCNULL;
+    return _namespace;
+}
+
+/*
+
 =item C<Parrot_oo_get_class>
 
 Lookup a class object from a namespace, string, or key PMC.

Reply via email to