[svn:parrot] r38825 - in trunk: lib/Parrot t/tools/ops2pm tools/dev

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Sat May 16 13:13:28 UTC 2009


Author: jkeenan
Date: Sat May 16 13:13:27 2009
New Revision: 38825
URL: https://trac.parrot.org/parrot/changeset/38825

Log:
Renumbering of opcodes no longer differs between pre- and post-1.0.0 Parrot.  Revise Parrot::OpsRenumber, the script that uses it, and the file that tests it.  Cf.:  https://trac.parrot.org/parrot/ticket/469.

Modified:
   trunk/lib/Parrot/OpsRenumber.pm
   trunk/t/tools/ops2pm/05-renum_op_map_file.t
   trunk/tools/dev/opsrenumber.pl

Modified: trunk/lib/Parrot/OpsRenumber.pm
==============================================================================
--- trunk/lib/Parrot/OpsRenumber.pm	Sat May 16 10:46:51 2009	(r38824)
+++ trunk/lib/Parrot/OpsRenumber.pm	Sat May 16 13:13:27 2009	(r38825)
@@ -17,16 +17,15 @@
 
     $self = Parrot::OpsRenumber->new( {
         argv            => [ @ARGV ],
-        nolines         => $nolines_flag,
         moddir          => "lib/Parrot/OpLib",
         module          => "core.pm",
         inc_dir         => "include/parrot/oplib",
         inc_f           => "ops.h",
-        script          => "tools/build/opsrenumber.pl",
+        script          => "tools/dev/opsrenumber.pl",
     } );
 
     $self->prepare_ops();
-    $self->renum_op_map_file( $PConfig{MAJOR} );
+    $self->renum_op_map_file();
 
 =cut
 
@@ -72,7 +71,6 @@
 
 sub renum_op_map_file {
     my $self = shift;
-    my $major_version = shift;
 
     my $file = scalar(@_) ? shift : $self->{num_file};
 
@@ -123,7 +121,7 @@
     # Parrot::Ops2pm::Base.  prepare_ops(), in turn, works off
     # Parrot::OpsFile.
 
-    # So whether a particular opcode will appear in the *new* ops.num
+    # So whether a particular opcode will continue to appear in ops.num
     # depends entirely on whether or not it's found in
     # @{ $self->{ops}->{OPS} }.  If a particular opcode has been deleted or
     # gone missing from that array, then it won't appear in the new

Modified: trunk/t/tools/ops2pm/05-renum_op_map_file.t
==============================================================================
--- trunk/t/tools/ops2pm/05-renum_op_map_file.t	Sat May 16 10:46:51 2009	(r38824)
+++ trunk/t/tools/ops2pm/05-renum_op_map_file.t	Sat May 16 13:13:27 2009	(r38825)
@@ -6,10 +6,9 @@
 use strict;
 use warnings;
 
-use Test::More qw(no_plan); # tests => 14;
+use Test::More tests =>  6;
 use Carp;
 use Cwd;
-use File::Basename;
 use File::Copy;
 use File::Path qw( mkpath );
 use File::Spec;
@@ -35,9 +34,6 @@
     my $opsdir = File::Spec->catdir ( $tdir, 'src', 'ops' );
     mkpath( $opsdir, 0, 755 ) or croak "Unable to make testing directory";
 
-    ##### Test pre-Parrot 1.0 case
-    my $major_version = 0;
-
     ##### Stage 1:  Generate ops.num de novo #####
 
     my @stage1 = qw(
@@ -56,7 +52,6 @@
             src/ops/bit.ops
         ) ],
         $numoutput,
-        $major_version,
     );
     is($lastcode, q{bxors_s_s_sc},
         "Stage 1:  Got expected last opcode");
@@ -73,7 +68,6 @@
             src/ops/bit.ops
         ) ],
         $numoutput,
-        $major_version,
     );
 
     is($lastcode, q{bxor_i_i_ic},
@@ -81,93 +75,6 @@
     is($lastnumber, 172,
         "Stage 2:  Got expected last opcode number");
 
-    ##### Stage 3:  Add some opcodes and regenerate ops.num #####
-
-  TODO: {
-        local $TODO = 'Post 1.0 regeneration problematic, TT #469';
-    my @stage3 = qw( pic_ops.original );
-    copy_into_position($samplesdir, \@stage3, q{original}, $opsdir);
-    ($lastcode, $lastnumber) = run_test_stage(
-        [ qw(
-            src/ops/core.ops
-            src/ops/bit.ops
-            src/ops/pic.ops
-        ) ],
-        $numoutput,
-        $major_version,
-    );
-    is($lastcode, q{pic_callr___pc},
-        "Stage 3:  Got expected last opcode");
-    is($lastnumber, 189,
-        "Stage 3:  Got expected last opcode number");
-  }
-
-    ##### Stage 4:  Again generate ops.num de novo #####
-
-    my @stage4 = qw(
-        core_ops.original
-        bit_ops.original
-        ops_num.original
-    );
-    copy_into_position($samplesdir, \@stage4, q{original}, $opsdir);
-    foreach my $f ( qw| core bit | ) {
-        copy qq{$samplesdir/${f}_ops.original}, qq{src/ops/$f.ops.post}
-            or croak "Unable to store $f for later testing: $!";
-    }
-    ($lastcode, $lastnumber) = run_test_stage(
-        [ qw(
-            src/ops/core.ops
-            src/ops/bit.ops
-        ) ],
-        $numoutput,
-        $major_version,
-    );
-    is($lastcode, q{bxors_s_s_sc},
-        "Stage 4:  Got expected last opcode");
-    is($lastnumber, 177,
-        "Stage 4:  Got expected last opcode number");
-
-    ##### Test post-Parrot 1.0 case
-    $major_version = 1;
-
-    ###### Stage 5:  Delete some opcodes and regenerate ops.num #####
-
-  TODO: {
-        local $TODO = 'Post 1.0 regeneration should work just like pre-1.0 regeneration, TT #469';
-    my @stage5 = qw( bit_ops.second );
-    copy_into_position($samplesdir, \@stage5, q{second}, $opsdir);
-    ($lastcode, $lastnumber) = run_test_stage(
-        [ qw(
-            src/ops/core.ops
-            src/ops/bit.ops
-        ) ],
-        $numoutput,
-        $major_version,
-    );
-    is($lastcode, q{bxor_i_ic_ic},
-        "Stage 5:  Got expected last opcode");
-    is($lastnumber, 189,
-        "Stage 5:  Got expected last opcode number");
-
-    ##### Stage 6:  Add some opcodes and regenerate ops.num #####
-
-    my @stage6 = qw( pic_ops.original );
-    copy_into_position($samplesdir, \@stage6, q{original}, $opsdir);
-    ($lastcode, $lastnumber) = run_test_stage(
-        [ qw(
-            src/ops/core.ops
-            src/ops/bit.ops
-            src/ops/pic.ops
-        ) ],
-        $numoutput,
-        $major_version,
-    );
-    is($lastcode, q{pic_callr___pc},
-        "Stage 6:  Got expected last opcode:  additions permitted");
-    is($lastnumber, 194,
-        "Stage 6:  Got expected last opcode number:  additions permitted");
-  }
-
     # Go back where we started to activate cleanup
     chdir $cwd or croak "Unable to change back to starting directory: $!";
 }
@@ -177,7 +84,7 @@
 #################### SUBROUTINES ####################
 
 sub run_test_stage {
-    my ($opsfilesref, $numoutput, $major_version) = @_;
+    my ($opsfilesref, $numoutput) = @_;
     my $self = Parrot::OpsRenumber->new(
         {
             argv    => $opsfilesref,
@@ -190,7 +97,7 @@
     );
 
     $self->prepare_ops();
-    $self->renum_op_map_file($major_version);
+    $self->renum_op_map_file();
     my ($lastcode, $lastnumber) = get_last_opcode($numoutput);
     return ($lastcode, $lastnumber);
 }

Modified: trunk/tools/dev/opsrenumber.pl
==============================================================================
--- trunk/tools/dev/opsrenumber.pl	Sat May 16 10:46:51 2009	(r38824)
+++ trunk/tools/dev/opsrenumber.pl	Sat May 16 13:13:27 2009	(r38825)
@@ -6,7 +6,6 @@
 use warnings;
 
 use lib 'lib';
-use Parrot::Config qw( %PConfig );
 use Parrot::OpsRenumber;
 
 my $self = Parrot::OpsRenumber->new(
@@ -21,7 +20,7 @@
 );
 
 $self->prepare_ops();
-$self->renum_op_map_file($PConfig{MAJOR});
+$self->renum_op_map_file();
 
 exit 0;
 
@@ -41,8 +40,15 @@
 
 All opcodes except the first seven are potentially deletable and the opcodes'
 order may be rearranged.  However, in and after Parrot 1.0.0, deletion of
-opcodes should be a rare event.  New opcodes should be added at the end of the
-list.
+opcodes should be a rare event.  The program will automatically detect which
+opcodes have been deleted and will renumber the remaining codes appropriately.
+
+The program, however, will B<not> automatically detect new opcodes.   This is
+a feature, not a bug, as it is intended to require someone to think about why
+new opcodes should be added.  Once a decision to add new opcodes has been
+made, those opcodes should be entered manually at the endc of
+F<src/ops/ops.num>, then F<tools/dev/opsrenumber.pl> (or F<make opsrenumber>)
+should be run.
 
 =head1 SEE ALSO
 


More information about the parrot-commits mailing list