This reports unknown method names when generating C code for PMCs.
WDOT?  Is this the right place for it?  Should it die instead of warn?

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/


* lib/Parrot/Pmc2c.pm:
   + Warn about definitions for unknown methods.

Diffs between last version checked in and current workfile(s):

Index: lib/Parrot/Pmc2c.pm
===================================================================
--- lib/Parrot/Pmc2c.pm (revision 18587)
+++ lib/Parrot/Pmc2c.pm (working copy)
@@ -629,15 +629,16 @@
     my ( $self, $line, $out_name ) = @_;
 
     my $cout = "";
+    my %method_used_p;
 
     # vtable methods
     foreach my $method ( @{ $self->{vtable}{methods} } ) {
         my $meth = $method->{meth};
-        next if $meth eq 'class_init';
         if ( $self->implements($meth) ) {
             my $ret = $self->body( $method, $line, $out_name );
             $line += count_newlines($ret);
             $cout .= $ret;
+            $method_used_p{$meth}++;
         }
     }
 
@@ -647,8 +648,16 @@
         my $ret = $self->body( $method, $line, $out_name );
         $line += count_newlines($ret);
         $cout .= $ret;
+        $method_used_p{$method->{meth}}++;
     }
 
+    # check for mispeled or unimplemented method names.
+    foreach my $method ( @{ $self->{methods} } ) {
+        my $meth = $method->{meth};
+        warn "Cannot generate code for method '$meth', which is unknown.\n"
+            unless $method_used_p{$meth} || $meth eq 'class_init';
+    }
+
     $cout =~ s/^\s+$//mg;
     return $cout;
 }

End of diffs.

Reply via email to