Commit | Line | Data |
36bb303b |
1 | BEGIN { |
2 | # Get function prototypes |
9ad884cb |
3 | require 'regen_lib.pl'; |
36bb303b |
4 | } |
d09b2d29 |
5 | #use Fatal qw(open close rename chmod unlink); |
6 | open DESC, 'regcomp.sym'; |
7 | $ind = 0; |
8 | |
9 | while (<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 | } |
17 | close DESC; |
18 | $tot = $ind; |
3dab1dad |
19 | die "Too many regexp opcodes! Maximum is 256, but there are $tot in file!" |
20 | if $tot>256; |
d09b2d29 |
21 | |
22 | $tmp_h = 'tmp_reg.h'; |
23 | |
24 | unlink $tmp_h if -f $tmp_h; |
25 | |
26 | open OUT, ">$tmp_h"; |
dfb1454f |
27 | binmode OUT; |
d09b2d29 |
28 | |
29 | print OUT <<EOP; |
37442d52 |
30 | /* -*- buffer-read-only: t -*- |
31 | !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
9b155405 |
32 | This file is built by regcomp.pl from regcomp.sym. |
d09b2d29 |
33 | Any changes made here will be lost! |
34 | */ |
35 | |
36 | EOP |
37 | |
38 | $ind = 0; |
39 | while (++$ind <= $tot) { |
40 | $oind = $ind - 1; |
41 | $hind = sprintf "%#4x", $oind; |
42 | print OUT <<EOP; |
43 | #define $name[$ind] $oind /* $hind $rest[$ind] */ |
44 | EOP |
45 | } |
46 | |
47 | print OUT <<EOP; |
48 | |
49 | #ifndef DOINIT |
22c35a8c |
50 | EXTCONST U8 PL_regkind[]; |
d09b2d29 |
51 | #else |
22c35a8c |
52 | EXTCONST U8 PL_regkind[] = { |
d09b2d29 |
53 | EOP |
54 | |
55 | $ind = 0; |
56 | while (++$ind <= $tot) { |
57 | print OUT <<EOP; |
58 | $type[$ind], /* $name[$ind] */ |
59 | EOP |
60 | } |
61 | |
62 | print OUT <<EOP; |
63 | }; |
64 | #endif |
65 | |
66 | |
67 | #ifdef REG_COMP_C |
29de9391 |
68 | static const U8 regarglen[] = { |
d09b2d29 |
69 | EOP |
70 | |
71 | $ind = 0; |
72 | while (++$ind <= $tot) { |
73 | $size = 0; |
74 | $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind]; |
75 | |
76 | print OUT <<EOP; |
77 | $size, /* $name[$ind] */ |
78 | EOP |
79 | } |
80 | |
81 | print OUT <<EOP; |
82 | }; |
83 | |
29de9391 |
84 | static const char reg_off_by_arg[] = { |
d09b2d29 |
85 | EOP |
86 | |
87 | $ind = 0; |
88 | while (++$ind <= $tot) { |
89 | $size = $longj[$ind] || 0; |
9b155405 |
90 | |
d09b2d29 |
91 | print OUT <<EOP; |
92 | $size, /* $name[$ind] */ |
93 | EOP |
94 | } |
95 | |
96 | print OUT <<EOP; |
97 | }; |
9b155405 |
98 | |
99 | #ifdef DEBUGGING |
29de9391 |
100 | static const char * const reg_name[] = { |
9b155405 |
101 | EOP |
102 | |
103 | $ind = 0; |
104 | while (++$ind <= $tot) { |
105 | $hind = sprintf "%#4x", $ind-1; |
106 | $size = $longj[$ind] || 0; |
107 | |
108 | print OUT <<EOP; |
109 | "$name[$ind]", /* $hind */ |
110 | EOP |
111 | } |
112 | |
113 | print OUT <<EOP; |
114 | }; |
115 | |
29de9391 |
116 | static const int reg_num = $tot; |
9b155405 |
117 | |
118 | #endif /* DEBUGGING */ |
d09b2d29 |
119 | #endif /* REG_COMP_C */ |
120 | |
37442d52 |
121 | /* ex: set ro: */ |
d09b2d29 |
122 | EOP |
123 | |
36bb303b |
124 | close OUT or die "close $tmp_h: $!"; |
d09b2d29 |
125 | |
36bb303b |
126 | safer_rename $tmp_h, 'regnodes.h'; |