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

[svn:parrot] r34666 - in trunk: compilers/imcc compilers/pirc/new src

From:
chromatic
Date:
December 30, 2008 12:47
Subject:
[svn:parrot] r34666 - in trunk: compilers/imcc compilers/pirc/new src
Message ID:
20081230204658.BE52FCB9FA@x12.develooper.com
Author: chromatic
Date: Tue Dec 30 12:46:56 2008
New Revision: 34666

Modified:
   trunk/compilers/imcc/pbc.c
   trunk/compilers/pirc/new/bcgen.c
   trunk/src/multidispatch.c

Log:
[IMCC] [PIRC] [MMD] Fixed generation of multi signatures with no arguments,
removing a nasty hack in the process (RT #45951).

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	(original)
+++ trunk/compilers/imcc/pbc.c	Tue Dec 30 12:46:56 2008
@@ -979,27 +979,20 @@
 static PMC*
 mk_multi_sig(PARROT_INTERP, ARGIN(const SymReg *r))
 {
-    PMC       * const multi_sig = pmc_new(interp, enum_class_FixedPMCArray);
-    pcc_sub_t * const pcc_sub   = r->pcc_sub;
-    const INTVAL      n         = pcc_sub->nmulti;
+    PMC              *multi_sig;
+    pcc_sub_t * const pcc_sub = r->pcc_sub;
+    const INTVAL      n       = pcc_sub->nmulti;
     INTVAL            i;
 
     PackFile_ConstTable *ct;
 
-    VTABLE_set_integer_native(interp, multi_sig, n);
-
-    /* :multi() n = 1, reg = NULL */
-    if (!pcc_sub->multi[0]) {
-        STRING * const sig     = string_from_literal(interp, "__VOID");
-        PMC    * const sig_pmc = pmc_new(interp, enum_class_String);
-
-        VTABLE_set_string_native(interp, sig_pmc, sig);
-        VTABLE_set_pmc_keyed_int(interp, multi_sig, 0, sig_pmc);
+    /* a :multi sub with no arguments */
+    if (!pcc_sub->multi[0])
+        return pmc_new(interp, enum_class_FixedIntegerArray);
 
-        return multi_sig;
-    }
-
-    ct = interp->code->const_table;
+    multi_sig = pmc_new(interp, enum_class_FixedPMCArray);
+    VTABLE_set_integer_native(interp, multi_sig, n);
+    ct        = interp->code->const_table;
 
     for (i = 0; i < n; ++i) {
         /* multi[i] can be a Key too -

Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c	(original)
+++ trunk/compilers/pirc/new/bcgen.c	Tue Dec 30 12:46:56 2008
@@ -423,32 +423,24 @@
 static PMC *
 generate_multi_signature(bytecode * const bc, multi_type * const types, unsigned type_count) {
     unsigned     i;
-    multi_type * iter;
-    PMC        * multi_signature;
+    multi_type *iter;
+    PMC        *multi_signature;
 
     /* cancel if there's no :multi flag */
     if (type_count == 0)
-        return NULL;
+        return PMCNULL;
+
+    /* A type_count of 1 means there was a :multi flag, but no :multi types.
+     * therefore, create a special signature and return that.  */
+    if (type_count == 1)
+        return pmc_new(interp, enum_class_FixedIntegerArray);
 
     /* create a FixedPMCArray to store all multi types */
     multi_signature = pmc_new(bc->interp, enum_class_FixedPMCArray);
+
     /* set its size as specified in type_count */
     VTABLE_set_integer_native(bc->interp, multi_signature, type_count);
 
-
-    /* A type_count of 1 means there was a :multi flag, but no :multi types.
-     * therefore, create a special signature and return that.
-     */
-    if (type_count == 1) {
-        STRING * const sig     = string_from_literal(bc->interp, "__VOID");
-        PMC    * const sig_pmc = pmc_new(bc->interp, enum_class_String);
-
-        VTABLE_set_string_native(bc->interp, sig_pmc, sig);
-        VTABLE_set_pmc_keyed_int(bc->interp, multi_signature, 0, sig_pmc);
-
-        return multi_signature;
-    }
-
     iter = types;
     --type_count; /* type count is 1 too high, fix that now. */
 
@@ -477,12 +469,12 @@
 
         /* store the signature PMC in the array */
         VTABLE_set_pmc_keyed_int(bc->interp, multi_signature, i, sig_pmc);
-
     }
-    return multi_signature;
 
+    return multi_signature;
 }
 
+
 /*
 
 =item C<static PMC *

Modified: trunk/src/multidispatch.c
==============================================================================
--- trunk/src/multidispatch.c	(original)
+++ trunk/src/multidispatch.c	Tue Dec 30 12:46:56 2008
@@ -976,16 +976,6 @@
             if (!sig)
                 return PMCNULL;
 
-            /* yes, this is horrible and ugly */
-            if (memcmp(sig->strstart, "__VOID", 6) == 0) {
-                if (PMC_IS_NULL(ar)) {
-                    ar = pmc_new(interp, enum_class_FixedIntegerArray);
-                    VTABLE_set_integer_native(interp, ar, n);
-                }
-                PMC_int_val(ar)--;  /* RT #45951 */
-                break;
-            }
-
             type = pmc_type(interp, sig);
 
             if (type == enum_type_undef)



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