Bell 32V development
[unix-history] / usr / src / cmd / f77 / init.c
CommitLineData
0d57d6f5
TL
1#include "defs"
2
3
4FILEP infile = { stdin };
5FILEP diagfile = { stderr };
6
7FILEP textfile;
8FILEP asmfile;
9FILEP initfile;
10long int headoffset;
11
12char token[100];
13int toklen;
14int lineno;
15char *infname;
16int needkwd;
17struct labelblock *thislabel = NULL;
18flag nowarnflag = NO;
19flag ftn66flag = NO;
20flag profileflag = NO;
21flag optimflag = NO;
22flag shiftcase = YES;
23flag undeftype = NO;
24flag shortsubs = YES;
25flag onetripflag = NO;
26flag checksubs = NO;
27flag debugflag = NO;
28int nerr;
29int nwarn;
30int ndata;
31
32flag saveall;
33flag substars;
34int parstate = OUTSIDE;
35flag headerdone = NO;
36int blklevel;
37int impltype[26];
38int implleng[26];
39int implstg[26];
40
41int tyint = TYLONG ;
42int tylogical = TYLONG;
43ftnint typesize[NTYPES]
44 = { 1, SZADDR, SZSHORT, SZLONG, SZLONG, 2*SZLONG,
45 2*SZLONG, 4*SZLONG, SZLONG, 1, 1, 1};
46int typealign[NTYPES]
47 = { 1, ALIADDR, ALISHORT, ALILONG, ALILONG, ALIDOUBLE,
48 ALILONG, ALIDOUBLE, ALILONG, 1, 1, 1};
49int procno;
50int proctype = TYUNKNOWN;
51char *procname;
52int rtvlabel[NTYPES];
53int fudgelabel;
54struct addrblock *typeaddr;
55struct addrblock *retslot;
56int cxslot = -1;
57int chslot = -1;
58int chlgslot = -1;
59int procclass = CLUNKNOWN;
60int nentry;
61flag multitype;
62ftnint procleng;
63int lastlabno = 10;
64int lastvarno;
65int lastargslot;
66int argloc;
67ftnint autoleng;
68ftnint bssleng = 0;
69int retlabel;
70int ret0label;
71struct ctlframe ctls[MAXCTL];
72struct ctlframe *ctlstack = ctls-1;
73struct ctlframe *lastctl = ctls+MAXCTL ;
74
75struct nameblock *regnamep[MAXREGVAR];
76int highregvar;
77int nregvar;
78
79struct extsym extsymtab[MAXEXT];
80struct extsym *nextext = extsymtab;
81struct extsym *lastext = extsymtab+MAXEXT;
82
83struct equivblock eqvclass[MAXEQUIV];
84struct hashentry hashtab[MAXHASH];
85struct hashentry *lasthash = hashtab+MAXHASH;
86
87struct labelblock labeltab[MAXSTNO];
88struct labelblock *labtabend = labeltab+MAXSTNO;
89struct labelblock *highlabtab = labeltab;
90struct rplblock *rpllist = NULL;
91chainp curdtp = NULL;
92flag toomanyinit;
93ftnint curdtelt;
94chainp templist = NULL;
95chainp holdtemps = NULL;
96int dorange = 0;
97struct entrypoint *entries = NULL;
98
99chainp chains = NULL;
100
101flag inioctl;
102struct addrblock *ioblkp;
103int iostmt;
104int nioctl;
105int nequiv = 0;
106int nintnames = 0;
107int nextnames = 0;
108
109struct literal litpool[MAXLITERALS];
110int nliterals;
111
112
113
114fileinit()
115{
116procno = 0;
117lastlabno = 10;
118lastvarno = 0;
119nextext = extsymtab;
120nliterals = 0;
121nerr = 0;
122ndata = 0;
123}
124
125
126
127
128
129procinit()
130{
131register struct nameblock *p;
132register struct dimblock *q;
133register struct hashentry *hp;
134register struct labelblock *lp;
135chainp cp;
136int i;
137
138pruse(asmfile, USECONST);
139#if FAMILY == SCJ
140 p2pass(USETEXT);
141#endif
142parstate = OUTSIDE;
143headerdone = NO;
144blklevel = 1;
145saveall = NO;
146substars = NO;
147nwarn = 0;
148thislabel = NULL;
149needkwd = 0;
150
151++procno;
152proctype = TYUNKNOWN;
153procname = "MAIN_ ";
154procclass = CLUNKNOWN;
155nentry = 0;
156multitype = NO;
157typeaddr = NULL;
158retslot = NULL;
159cxslot = -1;
160chslot = -1;
161chlgslot = -1;
162procleng = 0;
163blklevel = 1;
164lastargslot = 0;
165#if TARGET==PDP11
166 autoleng = 6;
167#else
168 autoleng = 0;
169#endif
170
171for(lp = labeltab ; lp < labtabend ; ++lp)
172 lp->stateno = 0;
173
174for(hp = hashtab ; hp < lasthash ; ++hp)
175 if(p = hp->varp)
176 {
177 frexpr(p->vleng);
178 if(q = p->vdim)
179 {
180 for(i = 0 ; i < q->ndim ; ++i)
181 {
182 frexpr(q->dims[i].dimsize);
183 frexpr(q->dims[i].dimexpr);
184 }
185 frexpr(q->nelt);
186 frexpr(q->baseoffset);
187 frexpr(q->basexpr);
188 free(q);
189 }
190 free(p);
191 hp->varp = NULL;
192 }
193nintnames = 0;
194highlabtab = labeltab;
195
196ctlstack = ctls - 1;
197for(cp = templist ; cp ; cp = cp->nextp)
198 free(cp->datap);
199frchain(&templist);
200holdtemps = NULL;
201dorange = 0;
202nregvar = 0;
203highregvar = 0;
204entries = NULL;
205rpllist = NULL;
206inioctl = NO;
207ioblkp = NULL;
208nequiv = 0;
209
210for(i = 0 ; i<NTYPES ; ++i)
211 rtvlabel[i] = 0;
212fudgelabel = 0;
213
214if(undeftype)
215 setimpl(TYUNKNOWN, (ftnint) 0, 'a', 'z');
216else
217 {
218 setimpl(TYREAL, (ftnint) 0, 'a', 'z');
219 setimpl(tyint, (ftnint) 0, 'i', 'n');
220 }
221setimpl(-STGBSS, (ftnint) 0, 'a', 'z'); /* set class */
222setlog();
223}
224
225
226
227
228setimpl(type, length, c1, c2)
229int type;
230ftnint length;
231int c1, c2;
232{
233int i;
234char buff[100];
235
236if(c1==0 || c2==0)
237 return;
238
239if(c1 > c2)
240 err( sprintf(buff, "characters out of order in implicit:%c-%c", c1, c2) );
241else
242 if(type < 0)
243 for(i = c1 ; i<=c2 ; ++i)
244 implstg[i-'a'] = - type;
245 else
246 {
247 type = lengtype(type, (int) length);
248 if(type != TYCHAR)
249 length = 0;
250 for(i = c1 ; i<=c2 ; ++i)
251 {
252 impltype[i-'a'] = type;
253 implleng[i-'a'] = length;
254 }
255 }
256}