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 2.12 by greg, Sat Feb 22 02:07:21 2003 UTC vs.
Revision 2.38 by greg, Fri Feb 23 03:47:57 2024 UTC

# Line 25 | Line 25 | static const char      RCSid[] = "$Id$";
25   *  2/19/03     Eliminated conditional compiles in favor of esupport extern.
26   */
27  
28 < /* ====================================================================
29 < * The Radiance Software License, Version 1.0
30 < *
31 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
32 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
33 < *
34 < * Redistribution and use in source and binary forms, with or without
35 < * modification, are permitted provided that the following conditions
36 < * are met:
37 < *
38 < * 1. Redistributions of source code must retain the above copyright
39 < *         notice, this list of conditions and the following disclaimer.
40 < *
41 < * 2. Redistributions in binary form must reproduce the above copyright
42 < *       notice, this list of conditions and the following disclaimer in
43 < *       the documentation and/or other materials provided with the
44 < *       distribution.
45 < *
46 < * 3. The end-user documentation included with the redistribution,
47 < *           if any, must include the following acknowledgment:
48 < *             "This product includes Radiance software
49 < *                 (http://radsite.lbl.gov/)
50 < *                 developed by the Lawrence Berkeley National Laboratory
51 < *               (http://www.lbl.gov/)."
52 < *       Alternately, this acknowledgment may appear in the software itself,
53 < *       if and wherever such third-party acknowledgments normally appear.
54 < *
55 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
56 < *       and "The Regents of the University of California" must
57 < *       not be used to endorse or promote products derived from this
58 < *       software without prior written permission. For written
59 < *       permission, please contact [email protected].
60 < *
61 < * 5. Products derived from this software may not be called "Radiance",
62 < *       nor may "Radiance" appear in their name, without prior written
63 < *       permission of Lawrence Berkeley National Laboratory.
64 < *
65 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
66 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
67 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
69 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
70 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
71 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
72 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
73 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
74 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
75 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76 < * SUCH DAMAGE.
77 < * ====================================================================
78 < *
79 < * This software consists of voluntary contributions made by many
80 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
81 < * information on Lawrence Berkeley National Laboratory, please see
82 < * <http://www.lbl.gov/>.
83 < */
28 > #include "copyright.h"
29  
85 #include  <stdio.h>
86
87 #include  <string.h>
88
30   #include  <ctype.h>
31  
32 + #include  "rterror.h"
33 + #include  "rtio.h"
34 + #include  "rtmisc.h"
35   #include  "calcomp.h"
36  
37   #ifndef  NHASH
# Line 98 | Line 42 | static const char      RCSid[] = "$Id$";
42  
43   #define  newnode()      (EPNODE *)ecalloc(1, sizeof(EPNODE))
44  
45 < static double  dvalue();
45 > static double  dvalue(char  *name, EPNODE *d);
46  
47   #define  MAXCLOCK       (1L<<31)        /* clock wrap value */
48  
# Line 114 | Line 58 | static VARDEF  *htpos;                 /* ...dfirst() and */
58   static EPNODE  *ochpos;                 /* ...dnext */
59   static EPNODE  *outchan;
60  
61 + static int  optimized = 0;              /* are we optimized? */
62 +
63   EPNODE  *curfunc = NULL;
118 #define  dname(ep)      ((ep)->v.kid->type == SYM ? \
119                        (ep)->v.kid->v.name : \
120                        (ep)->v.kid->v.kid->v.name)
64  
65  
66   void
67 < fcompile(fname)                 /* get definitions from a file */
68 < char  *fname;
67 > fcompile(                       /* get definitions from a file */
68 >        char  *fname
69 > )
70   {
71      FILE  *fp;
72  
# Line 133 | Line 77 | char  *fname;
77          eputs(": cannot open\n");
78          quit(1);
79      }
80 <    initfile(fp, fname, 0);
80 > #ifdef getc_unlocked                    /* avoid stupid semaphores */
81 >    flockfile(fp);
82 > #endif
83 >   initfile(fp, fname, 0);
84      while (nextc != EOF)
85          getstatement();
86      if (fname != NULL)
87          fclose(fp);
88 + #ifdef getc_unlocked
89 +    else
90 +        funlockfile(fp);
91 + #endif
92   }
93  
94  
95   void
96 < scompile(str, fn, ln)           /* get definitions from a string */
97 < char  *str;
98 < char  *fn;
99 < int  ln;
96 > scompile(               /* get definitions from a string */
97 >        char  *str,
98 >        char  *fn,
99 >        int  ln
100 > )
101   {
102      initstr(str, fn, ln);
103      while (nextc != EOF)
# Line 154 | Line 106 | int  ln;
106  
107  
108   double
109 < varvalue(vname)                 /* return a variable's value */
110 < char  *vname;
109 > varvalue(                       /* return a variable's value */
110 >        char  *vname
111 > )
112   {
113      return(dvalue(vname, dlookup(vname)));
114   }
115  
116  
117   double
118 < evariable(ep)                   /* evaluate a variable */
119 < EPNODE  *ep;
118 > evariable(                      /* evaluate a variable */
119 >        EPNODE  *ep
120 > )
121   {
122 <    register VARDEF  *dp = ep->v.ln;
122 >    VARDEF  *dp = ep->v.ln;
123  
124      return(dvalue(dp->name, dp->def));
125   }
126  
127  
128   void
129 < varset(vname, assign, val)      /* set a variable's value */
130 < char  *vname;
131 < int  assign;
132 < double  val;
129 > varset(         /* set a variable's value */
130 >        char  *vname,
131 >        int  assign,
132 >        double  val
133 > )
134   {
135      char  *qname;
136 <    register EPNODE  *ep1, *ep2;
136 >    EPNODE  *ep1, *ep2;
137                                          /* get qualified name */
138      qname = qualname(vname, 0);
139                                          /* check for quick set */
140 <    if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM) {
140 >    if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM &&
141 >                (ep1->type == ':') <= (assign == ':')) {
142          ep2 = ep1->v.kid->sibling;
143          if (ep2->type == NUM) {
144              ep2->v.num = val;
# Line 190 | Line 146 | double val;
146              return;
147          }
148      }
149 +    if (ep1 != NULL && esupport&E_REDEFW) {
150 +        wputs(qname);
151 +        if (ep1->type == ':')
152 +            wputs(": reset constant expression\n");
153 +        else
154 +            wputs(": reset expression\n");
155 +    }
156                                          /* hand build definition */
157      ep1 = newnode();
158      ep1->type = assign;
# Line 201 | Line 164 | double val;
164      ep2->type = NUM;
165      ep2->v.num = val;
166      addekid(ep1, ep2);
167 <    dremove(qname);
167 >    if (assign == ':')
168 >        dremove(qname);
169 >    else
170 >        dclear(qname);
171      dpush(qname, ep1);
172   }
173  
174  
175   void
176 < dclear(name)                    /* delete variable definitions of name */
177 < char  *name;
176 > dclear(                 /* delete variable definitions of name */
177 >        char  *name
178 > )
179   {
180 <    register EPNODE  *ep;
180 >    VARDEF  *vp;
181 >    EPNODE  *dp;
182  
183 <    while ((ep = dpop(name)) != NULL) {
184 <        if (ep->type == ':') {
185 <            dpush(name, ep);            /* don't clear constants */
186 <            return;
187 <        }
220 <        epfree(ep);
183 >    while ((vp = varlookup(name)) != NULL &&
184 >                (dp = vp->def) != NULL && dp->type == '=') {
185 >        vp->def = dp->sibling;
186 >        epfree(dp,1);
187 >        varfree(vp);
188      }
189   }
190  
191  
192   void
193 < dremove(name)                   /* delete all definitions of name */
194 < char  *name;
193 > dremove(                        /* delete all definitions of name */
194 >        char  *name
195 > )
196   {
197 <    register EPNODE  *ep;
197 >    EPNODE  *ep;
198  
199      while ((ep = dpop(name)) != NULL)
200 <        epfree(ep);
200 >        epfree(ep,1);
201   }
202  
203  
204   int
205 < vardefined(name)        /* return non-zero if variable defined */
206 < char  *name;
205 > vardefined(     /* return '=' or ':' if variable/constant defined */
206 >        char  *name
207 > )
208   {
209 <    register EPNODE  *dp;
209 >    EPNODE  *dp = dlookup(name);
210  
211 <    return((dp = dlookup(name)) != NULL && dp->v.kid->type == SYM);
211 >    if (dp == NULL || dp->v.kid->type != SYM)
212 >        return(0);
213 >
214 >    return(dp->type);
215   }
216  
217  
218   char *
219 < setcontext(ctx)                 /* set a new context path */
220 < register char  *ctx;
219 > calcontext(                     /* set a new context path */
220 >        char  *ctx
221 > )
222   {
223 <    register char  *cpp;
223 >    char  *cpp;
224  
225      if (ctx == NULL)
226          return(context);                /* just asking */
# Line 276 | Line 249 | register char  *ctx;
249  
250  
251   char *
252 < pushcontext(ctx)                /* push on another context */
253 < char  *ctx;
252 > pushcontext(            /* push on another context */
253 >        char  *ctx
254 > )
255   {
282    extern char  *strncpy(), *strcpy();
256      char  oldcontext[MAXCNTX+1];
257 <    register int  n;
257 >    int  n;
258  
259      strcpy(oldcontext, context);        /* save old context */
260 <    setcontext(ctx);                    /* set new context */
260 >    calcontext(ctx);                    /* set new context */
261      n = strlen(context);                /* tack on old */
262      if (n+strlen(oldcontext) > MAXCNTX) {
263          strncpy(context+n, oldcontext, MAXCNTX-n);
# Line 296 | Line 269 | char  *ctx;
269  
270  
271   char *
272 < popcontext()                    /* pop off top context */
272 > popcontext(void)                        /* pop off top context */
273   {
274 <    register char  *cp1, *cp2;
274 >    char  *cp1, *cp2;
275  
276      if (!context[0])                    /* nothing left to pop */
277          return(context);
# Line 306 | Line 279 | popcontext()                   /* pop off top context */
279      while (*++cp2 && *cp2 != CNTXMARK)
280          ;
281      cp1 = context;                      /* copy tail to front */
282 <    while (*cp1++ = *cp2++)
282 >    while ( (*cp1++ = *cp2++) )
283          ;
284      return(context);
285   }
286  
287  
288   char *
289 < qualname(nam, lvl)              /* get qualified name */
290 < register char  *nam;
291 < int  lvl;
289 > qualname(               /* get qualified name */
290 >        char  *nam,
291 >        int  lvl
292 > )
293   {
294 <    static char  nambuf[MAXWORD+1];
295 <    register char  *cp = nambuf, *cpp;
294 >    static char  nambuf[RMAXWORD+1];
295 >    char  *cp = nambuf, *cpp;
296                                  /* check for explicit local */
297 <    if (*nam == CNTXMARK)
297 >    if (*nam == CNTXMARK) {
298          if (lvl > 0)            /* only action is to refuse search */
299              return(NULL);
300 <        else
301 <            nam++;
328 <    else if (nam == nambuf)     /* check for repeat call */
300 >        nam++;
301 >    } else if (nam == nambuf)   /* check for repeat call */
302          return(lvl > 0 ? NULL : nam);
303                                  /* copy name to static buffer */
304      while (*nam) {
305 <        if (cp >= nambuf+MAXWORD)
305 >        if (cp >= nambuf+RMAXWORD)
306                  goto toolong;
307          *cp++ = *nam++;
308      }
# Line 347 | Line 320 | int  lvl;
320          while (*++cpp && *cpp != CNTXMARK)
321              ;
322      }
323 <    while (*cpp) {              /* copy context to static buffer */
324 <        if (cp >= nambuf+MAXWORD)
323 >    while (*cpp) {              /* add remaining context to name */
324 >        if (cp >= nambuf+RMAXWORD)
325              goto toolong;
326          *cp++ = *cpp++;
327      }
# Line 359 | Line 332 | toolong:
332  
333  
334   int
335 < incontext(qn)                   /* is qualified name in current context? */
336 < register char  *qn;
335 > incontext(                      /* is qualified name in current context? */
336 >        char  *qn
337 > )
338   {
339      if (!context[0])                    /* global context accepts all */
340          return(1);
# Line 371 | Line 345 | register char  *qn;
345  
346  
347   void
348 < chanout(cs)                     /* set output channels */
349 < int  (*cs)();
348 > chanout(                        /* set output channels */
349 >        void  (*cs)(int n, double v)
350 > )
351   {
352 <    register EPNODE  *ep;
352 >    EPNODE  *ep;
353  
354      for (ep = outchan; ep != NULL; ep = ep->sibling)
355          (*cs)(ep->v.kid->v.chan, evalue(ep->v.kid->sibling));
# Line 383 | Line 358 | int  (*cs)();
358  
359  
360   void
361 < dcleanup(lvl)           /* clear definitions (0->vars,1->output,2->consts) */
387 < int  lvl;
361 > doptimize(int activate)         /* optimize current and future definitions? */
362   {
363 <    register int  i;
364 <    register VARDEF  *vp;
365 <    register EPNODE  *ep;
363 >    EPNODE      *ep;
364 >
365 >    if (activate && optimized)
366 >        return;                 /* already going */
367 >
368 >    if (!(optimized = activate))
369 >        return;                 /* switching off */
370 >
371 >    for (ep = dfirst(); ep != NULL; ep = dnext())
372 >        epoptimize(ep);
373 > }
374 >
375 >
376 > void
377 > dcleanup(               /* clear definitions (0->vars,1->output,2->consts) */
378 >        int  lvl
379 > )
380 > {
381 >    int  i;
382 >    VARDEF  *vp;
383 >    EPNODE  *ep;
384                                  /* if context is global, clear all */
385      for (i = 0; i < NHASH; i++)
386          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
387 <            if (incontext(vp->name))
387 >            if (incontext(vp->name)) {
388                  if (lvl >= 2)
389                      dremove(vp->name);
390                  else
391                      dclear(vp->name);
392 <    if (lvl >= 1) {
393 <        for (ep = outchan; ep != NULL; ep = ep->sibling)
394 <            epfree(ep);
395 <        outchan = NULL;
396 <    }
392 >            }
393 >    if (lvl >= 1)
394 >        while (outchan != NULL) {
395 >            ep = outchan;
396 >            outchan = ep->sibling;
397 >            epfree(ep,1);
398 >        }
399   }
400  
401  
402   EPNODE *
403 < dlookup(name)                   /* look up a definition */
404 < char  *name;
403 > dlookup(                        /* look up a definition */
404 >        char  *name
405 > )
406   {
407 <    register VARDEF  *vp;
407 >    VARDEF  *vp;
408      
409      if ((vp = varlookup(name)) == NULL)
410          return(NULL);
# Line 418 | Line 413 | char  *name;
413  
414  
415   VARDEF *
416 < varlookup(name)                 /* look up a variable */
417 < char  *name;
416 > varlookup(                      /* look up a variable */
417 >        char  *name
418 > )
419   {
420      int  lvl = 0;
421 <    register char  *qname;
422 <    register VARDEF  *vp;
421 >    char  *qname;
422 >    VARDEF  *vp;
423                                  /* find most qualified match */
424      while ((qname = qualname(name, lvl++)) != NULL)
425          for (vp = hashtbl[hash(qname)]; vp != NULL; vp = vp->next)
# Line 434 | Line 430 | char  *name;
430  
431  
432   VARDEF *
433 < varinsert(name)                 /* get a link to a variable */
434 < char  *name;
433 > varinsert(                      /* get a link to a variable */
434 >        char  *name
435 > )
436   {
437 <    register VARDEF  *vp;
437 >    VARDEF  *vp;
438      int  hv;
439      
440      if ((vp = varlookup(name)) != NULL) {
# Line 459 | Line 456 | char  *name;
456  
457  
458   void
459 < libupdate(fn)                   /* update library links */
460 < char  *fn;
459 > libupdate(                      /* update library links */
460 >        char  *fn
461 > )
462   {
463 <    register int  i;
464 <    register VARDEF  *vp;
463 >    int  i;
464 >    VARDEF  *vp;
465                                          /* if fn is NULL then relink all */
466      for (i = 0; i < NHASH; i++)
467          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
468 <            if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name))
468 >            if ((vp->lib != NULL) | (fn == NULL) || !strcmp(fn, vp->name))
469                  vp->lib = liblookup(vp->name);
470   }
471  
472  
473   void
474 < varfree(ln)                             /* release link to variable */
475 < register VARDEF  *ln;
474 > varfree(                                /* release link to variable */
475 >        VARDEF   *ln
476 > )
477   {
478 <    register VARDEF  *vp;
478 >    VARDEF  *vp;
479      int  hv;
480  
481      if (--ln->nlinks > 0)
# Line 492 | Line 491 | register VARDEF         *ln;
491          vp->next = ln->next;
492      }
493      freestr(ln->name);
494 <    efree((char *)ln);
494 >    efree(ln);
495   }
496  
497  
498   EPNODE *
499 < dfirst()                        /* return pointer to first definition */
499 > dfirst(void)                    /* return pointer to first definition */
500   {
501      htndx = 0;
502      htpos = NULL;
# Line 507 | Line 506 | dfirst()                       /* return pointer to first definition */
506  
507  
508   EPNODE *
509 < dnext()                         /* return pointer to next definition */
509 > dnext(void)                             /* return pointer to next definition */
510   {
511 <    register EPNODE  *ep;
512 <    register char  *nm;
511 >    EPNODE  *ep;
512 >    char  *nm;
513  
514      while (htndx < NHASH) {
515          if (htpos == NULL)
# Line 530 | Line 529 | dnext()                                /* return pointer to next definition */
529  
530  
531   EPNODE *
532 < dpop(name)                      /* pop a definition */
533 < char  *name;
532 > dpop(                   /* pop a definition */
533 >        char  *name
534 > )
535   {
536 <    register VARDEF  *vp;
537 <    register EPNODE  *dp;
536 >    VARDEF  *vp;
537 >    EPNODE  *dp;
538      
539      if ((vp = varlookup(name)) == NULL || vp->def == NULL)
540          return(NULL);
# Line 546 | Line 546 | char  *name;
546  
547  
548   void
549 < dpush(nm, ep)                   /* push on a definition */
550 < char  *nm;
551 < register EPNODE  *ep;
549 > dpush(                  /* push on a definition */
550 >        char  *nm,
551 >        EPNODE   *ep
552 > )
553   {
554 <    register VARDEF  *vp;
554 >    VARDEF  *vp;
555  
556      vp = varinsert(nm);
557      ep->sibling = vp->def;
# Line 559 | Line 560 | register EPNODE         *ep;
560  
561  
562   void
563 < addchan(sp)                     /* add an output channel assignment */
564 < EPNODE  *sp;
563 > addchan(                        /* add an output channel assignment */
564 >        EPNODE  *sp
565 > )
566   {
567      int  ch = sp->v.kid->v.chan;
568 <    register EPNODE  *ep, *epl;
568 >    EPNODE  *ep, *epl;
569  
570      for (epl = NULL, ep = outchan; ep != NULL; epl = ep, ep = ep->sibling)
571          if (ep->v.kid->v.chan >= ch) {
# Line 575 | Line 577 | EPNODE *sp;
577                  sp->sibling = ep;
578              else {
579                  sp->sibling = ep->sibling;
580 <                epfree(ep);
580 >                epfree(ep,1);
581              }
582              return;
583          }
# Line 589 | Line 591 | EPNODE *sp;
591  
592  
593   void
594 < getstatement()                  /* get next statement */
594 > getstatement(void)                      /* get next statement */
595   {
596 <    register EPNODE  *ep;
596 >    EPNODE  *ep;
597      char  *qname;
598 <    register VARDEF  *vdef;
598 >    VARDEF  *vdef;
599  
600      if (nextc == ';') {         /* empty statement */
601          scan();
# Line 605 | Line 607 | getstatement()                 /* get next statement */
607          addchan(ep);
608      } else {                            /* ordinary definition */
609          ep = getdefn();
610 <        qname = qualname(dname(ep), 0);
611 <        if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL)
610 >        qname = qualname(dfn_name(ep), 0);
611 >        if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) {
612              if (vdef->def != NULL && epcmp(ep, vdef->def)) {
613                  wputs(qname);
614                  if (vdef->def->type == ':')
# Line 617 | Line 619 | getstatement()                 /* get next statement */
619                  wputs(qname);
620                  wputs(": definition hides library function\n");
621              }
622 +        }
623          if (ep->type == ':')
624              dremove(qname);
625          else
# Line 628 | Line 631 | getstatement()                 /* get next statement */
631              syntax("';' expected");
632          scan();
633      }
634 +    if (optimized)
635 +        epoptimize(ep);                 /* optimize new statement */
636   }
637  
638  
639   EPNODE *
640 < getdefn()                       /* A -> SYM = E1 */
641 <                                /*      SYM : E1 */
642 <                                /*      FUNC(SYM,..) = E1 */
643 <                                /*      FUNC(SYM,..) : E1 */
640 > getdefn(void)
641 >        /* A -> SYM = E1 */
642 >        /*      SYM : E1 */
643 >        /*      FUNC(SYM,..) = E1 */
644 >        /*      FUNC(SYM,..) : E1 */
645   {
646 <    register EPNODE  *ep1, *ep2;
646 >    EPNODE  *ep1, *ep2;
647  
648 <    if (!isalpha(nextc) && nextc != CNTXMARK)
648 >    if (!isalpha(nextc) & (nextc != CNTXMARK))
649          syntax("illegal variable name");
650  
651      ep1 = newnode();
# Line 654 | Line 660 | getdefn()                      /* A -> SYM = E1 */
660          do {
661              scan();
662              if (!isalpha(nextc))
663 <                syntax("illegal variable name");
663 >                syntax("illegal parameter name");
664              ep2 = newnode();
665              ep2->type = SYM;
666              ep2->v.name = savestr(getname());
667 +            if (strchr(ep2->v.name, CNTXMARK) != NULL)
668 +                syntax("illegal parameter name");
669              addekid(ep1, ep2);
670          } while (nextc == ',');
671          if (nextc != ')')
# Line 666 | Line 674 | getdefn()                      /* A -> SYM = E1 */
674          curfunc = ep1;
675      }
676  
677 <    if (nextc != '=' && nextc != ':')
677 >    if ((nextc != '=') & (nextc != ':'))
678          syntax("'=' or ':' expected");
679  
680      ep2 = newnode();
# Line 677 | Line 685 | getdefn()                      /* A -> SYM = E1 */
685  
686      if (ep1->type == SYM && ep1->sibling->type != NUM) {
687          ep1 = newnode();
688 <        ep1->type = TICK;
688 >        ep1->type = CLKT;
689          ep1->v.tick = 0;
690          addekid(ep2, ep1);
691          ep1 = newnode();
# Line 691 | Line 699 | getdefn()                      /* A -> SYM = E1 */
699  
700  
701   EPNODE *
702 < getchan()                       /* A -> $N = E1 */
702 > getchan(void)                   /* A -> $N = E1 */
703   {
704 <    register EPNODE  *ep1, *ep2;
704 >    EPNODE  *ep1, *ep2;
705  
706      if (nextc != '$')
707          syntax("missing '$'");
# Line 722 | Line 730 | getchan()                      /* A -> $N = E1 */
730   */
731  
732  
733 < static double
734 < dvalue(name, d)                 /* evaluate a variable */
727 < char  *name;
728 < EPNODE  *d;
733 > static double                   /* evaluate a variable */
734 > dvalue(char *name, EPNODE *d)
735   {
736 <    register EPNODE  *ep1, *ep2;
736 >    EPNODE  *ep1, *ep2;
737      
738      if (d == NULL || d->v.kid->type != SYM) {
739          eputs(name);
# Line 737 | Line 743 | EPNODE *d;
743      ep1 = d->v.kid->sibling;                    /* get expression */
744      if (ep1->type == NUM)
745          return(ep1->v.num);                     /* return if number */
746 +    if (esupport&E_RCONST && d->type == ':') {
747 +        wputs(name);
748 +        wputs(": assigned non-constant value\n");
749 +    }
750      ep2 = ep1->sibling;                         /* check time */
751      if (eclock >= MAXCLOCK)
752          eclock = 1;                             /* wrap clock counter */
753      if (ep2->v.tick < MAXCLOCK &&
754 <                ep2->v.tick == 0 | ep2->v.tick != eclock) {
754 >                (ep2->v.tick == 0) | (ep2->v.tick != eclock)) {
755          ep2->v.tick = d->type == ':' ? MAXCLOCK : eclock;
756          ep2 = ep2->sibling;
757          ep2->v.num = evalue(ep1);               /* needs new value */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines