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

[svn:parrot] r33659 - in trunk: compilers/imcc src t/compilers/imcc/syn

From:
tewk
Date:
December 8, 2008 08:49
Subject:
[svn:parrot] r33659 - in trunk: compilers/imcc src t/compilers/imcc/syn
Message ID:
20081208164930.74721CB9AF@x12.develooper.com
Author: tewk
Date: Mon Dec  8 08:49:29 2008
New Revision: 33659

Modified:
   trunk/compilers/imcc/pbc.c
   trunk/src/packdump.c
   trunk/t/compilers/imcc/syn/subflags.t

Log:
[subid] fixed multi lookup via subid


Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	(original)
+++ trunk/compilers/imcc/pbc.c	Mon Dec  8 08:49:29 2008
@@ -113,12 +113,15 @@
 static subs_t * find_global_label(PARROT_INTERP,
     ARGIN(const char *name),
     ARGIN(const subs_t *sym),
-    ARGOUT(int *pc))
+    ARGOUT(int *pc),
+    ARGOUT(int *sub_id))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
         __attribute__nonnull__(4)
+        __attribute__nonnull__(5)
         FUNC_MODIFIES(*pc);
+        FUNC_MODIFIES(*sub_id);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
@@ -656,7 +659,7 @@
 PARROT_CAN_RETURN_NULL
 static subs_t *
 find_global_label(PARROT_INTERP, ARGIN(const char *name),
-    ARGIN(const subs_t *sym), ARGOUT(int *pc))
+    ARGIN(const subs_t *sym), ARGOUT(int *pc), ARGOUT(int *subid_matched))
 {
     subs_t *s;
 
@@ -665,10 +668,12 @@
     for (s = IMCC_INFO(interp)->globals->cs->first; s; s = s->next) {
         SymReg * const r = s->unit->instructions->symregs[0];
 
+        *subid_matched = r && (r->subid && (strcmp(r->subid, name) == 0));
+
         /* if names and namespaces are matching - ok */
-        if (r && ((r->subid && (strcmp(r->subid, name) == 0))
+        if (r && ( *subid_matched 
                     || (r->name && (strcmp(r->name, name) == 0)))
-              && ((sym->unit->_namespace && s->unit->_namespace
+                && ((sym->unit->_namespace && s->unit->_namespace
                         && (strcmp(sym->unit->_namespace->name, s->unit->_namespace->name) == 0))
                     || (!sym->unit->_namespace && !s->unit->_namespace)))
             return s;
@@ -706,9 +711,10 @@
             for (fixup = hsh->data[i]; fixup; fixup = fixup->next) {
                 int pc, pmc_const;
                 int addr = jumppc + fixup->color;
+                int subid_matched = 0;
 
                 /* check in matching namespace */
-                subs_t *s1 = find_global_label(interp, fixup->name, s, &pc);
+                subs_t *s1 = find_global_label(interp, fixup->name, s, &pc, &subid_matched);
 
                 /*
                  * if failed change opcode:
@@ -732,7 +738,7 @@
                         PARROT_ASSERT(pcc_sub);
 
                         /* if the sub is multi, don't insert constant */
-                        if (pcc_sub->nmulti)
+                        if (pcc_sub->nmulti && !subid_matched)
                             s1 = NULL;
                     }
                 }

Modified: trunk/src/packdump.c
==============================================================================
--- trunk/src/packdump.c	(original)
+++ trunk/src/packdump.c	Mon Dec  8 08:49:29 2008
@@ -308,13 +308,19 @@
                             "\tclass => %Ss,\n"
                             "\tstart_offs => %d,\n"
                             "\tend_offs => %d,\n"
-                            "\tname => '%Ss',\n"
+                            "\tname    => '%Ss',\n"
+                            "\tsubid   => '%Ss',\n"
+                            "\tmethod  => '%Ss',\n"
+                            "\tnsentry => '%Ss',\n"
                             "\tnamespace => %Ss\n"
                             "\tHLL_id => %d,\n",
                             pmc->vtable->whoami,
                             sub->start_offs,
                             sub->end_offs,
                             sub->name,
+                            sub->subid,
+                            sub->method_name,
+                            sub->ns_entry_name,
                             namespace_description,
                             sub->HLL_id);
                     break;

Modified: trunk/t/compilers/imcc/syn/subflags.t
==============================================================================
--- trunk/t/compilers/imcc/syn/subflags.t	(original)
+++ trunk/t/compilers/imcc/syn/subflags.t	Mon Dec  8 08:49:29 2008
@@ -26,7 +26,7 @@
     test_namespace.'export_to'(curr_namespace, exports)
 
     ##  set our plan
-    plan(25)
+    plan(27)
 
     .local pmc pmcnull
     null pmcnull
@@ -109,8 +109,23 @@
     pop_eh
     $I0 = isa $P70, 'Sub'
     todo($I0, 'subid4 in another ns found w/.const')
+
+    ## find multis via subid
+    .const 'Sub' $P0 = 'above'
+    $P0(3)
+    ok(1, "multi found via subid 'above'")
+    .const 'Sub' $P1 = 'below'
+    $P1('3')
+    ok(1, "multi found via subid 'below'")
+.end
+
+.sub 'xyz' :multi(Integer) :subid('above')
+    .return('xyz above')
 .end
 
+.sub 'xyz' :multi(String) :subid('below')
+    .return('xyz below')
+.end
 
 .sub 'is_same'
     .param pmc x



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