Browse Source

use type `IFparm' to abbreviate some expressions

pre-master-46
rlar 13 years ago
parent
commit
4d65fb908d
  1. 12
      src/frontend/shyu.c
  2. 35
      src/frontend/spiceif.c
  3. 12
      src/spicelib/parser/inp2dot.c
  4. 4
      src/spicelib/parser/inpapnam.c
  5. 16
      src/spicelib/parser/inpdoopt.c

12
src/frontend/shyu.c

@ -318,6 +318,8 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab)
next: next:
while (*line) { /* read the entire line */ while (*line) { /* read the entire line */
IFparm *if_parm;
if (flag) if (flag)
INPgetTok(&line, &token, 1); INPgetTok(&line, &token, 1);
else else
@ -333,22 +335,24 @@ next:
continue; continue;
} }
if_parm = &(ft_sim->analyses[save]->analysisParms[i]);
/* found it, analysis which, parameter i */ /* found it, analysis which, parameter i */
if (ft_sim->analyses[save]->analysisParms[i].dataType & IF_FLAG) {
if (if_parm->dataType & IF_FLAG) {
/* one of the keywords! */ /* one of the keywords! */
ptemp.iValue = 1; ptemp.iValue = 1;
error = ft_sim->setAnalysisParm error = ft_sim->setAnalysisParm
(ckt, senseJob, (ckt, senseJob,
ft_sim->analyses[save]->analysisParms[i].id, &ptemp, NULL);
if_parm->id, &ptemp, NULL);
if (error) if (error)
current->error = INPerrCat(current->error, INPerror(error)); current->error = INPerrCat(current->error, INPerror(error));
} else { } else {
parm = INPgetValue parm = INPgetValue
(ckt, &line, (ckt, &line,
ft_sim->analyses[save]->analysisParms[i].dataType, tab);
if_parm->dataType, tab);
error = ft_sim->setAnalysisParm error = ft_sim->setAnalysisParm
(ckt, senseJob, (ckt, senseJob,
ft_sim->analyses[save]->analysisParms[i].id, parm, NULL);
if_parm->id, parm, NULL);
if (error) if (error)
current->error = INPerrCat(current->error, INPerror(error)); current->error = INPerrCat(current->error, INPerror(error));
} }

35
src/frontend/spiceif.c

@ -393,6 +393,7 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
int err, i; int err, i;
char **vv; char **vv;
int which = -1; int which = -1;
IFparm *if_parm;
if (eq(name, "acct")) { if (eq(name, "acct")) {
ft_acctprint = TRUE; ft_acctprint = TRUE;
@ -428,7 +429,9 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
} }
i = ft_find_analysis_parm(which, name); i = ft_find_analysis_parm(which, name);
if (i < 0 || !(ft_sim->analyses[which]->analysisParms[i].dataType & IF_SET)) {
if_parm = (i >= 0) ? &(ft_sim->analyses[which]->analysisParms[i]) : NULL;
if (!if_parm || !(if_parm->dataType & IF_SET)) {
/* See if this is unsupported or obsolete. */ /* See if this is unsupported or obsolete. */
for (vv = unsupported; *vv; vv++) for (vv = unsupported; *vv; vv++)
if (eq(name, *vv)) { if (eq(name, *vv)) {
@ -443,7 +446,7 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
return 0; return 0;
} }
switch (ft_sim->analyses[which]->analysisParms[i].dataType & IF_VARTYPES) {
switch (if_parm->dataType & IF_VARTYPES) {
case IF_REAL: case IF_REAL:
if (type == CP_REAL) if (type == CP_REAL)
pval.rValue = *((double *) value); pval.rValue = *((double *) value);
@ -477,7 +480,7 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
default: default:
fprintf(cp_err, fprintf(cp_err,
"if_option: Internal Error: bad option type %d.\n", "if_option: Internal Error: bad option type %d.\n",
ft_sim->analyses[which]->analysisParms[i].dataType);
if_parm->dataType);
} }
if (!ckt) { if (!ckt) {
@ -490,12 +493,12 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
#if (0) #if (0)
if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_curOpt, if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_curOpt,
ft_sim->analyses[which]->analysisParms[i].id, &pval,
if_parm->id, &pval,
NULL)) != OK) NULL)) != OK)
ft_sperror(err, "setAnalysisParm(options) ci_curOpt"); ft_sperror(err, "setAnalysisParm(options) ci_curOpt");
#else /*CDHW*/ #else /*CDHW*/
if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_defOpt, if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_defOpt,
ft_sim->analyses[which]->analysisParms[i].id, &pval,
if_parm->id, &pval,
NULL)) != OK) NULL)) != OK)
ft_sperror(err, "setAnalysisParm(options) ci_curOpt"); ft_sperror(err, "setAnalysisParm(options) ci_curOpt");
return 1; return 1;
@ -525,7 +528,7 @@ badtype:
break; break;
} }
fprintf(cp_err, ", type expected was "); fprintf(cp_err, ", type expected was ");
switch (ft_sim->analyses[which]->analysisParms[i].dataType & IF_VARTYPES) {
switch (if_parm->dataType & IF_VARTYPES) {
case IF_REAL: case IF_REAL:
fputs("real.\n", cp_err); fputs("real.\n", cp_err);
break; break;
@ -1209,12 +1212,15 @@ int
if_analQbyName(CKTcircuit *ckt, int which, JOB *anal, char *name, IFvalue *parm) if_analQbyName(CKTcircuit *ckt, int which, JOB *anal, char *name, IFvalue *parm)
{ {
int i; int i;
IFparm *if_parm;
i = ft_find_analysis_parm(which, name); i = ft_find_analysis_parm(which, name);
if (i < 0) if (i < 0)
return (E_BADPARM); return (E_BADPARM);
if_parm = &(ft_sim->analyses[which]->analysisParms[i]);
return (ft_sim->askAnalysisQuest return (ft_sim->askAnalysisQuest
(ckt, anal, ft_sim->analyses[which]->analysisParms[i].id, parm, NULL));
(ckt, anal, if_parm->id, parm, NULL));
} }
@ -1279,6 +1285,7 @@ if_getstat(CKTcircuit *ckt, char *name)
int options_idx, i; int options_idx, i;
IFanalysis *options; IFanalysis *options;
IFvalue parm; IFvalue parm;
IFparm *if_parm;
options_idx = ft_find_analysis("options"); options_idx = ft_find_analysis("options");
@ -1296,16 +1303,18 @@ if_getstat(CKTcircuit *ckt, char *name)
if (i < 0) if (i < 0)
return (NULL); return (NULL);
if_parm = &(options->analysisParms[i]);
if (ft_sim->askAnalysisQuest (ckt, if (ft_sim->askAnalysisQuest (ckt,
&(ft_curckt->ci_curTask->taskOptions), &(ft_curckt->ci_curTask->taskOptions),
options->analysisParms[i].id, &parm,
if_parm->id, &parm,
NULL) == -1) NULL) == -1)
{ {
fprintf(cp_err, "if_getstat: Internal Error: can't get %s\n", name); fprintf(cp_err, "if_getstat: Internal Error: can't get %s\n", name);
return (NULL); return (NULL);
} }
return (parmtovar(&parm, &(options->analysisParms[i])));
return (parmtovar(&parm, if_parm));
} else { } else {
@ -1313,19 +1322,21 @@ if_getstat(CKTcircuit *ckt, char *name)
for (i = 0; i < options->numParms; i++) { for (i = 0; i < options->numParms; i++) {
if (!(options->analysisParms[i].dataType & IF_ASK))
if_parm = &(options->analysisParms[i]);
if (!(if_parm->dataType & IF_ASK))
continue; continue;
if (ft_sim->askAnalysisQuest (ckt, if (ft_sim->askAnalysisQuest (ckt,
&(ft_curckt->ci_curTask->taskOptions), &(ft_curckt->ci_curTask->taskOptions),
options->analysisParms[i].id, &parm,
if_parm->id, &parm,
NULL) == -1) NULL) == -1)
{ {
fprintf(cp_err, "if_getstat: Internal Error: can't get %s\n", name); fprintf(cp_err, "if_getstat: Internal Error: can't get %s\n", name);
return (NULL); return (NULL);
} }
*v = parmtovar(&parm, &(options->analysisParms[i]));
*v = parmtovar(&parm, if_parm);
v = &((*v)->va_next); v = &((*v)->va_next);
} }

12
src/spicelib/parser/inp2dot.c

@ -514,6 +514,7 @@ dot_sens2(char *line, CKTcircuit *ckt, INPtables *tab, card *current,
} }
IFC(newAnalysis, (ckt, which, "Sensitivity-2 Analysis", &foo, task)); IFC(newAnalysis, (ckt, which, "Sensitivity-2 Analysis", &foo, task));
while (*line) { while (*line) {
IFparm *if_parm;
/* read the entire line */ /* read the entire line */
INPgetTok(&line, &token, 1); INPgetTok(&line, &token, 1);
i = ft_find_analysis_parm(which, token); i = ft_find_analysis_parm(which, token);
@ -522,13 +523,16 @@ dot_sens2(char *line, CKTcircuit *ckt, INPtables *tab, card *current,
LITERR(" Error: unknown parameter on .sens-ignored \n"); LITERR(" Error: unknown parameter on .sens-ignored \n");
continue; continue;
} }
if_parm = &(ft_sim->analyses[which]->analysisParms[i]);
/* found it, analysis which, parameter i */ /* found it, analysis which, parameter i */
if (ft_sim->analyses[which]->analysisParms[i].dataType & IF_FLAG) {
if (if_parm->dataType & IF_FLAG) {
/* one of the keywords! */ /* one of the keywords! */
ptemp.iValue = 1; ptemp.iValue = 1;
error = error =
ft_sim->setAnalysisParm (ckt, foo, ft_sim->setAnalysisParm (ckt, foo,
ft_sim->analyses[which]->analysisParms[i].id,
if_parm->id,
&ptemp, &ptemp,
NULL); NULL);
if (error) if (error)
@ -537,10 +541,10 @@ dot_sens2(char *line, CKTcircuit *ckt, INPtables *tab, card *current,
} else { } else {
parm = parm =
INPgetValue(ckt, &line, INPgetValue(ckt, &line,
ft_sim->analyses[which]->analysisParms[i].dataType, tab);
if_parm->dataType, tab);
error = error =
ft_sim->setAnalysisParm (ckt, foo, ft_sim->setAnalysisParm (ckt, foo,
ft_sim->analyses[which]->analysisParms[i].id,
if_parm->id,
parm, parm,
NULL); NULL);
if (error) if (error)

4
src/spicelib/parser/inpapnam.c

@ -16,6 +16,7 @@ INPapName(CKTcircuit *ckt, int type, JOB *analPtr, char *parmname,
IFvalue * value) IFvalue * value)
{ {
int i; int i;
IFparm *if_parm;
if (!parmname) if (!parmname)
return (E_BADPARM); return (E_BADPARM);
@ -28,8 +29,9 @@ INPapName(CKTcircuit *ckt, int type, JOB *analPtr, char *parmname,
if (i < 0) if (i < 0)
return (E_BADPARM); return (E_BADPARM);
if_parm = &(ft_sim->analyses[type]->analysisParms[i]);
return ft_sim->setAnalysisParm (ckt, analPtr, return ft_sim->setAnalysisParm (ckt, analPtr,
ft_sim->analyses[type]->analysisParms[i].id,
if_parm->id,
value, value,
NULL); NULL);
} }

16
src/spicelib/parser/inpdoopt.c

@ -43,25 +43,24 @@ INPdoOpts(
line = optCard->line; line = optCard->line;
INPgetTok(&line,&token,1); /* throw away '.option' */ INPgetTok(&line,&token,1); /* throw away '.option' */
while (*line) { while (*line) {
IFparm *if_parm;
INPgetTok(&line,&token,1); INPgetTok(&line,&token,1);
i = ft_find_analysis_parm(which, token); i = ft_find_analysis_parm(which, token);
if(i >= 0) {
if(!(prm->analysisParms[i].dataType & IF_UNIMP_MASK)) {
if_parm = (i >= 0) ? &(prm->analysisParms[i]) : NULL;
if(if_parm && !(if_parm->dataType & IF_UNIMP_MASK)) {
errmsg = TMALLOC(char, 45 + strlen(token)); errmsg = TMALLOC(char, 45 + strlen(token));
(void) sprintf(errmsg, (void) sprintf(errmsg,
" Warning: %s not yet implemented - ignored \n",token); " Warning: %s not yet implemented - ignored \n",token);
optCard->error = INPerrCat(optCard->error,errmsg); optCard->error = INPerrCat(optCard->error,errmsg);
val = INPgetValue(ckt,&line, val = INPgetValue(ckt,&line,
prm->analysisParms[i].dataType, tab);
if_parm->dataType, tab);
continue; continue;
}
} }
if(i >= 0) {
if(prm->analysisParms[i].dataType & IF_SET) {
if(if_parm && (if_parm->dataType & IF_SET)) {
val = INPgetValue(ckt,&line, val = INPgetValue(ckt,&line,
prm->analysisParms[i].dataType&IF_VARTYPES, tab);
if_parm->dataType&IF_VARTYPES, tab);
error = ft_sim->setAnalysisParm (ckt, anal, error = ft_sim->setAnalysisParm (ckt, anal,
prm->analysisParms[i].id, val, NULL);
if_parm->id, val, NULL);
if(error) { if(error) {
errmsg = TMALLOC(char, 35 + strlen(token)); errmsg = TMALLOC(char, 35 + strlen(token));
(void) sprintf(errmsg, (void) sprintf(errmsg,
@ -69,7 +68,6 @@ INPdoOpts(
optCard->error = INPerrCat(optCard->error, errmsg); optCard->error = INPerrCat(optCard->error, errmsg);
} }
continue; continue;
}
} }
errmsg = TMALLOC(char, 100); errmsg = TMALLOC(char, 100);
(void) strcpy(errmsg," Error: unknown option - ignored\n"); (void) strcpy(errmsg," Error: unknown option - ignored\n");

Loading…
Cancel
Save