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