Jspice3
inpgval.c File Reference
#include "spice.h"
#include "inpdefs.h"
#include "misc.h"
Include dependency graph for inpgval.c:

Go to the source code of this file.

Functions

IFvalueINPgetValue (GENERIC *ckt, char **line, int type, INPtables *tab)
 

Function Documentation

IFvalue* INPgetValue ( GENERIC ckt,
char **  line,
int  type,
INPtables tab 
)

Definition at line 14 of file inpgval.c.

20 {
21  double *list;
22  double tmp;
23  char *word;
24  int error;
25  static IFvalue temp;
26  INPparseTree *pt;
27 
28  /* make sure we get rid of extra bits in type */
29  type &= IF_VARTYPES;
30  if (type == IF_INTEGER) {
31  temp.iValue = INPevaluate(line,&error,1);
32  /*printf(" returning integer value %d\n",temp.iValue);*/
33  }
34  else if (type == IF_REAL) {
35  temp.rValue = INPevaluate(line,&error,1);
36  /*printf(" returning real value %e\n",temp.rValue);*/
37  }
38  else if (type == IF_REALVEC) {
39  temp.v.numValue = 0;
40  list = (double *)tmalloc(sizeof(double));
41  tmp = INPevaluate(line,&error,1);
42  while (error == 0) {
43  /*printf(" returning vector value %g\n",tmp); */
44  temp.v.numValue++;
45  list = (double *)
46  trealloc((char *)list,temp.v.numValue*sizeof(double));
47  *(list+temp.v.numValue-1) = tmp;
48  tmp = INPevaluate(line,&error,1);
49  }
50  temp.v.vec.rVec=list;
51  }
52  else if (type == IF_FLAG) {
53  temp.iValue = 1;
54  }
55  else if (type == IF_NODE) {
56  INPgetTok(line,&word,1);
57  INPtermInsert(ckt,&word,tab,&(temp.nValue));
58  }
59  else if (type == IF_INSTANCE) {
60  INPgetTok(line,&word,1);
61  INPinsert(&word,tab);
62  temp.nValue = word;
63  }
64  else if (type == IF_STRING) {
65  INPgetTok(line,&word,1);
66  temp.sValue = word;
67  }
68  else if (type == IF_PARSETREE) {
69  INPgetTree(line, &pt, ckt, tab);
70  if (!pt)
71  return ((IFvalue *)NULL);
72  temp.tValue = (IFparseTree *) pt;
73  /*INPptPrint("Parse tree is: ", temp.tValue);*/
74  }
75  else { /* don't know what type of parameter caller is talking about! */
76  return ((IFvalue *)NULL);
77  }
78  return (&temp);
79 }
int numValue
Definition: ifsim.h:240
int INPtermInsert()
void INPgetTree()
union uIFvalue::@13::@14 vec
double INPevaluate()
#define IF_INSTANCE
Definition: ifsim.h:112
int iValue
Definition: ifsim.h:232
double rValue
Definition: ifsim.h:233
int INPinsert()
char * tmalloc()
Definition: fteinp.h:14
#define NULL
Definition: spdefs.h:121
Definition: types.c:18
IFnode nValue
Definition: ifsim.h:237
#define IF_INTEGER
Definition: ifsim.h:107
#define IF_REAL
Definition: ifsim.h:108
IFparseTree * tValue
Definition: ifsim.h:238
#define IF_FLAG
Definition: ifsim.h:106
#define IF_REALVEC
Definition: ifsim.h:125
#define IF_VARTYPES
Definition: ifsim.h:133
Definition: dir.c:53
struct uIFvalue::@13 v
char * sValue
Definition: ifsim.h:235
#define IF_STRING
Definition: ifsim.h:111
#define IF_NODE
Definition: ifsim.h:110
char * trealloc()
#define IF_PARSETREE
Definition: ifsim.h:113
int INPgetTok()