Author: jonathan
Date: Wed Apr  4 15:30:17 2007
New Revision: 17982

Modified:
   trunk/languages/lua/pmc/luanumber.pmc
   trunk/lib/Parrot/Pmc2c.pm

Log:
Resolve bug in NCI method name mangling that broke Lua; make Lua build again.

Modified: trunk/languages/lua/pmc/luanumber.pmc
==============================================================================
--- trunk/languages/lua/pmc/luanumber.pmc       (original)
+++ trunk/languages/lua/pmc/luanumber.pmc       Wed Apr  4 15:30:17 2007
@@ -283,7 +283,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_add_LuaNumber(INTERP, SELF, n, dest);
             }
@@ -324,7 +324,7 @@
                 DYNSELF.get_number() + VTABLE_get_number(INTERP, value));
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_add_LuaNumber(INTERP, SELF, n);
             }
@@ -366,7 +366,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_subtract_LuaNumber(INTERP, SELF,
                                                            n, dest);
@@ -408,7 +408,7 @@
                 DYNSELF.get_number() - VTABLE_get_number(INTERP, value));
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_subtract_LuaNumber(INTERP, SELF, n);
             }
@@ -450,7 +450,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_multiply_LuaNumber(INTERP, SELF,
                                                            n, dest);
@@ -492,7 +492,7 @@
                 DYNSELF.get_number() * VTABLE_get_number(INTERP, value));
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_multiply_LuaNumber(INTERP, SELF, n);
             }
@@ -534,7 +534,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_divide_LuaNumber(INTERP, SELF,
                                                          n, dest);
@@ -576,7 +576,7 @@
                 DYNSELF.get_number() / VTABLE_get_number(INTERP, value));
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_divide_LuaNumber(INTERP, SELF, n);
             }
@@ -620,7 +620,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_modulus_LuaNumber(INTERP, SELF,
                                                           n, dest);
@@ -664,7 +664,7 @@
             VTABLE_set_number_native(INTERP, SELF, a - floor(a/b)*b);
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_modulus_LuaNumber(INTERP, SELF, n);
             }
@@ -706,7 +706,7 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 return Parrot_LuaNumber_pow_LuaNumber(INTERP, SELF, n, dest);
             }
@@ -747,7 +747,7 @@
                   pow(DYNSELF.get_number(), VTABLE_get_number(INTERP, value)));
         }
 MMD_LuaString: {
-            PMC* n = Parrot_LuaString_tonumber(INTERP, value);
+            PMC* n = Parrot_LuaString_nci_tonumber(INTERP, value);
             if (n->vtable->base_type == dynpmc_LuaNumber) {
                 Parrot_LuaNumber_i_pow_LuaNumber(INTERP, SELF, n);
             }

Modified: trunk/lib/Parrot/Pmc2c.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c.pm   (original)
+++ trunk/lib/Parrot/Pmc2c.pm   Wed Apr  4 15:30:17 2007
@@ -415,7 +415,7 @@
     return $ret;
 }
 
-=item C<rewrite_nci_method($class, $method, $super, $super_table)>
+=item C<rewrite_nci_method($self, $class, $method, $super, $super_table)>
 
 Rewrites the method body performing the various macro substitutions for
 nci method bodies (see F<tools/build/pmc2c.pl>).
@@ -423,9 +423,9 @@
 =cut
 
 sub rewrite_nci_method {
-    my ( $class, $method ) = @_;
+    my ( $self, $class, $method ) = @_;
 
-    local $_ = $_[2];
+    local $_ = $_[3];
 
     # Rewrite SELF -> pmc, INTERP -> interp
     s/\bSELF\b/pmc/g;
@@ -434,7 +434,7 @@
     return $_;
 }
 
-=item C<rewrite_vtable_method($class, $method, $super, $super_table)>
+=item C<rewrite_vtable_method($self, $class, $method, $super, $super_table)>
 
 Rewrites the method body performing the various macro substitutions for
 vtable method bodies (see F<tools/build/pmc2c.pl>).
@@ -442,8 +442,8 @@
 =cut
 
 sub rewrite_vtable_method {
-    my ( $class, $method, $super, $super_table ) = @_;
-    local $_ = $_[4];
+    my ( $self, $class, $method, $super, $super_table ) = @_;
+    local $_ = $_[5];
 
     # Rewrite method body
     my $supertype = "enum_class_$super";
@@ -483,13 +483,17 @@
       \.\bSELF\b            # Macro SELF
       \.(\w+)           # other_method
       \(\s*(.*?)\)      # capture argument list
-     /"Parrot_${1}_$2(" . full_arguments($3) . ')'/xeg;
+     /"Parrot_${1}" . 
+      ($self->is_vtable_method($2) ? "" : "_nci") .
+      "_$2(" . full_arguments($3) . ')'/xeg;
 
     # Rewrite SELF.other_method(args...)
     s/\bSELF\b              # Macro SELF
       \.(\w+)           # other_method
       \(\s*(.*?)\)      # capture argument list
-     /"Parrot_${class}_$1(".full_arguments($2).")"/xeg;
+     /"Parrot_${class}" .
+      ($self->is_vtable_method($1) ? "" : "_nci") .
+      "_$1(" . full_arguments($2) . ")"/xeg;
 
     # Rewrite SELF -> pmc, INTERP -> interp
     s/\bSELF\b/pmc/g;
@@ -522,10 +526,10 @@
 
     my $total_body;
     if ( $method->{loc} eq 'vtable' ) {
-        $total_body = rewrite_vtable_method( $classname, $meth, $super, 
$self->{super}, $body );
+        $total_body = $self->rewrite_vtable_method( $classname, $meth, $super, 
$self->{super}, $body );
     }
     else {
-        $total_body = rewrite_nci_method( $classname, $meth, $body );
+        $total_body = $self->rewrite_nci_method( $classname, $meth, $body );
     }
     Parrot::Pmc2c::PCCMETHOD::rewrite_pccinvoke( $method, \$total_body );
 
@@ -1176,6 +1180,14 @@
     return $self->{vtable}{methods}[$n]{mmd} =~ /MMD/ ? 0 : 1;
 }
 
+sub is_vtable_method {
+    my ( $self, $meth ) = @_;
+    foreach my $entry ( @{ $self->{vtable}{methods} } ) {
+        return 1 if $entry->{meth} eq $meth;
+    }
+    return 0;
+}
+
 =back
 
 =cut

Reply via email to