source: mainline/uspace/app/pcc/f77/fcom/init.c@ a7de7182

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a7de7182 was a7de7182, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Added pcc source tree (contents of pcc-1.0.0.tgz)

  • Property mode set to 100644
File size: 6.2 KB
Line 
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
39FILEP infile;
40FILEP diagfile;
41
42long int headoffset;
43
44char token[100];
45int toklen;
46int lineno;
47char *infname;
48int needkwd;
49struct labelblock *thislabel = NULL;
50flag nowarnflag = NO;
51flag ftn66flag = NO;
52flag profileflag = NO;
53flag optimflag = NO;
54flag quietflag = NO;
55flag shiftcase = YES;
56flag undeftype = NO;
57flag shortsubs = YES;
58flag onetripflag = NO;
59flag checksubs = NO;
60flag debugflag = NO;
61int nerr;
62int nwarn;
63int ndata;
64
65flag saveall;
66flag substars;
67int parstate = OUTSIDE;
68flag headerdone = NO;
69int blklevel;
70int impltype[26];
71int implleng[26];
72int implstg[26];
73
74int tyint = TYLONG ;
75int tylogical = TYLONG;
76ftnint typesize[NTYPES]
77 = { 1, FSZADDR, FSZSHORT, FSZLONG, FSZLONG, 2*FSZLONG,
78 2*FSZLONG, 4*FSZLONG, FSZLONG, 1, 1, 1};
79int typealign[NTYPES]
80 = { 1, ALIADDR, ALISHORT, ALILONG, ALILONG, ALIDOUBLE,
81 ALILONG, ALIDOUBLE, ALILONG, 1, 1, 1};
82int procno;
83int proctype = TYUNKNOWN;
84char *procname;
85int rtvlabel[NTYPES];
86int fudgelabel;
87struct bigblock *typeaddr;
88struct bigblock *retslot;
89int cxslot = -1;
90int chslot = -1;
91int chlgslot = -1;
92int procclass = CLUNKNOWN;
93int nentry;
94flag multitype;
95ftnint procleng;
96int lastlabno = 10;
97int lastvarno;
98int lastargslot;
99int argloc;
100ftnint autoleng;
101ftnint bssleng = 0;
102int retlabel;
103int ret0label;
104struct ctlframe ctls[MAXCTL];
105struct ctlframe *ctlstack = ctls-1;
106struct ctlframe *lastctl = ctls+MAXCTL ;
107
108bigptr regnamep[10]; /* XXX MAXREGVAR */
109int highregvar;
110
111struct extsym extsymtab[MAXEXT];
112struct extsym *nextext = extsymtab;
113struct extsym *lastext = extsymtab+MAXEXT;
114
115struct equivblock eqvclass[MAXEQUIV];
116struct hashentry hashtab[MAXHASH];
117struct hashentry *lasthash = hashtab+MAXHASH;
118
119struct labelblock labeltab[MAXSTNO];
120struct labelblock *labtabend = labeltab+MAXSTNO;
121struct labelblock *highlabtab = labeltab;
122chainp rpllist = NULL;
123chainp curdtp = NULL;
124flag toomanyinit;
125ftnint curdtelt;
126chainp templist = NULL;
127chainp holdtemps = NULL;
128int dorange = 0;
129chainp entries = NULL;
130chainp chains = NULL;
131
132flag inioctl;
133struct bigblock *ioblkp;
134int iostmt;
135int nioctl;
136int nequiv = 0;
137int nintnames = 0;
138int nextnames = 0;
139
140struct literal litpool[MAXLITERALS];
141int nliterals;
142
143/*
144 * Return a number for internal labels.
145 */
146int getlab(void);
147
148int crslab = 10;
149int
150getlab(void)
151{
152 return crslab++;
153}
154
155
156void
157fileinit()
158{
159procno = 0;
160lastlabno = 10;
161lastvarno = 0;
162nextext = extsymtab;
163nliterals = 0;
164nerr = 0;
165ndata = 0;
166}
167
168
169
170
171void
172procinit()
173{
174register struct bigblock *p;
175register struct dimblock *q;
176register struct hashentry *hp;
177register struct labelblock *lp;
178chainp cp;
179int i;
180
181 setloc(RDATA);
182parstate = OUTSIDE;
183headerdone = NO;
184blklevel = 1;
185saveall = NO;
186substars = NO;
187nwarn = 0;
188thislabel = NULL;
189needkwd = 0;
190
191++procno;
192proctype = TYUNKNOWN;
193procname = "MAIN_ ";
194procclass = CLUNKNOWN;
195nentry = 0;
196multitype = NO;
197typeaddr = NULL;
198retslot = NULL;
199cxslot = -1;
200chslot = -1;
201chlgslot = -1;
202procleng = 0;
203blklevel = 1;
204lastargslot = 0;
205 autoleng = AUTOINIT;
206
207for(lp = labeltab ; lp < labtabend ; ++lp)
208 lp->stateno = 0;
209
210for(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 }
229nintnames = 0;
230highlabtab = labeltab;
231
232ctlstack = ctls - 1;
233for(cp = templist ; cp ; cp = cp->chain.nextp)
234 ckfree(cp->chain.datap);
235frchain(&templist);
236holdtemps = NULL;
237dorange = 0;
238highregvar = 0;
239entries = NULL;
240rpllist = NULL;
241inioctl = NO;
242ioblkp = NULL;
243nequiv = 0;
244
245for(i = 0 ; i<NTYPES ; ++i)
246 rtvlabel[i] = 0;
247fudgelabel = 0;
248
249if(undeftype)
250 setimpl(TYUNKNOWN, (ftnint) 0, 'a', 'z');
251else
252 {
253 setimpl(TYREAL, (ftnint) 0, 'a', 'z');
254 setimpl(tyint, (ftnint) 0, 'i', 'n');
255 }
256setimpl(-STGBSS, (ftnint) 0, 'a', 'z'); /* set class */
257setlog();
258}
259
260
261
262void
263setimpl(type, length, c1, c2)
264int type;
265ftnint length;
266int c1, c2;
267{
268int i;
269char buff[100];
270
271if(c1==0 || c2==0)
272 return;
273
274if(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}
Note: See TracBrowser for help on using the repository browser.