32 |
|
#include <ctype.h> |
33 |
|
|
34 |
|
#include "rterror.h" |
35 |
+ |
#include "rtio.h" |
36 |
+ |
#include "rtmisc.h" |
37 |
|
#include "calcomp.h" |
38 |
|
|
39 |
|
#ifndef NHASH |
115 |
|
EPNODE *ep |
116 |
|
) |
117 |
|
{ |
118 |
< |
register VARDEF *dp = ep->v.ln; |
118 |
> |
VARDEF *dp = ep->v.ln; |
119 |
|
|
120 |
|
return(dvalue(dp->name, dp->def)); |
121 |
|
} |
129 |
|
) |
130 |
|
{ |
131 |
|
char *qname; |
132 |
< |
register EPNODE *ep1, *ep2; |
132 |
> |
EPNODE *ep1, *ep2; |
133 |
|
/* get qualified name */ |
134 |
|
qname = qualname(vname, 0); |
135 |
|
/* check for quick set */ |
136 |
< |
if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM) { |
136 |
> |
if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM && |
137 |
> |
(ep1->type == ':') <= (assign == ':')) { |
138 |
|
ep2 = ep1->v.kid->sibling; |
139 |
|
if (ep2->type == NUM) { |
140 |
|
ep2->v.num = val; |
142 |
|
return; |
143 |
|
} |
144 |
|
} |
145 |
+ |
if (ep1 != NULL && esupport&E_REDEFW) { |
146 |
+ |
wputs(qname); |
147 |
+ |
if (ep1->type == ':') |
148 |
+ |
wputs(": reset constant expression\n"); |
149 |
+ |
else |
150 |
+ |
wputs(": reset expression\n"); |
151 |
+ |
} |
152 |
|
/* hand build definition */ |
153 |
|
ep1 = newnode(); |
154 |
|
ep1->type = assign; |
160 |
|
ep2->type = NUM; |
161 |
|
ep2->v.num = val; |
162 |
|
addekid(ep1, ep2); |
163 |
< |
dremove(qname); |
163 |
> |
if (assign == ':') |
164 |
> |
dremove(qname); |
165 |
> |
else |
166 |
> |
dclear(qname); |
167 |
|
dpush(qname, ep1); |
168 |
|
} |
169 |
|
|
173 |
|
char *name |
174 |
|
) |
175 |
|
{ |
176 |
< |
register EPNODE *ep; |
176 |
> |
EPNODE *ep; |
177 |
|
|
178 |
|
while ((ep = dpop(name)) != NULL) { |
179 |
|
if (ep->type == ':') { |
190 |
|
char *name |
191 |
|
) |
192 |
|
{ |
193 |
< |
register EPNODE *ep; |
193 |
> |
EPNODE *ep; |
194 |
|
|
195 |
|
while ((ep = dpop(name)) != NULL) |
196 |
|
epfree(ep); |
202 |
|
char *name |
203 |
|
) |
204 |
|
{ |
205 |
< |
register EPNODE *dp; |
205 |
> |
EPNODE *dp; |
206 |
|
|
207 |
|
return((dp = dlookup(name)) != NULL && dp->v.kid->type == SYM); |
208 |
|
} |
210 |
|
|
211 |
|
char * |
212 |
|
setcontext( /* set a new context path */ |
213 |
< |
register char *ctx |
213 |
> |
char *ctx |
214 |
|
) |
215 |
|
{ |
216 |
< |
register char *cpp; |
216 |
> |
char *cpp; |
217 |
|
|
218 |
|
if (ctx == NULL) |
219 |
|
return(context); /* just asking */ |
247 |
|
) |
248 |
|
{ |
249 |
|
char oldcontext[MAXCNTX+1]; |
250 |
< |
register int n; |
250 |
> |
int n; |
251 |
|
|
252 |
|
strcpy(oldcontext, context); /* save old context */ |
253 |
|
setcontext(ctx); /* set new context */ |
264 |
|
char * |
265 |
|
popcontext(void) /* pop off top context */ |
266 |
|
{ |
267 |
< |
register char *cp1, *cp2; |
267 |
> |
char *cp1, *cp2; |
268 |
|
|
269 |
|
if (!context[0]) /* nothing left to pop */ |
270 |
|
return(context); |
280 |
|
|
281 |
|
char * |
282 |
|
qualname( /* get qualified name */ |
283 |
< |
register char *nam, |
283 |
> |
char *nam, |
284 |
|
int lvl |
285 |
|
) |
286 |
|
{ |
287 |
|
static char nambuf[RMAXWORD+1]; |
288 |
< |
register char *cp = nambuf, *cpp; |
288 |
> |
char *cp = nambuf, *cpp; |
289 |
|
/* check for explicit local */ |
290 |
|
if (*nam == CNTXMARK) |
291 |
|
if (lvl > 0) /* only action is to refuse search */ |
327 |
|
|
328 |
|
int |
329 |
|
incontext( /* is qualified name in current context? */ |
330 |
< |
register char *qn |
330 |
> |
char *qn |
331 |
|
) |
332 |
|
{ |
333 |
|
if (!context[0]) /* global context accepts all */ |
343 |
|
void (*cs)(int n, double v) |
344 |
|
) |
345 |
|
{ |
346 |
< |
register EPNODE *ep; |
346 |
> |
EPNODE *ep; |
347 |
|
|
348 |
|
for (ep = outchan; ep != NULL; ep = ep->sibling) |
349 |
|
(*cs)(ep->v.kid->v.chan, evalue(ep->v.kid->sibling)); |
356 |
|
int lvl |
357 |
|
) |
358 |
|
{ |
359 |
< |
register int i; |
360 |
< |
register VARDEF *vp; |
361 |
< |
register EPNODE *ep; |
359 |
> |
int i; |
360 |
> |
VARDEF *vp; |
361 |
> |
EPNODE *ep; |
362 |
|
/* if context is global, clear all */ |
363 |
|
for (i = 0; i < NHASH; i++) |
364 |
|
for (vp = hashtbl[i]; vp != NULL; vp = vp->next) |
381 |
|
char *name |
382 |
|
) |
383 |
|
{ |
384 |
< |
register VARDEF *vp; |
384 |
> |
VARDEF *vp; |
385 |
|
|
386 |
|
if ((vp = varlookup(name)) == NULL) |
387 |
|
return(NULL); |
395 |
|
) |
396 |
|
{ |
397 |
|
int lvl = 0; |
398 |
< |
register char *qname; |
399 |
< |
register VARDEF *vp; |
398 |
> |
char *qname; |
399 |
> |
VARDEF *vp; |
400 |
|
/* find most qualified match */ |
401 |
|
while ((qname = qualname(name, lvl++)) != NULL) |
402 |
|
for (vp = hashtbl[hash(qname)]; vp != NULL; vp = vp->next) |
411 |
|
char *name |
412 |
|
) |
413 |
|
{ |
414 |
< |
register VARDEF *vp; |
414 |
> |
VARDEF *vp; |
415 |
|
int hv; |
416 |
|
|
417 |
|
if ((vp = varlookup(name)) != NULL) { |
437 |
|
char *fn |
438 |
|
) |
439 |
|
{ |
440 |
< |
register int i; |
441 |
< |
register VARDEF *vp; |
440 |
> |
int i; |
441 |
> |
VARDEF *vp; |
442 |
|
/* if fn is NULL then relink all */ |
443 |
|
for (i = 0; i < NHASH; i++) |
444 |
|
for (vp = hashtbl[i]; vp != NULL; vp = vp->next) |
449 |
|
|
450 |
|
void |
451 |
|
varfree( /* release link to variable */ |
452 |
< |
register VARDEF *ln |
452 |
> |
VARDEF *ln |
453 |
|
) |
454 |
|
{ |
455 |
< |
register VARDEF *vp; |
455 |
> |
VARDEF *vp; |
456 |
|
int hv; |
457 |
|
|
458 |
|
if (--ln->nlinks > 0) |
485 |
|
EPNODE * |
486 |
|
dnext(void) /* return pointer to next definition */ |
487 |
|
{ |
488 |
< |
register EPNODE *ep; |
489 |
< |
register char *nm; |
488 |
> |
EPNODE *ep; |
489 |
> |
char *nm; |
490 |
|
|
491 |
|
while (htndx < NHASH) { |
492 |
|
if (htpos == NULL) |
510 |
|
char *name |
511 |
|
) |
512 |
|
{ |
513 |
< |
register VARDEF *vp; |
514 |
< |
register EPNODE *dp; |
513 |
> |
VARDEF *vp; |
514 |
> |
EPNODE *dp; |
515 |
|
|
516 |
|
if ((vp = varlookup(name)) == NULL || vp->def == NULL) |
517 |
|
return(NULL); |
525 |
|
void |
526 |
|
dpush( /* push on a definition */ |
527 |
|
char *nm, |
528 |
< |
register EPNODE *ep |
528 |
> |
EPNODE *ep |
529 |
|
) |
530 |
|
{ |
531 |
< |
register VARDEF *vp; |
531 |
> |
VARDEF *vp; |
532 |
|
|
533 |
|
vp = varinsert(nm); |
534 |
|
ep->sibling = vp->def; |
542 |
|
) |
543 |
|
{ |
544 |
|
int ch = sp->v.kid->v.chan; |
545 |
< |
register EPNODE *ep, *epl; |
545 |
> |
EPNODE *ep, *epl; |
546 |
|
|
547 |
|
for (epl = NULL, ep = outchan; ep != NULL; epl = ep, ep = ep->sibling) |
548 |
|
if (ep->v.kid->v.chan >= ch) { |
570 |
|
void |
571 |
|
getstatement(void) /* get next statement */ |
572 |
|
{ |
573 |
< |
register EPNODE *ep; |
573 |
> |
EPNODE *ep; |
574 |
|
char *qname; |
575 |
< |
register VARDEF *vdef; |
575 |
> |
VARDEF *vdef; |
576 |
|
|
577 |
|
if (nextc == ';') { /* empty statement */ |
578 |
|
scan(); |
618 |
|
/* FUNC(SYM,..) = E1 */ |
619 |
|
/* FUNC(SYM,..) : E1 */ |
620 |
|
{ |
621 |
< |
register EPNODE *ep1, *ep2; |
621 |
> |
EPNODE *ep1, *ep2; |
622 |
|
|
623 |
|
if (!isalpha(nextc) && nextc != CNTXMARK) |
624 |
|
syntax("illegal variable name"); |
635 |
|
do { |
636 |
|
scan(); |
637 |
|
if (!isalpha(nextc)) |
638 |
< |
syntax("illegal variable name"); |
638 |
> |
syntax("illegal parameter name"); |
639 |
|
ep2 = newnode(); |
640 |
|
ep2->type = SYM; |
641 |
|
ep2->v.name = savestr(getname()); |
658 |
|
|
659 |
|
if (ep1->type == SYM && ep1->sibling->type != NUM) { |
660 |
|
ep1 = newnode(); |
661 |
< |
ep1->type = TICK; |
661 |
> |
ep1->type = CLKT; |
662 |
|
ep1->v.tick = 0; |
663 |
|
addekid(ep2, ep1); |
664 |
|
ep1 = newnode(); |
674 |
|
EPNODE * |
675 |
|
getchan(void) /* A -> $N = E1 */ |
676 |
|
{ |
677 |
< |
register EPNODE *ep1, *ep2; |
677 |
> |
EPNODE *ep1, *ep2; |
678 |
|
|
679 |
|
if (nextc != '$') |
680 |
|
syntax("missing '$'"); |
706 |
|
static double /* evaluate a variable */ |
707 |
|
dvalue(char *name, EPNODE *d) |
708 |
|
{ |
709 |
< |
register EPNODE *ep1, *ep2; |
709 |
> |
EPNODE *ep1, *ep2; |
710 |
|
|
711 |
|
if (d == NULL || d->v.kid->type != SYM) { |
712 |
|
eputs(name); |