58 |
|
static EPNODE *ochpos; /* ...dnext */ |
59 |
|
static EPNODE *outchan; |
60 |
|
|
61 |
+ |
static int optimized = 0; /* are we optimized? */ |
62 |
+ |
|
63 |
|
EPNODE *curfunc = NULL; |
64 |
|
|
65 |
|
|
183 |
|
while ((vp = varlookup(name)) != NULL && |
184 |
|
(dp = vp->def) != NULL && dp->type == '=') { |
185 |
|
vp->def = dp->sibling; |
186 |
< |
epfree(dp); |
186 |
> |
epfree(dp,1); |
187 |
|
varfree(vp); |
188 |
|
} |
189 |
|
} |
197 |
|
EPNODE *ep; |
198 |
|
|
199 |
|
while ((ep = dpop(name)) != NULL) |
200 |
< |
epfree(ep); |
200 |
> |
epfree(ep,1); |
201 |
|
} |
202 |
|
|
203 |
|
|
358 |
|
|
359 |
|
|
360 |
|
void |
361 |
+ |
doptimize(int activate) /* optimize current and future definitions? */ |
362 |
+ |
{ |
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 |
|
) |
394 |
|
while (outchan != NULL) { |
395 |
|
ep = outchan; |
396 |
|
outchan = ep->sibling; |
397 |
< |
ep->sibling = NULL; |
380 |
< |
epfree(ep); |
397 |
> |
epfree(ep,1); |
398 |
|
} |
399 |
|
} |
400 |
|
|
577 |
|
sp->sibling = ep; |
578 |
|
else { |
579 |
|
sp->sibling = ep->sibling; |
580 |
< |
epfree(ep); |
580 |
> |
epfree(ep,1); |
581 |
|
} |
582 |
|
return; |
583 |
|
} |
631 |
|
syntax("';' expected"); |
632 |
|
scan(); |
633 |
|
} |
634 |
+ |
if (optimized) |
635 |
+ |
epoptimize(ep); /* optimize new statement */ |
636 |
|
} |
637 |
|
|
638 |
|
|