ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/caldefn.c
(Generate patch)

Comparing ray/src/common/caldefn.c (file contents):
Revision 1.8 by greg, Tue Apr 23 12:59:33 1991 UTC vs.
Revision 1.10 by greg, Mon Apr 29 08:33:13 1991 UTC

# Line 1 | Line 1
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";
# Line 19 | Line 19 | 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>
# Line 185 | Line 185 | int  (*cs)();
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;
# Line 193 | Line 194 | dclearall()                    /* clear all definitions */
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  
# Line 372 | Line 378 | EPNODE  *sp;
378   loaddefn()                      /* load next definition */
379   {
380      register EPNODE  *ep;
381 +    EPNODE  *lastdef;
382  
383      if (nextc == ';') {         /* empty statement */
384          scan();
# Line 386 | Line 393 | loaddefn()                     /* load next definition */
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 &&
# Line 401 | Line 407 | loaddefn()                     /* load next definition */
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) {
# Line 459 | Line 467 | getdefn()                      /* A -> SYM = E1 */
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 (

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines