ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/caldefn.c
Revision: 2.28
Committed: Thu Apr 2 18:00:34 2020 UTC (4 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R3
Changes since 2.27: +6 -2 lines
Log Message:
Added warning about assigning non-constant to constant variable

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.28 static const char RCSid[] = "$Id: caldefn.c,v 2.27 2019/12/28 18:05:13 greg Exp $";
3 greg 1.1 #endif
4     /*
5     * Store variable definitions.
6     *
7     * 7/1/85 Greg Ward
8     *
9     * 11/11/85 Added conditional compiles (OUTCHAN) for control output.
10     *
11     * 4/2/86 Added conditional compiles for function definitions (FUNCTION).
12     *
13     * 1/15/88 Added clock for caching of variable values.
14     *
15     * 11/16/88 Added VARDEF structure for hard linking.
16 greg 1.2 *
17     * 5/31/90 Added conditional compile (REDEFW) for redefinition warning.
18 greg 1.8 *
19 greg 1.10 * 4/23/91 Added ':' assignment for constant expressions
20 greg 1.13 *
21     * 8/7/91 Added optional context path to append to variable names
22 greg 2.12 *
23     * 5/17/2001 Fixed clock counter wrapping behavior
24     *
25     * 2/19/03 Eliminated conditional compiles in favor of esupport extern.
26     */
27    
28 greg 2.13 #include "copyright.h"
29 greg 1.1
30     #include <ctype.h>
31    
32 schorsch 2.18 #include "rterror.h"
33 schorsch 2.22 #include "rtio.h"
34 schorsch 2.21 #include "rtmisc.h"
35 greg 1.1 #include "calcomp.h"
36    
37 greg 2.4 #ifndef NHASH
38     #define NHASH 521 /* hash size (a prime!) */
39 greg 1.1 #endif
40    
41 greg 2.5 #define hash(s) (shash(s)%NHASH)
42    
43 greg 2.4 #define newnode() (EPNODE *)ecalloc(1, sizeof(EPNODE))
44 greg 1.1
45 schorsch 2.18 static double dvalue(char *name, EPNODE *d);
46 greg 1.1
47 greg 2.12 #define MAXCLOCK (1L<<31) /* clock wrap value */
48 greg 1.1
49 greg 2.8 unsigned long eclock = 0; /* value storage timer */
50 greg 1.1
51 greg 2.11 #define MAXCNTX 1023 /* maximum context length */
52 greg 1.13
53 greg 2.11 static char context[MAXCNTX+1]; /* current context path */
54    
55 greg 1.1 static VARDEF *hashtbl[NHASH]; /* definition list */
56     static int htndx; /* index for */
57     static VARDEF *htpos; /* ...dfirst() and */
58     static EPNODE *ochpos; /* ...dnext */
59     static EPNODE *outchan;
60    
61 greg 2.10 EPNODE *curfunc = NULL;
62 greg 2.4 #define dname(ep) ((ep)->v.kid->type == SYM ? \
63 greg 1.1 (ep)->v.kid->v.name : \
64     (ep)->v.kid->v.kid->v.name)
65    
66    
67 greg 2.12 void
68 schorsch 2.16 fcompile( /* get definitions from a file */
69     char *fname
70     )
71 greg 1.1 {
72     FILE *fp;
73    
74     if (fname == NULL)
75     fp = stdin;
76     else if ((fp = fopen(fname, "r")) == NULL) {
77     eputs(fname);
78     eputs(": cannot open\n");
79     quit(1);
80     }
81 greg 1.4 initfile(fp, fname, 0);
82 greg 1.1 while (nextc != EOF)
83 greg 1.13 getstatement();
84 greg 1.1 if (fname != NULL)
85     fclose(fp);
86     }
87    
88    
89 greg 2.12 void
90 schorsch 2.16 scompile( /* get definitions from a string */
91     char *str,
92     char *fn,
93     int ln
94     )
95 greg 1.1 {
96 greg 1.4 initstr(str, fn, ln);
97 greg 1.1 while (nextc != EOF)
98 greg 1.13 getstatement();
99 greg 1.1 }
100    
101    
102     double
103 schorsch 2.16 varvalue( /* return a variable's value */
104     char *vname
105     )
106 greg 1.1 {
107     return(dvalue(vname, dlookup(vname)));
108     }
109    
110    
111     double
112 schorsch 2.16 evariable( /* evaluate a variable */
113     EPNODE *ep
114     )
115 greg 1.1 {
116 greg 2.25 VARDEF *dp = ep->v.ln;
117 greg 1.1
118     return(dvalue(dp->name, dp->def));
119     }
120    
121    
122 greg 2.12 void
123 schorsch 2.16 varset( /* set a variable's value */
124     char *vname,
125     int assign,
126     double val
127     )
128 greg 1.1 {
129 greg 1.13 char *qname;
130 greg 2.25 EPNODE *ep1, *ep2;
131 greg 1.13 /* get qualified name */
132     qname = qualname(vname, 0);
133 greg 1.1 /* check for quick set */
134 greg 2.25 if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM &&
135     (ep1->type == ':') <= (assign == ':')) {
136 greg 1.1 ep2 = ep1->v.kid->sibling;
137     if (ep2->type == NUM) {
138     ep2->v.num = val;
139 greg 1.8 ep1->type = assign;
140 greg 1.1 return;
141     }
142     }
143 greg 2.26 if (ep1 != NULL && esupport&E_REDEFW) {
144     wputs(qname);
145     if (ep1->type == ':')
146     wputs(": reset constant expression\n");
147     else
148     wputs(": reset expression\n");
149     }
150 greg 1.1 /* hand build definition */
151     ep1 = newnode();
152 greg 1.8 ep1->type = assign;
153 greg 1.1 ep2 = newnode();
154     ep2->type = SYM;
155     ep2->v.name = savestr(vname);
156     addekid(ep1, ep2);
157     ep2 = newnode();
158     ep2->type = NUM;
159     ep2->v.num = val;
160     addekid(ep1, ep2);
161 greg 2.25 if (assign == ':')
162     dremove(qname);
163     else
164     dclear(qname);
165 greg 1.13 dpush(qname, ep1);
166 greg 1.1 }
167    
168    
169 greg 2.12 void
170 schorsch 2.16 dclear( /* delete variable definitions of name */
171     char *name
172     )
173 greg 1.1 {
174 greg 2.25 EPNODE *ep;
175 greg 1.1
176 greg 1.8 while ((ep = dpop(name)) != NULL) {
177     if (ep->type == ':') {
178 greg 1.13 dpush(name, ep); /* don't clear constants */
179 greg 1.8 return;
180     }
181     epfree(ep);
182     }
183     }
184    
185    
186 greg 2.12 void
187 schorsch 2.16 dremove( /* delete all definitions of name */
188     char *name
189     )
190 greg 1.8 {
191 greg 2.25 EPNODE *ep;
192 greg 1.8
193 greg 1.1 while ((ep = dpop(name)) != NULL)
194     epfree(ep);
195     }
196    
197    
198 greg 2.12 int
199 schorsch 2.16 vardefined( /* return non-zero if variable defined */
200     char *name
201     )
202 greg 1.1 {
203 greg 2.25 EPNODE *dp;
204 greg 1.1
205     return((dp = dlookup(name)) != NULL && dp->v.kid->type == SYM);
206     }
207    
208    
209 greg 1.13 char *
210 schorsch 2.16 setcontext( /* set a new context path */
211 greg 2.25 char *ctx
212 schorsch 2.16 )
213 greg 1.13 {
214 greg 2.25 char *cpp;
215 greg 1.13
216     if (ctx == NULL)
217     return(context); /* just asking */
218 greg 2.6 while (*ctx == CNTXMARK)
219     ctx++; /* skip past marks */
220 greg 1.13 if (!*ctx) {
221 greg 2.6 context[0] = '\0'; /* empty means clear context */
222 greg 1.13 return(context);
223     }
224 greg 2.6 cpp = context; /* start context with mark */
225     *cpp++ = CNTXMARK;
226     do { /* carefully copy new context */
227 greg 2.11 if (cpp >= context+MAXCNTX)
228 greg 1.18 break; /* just copy what we can */
229 greg 1.13 if (isid(*ctx))
230     *cpp++ = *ctx++;
231     else {
232     *cpp++ = '_'; ctx++;
233     }
234     } while (*ctx);
235 greg 2.6 while (cpp[-1] == CNTXMARK) /* cannot end in context mark */
236     cpp--;
237 greg 1.13 *cpp = '\0';
238 greg 2.6 return(context);
239     }
240    
241    
242     char *
243 schorsch 2.16 pushcontext( /* push on another context */
244     char *ctx
245     )
246 greg 2.6 {
247 greg 2.11 char oldcontext[MAXCNTX+1];
248 greg 2.25 int n;
249 greg 2.6
250     strcpy(oldcontext, context); /* save old context */
251     setcontext(ctx); /* set new context */
252     n = strlen(context); /* tack on old */
253 greg 2.11 if (n+strlen(oldcontext) > MAXCNTX) {
254     strncpy(context+n, oldcontext, MAXCNTX-n);
255     context[MAXCNTX] = '\0';
256 greg 2.6 } else
257     strcpy(context+n, oldcontext);
258     return(context);
259     }
260    
261    
262     char *
263 schorsch 2.16 popcontext(void) /* pop off top context */
264 greg 2.6 {
265 greg 2.25 char *cp1, *cp2;
266 greg 2.6
267     if (!context[0]) /* nothing left to pop */
268     return(context);
269     cp2 = context; /* find mark */
270     while (*++cp2 && *cp2 != CNTXMARK)
271     ;
272     cp1 = context; /* copy tail to front */
273 schorsch 2.20 while ( (*cp1++ = *cp2++) )
274 greg 2.6 ;
275 greg 1.13 return(context);
276     }
277    
278    
279     char *
280 schorsch 2.16 qualname( /* get qualified name */
281 greg 2.25 char *nam,
282 schorsch 2.16 int lvl
283     )
284 greg 1.13 {
285 schorsch 2.17 static char nambuf[RMAXWORD+1];
286 greg 2.25 char *cp = nambuf, *cpp;
287 greg 1.17 /* check for explicit local */
288 greg 1.15 if (*nam == CNTXMARK)
289 greg 1.17 if (lvl > 0) /* only action is to refuse search */
290     return(NULL);
291     else
292     nam++;
293     else if (nam == nambuf) /* check for repeat call */
294     return(lvl > 0 ? NULL : nam);
295 greg 1.13 /* copy name to static buffer */
296     while (*nam) {
297 schorsch 2.17 if (cp >= nambuf+RMAXWORD)
298 greg 1.13 goto toolong;
299 greg 1.17 *cp++ = *nam++;
300 greg 1.13 }
301 greg 1.17 /* check for explicit global */
302     if (cp > nambuf && cp[-1] == CNTXMARK) {
303 greg 1.13 if (lvl > 0)
304 greg 1.17 return(NULL);
305     *--cp = '\0';
306     return(nambuf); /* already qualified */
307     }
308     cpp = context; /* else skip the requested levels */
309     while (lvl-- > 0) {
310     if (!*cpp)
311     return(NULL); /* return NULL if past global level */
312     while (*++cpp && *cpp != CNTXMARK)
313     ;
314     }
315 greg 1.13 while (*cpp) { /* copy context to static buffer */
316 schorsch 2.17 if (cp >= nambuf+RMAXWORD)
317 greg 1.13 goto toolong;
318     *cp++ = *cpp++;
319     }
320 greg 1.18 toolong:
321 greg 1.13 *cp = '\0';
322     return(nambuf); /* return qualified name */
323     }
324    
325    
326 greg 2.12 int
327 schorsch 2.16 incontext( /* is qualified name in current context? */
328 greg 2.25 char *qn
329 schorsch 2.16 )
330 greg 1.14 {
331 greg 2.9 if (!context[0]) /* global context accepts all */
332     return(1);
333 greg 1.14 while (*qn && *qn != CNTXMARK) /* find context mark */
334 greg 1.19 qn++;
335 greg 1.14 return(!strcmp(qn, context));
336     }
337    
338    
339 greg 2.12 void
340 schorsch 2.16 chanout( /* set output channels */
341     void (*cs)(int n, double v)
342     )
343 greg 1.1 {
344 greg 2.25 EPNODE *ep;
345 greg 1.1
346     for (ep = outchan; ep != NULL; ep = ep->sibling)
347 greg 1.6 (*cs)(ep->v.kid->v.chan, evalue(ep->v.kid->sibling));
348 greg 1.1
349     }
350    
351    
352 greg 2.12 void
353 schorsch 2.16 dcleanup( /* clear definitions (0->vars,1->output,2->consts) */
354     int lvl
355     )
356 greg 1.1 {
357 greg 2.25 int i;
358     VARDEF *vp;
359     EPNODE *ep;
360 greg 1.14 /* if context is global, clear all */
361 greg 1.1 for (i = 0; i < NHASH; i++)
362     for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
363 schorsch 2.19 if (incontext(vp->name)) {
364 greg 1.14 if (lvl >= 2)
365     dremove(vp->name);
366     else
367     dclear(vp->name);
368 schorsch 2.19 }
369 greg 1.12 if (lvl >= 1) {
370 greg 1.9 for (ep = outchan; ep != NULL; ep = ep->sibling)
371     epfree(ep);
372     outchan = NULL;
373     }
374 greg 1.1 }
375    
376    
377     EPNODE *
378 schorsch 2.16 dlookup( /* look up a definition */
379     char *name
380     )
381 greg 1.1 {
382 greg 2.25 VARDEF *vp;
383 greg 1.1
384     if ((vp = varlookup(name)) == NULL)
385 greg 2.4 return(NULL);
386 greg 1.1 return(vp->def);
387     }
388    
389    
390     VARDEF *
391 schorsch 2.16 varlookup( /* look up a variable */
392     char *name
393     )
394 greg 1.1 {
395 greg 2.4 int lvl = 0;
396 greg 2.25 char *qname;
397     VARDEF *vp;
398 greg 2.4 /* find most qualified match */
399 greg 1.13 while ((qname = qualname(name, lvl++)) != NULL)
400     for (vp = hashtbl[hash(qname)]; vp != NULL; vp = vp->next)
401     if (!strcmp(vp->name, qname))
402     return(vp);
403 greg 1.1 return(NULL);
404     }
405    
406    
407     VARDEF *
408 schorsch 2.16 varinsert( /* get a link to a variable */
409     char *name
410     )
411 greg 1.1 {
412 greg 2.25 VARDEF *vp;
413 greg 2.4 int hv;
414 greg 1.1
415 greg 1.13 if ((vp = varlookup(name)) != NULL) {
416     vp->nlinks++;
417     return(vp);
418     }
419 greg 2.3 vp = (VARDEF *)emalloc(sizeof(VARDEF));
420     vp->lib = liblookup(name);
421     if (vp->lib == NULL) /* if name not in library */
422 greg 1.16 name = qualname(name, 0); /* use fully qualified version */
423 greg 1.1 hv = hash(name);
424     vp->name = savestr(name);
425     vp->nlinks = 1;
426     vp->def = NULL;
427     vp->next = hashtbl[hv];
428     hashtbl[hv] = vp;
429     return(vp);
430     }
431 greg 2.2
432    
433 greg 2.12 void
434 schorsch 2.16 libupdate( /* update library links */
435     char *fn
436     )
437 greg 2.2 {
438 greg 2.25 int i;
439     VARDEF *vp;
440 greg 2.2 /* if fn is NULL then relink all */
441     for (i = 0; i < NHASH; i++)
442     for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
443     if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name))
444     vp->lib = liblookup(vp->name);
445     }
446 greg 1.1
447    
448 greg 2.12 void
449 schorsch 2.16 varfree( /* release link to variable */
450 greg 2.25 VARDEF *ln
451 schorsch 2.16 )
452 greg 1.1 {
453 greg 2.25 VARDEF *vp;
454 greg 2.4 int hv;
455 greg 1.1
456     if (--ln->nlinks > 0)
457 greg 2.4 return; /* still active */
458 greg 1.1
459     hv = hash(ln->name);
460     vp = hashtbl[hv];
461     if (vp == ln)
462 greg 2.4 hashtbl[hv] = vp->next;
463 greg 1.1 else {
464 greg 2.4 while (vp->next != ln) /* must be in list */
465     vp = vp->next;
466     vp->next = ln->next;
467 greg 1.1 }
468     freestr(ln->name);
469     efree((char *)ln);
470     }
471    
472    
473     EPNODE *
474 schorsch 2.16 dfirst(void) /* return pointer to first definition */
475 greg 1.1 {
476     htndx = 0;
477     htpos = NULL;
478     ochpos = outchan;
479     return(dnext());
480     }
481    
482    
483     EPNODE *
484 schorsch 2.16 dnext(void) /* return pointer to next definition */
485 greg 1.1 {
486 greg 2.25 EPNODE *ep;
487     char *nm;
488 greg 1.1
489     while (htndx < NHASH) {
490 greg 2.4 if (htpos == NULL)
491     htpos = hashtbl[htndx++];
492     while (htpos != NULL) {
493     ep = htpos->def;
494 greg 1.19 nm = htpos->name;
495 greg 2.4 htpos = htpos->next;
496     if (ep != NULL && incontext(nm))
497     return(ep);
498     }
499 greg 1.1 }
500     if ((ep = ochpos) != NULL)
501 greg 2.4 ochpos = ep->sibling;
502 greg 1.1 return(ep);
503     }
504    
505    
506     EPNODE *
507 schorsch 2.16 dpop( /* pop a definition */
508     char *name
509     )
510 greg 1.1 {
511 greg 2.25 VARDEF *vp;
512     EPNODE *dp;
513 greg 1.1
514     if ((vp = varlookup(name)) == NULL || vp->def == NULL)
515 greg 2.4 return(NULL);
516 greg 1.1 dp = vp->def;
517     vp->def = dp->sibling;
518     varfree(vp);
519     return(dp);
520     }
521    
522    
523 greg 2.12 void
524 schorsch 2.16 dpush( /* push on a definition */
525     char *nm,
526 greg 2.25 EPNODE *ep
527 schorsch 2.16 )
528 greg 1.1 {
529 greg 2.25 VARDEF *vp;
530 greg 1.1
531 greg 1.13 vp = varinsert(nm);
532 greg 1.1 ep->sibling = vp->def;
533     vp->def = ep;
534     }
535    
536    
537 greg 2.12 void
538 schorsch 2.16 addchan( /* add an output channel assignment */
539     EPNODE *sp
540     )
541 greg 1.1 {
542 greg 2.4 int ch = sp->v.kid->v.chan;
543 greg 2.25 EPNODE *ep, *epl;
544 greg 1.1
545     for (epl = NULL, ep = outchan; ep != NULL; epl = ep, ep = ep->sibling)
546     if (ep->v.kid->v.chan >= ch) {
547     if (epl != NULL)
548     epl->sibling = sp;
549     else
550     outchan = sp;
551     if (ep->v.kid->v.chan > ch)
552     sp->sibling = ep;
553     else {
554     sp->sibling = ep->sibling;
555     epfree(ep);
556     }
557     return;
558     }
559     if (epl != NULL)
560     epl->sibling = sp;
561     else
562     outchan = sp;
563     sp->sibling = NULL;
564    
565     }
566    
567    
568 greg 2.12 void
569 schorsch 2.16 getstatement(void) /* get next statement */
570 greg 1.1 {
571 greg 2.25 EPNODE *ep;
572 greg 1.13 char *qname;
573 greg 2.25 VARDEF *vdef;
574 greg 1.1
575     if (nextc == ';') { /* empty statement */
576     scan();
577     return;
578     }
579 greg 2.12 if (esupport&E_OUTCHAN &&
580     nextc == '$') { /* channel assignment */
581 greg 1.1 ep = getchan();
582     addchan(ep);
583 greg 2.12 } else { /* ordinary definition */
584 greg 1.1 ep = getdefn();
585 greg 1.13 qname = qualname(dname(ep), 0);
586 schorsch 2.19 if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) {
587 greg 2.7 if (vdef->def != NULL && epcmp(ep, vdef->def)) {
588 greg 1.16 wputs(qname);
589     if (vdef->def->type == ':')
590     wputs(": redefined constant expression\n");
591     else
592     wputs(": redefined\n");
593 greg 2.12 } else if (ep->v.kid->type == FUNC && vdef->lib != NULL) {
594 greg 1.16 wputs(qname);
595     wputs(": definition hides library function\n");
596     }
597 schorsch 2.19 }
598 greg 1.10 if (ep->type == ':')
599 greg 1.13 dremove(qname);
600 greg 1.10 else
601 greg 1.13 dclear(qname);
602     dpush(qname, ep);
603 greg 1.1 }
604     if (nextc != EOF) {
605     if (nextc != ';')
606     syntax("';' expected");
607     scan();
608     }
609     }
610    
611    
612     EPNODE *
613 schorsch 2.16 getdefn(void)
614     /* A -> SYM = E1 */
615     /* SYM : E1 */
616     /* FUNC(SYM,..) = E1 */
617     /* FUNC(SYM,..) : E1 */
618 greg 1.1 {
619 greg 2.25 EPNODE *ep1, *ep2;
620 greg 1.1
621 greg 1.18 if (!isalpha(nextc) && nextc != CNTXMARK)
622 greg 1.1 syntax("illegal variable name");
623    
624     ep1 = newnode();
625     ep1->type = SYM;
626     ep1->v.name = savestr(getname());
627    
628 greg 2.12 if (esupport&E_FUNCTION && nextc == '(') {
629 greg 1.1 ep2 = newnode();
630     ep2->type = FUNC;
631     addekid(ep2, ep1);
632     ep1 = ep2;
633     do {
634     scan();
635     if (!isalpha(nextc))
636 greg 2.24 syntax("illegal parameter name");
637 greg 1.1 ep2 = newnode();
638     ep2->type = SYM;
639     ep2->v.name = savestr(getname());
640     addekid(ep1, ep2);
641     } while (nextc == ',');
642     if (nextc != ')')
643     syntax("')' expected");
644     scan();
645     curfunc = ep1;
646 greg 2.10 }
647 greg 1.1
648 greg 1.8 if (nextc != '=' && nextc != ':')
649     syntax("'=' or ':' expected");
650 greg 1.1
651     ep2 = newnode();
652 greg 1.8 ep2->type = nextc;
653     scan();
654 greg 1.1 addekid(ep2, ep1);
655     addekid(ep2, getE1());
656    
657 greg 2.12 if (ep1->type == SYM && ep1->sibling->type != NUM) {
658 greg 1.1 ep1 = newnode();
659 greg 2.23 ep1->type = CLKT;
660 greg 2.8 ep1->v.tick = 0;
661 greg 1.1 addekid(ep2, ep1);
662     ep1 = newnode();
663     ep1->type = NUM;
664     addekid(ep2, ep1);
665     }
666 greg 2.10 curfunc = NULL;
667 greg 1.1
668     return(ep2);
669     }
670    
671    
672     EPNODE *
673 schorsch 2.16 getchan(void) /* A -> $N = E1 */
674 greg 1.1 {
675 greg 2.25 EPNODE *ep1, *ep2;
676 greg 1.1
677     if (nextc != '$')
678     syntax("missing '$'");
679     scan();
680    
681     ep1 = newnode();
682     ep1->type = CHAN;
683     ep1->v.chan = getinum();
684    
685     if (nextc != '=')
686     syntax("'=' expected");
687     scan();
688    
689     ep2 = newnode();
690     ep2->type = '=';
691     addekid(ep2, ep1);
692     addekid(ep2, getE1());
693    
694     return(ep2);
695     }
696    
697    
698    
699     /*
700     * The following routines are for internal use only:
701     */
702    
703    
704 schorsch 2.18 static double /* evaluate a variable */
705 greg 2.28 dvalue(char *name, EPNODE *d)
706 greg 1.1 {
707 greg 2.25 EPNODE *ep1, *ep2;
708 greg 1.1
709     if (d == NULL || d->v.kid->type != SYM) {
710     eputs(name);
711     eputs(": undefined variable\n");
712     quit(1);
713     }
714     ep1 = d->v.kid->sibling; /* get expression */
715 greg 1.5 if (ep1->type == NUM)
716     return(ep1->v.num); /* return if number */
717 greg 2.28 if (esupport&E_RCONST && d->type == ':') {
718     wputs(name);
719     wputs(": assigned non-constant value\n");
720     }
721 greg 1.1 ep2 = ep1->sibling; /* check time */
722 greg 2.12 if (eclock >= MAXCLOCK)
723     eclock = 1; /* wrap clock counter */
724     if (ep2->v.tick < MAXCLOCK &&
725 schorsch 2.20 (ep2->v.tick == 0) | (ep2->v.tick != eclock)) {
726 greg 2.12 ep2->v.tick = d->type == ':' ? MAXCLOCK : eclock;
727 greg 1.1 ep2 = ep2->sibling;
728 greg 1.5 ep2->v.num = evalue(ep1); /* needs new value */
729 greg 1.1 } else
730 greg 1.5 ep2 = ep2->sibling; /* else reuse old value */
731 greg 1.1
732     return(ep2->v.num);
733     }