Debian Codegraph @

f77/fcom/init.c

raw symbols SCIP
1 /* $Id: init.c,v 1.16 2008/12/24 17:40:41 sgk Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35 #include "defines.h"
36 #include "defs.h"
37
38
39 FILEP infile;
40 FILEP diagfile;
41
42 long int headoffset;
43
44 char token[100];
45 int toklen;
46 int lineno;
47 char *infname;
48 int needkwd;
49 struct labelblock *thislabel = NULL;
50 flag nowarnflag = NO;
51 flag ftn66flag = NO;
52 flag profileflag = NO;
53 flag optimflag = NO;
54 flag quietflag = NO;
55 flag shiftcase = YES;
56 flag undeftype = NO;
57 flag shortsubs = YES;
58 flag onetripflag = NO;
59 flag checksubs = NO;
60 flag debugflag = NO;
61 int nerr;
62 int nwarn;
63 int ndata;
64
65 flag saveall;
66 flag substars;
67 int parstate = OUTSIDE;
68 flag headerdone = NO;
69 int blklevel;
70 int impltype[26];
71 int implleng[26];
72 int implstg[26];
73
74 int tyint = TYLONG ;
75 int tylogical = TYLONG;
76 ftnint typesize[NTYPES]
77 = { 1, FSZADDR, FSZSHORT, FSZLONG, FSZLONG, 2*FSZLONG,
78 2*FSZLONG, 4*FSZLONG, FSZLONG, 1, 1, 1};
79 int typealign[NTYPES]
80 = { 1, ALIADDR, ALISHORT, ALILONG, ALILONG, ALIDOUBLE,
81 ALILONG, ALIDOUBLE, ALILONG, 1, 1, 1};
82 int procno;
83 int proctype = TYUNKNOWN;
84 char *procname;
85 int rtvlabel[NTYPES];
86 int fudgelabel;
87 struct bigblock *typeaddr;
88 struct bigblock *retslot;
89 int cxslot = -1;
90 int chslot = -1;
91 int chlgslot = -1;
92 int procclass = CLUNKNOWN;
93 int nentry;
94 flag multitype;
95 ftnint procleng;
96 int lastlabno = 10;
97 int lastvarno;
98 int lastargslot;
99 int argloc;
100 ftnint autoleng;
101 ftnint bssleng = 0;
102 int retlabel;
103 int ret0label;
104 struct ctlframe ctls[MAXCTL];
105 struct ctlframe *ctlstack = ctls-1;
106 struct ctlframe *lastctl = ctls+MAXCTL ;
107
108 bigptr regnamep[10]; /* XXX MAXREGVAR */
109 int highregvar;
110
111 struct extsym extsymtab[MAXEXT];
112 struct extsym *nextext = extsymtab;
113 struct extsym *lastext = extsymtab+MAXEXT;
114
115 struct equivblock eqvclass[MAXEQUIV];
116 struct hashentry hashtab[MAXHASH];
117 struct hashentry *lasthash = hashtab+MAXHASH;
118
119 struct labelblock labeltab[MAXSTNO];
120 struct labelblock *labtabend = labeltab+MAXSTNO;
121 struct labelblock *highlabtab = labeltab;
122 chainp rpllist = NULL;
123 chainp curdtp = NULL;
124 flag toomanyinit;
125 ftnint curdtelt;
126 chainp templist = NULL;
127 chainp holdtemps = NULL;
128 int dorange = 0;
129 chainp entries = NULL;
130 chainp chains = NULL;
131
132 flag inioctl;
133 struct bigblock *ioblkp;
134 int iostmt;
135 int nioctl;
136 int nequiv = 0;
137 int nintnames = 0;
138 int nextnames = 0;
139
140 struct literal litpool[MAXLITERALS];
141 int nliterals;
142
143 /*
144 * Return a number for internal labels.
145 */
146 int getlab(void);
147
148 int crslab = 10;
149 int
150 getlab(void)
151 {
152 return crslab++;
153 }
154
155
156 void
157 fileinit()
158 {
159 procno = 0;
160 lastlabno = 10;
161 lastvarno = 0;
162 nextext = extsymtab;
163 nliterals = 0;
164 nerr = 0;
165 ndata = 0;
166 }
167
168
169
170
171 void
172 procinit()
173 {
174 register struct bigblock *p;
175 register struct dimblock *q;
176 register struct hashentry *hp;
177 register struct labelblock *lp;
178 chainp cp;
179 int i;
180
181 setloc(RDATA);
182 parstate = OUTSIDE;
183 headerdone = NO;
184 blklevel = 1;
185 saveall = NO;
186 substars = NO;
187 nwarn = 0;
188 thislabel = NULL;
189 needkwd = 0;
190
191 ++procno;
192 proctype = TYUNKNOWN;
193 procname = "MAIN_ ";
194 procclass = CLUNKNOWN;
195 nentry = 0;
196 multitype = NO;
197 typeaddr = NULL;
198 retslot = NULL;
199 cxslot = -1;
200 chslot = -1;
201 chlgslot = -1;
202 procleng = 0;
203 blklevel = 1;
204 lastargslot = 0;
205 autoleng = AUTOINIT;
206
207 for(lp = labeltab ; lp < labtabend ; ++lp)
208 lp->stateno = 0;
209
210 for(hp = hashtab ; hp < lasthash ; ++hp)
211 if((p = hp->varp))
212 {
213 frexpr(p->vleng);
214 if((q = p->b_name.vdim))
215 {
216 for(i = 0 ; i < q->ndim ; ++i)
217 {
218 frexpr(q->dims[i].dimsize);
219 frexpr(q->dims[i].dimexpr);
220 }
221 frexpr(q->nelt);
222 frexpr(q->baseoffset);
223 frexpr(q->basexpr);
224 ckfree(q);
225 }
226 ckfree(p);
227 hp->varp = NULL;
228 }
229 nintnames = 0;
230 highlabtab = labeltab;
231
232 ctlstack = ctls - 1;
233 for(cp = templist ; cp ; cp = cp->chain.nextp)
234 ckfree(cp->chain.datap);
235 frchain(&templist);
236 holdtemps = NULL;
237 dorange = 0;
238 highregvar = 0;
239 entries = NULL;
240 rpllist = NULL;
241 inioctl = NO;
242 ioblkp = NULL;
243 nequiv = 0;
244
245 for(i = 0 ; i<NTYPES ; ++i)
246 rtvlabel[i] = 0;
247 fudgelabel = 0;
248
249 if(undeftype)
250 setimpl(TYUNKNOWN, (ftnint) 0, 'a', 'z');
251 else
252 {
253 setimpl(TYREAL, (ftnint) 0, 'a', 'z');
254 setimpl(tyint, (ftnint) 0, 'i', 'n');
255 }
256 setimpl(-STGBSS, (ftnint) 0, 'a', 'z'); /* set class */
257 setlog();
258 }
259
260
261
262 void
263 setimpl(type, length, c1, c2)
264 int type;
265 ftnint length;
266 int c1, c2;
267 {
268 int i;
269 char buff[100];
270
271 if(c1==0 || c2==0)
272 return;
273
274 if(c1 > c2) {
275 sprintf(buff, "characters out of order in implicit:%c-%c", c1, c2);
276 err(buff);
277 } else
278 if(type < 0)
279 for(i = c1 ; i<=c2 ; ++i)
280 implstg[i-'a'] = - type;
281 else
282 {
283 type = lengtype(type, (int) length);
284 if(type != TYCHAR)
285 length = 0;
286 for(i = c1 ; i<=c2 ; ++i)
287 {
288 impltype[i-'a'] = type;
289 implleng[i-'a'] = length;
290 }
291 }
292 }