Index: lib/Parrot/OpsRenumber.pm =================================================================== --- lib/Parrot/OpsRenumber.pm (revision 38786) +++ lib/Parrot/OpsRenumber.pm (working copy) @@ -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,9 +71,8 @@ sub renum_op_map_file { my $self = shift; - my $major_version = shift; - my $file = scalar(@_) ? shift : $self->{num_file}; + my $file = $self->{num_file}; # We open up the currently existing ops.num and file and read it # line-by-line. That file is basically divided into two halves @@ -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 Index: tools/dev/opsrenumber.pl =================================================================== --- tools/dev/opsrenumber.pl (revision 38786) +++ tools/dev/opsrenumber.pl (working copy) @@ -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,9 +40,16 @@ 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 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, then F (or F) +should be run. + =head1 SEE ALSO =over 4 Index: t/tools/ops2pm/05-renum_op_map_file.t =================================================================== --- t/tools/ops2pm/05-renum_op_map_file.t (revision 38786) +++ t/tools/ops2pm/05-renum_op_map_file.t (working copy) @@ -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); }