The patch below my sig adds two new features.

        1.  Compiler directives, etc. in files other than core.ops will now
work.

The bug that caused this not to work was based on how the ops files were
loaded in.  Originally, it would loop through each ops file and allocate
an object for it, then copy the ops out and throw the object away.  At
some point somebody slipped in the capability to do multiple files with
one object, but it appears that ops2c.pl was never modified to take
advantage of that.  Now it does.

        2.  Compiler warnings will now display the file and line number of the
opcode file.

For example, my rx.ops has tons of stupid little compile errors in it at
the moment.  (Give me a break--I just got it to the point where I could
even include its header.)  The errors come out like this:

rx.ops(214) : error C2039: 'set_value' : is not a member of 'PMC'
        include\parrot\pmc.h(28) : see declaration of 'PMC'
rx.ops(229) : error C2143: syntax error : missing ';' before 'type'
rx.ops(231) : error C2065: 'rx2' : undeclared identifier
rx.ops(231) : error C2100: illegal indirection
rx.ops(231) : error C2440: '=' : cannot convert from 'rxinfo' to 'int'
rx.ops(233) : warning C4022: 'function through pointer' : pointer
mismatch for actual parameter 3

Before, it would have listed those errors as being at "core_ops.c(1337)"
or something like that.  This makes the compiler errors much more
useful.

On the other hand, it will make it more difficult to debug ops2c.pl and
friends.  If that becomes a problem, it's a very simple edit to
temporarily remove the line numbering changes.

--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6

"Nothing important happened today."
    --George III of England's diary entry for 4-Jul-1776


--- ..\..\parrot-cvs\parrot\ops2c.pl    Thu Jan  3 14:18:06 2002
+++ ops2c.pl    Sun Jan  6 01:08:58 2002
@@ -52,20 +52,13 @@

 die "$0: Could not read ops file '$file'!\n" unless -e $file;

-my $ops = new Parrot::OpsFile $file;
+my $ops = new Parrot::OpsFile $file, @ARGV;

 my $version       = $ops->version;
 my $major_version = $ops->major_version;
 my $minor_version = $ops->minor_version;
 my $patch_version = $ops->patch_version;

-for $file (@ARGV) {
-    die "$0: Could not read ops file '$file'!\n" unless -e $file;
-    my $temp_ops = new Parrot::OpsFile $file;
-    for(@{$temp_ops->{OPS}}) {
-       push @{$ops->{OPS}},$_;
-    }
-}
 my $cur_code = 0;
 for(@{$ops->{OPS}}) {
    $_->{CODE}=$cur_code++;
--- ..\..\parrot-cvs\parrot\Parrot\OpsFile.pm   Sat Jan  5 03:58:50 2002
+++ Parrot\OpsFile.pm   Sun Jan  6 01:13:14 2002
@@ -17,7 +17,6 @@
     @EXPORT = qw(%op_body);
 };

-
 #my %opcodes = Parrot::Opcode::read_ops();
 #my %opcode;
 #my $opcode;
@@ -51,6 +50,8 @@
   my $self = bless { PREAMBLE => '' }, $class;

   $self->read_ops($_) for @files;
+
+  $self->{FILE}=~s/, $//;

   return $self;
 }
@@ -68,14 +69,14 @@

   die "Parrot::OpFunc::init(): No file specified!\n" unless defined
$file;

-  $self->{FILE} = $file;
+  $self->{FILE} .= $file.', ';

   my $orig = $file;
   open OPS, $file or die "Can't open $file, $!/$^E";
   if (! ($file =~ s/\.ops$/.c/)) {
       $file .= ".c";
   }
-
+
   #
   # Read through the file, creating and storing Parrot::Op objects:
   #
@@ -91,6 +92,7 @@
   my @args;
   my $seen_pod;
   my $seen_op;
+  my $line;

   while (<OPS>) {
     $seen_pod = 1 if m|^=|;
@@ -117,7 +119,7 @@

       $self->{PREAMBLE} .= $_ unless $seen_pod or $count; # Lines up to
first op def.
       next;
-    };
+    }

     die "No 'VERSION = ...;' line found before beginning of ops in file
'$orig'!\n"
       unless defined $self->version;
@@ -161,6 +163,7 @@
       @args       = split(/\s*,\s*/, $args);
       $body       = '';
       $seen_op    = 1;
+      $line          = $.+1;

       next;
     }
@@ -174,7 +177,7 @@
     #

     if (/^}\s*$/) {
-      $count += $self->make_op($count, $type, $short_name, $body,
\@args);
+      $count += $self->make_op($count, $type, $short_name, $body,
\@args, $line, $orig);

       $seen_op = 0;

@@ -208,7 +211,7 @@

 sub make_op
 {
-  my ($self, $code, $type, $short_name, $body, $args) = @_;
+  my ($self, $code, $type, $short_name, $body, $args, $line, $file) =
@_;
   my $counter = 0;

   foreach my $variant (expand_args(@$args)) {
@@ -254,7 +257,7 @@

       $body =~ s/\$(\d+)/{{\@$1}}/mg;

-      $op->body($body);
+      $op->body(qq{#line $line "$file"\n}.$body);

       $self->push_op($op);
       $counter++;

Reply via email to