4 my $in = shift or die "No input name";
5 my $out = shift or die "No output name";
6 open(IN, $in) or die "Cannot open input $in: $!";
7 open(OUT, "> $out") or die "Cannot create $out: $!";
10 # AUTOMATICALLY GENERATED BY regops.perl
11 package Imager::Regops;
14 use vars qw(@ISA @EXPORT @EXPORT_OK %Attr $MaxOperands $PackCode);
16 @EXPORT_OK = qw(%Attr $MaxOperands $PackCode);
25 if (/^\s*rbc_(\w+)/) {
27 push(@ops, uc "RBC_$op");
28 # each line has a comment with the registers used - find the maximum
29 # I could probably do this as one line, but let's not
30 my @parms = /\b([rp][a-z])\b/g;
31 $max_opr = @parms if @parms > $max_opr;
32 my $types = join("", map {substr($_,0,1)} @parms);
33 my ($result) = /->\s*([rp])/;
34 $attr{$op} = { parms=>scalar @parms,
40 print OUT "use constant RBC_\U$op\E => $opcode;\n";
43 if (/^\#define RM_WORD_PACK \"(.)\"/) {
47 print OUT "\n\@EXPORT = qw(@ops);\n\n";
48 # previously we used Data::Dumper, with Sortkeys()
49 # to make sure the generated code only changed when the data
50 # changed. Unfortunately Sortkeys isn't supported in some versions of
51 # perl we try to support, so we now generate this manually
52 print OUT "%Attr =\n (\n";
53 for my $opname (sort keys %attr) {
54 my $op = $attr{$opname};
55 print OUT " '$opname' =>\n {\n";
56 for my $attrname (sort keys %$op) {
57 my $attr = $op->{$attrname};
58 print OUT " '$attrname' => ";
60 if ($attr =~ /^\d+$/) {
76 print OUT "\$MaxOperands = $max_opr;\n";
77 print OUT qq/\$PackCode = "$reg_pack";\n/;
85 Imager::Regops - generated information about the register based virtual machine
90 $Imager::Regops::Attr{$opname}->{opcode} # opcode for given operator
91 $Imager::Regops::Attr{$opname}->{parms} # number of parameters
92 $Imager::Regops::Attr{$opname}->{types} # types of parameters
93 $Imager::Regops::Attr{$opname}->{func} # operator is a function
94 $Imager::Regops::Attr{$opname}->{result} # r for numeric, p for pixel result
95 $Imager::Regops::MaxOperands; # maximum number of operands
99 This module is generated automatically from F<regmach.h> so we don't need to
100 maintain the same information in at least one extra place.
102 At least that's the idea.
106 Tony Cook, tony@develop-help.com
110 perl(1), Imager(3), http://imager.perl.org/
115 close(OUT) or die "Cannot close $out: $!";