Jspice3
inpgval.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include "inpdefs.h"
10 #include "misc.h"
11 
12 
13 IFvalue *
15 
16 GENERIC *ckt;
17 char ** line;
18 int type;
19 INPtables *tab;
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()
Definition: subckt.c:51
#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
IFvalue * INPgetValue(GENERIC *ckt, char **line, int type, INPtables *tab)
Definition: inpgval.c:14
char * trealloc()
char GENERIC
Definition: ifsim.h:27
#define IF_PARSETREE
Definition: ifsim.h:113
int INPgetTok()