[cage] Add some karma aliases for myself
[parrot.git] / tools / build / ops2pm.pl
blob764798398b205072de40fe432b5e7d107ec24c9a
1 #! perl
2 # Copyright (C) 2001-2007, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
8 use lib 'lib';
9 use Parrot::Ops2pm;
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->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();
33 $self->load_op_map_files();
34 $self->sort_ops();
35 $self->prepare_real_ops();
36 $self->print_module();
37 $self->print_h();
39 exit 0;
41 ################### DOCUMENTATION ####################
43 =head1 NAME
45 tools/build/ops2pm.pl - Generate Perl module from operation definitions
47 =head1 SYNOPSIS
49 $ perl tools/build/ops2pm.pl [--help] [--no-lines] input.ops [input2.ops ...]
50 $ perl tools/build/ops2pm.pl [--renum] input.ops [input2.ops ...]
52 =head1 DESCRIPTION
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
57 F<make>.
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.
62 =head1 OPTIONS
64 =over 4
66 =item C<--help>
68 Print synopsis.
70 =item C<--no-lines>
72 Do not generate C<#line> directives in the generated C code.
74 =item C<--renum>
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>.
79 =back
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/>.
87 =head1 WARNING
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.
95 =head1 TODO
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.
116 =head1 SEE ALSO
118 =over 4
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>.
128 =back
130 =head1 AUTHOR
132 Over the years, F<tools/build/ops2pm.pl> has been worked on by the following Parrot hackers:
134 bernhard
135 brentdax
136 chip
137 chromatic
138 coke
140 gregor
141 jkeenan
143 mikescott
144 particle
145 paultcochrane
146 petdance
147 robert
148 simon
149 tewk
151 Others who provided code cited in the version control logs include:
153 Andy Dougherty
154 Jeff Gof
155 Steve Fink
157 =cut
159 # Local Variables:
160 # mode: cperl
161 # cperl-indent-level: 4
162 # fill-column: 100
163 # End:
164 # vim: expandtab shiftwidth=4: