numparam, rename `local_symbols' --> `symbols'

This commit is contained in:
rlar 2014-08-09 20:49:25 +02:00
parent 30fc375e2c
commit 8ee943e0c8
3 changed files with 26 additions and 25 deletions

View File

@ -46,7 +46,8 @@ typedef struct _ttdico { /* the input scanner data structure */
int errcount;
int symbol_stack_alloc; /* stack allocation */
int stack_depth; /* current depth of the symbol stack */
NGHASHPTR *local_symbols; /* stack of locally defined symbols */
NGHASHPTR *symbols; /* stack of scopes for symbol lookup */
/* [0] denotes global scope */
NGHASHPTR inst_symbols; /* instance qualified symbols - after a pop */
char **inst_name; /* name of subcircuit */
fumas fms[101];

View File

@ -471,8 +471,8 @@ nupa_del_dicoS(void)
dispose(dicoS->dynrefptr);
dispose(dicoS->dyncategory);
dispose(dicoS->inst_name);
nghash_free(dicoS->local_symbols[0], del_attrib, NULL);
dispose(dicoS->local_symbols);
nghash_free(dicoS->symbols[0], del_attrib, NULL);
dispose(dicoS->symbols);
dispose(dicoS);
dicoS = NULL;
}
@ -577,7 +577,7 @@ nupa_list_params(FILE *cp_out)
* we use lazy allocation to save memory.
* ----------------------------------------------------------------- */
for (depth = dico_p->stack_depth; depth > 0; depth--) {
NGHASHPTR htable_p = dico_p->local_symbols[depth];
NGHASHPTR htable_p = dico_p->symbols[depth];
if (htable_p) {
fprintf(cp_out, " local symbol definitions for:%s\n", dico_p->inst_name[depth]);
dump_symbol_table(dico_p, htable_p, cp_out);
@ -588,7 +588,7 @@ nupa_list_params(FILE *cp_out)
* Finally dump the global symbols.
* ----------------------------------------------------------------- */
fprintf(cp_out, " global symbol definitions:\n");
dump_symbol_table(dico_p, dico_p->local_symbols[0], cp_out);
dump_symbol_table(dico_p, dico_p->symbols[0], cp_out);
}
@ -616,7 +616,7 @@ nupa_get_param(char *param_name, int *found)
*found = 0;
for (depth = dico_p->stack_depth; depth > 0; depth--) {
NGHASHPTR htable_p = dico_p->local_symbols[depth];
NGHASHPTR htable_p = dico_p->symbols[depth];
if (htable_p) {
entry_p = (entry *) nghash_find(htable_p, up_name);
if (entry_p) {
@ -629,7 +629,7 @@ nupa_get_param(char *param_name, int *found)
if (!(*found)) {
/* No luck. Try the global table. */
entry_p = (entry *) nghash_find(dico_p->local_symbols[0], up_name);
entry_p = (entry *) nghash_find(dico_p->symbols[0], up_name);
if (entry_p) {
result = entry_p->vl;
*found = 1;
@ -660,12 +660,12 @@ nupa_add_param(char *param_name, double value)
if (dico_p->stack_depth > 0) {
/* can't be lazy anymore */
if (!(dico_p->local_symbols[dico_p->stack_depth]))
dico_p->local_symbols[dico_p->stack_depth] = nghash_init(NGHASH_MIN_SIZE);
htable_p = dico_p->local_symbols[dico_p->stack_depth];
if (!(dico_p->symbols[dico_p->stack_depth]))
dico_p->symbols[dico_p->stack_depth] = nghash_init(NGHASH_MIN_SIZE);
htable_p = dico_p->symbols[dico_p->stack_depth];
} else {
/* global symbol */
htable_p = dico_p->local_symbols[0];
htable_p = dico_p->symbols[0];
}
entry_p = attrib(dico_p, htable_p, up_name, 'N');

View File

@ -254,12 +254,12 @@ initdico(tdico *dico)
asize = dico->symbol_stack_alloc = 10;/* expected stack depth - no longer limited */
asize++; /* account for zero */
dico->local_symbols = TMALLOC(NGHASHPTR, asize);
dico->symbols = TMALLOC(NGHASHPTR, asize);
dico->inst_name = TMALLOC(char*, asize);
dico->stack_depth = 0; /* top of the stack */
dico->local_symbols[0] = nghash_init(NGHASH_MIN_SIZE);
nghash_unique(dico->local_symbols[0], TRUE); /* no rewrite of global symbols */
dico->symbols[0] = nghash_init(NGHASH_MIN_SIZE);
nghash_unique(dico->symbols[0], TRUE); /* no rewrite of global symbols */
dico->inst_symbols = NULL; /* instance qualified are lazily allocated */
@ -300,11 +300,11 @@ dicostack_push(tdico *dico)
/* Just double the stack alloc */
dico->symbol_stack_alloc *= 2;
asize = dico->symbol_stack_alloc + 1; /* account for zero */
dico->local_symbols = TREALLOC(NGHASHPTR, dico->local_symbols, asize);
dico->symbols = TREALLOC(NGHASHPTR, dico->symbols, asize);
dico->inst_name = TREALLOC(char*, dico->inst_name, asize);
}
/* lazy allocation - don't allocate space if we can help it */
dico->local_symbols[dico->stack_depth] = NULL;
dico->symbols[dico->stack_depth] = NULL;
dico->inst_name[dico->stack_depth] = nupa_inst_name;
}
@ -329,7 +329,7 @@ dicostack_pop(tdico *dico)
* scope variables to an instance qualified hash table.
* ----------------------------------------------------------------- */
inst_name = dico->inst_name[dico->stack_depth];
htable_p = dico->local_symbols[dico->stack_depth];
htable_p = dico->symbols[dico->stack_depth];
if (htable_p) {
SPICE_DSTRING param_name; /* build a qualified name */
spice_dstring_init(&param_name);
@ -351,7 +351,7 @@ dicostack_pop(tdico *dico)
tfree(inst_name);
dico->inst_name[dico->stack_depth] = NULL;
dico->local_symbols[dico->stack_depth] = NULL;
dico->symbols[dico->stack_depth] = NULL;
dico->stack_depth--;
}
@ -359,7 +359,7 @@ dicostack_pop(tdico *dico)
int
donedico(tdico *dico)
{
int sze = nghash_get_size(dico->local_symbols[0]);
int sze = nghash_get_size(dico->symbols[0]);
return sze;
}
@ -378,7 +378,7 @@ entrynb(tdico *d, char *s)
/* look at the current scope and then backup the stack */
for (depth = d->stack_depth; depth > 0; depth--) {
htable_p = d->local_symbols[depth];
htable_p = d->symbols[depth];
if (htable_p) {
entry_p = (entry *) nghash_find(htable_p, s);
if (entry_p)
@ -387,7 +387,7 @@ entrynb(tdico *d, char *s)
}
/* No local symbols - try the global table */
entry_p = (entry *) nghash_find(d->local_symbols[0], s);
entry_p = (entry *) nghash_find(d->symbols[0], s);
return (entry_p);
}
@ -509,13 +509,13 @@ nupa_define(tdico *dico,
if (dico->stack_depth > 0) {
/* can't be lazy anymore */
if (!(dico->local_symbols[dico->stack_depth]))
dico->local_symbols[dico->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->local_symbols[dico->stack_depth];
htable_p = dico->symbols[dico->stack_depth];
} else {
/* global symbol */
htable_p = dico->local_symbols[0];
htable_p = dico->symbols[0];
}
entry_p = attrib(dico, htable_p, t, op);