1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
19 |
|
* |
20 |
|
* 5/31/90 Added conditional compile (REDEFW) for redefinition warning. |
21 |
|
* |
22 |
< |
* 4/23/91 Added ':' defines for constant expressions (RCONST) |
22 |
> |
* 4/23/91 Added ':' assignment for constant expressions |
23 |
|
*/ |
24 |
|
|
25 |
|
#include <stdio.h> |
185 |
|
#endif |
186 |
|
|
187 |
|
|
188 |
< |
dclearall() /* clear all definitions */ |
188 |
> |
dcleanup(lvl) /* clear definitions (0->vars,1->consts,2->output) */ |
189 |
> |
int lvl; |
190 |
|
{ |
191 |
|
register int i; |
192 |
|
register VARDEF *vp; |
194 |
|
|
195 |
|
for (i = 0; i < NHASH; i++) |
196 |
|
for (vp = hashtbl[i]; vp != NULL; vp = vp->next) |
197 |
< |
dremove(vp->name); |
197 |
> |
if (lvl >= 1) |
198 |
> |
dremove(vp->name); |
199 |
> |
else |
200 |
> |
dclear(vp->name); |
201 |
|
#ifdef OUTCHAN |
202 |
< |
for (ep = outchan; ep != NULL; ep = ep->sibling) |
203 |
< |
epfree(ep); |
204 |
< |
outchan = NULL; |
202 |
> |
if (lvl >= 2) { |
203 |
> |
for (ep = outchan; ep != NULL; ep = ep->sibling) |
204 |
> |
epfree(ep); |
205 |
> |
outchan = NULL; |
206 |
> |
} |
207 |
|
#endif |
208 |
|
} |
209 |
|
|
378 |
|
loaddefn() /* load next definition */ |
379 |
|
{ |
380 |
|
register EPNODE *ep; |
381 |
+ |
EPNODE *lastdef; |
382 |
|
|
383 |
|
if (nextc == ';') { /* empty statement */ |
384 |
|
scan(); |
393 |
|
{ /* ordinary definition */ |
394 |
|
ep = getdefn(); |
395 |
|
#ifdef REDEFW |
396 |
< |
if (dlookup(dname(ep)) != NULL) { |
390 |
< |
dclear(dname(ep)); |
396 |
> |
if ((lastdef = dlookup(dname(ep))) != NULL) { |
397 |
|
wputs(dname(ep)); |
398 |
< |
if (dlookup(dname(ep)) == NULL) |
393 |
< |
wputs(": redefined\n"); |
394 |
< |
else |
398 |
> |
if (lastdef->type == ':') |
399 |
|
wputs(": redefined constant expression\n"); |
400 |
+ |
else |
401 |
+ |
wputs(": redefined\n"); |
402 |
|
} |
403 |
|
#ifdef FUNCTION |
404 |
|
else if (ep->v.kid->type == FUNC && |
407 |
|
wputs(": redefined library function\n"); |
408 |
|
} |
409 |
|
#endif |
404 |
– |
#else |
405 |
– |
dclear(dname(ep)); |
410 |
|
#endif |
411 |
+ |
if (ep->type == ':') |
412 |
+ |
dremove(dname(ep)); |
413 |
+ |
else |
414 |
+ |
dclear(dname(ep)); |
415 |
|
dpush(ep); |
416 |
|
} |
417 |
|
if (nextc != EOF) { |
467 |
|
ep2->type = nextc; |
468 |
|
scan(); |
469 |
|
addekid(ep2, ep1); |
462 |
– |
#ifdef RCONST |
463 |
– |
if ( |
464 |
– |
#ifdef FUNCTION |
465 |
– |
ep1->type == SYM && |
466 |
– |
#endif |
467 |
– |
ep2->type == ':') |
468 |
– |
addekid(ep2, rconst(getE1())); |
469 |
– |
else |
470 |
– |
#endif |
470 |
|
addekid(ep2, getE1()); |
471 |
|
|
472 |
|
if ( |