Add a test for [perl #17753].
[p5sagit/p5-mst-13.2.git] / regcomp.pl
CommitLineData
36bb303b 1BEGIN {
2 # Get function prototypes
9ad884cb 3 require 'regen_lib.pl';
36bb303b 4}
d09b2d29 5#use Fatal qw(open close rename chmod unlink);
6open DESC, 'regcomp.sym';
7$ind = 0;
8
9while (<DESC>) {
10 next if /^\s*($|\#)/;
11 $ind++;
12 chomp;
13 ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3;
14 ($type[$ind], $code[$ind], $args[$ind], $longj[$ind])
15 = split /[,\s]\s*/, $desc, 4;
16}
17close DESC;
18$tot = $ind;
19
20$tmp_h = 'tmp_reg.h';
21
22unlink $tmp_h if -f $tmp_h;
23
24open OUT, ">$tmp_h";
25
26print OUT <<EOP;
27/* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
9b155405 28 This file is built by regcomp.pl from regcomp.sym.
d09b2d29 29 Any changes made here will be lost!
30*/
31
32EOP
33
34$ind = 0;
35while (++$ind <= $tot) {
36 $oind = $ind - 1;
37 $hind = sprintf "%#4x", $oind;
38 print OUT <<EOP;
39#define $name[$ind] $oind /* $hind $rest[$ind] */
40EOP
41}
42
43print OUT <<EOP;
44
45#ifndef DOINIT
22c35a8c 46EXTCONST U8 PL_regkind[];
d09b2d29 47#else
22c35a8c 48EXTCONST U8 PL_regkind[] = {
d09b2d29 49EOP
50
51$ind = 0;
52while (++$ind <= $tot) {
53 print OUT <<EOP;
54 $type[$ind], /* $name[$ind] */
55EOP
56}
57
58print OUT <<EOP;
59};
60#endif
61
62
63#ifdef REG_COMP_C
29de9391 64static const U8 regarglen[] = {
d09b2d29 65EOP
66
67$ind = 0;
68while (++$ind <= $tot) {
69 $size = 0;
70 $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind];
71
72 print OUT <<EOP;
73 $size, /* $name[$ind] */
74EOP
75}
76
77print OUT <<EOP;
78};
79
29de9391 80static const char reg_off_by_arg[] = {
d09b2d29 81EOP
82
83$ind = 0;
84while (++$ind <= $tot) {
85 $size = $longj[$ind] || 0;
9b155405 86
d09b2d29 87 print OUT <<EOP;
88 $size, /* $name[$ind] */
89EOP
90}
91
92print OUT <<EOP;
93};
9b155405 94
95#ifdef DEBUGGING
29de9391 96static const char * const reg_name[] = {
9b155405 97EOP
98
99$ind = 0;
100while (++$ind <= $tot) {
101 $hind = sprintf "%#4x", $ind-1;
102 $size = $longj[$ind] || 0;
103
104 print OUT <<EOP;
105 "$name[$ind]", /* $hind */
106EOP
107}
108
109print OUT <<EOP;
110};
111
29de9391 112static const int reg_num = $tot;
9b155405 113
114#endif /* DEBUGGING */
d09b2d29 115#endif /* REG_COMP_C */
116
117EOP
118
36bb303b 119close OUT or die "close $tmp_h: $!";
d09b2d29 120
36bb303b 121safer_rename $tmp_h, 'regnodes.h';