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

[svn:parrot] r34013 - in branches/cc_restart: include/parrot src

From:
allison
Date:
December 17, 2008 00:03
Subject:
[svn:parrot] r34013 - in branches/cc_restart: include/parrot src
Message ID:
20081217080344.70F04CBA12@x12.develooper.com
Author: allison
Date: Wed Dec 17 00:03:42 2008
New Revision: 34013

Modified:
   branches/cc_restart/include/parrot/multidispatch.h
   branches/cc_restart/src/inter_call.c
   branches/cc_restart/src/multidispatch.c

Log:
[calling_conventions] Process an optional invocant argument when building the
CallSignature object. (Causes no test failures.)


Modified: branches/cc_restart/include/parrot/multidispatch.h
==============================================================================
--- branches/cc_restart/include/parrot/multidispatch.h	(original)
+++ branches/cc_restart/include/parrot/multidispatch.h	Wed Dec 17 00:03:42 2008
@@ -72,10 +72,11 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC* Parrot_build_sig_object_from_varargs(PARROT_INTERP,
+    ARGIN_NULLOK(PMC* obj),
     ARGIN(const char *sig),
     va_list args)
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(3);
 
 PARROT_EXPORT
 void Parrot_mmd_add_function(PARROT_INTERP,

Modified: branches/cc_restart/src/inter_call.c
==============================================================================
--- branches/cc_restart/src/inter_call.c	(original)
+++ branches/cc_restart/src/inter_call.c	Wed Dec 17 00:03:42 2008
@@ -2347,7 +2347,7 @@
     PMC *sig_obj;
     va_list args;
     va_start(args, sig);
-    sig_obj = Parrot_build_sig_object_from_varargs(interp, sig, args);
+    sig_obj = Parrot_build_sig_object_from_varargs(interp, PMCNULL, sig, args);
     va_end(args);
 
     Parrot_pcc_invoke_sub_from_sig_object(interp, sub_obj, sig_obj);

Modified: branches/cc_restart/src/multidispatch.c
==============================================================================
--- branches/cc_restart/src/multidispatch.c	(original)
+++ branches/cc_restart/src/multidispatch.c	Wed Dec 17 00:03:42 2008
@@ -352,7 +352,8 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC*
-Parrot_build_sig_object_from_varargs(PARROT_INTERP, ARGIN(const char *sig), va_list args)
+Parrot_build_sig_object_from_varargs(PARROT_INTERP, ARGIN_NULLOK(PMC* obj),
+        ARGIN(const char *sig), va_list args)
 {
     PMC         *type_tuple    = PMCNULL;
     PMC         *returns       = PMCNULL;
@@ -370,6 +371,7 @@
 
     VTABLE_set_string_native(interp, call_object, string_sig);
 
+    /* Process the varargs list */
     for (i = 0; i < sig_len; ++i) {
         INTVAL type = string_index(interp, string_sig, i);
 
@@ -439,8 +441,17 @@
         }
     }
 
+    /* Check if we have an invocant, and add it to the front of the arguments */
+    if (!PMC_IS_NULL(obj)) {
+        string_sig = string_concat(interp, CONST_STRING(interp, "Pi"), string_sig, 0);
+        VTABLE_set_string_native(interp, call_object, string_sig);
+        VTABLE_unshift_pmc(interp, call_object, obj);
+    }
+
+    /* Build a type_tuple for multiple dispatch */
     type_tuple = Parrot_mmd_build_type_tuple_from_sig_obj(interp, call_object);
     VTABLE_set_pmc(interp, call_object, type_tuple);
+
     return call_object;
 }
 
@@ -469,7 +480,7 @@
 
     va_list args;
     va_start(args, sig);
-    sig_object = Parrot_build_sig_object_from_varargs(interp, sig, args);
+    sig_object = Parrot_build_sig_object_from_varargs(interp, PMCNULL, sig, args);
     va_end(args);
 
     /* Check the cache. */



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