2 # Copyright (C) 2001-2007, Parrot Foundation.
10 use Parrot
::Ops2pm
::Auxiliary
qw( Usage getoptions );
12 my $flagref = getoptions
();
14 if ( $flagref->{help
} or !@ARGV ) {
19 my $self = Parrot
::Ops2pm
->new(
22 nolines
=> $flagref->{nolines
},
23 renum
=> $flagref->{renum
},
24 moddir
=> "lib/Parrot/OpLib",
26 inc_dir
=> "include/parrot/oplib",
28 script
=> "tools/build/ops2pm.pl",
33 $self->load_op_map_files();
35 $self->prepare_real_ops();
36 $self->print_module();
41 ################### DOCUMENTATION ####################
45 tools/build/ops2pm.pl - Generate Perl module from operation definitions
49 $ perl tools/build/ops2pm.pl [--help] [--no-lines] input.ops [input2.ops ...]
50 $ perl tools/build/ops2pm.pl [--renum] input.ops [input2.ops ...]
54 Reads the ops files listed on the command line and outputs a
55 F<Parrot::OpLib::core> module containing information about the ops.
56 Also outputs F<include/parrot/oplib/ops.h>. This program is called by Parrot's
59 If called with the C<--renum> flag, renumbers the file F<src/ops/ops.num>.
60 This is mandatory when adding or removing opcodes.
72 Do not generate C<#line> directives in the generated C code.
76 Renumber opcodes according to existing ops in ops/num and natural
77 order in the given ops files. See also F<tools/dev/ops_renum.mak>.
81 Most of the functionality in this program is now held in Parrot::Ops2pm::Util
82 methods and a small number of Parrot::Ops2pm::Auxiliary subroutines.
83 See those modules' documentation for discussion of those functions.
84 Revisions to the functionality should be made in those packages and tested
85 against tests found in F<t/tools/ops2pm/>.
89 Generating a C<Parrot::OpLib::core> module for a set of ops files that
90 you do not later turn into C code (see F<tools/build/ops2c.pl>) with the
91 same op content and order is a recipe for disaster. But as long as you
92 just run these tools in the standard build process via C<make> there
93 shouldn't be a problem.
97 The original design of the ops processing code was intended to be
98 a read-only representation of what was in a particular ops file. It was
99 not originally intended that it was a mechanism for building a bigger
100 virtual ops file from multiple physical ops files.
102 This code does half of that job (the other half is getting them to
103 compile together instead of separately in a F<*_ops.c> file).
105 You can see evidence of this by the way this code reaches in to the
106 internal C<OPS> hash key to do its concatenation, and the way it
107 twiddles each op's C<CODE> hash key after that.
109 If the op and oplib Perl modules are going to be used for modifying
110 information read from ops files in addition to reading it, they should
111 be changed to make the above operations explicitly supported.
113 Otherwise, the Parrot build and interpreter start-up logic should be
114 modified so that it doesn't need to concatenate separate ops files.
120 =item F<tools/build/ops2c.pl>.
122 =item F<lib/Parrot/Ops2pm.pm>.
124 =item F<lib/Parrot/Ops2pm/Auxiliary.pm>.
126 =item F<tools/dev/ops_renum.mak>.
132 Over the years, F<tools/build/ops2pm.pl> has been worked on by the following Parrot hackers:
151 Others who provided code cited in the version control logs include:
161 # cperl-indent-level: 4
164 # vim: expandtab shiftwidth=4: