numparam, unify `dico' variable
This commit is contained in:
parent
e952500be3
commit
a67b74ab9f
|
|
@ -49,16 +49,16 @@ typedef struct { /* the input scanner data structure */
|
|||
} dico_t;
|
||||
|
||||
|
||||
void initdico(dico_t *dico);
|
||||
int donedico(dico_t *dico);
|
||||
void initdico(dico_t *);
|
||||
int donedico(dico_t *);
|
||||
void dico_free_entry(entry_t *entry_p);
|
||||
bool defsubckt(dico_t *dico, char *s, int w, char categ);
|
||||
int findsubckt(dico_t *dico, char *s, SPICE_DSTRINGPTR subname);
|
||||
bool nupa_substitute(dico_t *dico, char *s, char *r, bool err);
|
||||
bool nupa_assignment(dico_t *dico, char *s, char mode);
|
||||
bool nupa_subcktcall(dico_t *dico, char *s, char *x, bool err);
|
||||
void nupa_subcktexit(dico_t *dico);
|
||||
bool defsubckt(dico_t *, char *s, int w, char categ);
|
||||
int findsubckt(dico_t *, char *s, SPICE_DSTRINGPTR subname);
|
||||
bool nupa_substitute(dico_t *, char *s, char *r, bool err);
|
||||
bool nupa_assignment(dico_t *, char *s, char mode);
|
||||
bool nupa_subcktcall(dico_t *, char *s, char *x, bool err);
|
||||
void nupa_subcktexit(dico_t *);
|
||||
dico_t *nupa_fetchinstance(void);
|
||||
char getidtype(dico_t *d, char *s);
|
||||
entry_t *attrib(dico_t *d, NGHASHPTR htable, char *t, char op);
|
||||
char getidtype(dico_t *, char *s);
|
||||
entry_t *attrib(dico_t *, NGHASHPTR htable, char *t, char op);
|
||||
void del_attrib(void *);
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ char * nbofnodes = "222222444443222240334";
|
|||
char * nbsubdevice = "000000000000111002000";
|
||||
|
||||
void prefixing(char * s, char * p, char * formals, char * actuals,
|
||||
char categ, dico_t *dic)
|
||||
char categ, dico_t *dico)
|
||||
/* s is a line in expanded subcircuit.
|
||||
p is the prefix to be glued anywhere .
|
||||
assume that everything except first and last word in s may be a node.
|
||||
|
|
@ -277,7 +277,7 @@ Reminder on Numparam symbols:
|
|||
/* bug: are there semilocal nodes ? in nested subckt declarations ? */
|
||||
if ( (leadchar=='Q') && (! done) ) { /* BJT: watch non-node name */
|
||||
scopy(v,u); stupcase(v);
|
||||
done= getidtype(dic, v) == 'O'; /* a model name stops the node list */;
|
||||
done= getidtype(dico, v) == 'O'; /* a model name stops the node list */;
|
||||
}
|
||||
if ( (! done) && (nodes>0) ) { /* transform a node name */
|
||||
k= inwordlist(u, formals);
|
||||
|
|
@ -303,7 +303,7 @@ Reminder on Numparam symbols:
|
|||
}
|
||||
}
|
||||
|
||||
void getnodelist(char * form, char * act, char * s, dico_t *dic, int k)
|
||||
void getnodelist(char * form, char * act, char * s, dico_t *dico, int k)
|
||||
/* the line s contains the actual node parameters, between 1st & last word */
|
||||
{
|
||||
int j,ls, idef;
|
||||
|
|
@ -316,7 +316,7 @@ void getnodelist(char * form, char * act, char * s, dico_t *dic, int k)
|
|||
if ( j<ls ) { sadd(act,u); cadd(act,' ') ;}
|
||||
}
|
||||
/* now u already holds the subckt name if all is ok ? */
|
||||
idef = findsubckt( dic, buf2[k], u);
|
||||
idef = findsubckt( dico, buf2[k], u);
|
||||
/* line buf2[idef] contains: .subckt name < formal list > */
|
||||
if ( idef>0 ) {
|
||||
scopy(t, buf2[idef]);
|
||||
|
|
@ -337,7 +337,7 @@ void nupa_test(char * fname, char mode)
|
|||
/* bugs in nupa_eval(), and for nested subckt definitions !?! */
|
||||
{
|
||||
FILE * tf, fout;
|
||||
dico_t * dic; /* dictionary data pointer */
|
||||
dico_t * dico; /* dictionary data pointer */
|
||||
Strbig(Llen,s);
|
||||
Str(80, prefix);
|
||||
/* Strbig(Llen, formals); Strbig(Llen,actuals); */
|
||||
|
|
@ -369,12 +369,12 @@ void nupa_test(char * fname, char mode)
|
|||
*/
|
||||
gluepluslines(i); /* must re-allocate certain buff[i] */
|
||||
nupa_signal(NUPADECKCOPY, fname);
|
||||
dic= nupa_fetchinstance(); /* bug: should have a task handle as arg */
|
||||
dico= nupa_fetchinstance(); /* bug: should have a task handle as arg */
|
||||
for ( j=1; j<=i; Inc(j) ) {
|
||||
buf2[j]= nupa_copy(buff[j], j); /* transformed data */;
|
||||
}
|
||||
nupa_signal(NUPASUBDONE, NULL);
|
||||
nline= runscript(dic, "", 1,i, 20); /* our own subckt expansion */
|
||||
nline= runscript(dico, "", 1,i, 20); /* our own subckt expansion */
|
||||
/* putlogfile(' ',nline," expanded lines"); */
|
||||
if ( mode=='w' ) {
|
||||
i= cpos('.', fname);
|
||||
|
|
@ -392,13 +392,13 @@ void nupa_test(char * fname, char mode)
|
|||
scopy(prefix,pxbuf[pindex[j]]);
|
||||
if ( NotZ(prefix[0]) ) { cadd(prefix, pfxsep) ;}
|
||||
prefixing(s, prefix, formals[parstack], actuals[parstack],
|
||||
dic->category[k], dic);
|
||||
if ( dic->category[k] == 'X' ) {
|
||||
dico->category[k], dico);
|
||||
if ( dico->category[k] == 'X' ) {
|
||||
if ( parstack< (10-1) ) { Inc(parstack) ;}
|
||||
getnodelist(formals[parstack], actuals[parstack], s, dic,k);
|
||||
getnodelist(formals[parstack], actuals[parstack], s, dico,k);
|
||||
/*dbg: printf("Form: %s\n", formals[parstack]); */
|
||||
/*dbg: printf("Actu: %s\n", actuals[parstack]); */;
|
||||
} else if ( dic->category[k]=='U' ) { /* return from subckt */
|
||||
} else if ( dico->category[k]=='U' ) { /* return from subckt */
|
||||
if ( parstack>0 ) { Dec(parstack) ;}
|
||||
}
|
||||
if ( fout != NULL ) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ Todo:
|
|||
|
||||
extern bool ft_batchmode;
|
||||
|
||||
void dump_symbols(dico_t *dico_p);
|
||||
void dump_symbols(dico_t *);
|
||||
|
||||
char *nupa_inst_name;
|
||||
|
||||
|
|
@ -532,7 +532,7 @@ nupa_scan(char *s, int linenum, int is_subckt)
|
|||
* Dump the contents of a symbol table.
|
||||
* ----------------------------------------------------------------- */
|
||||
static void
|
||||
dump_symbol_table(dico_t *dico_p, NGHASHPTR htable_p, FILE *cp_out)
|
||||
dump_symbol_table(dico_t *dico, NGHASHPTR htable_p, FILE *cp_out)
|
||||
{
|
||||
char *name; /* current symbol */
|
||||
entry_t *entry_p; /* current entry */
|
||||
|
|
@ -544,11 +544,11 @@ dump_symbol_table(dico_t *dico_p, NGHASHPTR htable_p, FILE *cp_out)
|
|||
entry_p = (entry_t *) nghash_enumerateRE(htable_p, &iter))
|
||||
{
|
||||
if (entry_p->tp == 'R') {
|
||||
spice_dstring_reinit(& dico_p->lookup_buf);
|
||||
scopy_lower(& dico_p->lookup_buf, entry_p->symbol);
|
||||
name = spice_dstring_value(& dico_p->lookup_buf);
|
||||
spice_dstring_reinit(& dico->lookup_buf);
|
||||
scopy_lower(& dico->lookup_buf, entry_p->symbol);
|
||||
name = spice_dstring_value(& dico->lookup_buf);
|
||||
fprintf(cp_out, " ---> %s = %g\n", name, entry_p->vl);
|
||||
spice_dstring_free(& dico_p->lookup_buf);
|
||||
spice_dstring_free(& dico->lookup_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -561,24 +561,24 @@ void
|
|||
nupa_list_params(FILE *cp_out)
|
||||
{
|
||||
int depth; /* nested subcircit depth */
|
||||
dico_t *dico_p; /* local copy for speed */
|
||||
dico_t *dico; /* local copy for speed */
|
||||
|
||||
dico_p = dicoS;
|
||||
if (dico_p == NULL) {
|
||||
dico = dicoS;
|
||||
if (dico == NULL) {
|
||||
fprintf(cp_err, "\nWarning: No symbol table available for 'listing param'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(cp_out, "\n\n");
|
||||
|
||||
for (depth = dico_p->stack_depth; depth >= 0; depth--) {
|
||||
NGHASHPTR htable_p = dico_p->symbols[depth];
|
||||
for (depth = dico->stack_depth; depth >= 0; depth--) {
|
||||
NGHASHPTR htable_p = dico->symbols[depth];
|
||||
if (htable_p) {
|
||||
if (depth > 0)
|
||||
fprintf(cp_out, " local symbol definitions for: %s\n", dico_p->inst_name[depth]);
|
||||
fprintf(cp_out, " local symbol definitions for: %s\n", dico->inst_name[depth]);
|
||||
else
|
||||
fprintf(cp_out, " global symbol definitions:\n");
|
||||
dump_symbol_table(dico_p, htable_p, cp_out);
|
||||
dump_symbol_table(dico, htable_p, cp_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -598,17 +598,17 @@ nupa_get_param(char *param_name, int *found)
|
|||
int depth; /* nested subcircit depth */
|
||||
char *up_name; /* current parameter upper case */
|
||||
entry_t *entry_p; /* current entry */
|
||||
dico_t *dico_p; /* local copy for speed */
|
||||
dico_t *dico; /* local copy for speed */
|
||||
double result = 0; /* parameter value */
|
||||
|
||||
dico_p = dicoS;
|
||||
spice_dstring_reinit(& dico_p->lookup_buf);
|
||||
scopy_up(& dico_p->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico_p->lookup_buf);
|
||||
dico = dicoS;
|
||||
spice_dstring_reinit(& dico->lookup_buf);
|
||||
scopy_up(& dico->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico->lookup_buf);
|
||||
|
||||
*found = 0;
|
||||
for (depth = dico_p->stack_depth; depth >= 0; depth--) {
|
||||
NGHASHPTR htable_p = dico_p->symbols[depth];
|
||||
for (depth = dico->stack_depth; depth >= 0; depth--) {
|
||||
NGHASHPTR htable_p = dico->symbols[depth];
|
||||
if (htable_p) {
|
||||
entry_p = (entry_t *) nghash_find(htable_p, up_name);
|
||||
if (entry_p) {
|
||||
|
|
@ -619,7 +619,7 @@ nupa_get_param(char *param_name, int *found)
|
|||
}
|
||||
}
|
||||
|
||||
spice_dstring_free(& dico_p->lookup_buf);
|
||||
spice_dstring_free(& dico->lookup_buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -629,25 +629,25 @@ nupa_add_param(char *param_name, double value)
|
|||
{
|
||||
char *up_name; /* current parameter upper case */
|
||||
entry_t *entry_p; /* current entry */
|
||||
dico_t *dico_p; /* local copy for speed */
|
||||
dico_t *dico; /* local copy for speed */
|
||||
NGHASHPTR htable_p; /* hash table of interest */
|
||||
|
||||
dico_p = dicoS;
|
||||
dico = dicoS;
|
||||
/* -----------------------------------------------------------------
|
||||
* We use a dynamic string here because most of the time we will
|
||||
* be using short names and no memory allocation will occur.
|
||||
* ----------------------------------------------------------------- */
|
||||
spice_dstring_reinit(& dico_p->lookup_buf);
|
||||
scopy_up(& dico_p->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico_p->lookup_buf);
|
||||
spice_dstring_reinit(& dico->lookup_buf);
|
||||
scopy_up(& dico->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico->lookup_buf);
|
||||
|
||||
/* can't be lazy anymore */
|
||||
if (!(dico_p->symbols[dico_p->stack_depth]))
|
||||
dico_p->symbols[dico_p->stack_depth] = nghash_init(NGHASH_MIN_SIZE);
|
||||
if (!(dico->symbols[dico->stack_depth]))
|
||||
dico->symbols[dico->stack_depth] = nghash_init(NGHASH_MIN_SIZE);
|
||||
|
||||
htable_p = dico_p->symbols[dico_p->stack_depth];
|
||||
htable_p = dico->symbols[dico->stack_depth];
|
||||
|
||||
entry_p = attrib(dico_p, htable_p, up_name, 'N');
|
||||
entry_p = attrib(dico, htable_p, up_name, 'N');
|
||||
if (entry_p) {
|
||||
entry_p->vl = value;
|
||||
entry_p->tp = 'R';
|
||||
|
|
@ -655,7 +655,7 @@ nupa_add_param(char *param_name, double value)
|
|||
entry_p->sbbase = NULL;
|
||||
}
|
||||
|
||||
spice_dstring_free(& dico_p->lookup_buf);
|
||||
spice_dstring_free(& dico->lookup_buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -664,17 +664,17 @@ nupa_add_inst_param(char *param_name, double value)
|
|||
{
|
||||
char *up_name; /* current parameter upper case */
|
||||
entry_t *entry_p; /* current entry */
|
||||
dico_t *dico_p; /* local copy for speed */
|
||||
dico_t *dico; /* local copy for speed */
|
||||
|
||||
dico_p = dicoS;
|
||||
spice_dstring_reinit(& dico_p->lookup_buf);
|
||||
scopy_up(& dico_p->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico_p->lookup_buf);
|
||||
dico = dicoS;
|
||||
spice_dstring_reinit(& dico->lookup_buf);
|
||||
scopy_up(& dico->lookup_buf, param_name);
|
||||
up_name = spice_dstring_value(& dico->lookup_buf);
|
||||
|
||||
if (!(dico_p->inst_symbols))
|
||||
dico_p->inst_symbols = nghash_init(NGHASH_MIN_SIZE);
|
||||
if (!(dico->inst_symbols))
|
||||
dico->inst_symbols = nghash_init(NGHASH_MIN_SIZE);
|
||||
|
||||
entry_p = attrib(dico_p, dico_p->inst_symbols, up_name, 'N');
|
||||
entry_p = attrib(dico, dico->inst_symbols, up_name, 'N');
|
||||
if (entry_p) {
|
||||
entry_p->vl = value;
|
||||
entry_p->tp = 'R';
|
||||
|
|
@ -682,7 +682,7 @@ nupa_add_inst_param(char *param_name, double value)
|
|||
entry_p->sbbase = NULL;
|
||||
}
|
||||
|
||||
spice_dstring_free(& dico_p->lookup_buf);
|
||||
spice_dstring_free(& dico->lookup_buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -695,26 +695,26 @@ void
|
|||
nupa_copy_inst_dico(void)
|
||||
{
|
||||
entry_t *entry_p; /* current entry */
|
||||
dico_t *dico_p; /* local copy for speed */
|
||||
dico_t *dico; /* local copy for speed */
|
||||
NGHASHITER iter; /* hash iterator - thread safe */
|
||||
|
||||
dico_p = dicoS;
|
||||
if (dico_p->inst_symbols) {
|
||||
dico = dicoS;
|
||||
if (dico->inst_symbols) {
|
||||
/* We we perform this operation we should be in global scope */
|
||||
if (dico_p->stack_depth > 0)
|
||||
if (dico->stack_depth > 0)
|
||||
fprintf(stderr, "stack depth should be zero.\n");
|
||||
|
||||
NGHASH_FIRST(&iter);
|
||||
for (entry_p = (entry_t *) nghash_enumerateRE(dico_p->inst_symbols, &iter);
|
||||
for (entry_p = (entry_t *) nghash_enumerateRE(dico->inst_symbols, &iter);
|
||||
entry_p;
|
||||
entry_p = (entry_t *) nghash_enumerateRE(dico_p->inst_symbols, &iter))
|
||||
entry_p = (entry_t *) nghash_enumerateRE(dico->inst_symbols, &iter))
|
||||
{
|
||||
nupa_add_param(entry_p->symbol, entry_p->vl);
|
||||
dico_free_entry(entry_p);
|
||||
}
|
||||
|
||||
nghash_free(dico_p->inst_symbols, NULL, NULL);
|
||||
dico_p->inst_symbols = NULL;
|
||||
nghash_free(dico->inst_symbols, NULL, NULL);
|
||||
dico->inst_symbols = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -892,9 +892,10 @@ nupa_fetchinstance(void)
|
|||
#endif
|
||||
|
||||
|
||||
void dump_symbols(dico_t *dico_p)
|
||||
void
|
||||
dump_symbols(dico_t *dico)
|
||||
{
|
||||
NG_IGNORE(dico_p);
|
||||
NG_IGNORE(dico);
|
||||
|
||||
fprintf(stderr, "Symbol table\n");
|
||||
nupa_list_params(stderr);
|
||||
|
|
|
|||
|
|
@ -205,32 +205,32 @@ mathfunction(int f, double z, double x)
|
|||
|
||||
|
||||
#ifdef __GNUC__
|
||||
static bool message(dico_t *dic, const char *fmt, ...)
|
||||
static bool message(dico_t *dico, const char *fmt, ...)
|
||||
__attribute__ ((format (__printf__, 2, 3)));
|
||||
#endif
|
||||
|
||||
|
||||
static bool
|
||||
message(dico_t *dic, const char *fmt, ...)
|
||||
message(dico_t *dico, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
char *srcfile = spice_dstring_value(&(dic->srcfile));
|
||||
char *srcfile = spice_dstring_value(&(dico->srcfile));
|
||||
|
||||
if (srcfile && *srcfile)
|
||||
fprintf(stderr, "%s:", srcfile);
|
||||
|
||||
if (dic->srcline >= 0)
|
||||
if (dico->srcline >= 0)
|
||||
fprintf
|
||||
(stderr,
|
||||
"Original line no.: %d, new internal line no.: %d:\n",
|
||||
dic->oldline, dic->srcline);
|
||||
dico->oldline, dico->srcline);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
dic->errcount++;
|
||||
dico->errcount++;
|
||||
|
||||
return 1; /* error! */
|
||||
}
|
||||
|
|
@ -367,15 +367,15 @@ donedico(dico_t *dico)
|
|||
* symbols in that order.
|
||||
* ----------------------------------------------------------------- */
|
||||
static entry_t *
|
||||
entrynb(dico_t *d, char *s)
|
||||
entrynb(dico_t *dico, char *s)
|
||||
{
|
||||
int depth; /* stack depth */
|
||||
entry_t *entry_p; /* search hash table */
|
||||
NGHASHPTR htable_p; /* hash table */
|
||||
|
||||
/* look at the current scope and then backup the stack */
|
||||
for (depth = d->stack_depth; depth >= 0; depth--) {
|
||||
htable_p = d->symbols[depth];
|
||||
for (depth = dico->stack_depth; depth >= 0; depth--) {
|
||||
htable_p = dico->symbols[depth];
|
||||
if (htable_p) {
|
||||
entry_p = (entry_t *) nghash_find(htable_p, s);
|
||||
if (entry_p)
|
||||
|
|
@ -388,13 +388,13 @@ entrynb(dico_t *d, char *s)
|
|||
|
||||
|
||||
char
|
||||
getidtype(dico_t *d, char *s)
|
||||
getidtype(dico_t *dico, char *s)
|
||||
/* test if identifier s is known. Answer its type, or '?' if not in table */
|
||||
{
|
||||
entry_t *entry_p; /* hash table entry */
|
||||
char itp = '?'; /* assume unknown */
|
||||
|
||||
entry_p = entrynb(d, s);
|
||||
entry_p = entrynb(dico, s);
|
||||
if (entry_p)
|
||||
itp = entry_p->tp;
|
||||
|
||||
|
|
@ -435,7 +435,7 @@ fetchnumentry(dico_t *dico, char *t, bool *perr)
|
|||
/******* writing dictionary entries *********/
|
||||
|
||||
entry_t *
|
||||
attrib(dico_t *dico_p, NGHASHPTR htable_p, char *t, char op)
|
||||
attrib(dico_t *dico, NGHASHPTR htable_p, char *t, char op)
|
||||
{
|
||||
/* seek or attribute dico entry number for string t.
|
||||
Option op='N' : force a new entry, if tos>level and old is valid.
|
||||
|
|
@ -444,7 +444,7 @@ attrib(dico_t *dico_p, NGHASHPTR htable_p, char *t, char op)
|
|||
|
||||
entry_p = (entry_t *) nghash_find(htable_p, t);
|
||||
if (entry_p && (op == 'N') &&
|
||||
(entry_p->level < dico_p->stack_depth) && (entry_p->tp != '?'))
|
||||
(entry_p->level < dico->stack_depth) && (entry_p->tp != '?'))
|
||||
{
|
||||
entry_p = NULL;
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ attrib(dico_t *dico_p, NGHASHPTR htable_p, char *t, char op)
|
|||
entry_p = TMALLOC(entry_t, 1);
|
||||
entry_p->symbol = strdup(t);
|
||||
entry_p->tp = '?'; /* signal Unknown */
|
||||
entry_p->level = dico_p->stack_depth;
|
||||
entry_p->level = dico->stack_depth;
|
||||
nghash_insert(htable_p, t, entry_p);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue