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