tagged release 0.6.4
[parrot.git] / tools / build / ops2pm.pl
blob70e5b53fbbe1f7ff5e7cad976786c091c4429019
1 #! perl
2 # Copyright (C) 2001-2007, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
8 use lib 'lib';
9 use Parrot::Ops2pm::Utils;
10 use Parrot::Ops2pm::Auxiliary qw( Usage getoptions );
12 my $flagref = getoptions();
14 if ( $flagref->{help} or !@ARGV ) {
15 Usage();
16 exit;
19 my $self = Parrot::Ops2pm::Utils->new(
21 argv => [@ARGV],
22 nolines => $flagref->{nolines},
23 renum => $flagref->{renum},
24 moddir => "lib/Parrot/OpLib",
25 module => "core.pm",
26 inc_dir => "include/parrot/oplib",
27 inc_f => "ops.h",
28 script => "tools/build/ops2pm.pl",
32 $self->prepare_ops();
34 if ( $flagref->{renum} ) {
35 $self->renum_op_map_file();
36 exit 0;
39 $self->load_op_map_files();
40 $self->sort_ops();
41 $self->prepare_real_ops();
42 $self->print_module();
43 $self->print_h();
45 exit 0;
47 ################### DOCUMENTATION ####################
49 =head1 NAME
51 tools/build/ops2pm.pl - Generate Perl module from operation definitions
53 =head1 SYNOPSIS
55 $ perl tools/build/ops2pm.pl [--help] [--no-lines] input.ops [input2.ops ...]
56 $ perl tools/build/ops2pm.pl [--renum] input.ops [input2.ops ...]
58 =head1 DESCRIPTION
60 Reads the ops files listed on the command line and outputs a
61 F<Parrot::OpLib::core> module containing information about the ops.
62 Also outputs F<include/parrot/oplib/ops.h>. This program is called by Parrot's
63 F<make>.
65 If called with the C<--renum> flag, renumbers the file F<src/ops/ops.num>.
66 This is mandatory when adding or removing opcodes.
68 =head1 OPTIONS
70 =over 4
72 =item C<--help>
74 Print synopsis.
76 =item C<--no-lines>
78 Do not generate C<#line> directives in the generated C code.
80 =item C<--renum>
82 Renumber opcodes according to existing ops in ops/num and natural
83 order in the given ops files. See also F<tools/dev/ops_renum.mak>.
85 =back
87 Most of the functionality in this program is now held in Parrot::Ops2pm::Util
88 methods and a small number of Parrot::Ops2pm::Auxiliary subroutines.
89 See those modules' documentation for discussion of those functions.
90 Revisions to the functionality should be made in those packages and tested
91 against tests found in F<t/tools/ops2pmutils/>.
93 =head1 WARNING
95 Generating a C<Parrot::OpLib::core> module for a set of ops files that
96 you do not later turn into C code (see F<tools/build/ops2c.pl>) with the
97 same op content and order is a recipe for disaster. But as long as you
98 just run these tools in the standard build process via C<make> there
99 shouldn't be a problem.
101 =head1 TODO
103 The original design of the ops processing code was intended to be
104 a read-only representation of what was in a particular ops file. It was
105 not originally intended that it was a mechanism for building a bigger
106 virtual ops file from multiple physical ops files.
108 This code does half of that job (the other half is getting them to
109 compile together instead of separately in a F<*_ops.c> file).
111 You can see evidence of this by the way this code reaches in to the
112 internal C<OPS> hash key to do its concatenation, and the way it
113 twiddles each op's C<CODE> hash key after that.
115 If the op and oplib Perl modules are going to be used for modifying
116 information read from ops files in addition to reading it, they should
117 be changed to make the above operations explicitly supported.
119 Otherwise, the Parrot build and interpreter start-up logic should be
120 modified so that it doesn't need to concatenate separate ops files.
122 =head1 SEE ALSO
124 =over 4
126 =item F<tools/build/ops2c.pl>.
128 =item F<lib/Parrot/Ops2pm/Utils.pm>.
130 =item F<lib/Parrot/Ops2pm/Auxiliary.pm>.
132 =item F<tools/dev/ops_renum.mak>.
134 =back
136 =head1 AUTHOR
138 Over the years, F<tools/build/ops2pm.pl> has been worked on by the following Parrot hackers:
140 bernhard
141 brentdax
142 chip
143 chromatic
144 coke
146 gregor
147 jkeenan
149 mikescott
150 particle
151 paultcochrane
152 petdance
153 robert
154 simon
155 tewk
157 Others who provided code cited in the version control logs include:
159 Andy Dougherty
160 Jeff Gof
161 Steve Fink
163 =cut
165 # Local Variables:
166 # mode: cperl
167 # cperl-indent-level: 4
168 # fill-column: 100
169 # End:
170 # vim: expandtab shiftwidth=4: