| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 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]; |
| 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 |
|
| 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'); |
| 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 |
} |