Browse Source

numparam, rename `tdico' --> `dico_t'

pre-master-46
rlar 12 years ago
parent
commit
e952500be3
  1. 24
      src/frontend/numparam/numparam.h
  2. 8
      src/frontend/numparam/nupatest.c
  3. 28
      src/frontend/numparam/spicenum.c
  4. 44
      src/frontend/numparam/xpressn.c

24
src/frontend/numparam/numparam.h

@ -46,19 +46,19 @@ typedef struct { /* the input scanner data structure */
char **dynrefptr; char **dynrefptr;
char *dyncategory; char *dyncategory;
int hs_compatibility; /* allow extra keywords */ int hs_compatibility; /* allow extra keywords */
} tdico;
} dico_t;
void initdico(tdico *dico);
int donedico(tdico *dico);
void initdico(dico_t *dico);
int donedico(dico_t *dico);
void dico_free_entry(entry_t *entry_p); void dico_free_entry(entry_t *entry_p);
bool defsubckt(tdico *dico, char *s, int w, char categ);
int findsubckt(tdico *dico, char *s, SPICE_DSTRINGPTR subname);
bool nupa_substitute(tdico *dico, char *s, char *r, bool err);
bool nupa_assignment(tdico *dico, char *s, char mode);
bool nupa_subcktcall(tdico *dico, char *s, char *x, bool err);
void nupa_subcktexit(tdico *dico);
tdico *nupa_fetchinstance(void);
char getidtype(tdico *d, char *s);
entry_t *attrib(tdico *d, NGHASHPTR htable, char *t, char op);
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);
dico_t *nupa_fetchinstance(void);
char getidtype(dico_t *d, char *s);
entry_t *attrib(dico_t *d, NGHASHPTR htable, char *t, char op);
void del_attrib(void *); void del_attrib(void *);

8
src/frontend/numparam/nupatest.c

@ -48,7 +48,7 @@ and substitute node/device name arguments.
*/ */
int runscript( tdico *dico, char * prefix,
int runscript( dico_t *dico, char * prefix,
int istart, int istop, int maxnest) int istart, int istop, int maxnest)
/* recursive top-down expansion: circuit --> list of line numbers */ /* recursive top-down expansion: circuit --> list of line numbers */
/* keep it simple,stupid compared to Spice's code */ /* keep it simple,stupid compared to Spice's code */
@ -233,7 +233,7 @@ char * nbofnodes = "222222444443222240334";
char * nbsubdevice = "000000000000111002000"; char * nbsubdevice = "000000000000111002000";
void prefixing(char * s, char * p, char * formals, char * actuals, void prefixing(char * s, char * p, char * formals, char * actuals,
char categ, tdico *dic)
char categ, dico_t *dic)
/* s is a line in expanded subcircuit. /* s is a line in expanded subcircuit.
p is the prefix to be glued anywhere . p is the prefix to be glued anywhere .
assume that everything except first and last word in s may be a node. assume that everything except first and last word in s may be a node.
@ -303,7 +303,7 @@ Reminder on Numparam symbols:
} }
} }
void getnodelist(char * form, char * act, char * s, tdico *dic, int k)
void getnodelist(char * form, char * act, char * s, dico_t *dic, int k)
/* the line s contains the actual node parameters, between 1st & last word */ /* the line s contains the actual node parameters, between 1st & last word */
{ {
int j,ls, idef; int j,ls, idef;
@ -337,7 +337,7 @@ void nupa_test(char * fname, char mode)
/* bugs in nupa_eval(), and for nested subckt definitions !?! */ /* bugs in nupa_eval(), and for nested subckt definitions !?! */
{ {
FILE * tf, fout; FILE * tf, fout;
tdico * dic; /* dictionary data pointer */
dico_t * dic; /* dictionary data pointer */
Strbig(Llen,s); Strbig(Llen,s);
Str(80, prefix); Str(80, prefix);
/* Strbig(Llen, formals); Strbig(Llen,actuals); */ /* Strbig(Llen, formals); Strbig(Llen,actuals); */

28
src/frontend/numparam/spicenum.c

@ -31,7 +31,7 @@ Todo:
extern bool ft_batchmode; extern bool ft_batchmode;
void dump_symbols(tdico *dico_p);
void dump_symbols(dico_t *dico_p);
char *nupa_inst_name; char *nupa_inst_name;
@ -166,7 +166,7 @@ stripbraces(SPICE_DSTRINGPTR dstr_p)
static int static int
findsubname(tdico *dico, SPICE_DSTRINGPTR dstr_p)
findsubname(dico_t *dico, SPICE_DSTRINGPTR dstr_p)
/* truncate the parameterized subckt call to regular old Spice */ /* truncate the parameterized subckt call to regular old Spice */
/* scan a string from the end, skipping non-idents and {expressions} */ /* scan a string from the end, skipping non-idents and {expressions} */
/* then truncate s after the last subckt(?) identifier */ /* then truncate s after the last subckt(?) identifier */
@ -290,7 +290,7 @@ modernizeex(SPICE_DSTRINGPTR dstr_p)
static char static char
transform(tdico *dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
transform(dico_t *dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
SPICE_DSTRINGPTR u_p) SPICE_DSTRINGPTR u_p)
/* line s is categorized and crippled down to basic Spice /* line s is categorized and crippled down to basic Spice
* returns in u control word following dot, if any * returns in u control word following dot, if any
@ -390,7 +390,7 @@ transform(tdico *dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
/************ core of numparam **************/ /************ core of numparam **************/
/* some day, all these nasty globals will go into the tdico structure
/* some day, all these nasty globals will go into the dico_t structure
and everything will get hidden behind some "handle" ... and everything will get hidden behind some "handle" ...
For the time being we will rename this variable to end in S so we know For the time being we will rename this variable to end in S so we know
they are statics within this file for easier reading of the code. they are statics within this file for easier reading of the code.
@ -404,7 +404,7 @@ static unsigned char incontrolS = 0; /* flag control code sections */
static unsigned char dologfileS = 0; /* for debugging */ static unsigned char dologfileS = 0; /* for debugging */
static unsigned char firstsignalS = 1; static unsigned char firstsignalS = 1;
static FILE *logfileS = NULL; static FILE *logfileS = NULL;
static tdico *dicoS = NULL;
static dico_t *dicoS = NULL;
/* already part of dico : */ /* already part of dico : */
@ -440,7 +440,7 @@ nupa_init(char *srcfile)
linecountS = 0; linecountS = 0;
incontrolS = 0; incontrolS = 0;
placeholder = 0; placeholder = 0;
dicoS = (tdico *) new(sizeof(tdico));
dicoS = (dico_t *) new(sizeof(dico_t));
initdico(dicoS); initdico(dicoS);
dicoS->dynrefptr = TMALLOC(char*, dynmaxline + 1); dicoS->dynrefptr = TMALLOC(char*, dynmaxline + 1);
@ -532,7 +532,7 @@ nupa_scan(char *s, int linenum, int is_subckt)
* Dump the contents of a symbol table. * Dump the contents of a symbol table.
* ----------------------------------------------------------------- */ * ----------------------------------------------------------------- */
static void static void
dump_symbol_table(tdico *dico_p, NGHASHPTR htable_p, FILE *cp_out)
dump_symbol_table(dico_t *dico_p, NGHASHPTR htable_p, FILE *cp_out)
{ {
char *name; /* current symbol */ char *name; /* current symbol */
entry_t *entry_p; /* current entry */ entry_t *entry_p; /* current entry */
@ -561,7 +561,7 @@ void
nupa_list_params(FILE *cp_out) nupa_list_params(FILE *cp_out)
{ {
int depth; /* nested subcircit depth */ int depth; /* nested subcircit depth */
tdico *dico_p; /* local copy for speed */
dico_t *dico_p; /* local copy for speed */
dico_p = dicoS; dico_p = dicoS;
if (dico_p == NULL) { if (dico_p == NULL) {
@ -598,7 +598,7 @@ nupa_get_param(char *param_name, int *found)
int depth; /* nested subcircit depth */ int depth; /* nested subcircit depth */
char *up_name; /* current parameter upper case */ char *up_name; /* current parameter upper case */
entry_t *entry_p; /* current entry */ entry_t *entry_p; /* current entry */
tdico *dico_p; /* local copy for speed */
dico_t *dico_p; /* local copy for speed */
double result = 0; /* parameter value */ double result = 0; /* parameter value */
dico_p = dicoS; dico_p = dicoS;
@ -629,7 +629,7 @@ nupa_add_param(char *param_name, double value)
{ {
char *up_name; /* current parameter upper case */ char *up_name; /* current parameter upper case */
entry_t *entry_p; /* current entry */ entry_t *entry_p; /* current entry */
tdico *dico_p; /* local copy for speed */
dico_t *dico_p; /* local copy for speed */
NGHASHPTR htable_p; /* hash table of interest */ NGHASHPTR htable_p; /* hash table of interest */
dico_p = dicoS; dico_p = dicoS;
@ -664,7 +664,7 @@ nupa_add_inst_param(char *param_name, double value)
{ {
char *up_name; /* current parameter upper case */ char *up_name; /* current parameter upper case */
entry_t *entry_p; /* current entry */ entry_t *entry_p; /* current entry */
tdico *dico_p; /* local copy for speed */
dico_t *dico_p; /* local copy for speed */
dico_p = dicoS; dico_p = dicoS;
spice_dstring_reinit(& dico_p->lookup_buf); spice_dstring_reinit(& dico_p->lookup_buf);
@ -695,7 +695,7 @@ void
nupa_copy_inst_dico(void) nupa_copy_inst_dico(void)
{ {
entry_t *entry_p; /* current entry */ entry_t *entry_p; /* current entry */
tdico *dico_p; /* local copy for speed */
dico_t *dico_p; /* local copy for speed */
NGHASHITER iter; /* hash iterator - thread safe */ NGHASHITER iter; /* hash iterator - thread safe */
dico_p = dicoS; dico_p = dicoS;
@ -884,7 +884,7 @@ nupa_signal(int sig, char *info)
#ifdef USING_NUPATEST #ifdef USING_NUPATEST
/* This is use only by the nupatest program */ /* This is use only by the nupatest program */
tdico *
dico_t *
nupa_fetchinstance(void) nupa_fetchinstance(void)
{ {
return dico; return dico;
@ -892,7 +892,7 @@ nupa_fetchinstance(void)
#endif #endif
void dump_symbols(tdico *dico_p)
void dump_symbols(dico_t *dico_p)
{ {
NG_IGNORE(dico_p); NG_IGNORE(dico_p);

44
src/frontend/numparam/xpressn.c

@ -205,13 +205,13 @@ mathfunction(int f, double z, double x)
#ifdef __GNUC__ #ifdef __GNUC__
static bool message(tdico *dic, const char *fmt, ...)
static bool message(dico_t *dic, const char *fmt, ...)
__attribute__ ((format (__printf__, 2, 3))); __attribute__ ((format (__printf__, 2, 3)));
#endif #endif
static bool static bool
message(tdico *dic, const char *fmt, ...)
message(dico_t *dic, const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -239,7 +239,7 @@ message(tdico *dic, const char *fmt, ...)
/************ the input text symbol table (dictionary) *************/ /************ the input text symbol table (dictionary) *************/
void void
initdico(tdico *dico)
initdico(dico_t *dico)
{ {
int asize = 10; /* default allocation depth of the synbol stack */ int asize = 10; /* default allocation depth of the synbol stack */
COMPATMODE_T compat_mode; COMPATMODE_T compat_mode;
@ -289,7 +289,7 @@ dico_free_entry(entry_t *entry_p)
*/ */
static void static void
dicostack_push(tdico *dico)
dicostack_push(dico_t *dico)
/* push operation for nested subcircuit locals */ /* push operation for nested subcircuit locals */
{ {
dico->stack_depth++; dico->stack_depth++;
@ -307,7 +307,7 @@ dicostack_push(tdico *dico)
static void static void
dicostack_pop(tdico *dico)
dicostack_pop(dico_t *dico)
/* pop operation for nested subcircuit locals */ /* pop operation for nested subcircuit locals */
{ {
char *inst_name; /* name of subcircuit instance */ char *inst_name; /* name of subcircuit instance */
@ -354,7 +354,7 @@ dicostack_pop(tdico *dico)
int int
donedico(tdico *dico)
donedico(dico_t *dico)
{ {
int sze = nghash_get_size(dico->symbols[0]); int sze = nghash_get_size(dico->symbols[0]);
return sze; return sze;
@ -367,7 +367,7 @@ donedico(tdico *dico)
* symbols in that order. * symbols in that order.
* ----------------------------------------------------------------- */ * ----------------------------------------------------------------- */
static entry_t * static entry_t *
entrynb(tdico *d, char *s)
entrynb(dico_t *d, char *s)
{ {
int depth; /* stack depth */ int depth; /* stack depth */
entry_t *entry_p; /* search hash table */ entry_t *entry_p; /* search hash table */
@ -388,7 +388,7 @@ entrynb(tdico *d, char *s)
char char
getidtype(tdico *d, char *s)
getidtype(dico_t *d, char *s)
/* test if identifier s is known. Answer its type, or '?' if not in table */ /* test if identifier s is known. Answer its type, or '?' if not in table */
{ {
entry_t *entry_p; /* hash table entry */ entry_t *entry_p; /* hash table entry */
@ -403,7 +403,7 @@ getidtype(tdico *d, char *s)
static double static double
fetchnumentry(tdico *dico, char *t, bool *perr)
fetchnumentry(dico_t *dico, char *t, bool *perr)
{ {
bool err = *perr; bool err = *perr;
double u; double u;
@ -435,7 +435,7 @@ fetchnumentry(tdico *dico, char *t, bool *perr)
/******* writing dictionary entries *********/ /******* writing dictionary entries *********/
entry_t * entry_t *
attrib(tdico *dico_p, NGHASHPTR htable_p, char *t, char op)
attrib(dico_t *dico_p, NGHASHPTR htable_p, char *t, char op)
{ {
/* seek or attribute dico entry number for string t. /* seek or attribute dico entry number for string t.
Option op='N' : force a new entry, if tos>level and old is valid. Option op='N' : force a new entry, if tos>level and old is valid.
@ -478,7 +478,7 @@ del_attrib(void *e_p)
static bool static bool
nupa_define(tdico *dico,
nupa_define(dico_t *dico,
char *t, /* identifier to define */ char *t, /* identifier to define */
char op, /* option */ char op, /* option */
char tpe, /* type marker */ char tpe, /* type marker */
@ -555,7 +555,7 @@ nupa_define(tdico *dico,
bool bool
defsubckt(tdico *dico, char *s, int w, char categ)
defsubckt(dico_t *dico, char *s, int w, char categ)
/* called on 1st pass of spice source code, /* called on 1st pass of spice source code,
to enter subcircuit (categ=U) and model (categ=O) names to enter subcircuit (categ=U) and model (categ=O) names
*/ */
@ -595,7 +595,7 @@ defsubckt(tdico *dico, char *s, int w, char categ)
int int
findsubckt(tdico *dico, char *s, SPICE_DSTRINGPTR subname)
findsubckt(dico_t *dico, char *s, SPICE_DSTRINGPTR subname)
/* input: s is a subcircuit invocation line. /* input: s is a subcircuit invocation line.
returns 0 if not found, else the stored definition line number value returns 0 if not found, else the stored definition line number value
and the name in string subname */ and the name in string subname */
@ -729,7 +729,7 @@ fetchid(SPICE_DSTRINGPTR t, const char *s_end, const char *iptr)
static double static double
fetchnumber(tdico *dico, const char **pi, bool *perror)
fetchnumber(dico_t *dico, const char **pi, bool *perror)
/* parse a Spice number in string s */ /* parse a Spice number in string s */
{ {
double u; double u;
@ -762,7 +762,7 @@ fetchnumber(tdico *dico, const char **pi, bool *perror)
static char static char
fetchoperator(tdico *dico,
fetchoperator(dico_t *dico,
const char *s_end, const char *s_end,
const char **pi, const char **pi,
unsigned char *pstate, unsigned char *plevel, unsigned char *pstate, unsigned char *plevel,
@ -941,7 +941,7 @@ operate(char op, double x, double y)
static double static double
formula(tdico *dico, const char *s, const char *s_end, bool *perror)
formula(dico_t *dico, const char *s, const char *s_end, bool *perror)
{ {
/* Expression parser. /* Expression parser.
s is a formula with parentheses and math ops +-* / ... s is a formula with parentheses and math ops +-* / ...
@ -1163,7 +1163,7 @@ formula(tdico *dico, const char *s, const char *s_end, bool *perror)
static bool static bool
evaluate(tdico *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
evaluate(dico_t *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
{ {
/* transform t to result q. mode 0: expression, mode 1: simple variable */ /* transform t to result q. mode 0: expression, mode 1: simple variable */
double u = 0.0; double u = 0.0;
@ -1249,7 +1249,7 @@ evaluate(tdico *dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
/********* interface functions for spice3f5 extension ***********/ /********* interface functions for spice3f5 extension ***********/
static int static int
insertnumber(tdico *dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
insertnumber(dico_t *dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
/* insert u in string s in place of the next placeholder number */ /* insert u in string s in place of the next placeholder number */
{ {
const char *u = spice_dstring_value(ustr_p); const char *u = spice_dstring_value(ustr_p);
@ -1283,7 +1283,7 @@ insertnumber(tdico *dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
bool bool
nupa_substitute(tdico *dico, char *s, char *r, bool err)
nupa_substitute(dico_t *dico, char *s, char *r, bool err)
/* s: pointer to original source line. /* s: pointer to original source line.
r: pointer to result line, already heavily modified wrt s r: pointer to result line, already heavily modified wrt s
anywhere we find a 10-char numstring in r, substitute it. anywhere we find a 10-char numstring in r, substitute it.
@ -1528,7 +1528,7 @@ getexpress(char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
bool bool
nupa_assignment(tdico *dico, char *s, char mode)
nupa_assignment(dico_t *dico, char *s, char mode)
/* is called for all 'Param' lines of the input file. /* is called for all 'Param' lines of the input file.
is also called for the params: section of a subckt . is also called for the params: section of a subckt .
mode='N' define new local variable, else global... mode='N' define new local variable, else global...
@ -1608,7 +1608,7 @@ nupa_assignment(tdico *dico, char *s, char mode)
bool bool
nupa_subcktcall(tdico *dico, char *s, char *x, bool err)
nupa_subcktcall(dico_t *dico, char *s, char *x, bool err)
/* s= a subckt define line, with formal params. /* s= a subckt define line, with formal params.
x= a matching subckt call line, with actual params x= a matching subckt call line, with actual params
*/ */
@ -1832,7 +1832,7 @@ nupa_subcktcall(tdico *dico, char *s, char *x, bool err)
void void
nupa_subcktexit(tdico *dico)
nupa_subcktexit(dico_t *dico)
{ {
dicostack_pop(dico); dicostack_pop(dico);
} }
Loading…
Cancel
Save