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