NEURON
consist.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 /* /local/src/master/nrn/src/modlunit/consist.c,v 1.2 1995/09/05 20:24:01 hines Exp */
3 
4 /*
5  * Check that names do not have conflicting types. This is done after the
6  * entire file is read in and allows declaring a variable after its use (very
7  * bad style) to work.
8  */
9 #include "model.h"
10 #include "parse1.hpp"
11 #include "symbol.h"
12 
13 extern Item** scop_indep;
14 
15 #define con(arg1, arg2, arg3) \
16  if (t & (arg2)) \
17  if (t & (~(arg2 | arg3))) { \
18  Fprintf(stderr, "%s is a %s\n", s->name, arg1); \
19  err = 1; \
20  }
21 
22 void consistency() {
23  int tu, err = 0;
24  long t;
25  Symbol* sindep;
26 
27 
28  /* the scop_indep can also be a automatic constant */
29  sindep = SYM(scop_indep[0]);
30  if (sindep != indepsym && sindep->subtype == (modlunitCONST | INDEP)) {
31  sindep->subtype = INDEP;
32  }
33 
34  SYMITERALL {
35  t = s->subtype;
36  con("KEYWORD", KEYWORD, 0);
37  con("CONSTANT", modlunitCONST, ARRAY);
38  con("INDEPENDENT", INDEP, 0);
39  con("DEPENDENT", DEP, ARRAY);
40  con("STATE", STAT, ARRAY);
41  con("FUNCTION", FUNCT, 0);
42  con("PROCEDURE", PROCED, 0);
43  con("DERIVATIVE", DERF, 0);
44  con(" KINETIC", KINF, 0);
45  con("LINEAR", LINF, 0);
46  con("NONLINEAR", NLINF, 0);
47  con("DISCRETE", DISCF, 0);
48  con("PARTIAL", PARF, 0);
49  tu = s->usage;
50  if ((tu & DEP) && (tu & FUNCT))
51  diag(s->name, "used as both variable and function");
52  if ((t == 0) && tu)
53  Fprintf(stderr, "Warning: %s undefined. (declared within VERBATIM?)\n", s->name);
54  }
55 }
56 if (err) {
57  diag("multiple uses for same variable", (char*) 0);
58 }
59 if (indepsym == SYM0) {
60  diag("Independent variable is not defined", (char*) 0);
61 }
62 }
63 
64 /* consist.c,v
65  * Revision 1.2 1995/09/05 20:24:01 hines
66  * paramter arrays and limits syntax is now < a, b >
67  *
68  * Revision 1.1.1.1 1994/10/12 17:22:47 hines
69  * NEURON 3.0 distribution
70  *
71  * Revision 1.1 90/11/13 16:09:24 hines
72  * Initial revision
73  * */
#define DEP
Definition: membfunc.hpp:64
#define DERF
Definition: model.h:114
#define FUNCT
Definition: model.h:108
#define SYM0
Definition: model.h:63
#define LINF
Definition: model.h:115
#define STAT
Definition: model.h:106
#define DISCF
Definition: model.h:117
#define INDEP
Definition: model.h:104
#define modlunitCONST
Definition: model.h:103
#define PARF
Definition: model.h:118
#define SYM(q)
Definition: model.h:75
#define KINF
Definition: model.h:120
#define KEYWORD
Definition: model.h:102
#define NLINF
Definition: model.h:116
#define ARRAY
Definition: model.h:107
#define PROCED
Definition: model.h:109
Item ** scop_indep
Definition: declare.cpp:9
#define con(arg1, arg2, arg3)
Definition: consist.cpp:15
void consistency()
Definition: consist.cpp:22
#define SYMITERALL
Definition: symbol.h:4
Symbol * indepsym
Definition: declare.cpp:8
#define diag(s)
Definition: nonlin.cpp:19
s
Definition: multisend.cpp:521
Definition: model.h:8
Definition: model.h:47
long subtype
Definition: model.h:49
int Fprintf(FILE *stream, const char *fmt, Args... args)
Definition: logger.hpp:8