source: trunk/third/perl/regcomp.pl @ 14545

Revision 14545, 1.7 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14544, which included commits to RCS files with non-trunk default branches.
Line 
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   !!!!!!!
24   This file is built by regcomp.pl from regcomp.sym.
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
42EXTCONST U8 PL_regkind[];
43#else
44EXTCONST U8 PL_regkind[] = {
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
60const static U8 regarglen[] = {
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
76const static char reg_off_by_arg[] = {
77EOP
78
79$ind = 0;
80while (++$ind <= $tot) {
81  $size = $longj[$ind] || 0;
82
83  print OUT <<EOP;
84        $size,          /* $name[$ind] */
85EOP
86}
87
88print OUT <<EOP;
89};
90
91#ifdef DEBUGGING
92const static char * const reg_name[] = {
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
108const static int reg_num = $tot;
109
110#endif /* DEBUGGING */
111#endif /* REG_COMP_C */
112
113EOP
114
115close OUT;
116
117chmod 0666, 'regnodes.h';
118unlink 'regnodes.h';
119rename $tmp_h, 'regnodes.h';
Note: See TracBrowser for help on using the repository browser.