lists struct pt_temper *modtlist and struct pt_temper *devtlist

contain parse trees handling TEMPER equations in model or instance lines.
Create new lists  upon entering inp_parse_temper().
Save pointers to lists in current circuit ft_curckt.
Upon changing circuit, reload lists from ft_curckt.
Upon removing current circuit, delete lists.
This commit is contained in:
h_vogt 2016-11-04 22:01:55 +01:00 committed by rlar
parent ef21363e4f
commit c9517c397b
5 changed files with 55 additions and 16 deletions

View File

@ -69,18 +69,6 @@ void inp_evaluate_temper(void);
extern bool ft_batchmode;
/* structure used to save expression parse trees for .model and
* device instance lines
*/
struct pt_temper {
char *expression;
wordlist *wl;
wordlist *wlend;
INPparseTree *pt;
struct pt_temper *next;
};
/*
* create an unique artificial *unusable* FILE ptr
* meant to be used with Xprintf() only to eventually
@ -1697,9 +1685,13 @@ inp_parse_temper(struct line *card)
{
int error = 0;
char *end_tstr, *beg_tstr, *beg_pstr, *str_ptr, *devmodname, *paramname;
/* reset lists */
modtlist = NULL;
devtlist = NULL;
/* skip title line */
card = card->li_next;
for (; card; card = card->li_next) {
char *curr_line = card->li_line;
@ -1830,11 +1822,39 @@ inp_parse_temper_trees(void)
for(d = devtlist; d; d = d->next)
INPgetTree(&d->expression, &d->pt, ft_curckt->ci_ckt, NULL);
ft_curckt->devtlist = devtlist;
for(d = modtlist; d; d = d->next)
INPgetTree(&d->expression, &d->pt, ft_curckt->ci_ckt, NULL);
ft_curckt->modtlist = modtlist;
}
/* set modtlist and devtlist. Called from com_scirc(), when another circuit is selected */
void
set_tlist(struct circ *curckt)
{
modtlist = curckt->modtlist;
devtlist = curckt->devtlist;
expr_w_temper = (modtlist || devtlist);
}
/* remove the actual modtlist and devtlist */
void
rem_tlist(void)
{
if (devtlist) {
// tfree(devtlist->expression);
wl_free(devtlist->wl);
/*should we remove the parse tree pt ?*/
tfree(devtlist);
}
if (modtlist) {
// tfree(modtlist->expression);
wl_free(modtlist->wl);
/*should we remove the parse tree pt ?*/
tfree(modtlist);
}
}
void
inp_evaluate_temper(void)

View File

@ -112,6 +112,8 @@ com_scirc(wordlist *wl)
dbs = ft_curckt->ci_dbs;
/* set the numparam dicos structure for use with measure */
nupa_set_dicoslist(ft_curckt->ci_dicos);
/* set the temper lists */
set_tlist(ft_curckt);
}

View File

@ -259,6 +259,7 @@ com_remcirc(wordlist *wl)
tfree(ft_curckt->ci_name);
if (ft_curckt->ci_filename)
tfree(ft_curckt->ci_filename);
rem_tlist();
/* delete the actual circuit entry from ft_circuits */
for (p = ft_circuits; p; p = p->ci_next) {
@ -284,5 +285,6 @@ com_remcirc(wordlist *wl)
modtab = ft_curckt->ci_modtab;
dbs = ft_curckt->ci_dbs;
nupa_set_dicoslist(ft_curckt->ci_dicos);
set_tlist(ft_curckt);
}
}

View File

@ -25,7 +25,19 @@ struct save_info {
int used;
};
/* The curcuits that are currently available to the user. */
/* structure used to save expression parse trees for .model and
* device instance lines
*/
struct pt_temper {
char *expression;
wordlist *wl;
wordlist *wlend;
INPparseTree *pt;
struct pt_temper *next;
};
/* The circuits that are currently available to the user. */
struct circ {
char *ci_name; /* What the circuit can be called. */
@ -54,7 +66,8 @@ struct circ {
JOB *ci_curOpt; /* the most recent options anal. for the circuit */
char *ci_last_an; /* name of last analysis run */
int ci_dicos; /* index to the numparam dicoS structure for this circuit*/
struct pt_temper *modtlist; /* List of all expressions with 'temper' in .model lines */
struct pt_temper *devtlist; /* List of all expressions with 'temper' in device instance lines */
FTESTATistics *FTEstats; /* Statistics for the front end */
} ;

View File

@ -207,7 +207,7 @@ extern bool gr_circular;
/* inp.c */
void inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
struct line *options, char *filename);
struct line *options, char *filename);
extern void inp_source(char *file);
void inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile);
extern void inp_casefix(char *string);
@ -221,12 +221,14 @@ extern void mc_free(void);
void eval_seed_opt(struct line *deck);
extern char** circarray;
extern void set_tlist(struct circ *curckt);
extern void rem_tlist(void);
/* nutinp.c */
void inp_nutsource(FILE *fp, bool comfile, char *filename);
void nutinp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
struct line *options, char *filename);
struct line *options, char *filename);
extern void nutcom_source(wordlist *wl);
/* interpolate.c */