1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*   File....: mme.h                                                         */
4 /*   Name....: Mathematical Modelling Engine                                 */
5 /*   Author..: Thorsten Koch                                                 */
6 /*   Copyright by Author, All rights reserved                                */
7 /*                                                                           */
8 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9 /*
10  * Copyright (C) 2001-2018 by Thorsten Koch <koch@zib.de>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 3
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25  */
26 #ifndef _MME_H_
27 #define _MME_H_
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define ZIMPL_VERSION  336
34 
35 /* the following is not in code.h because code.h needs mme.h anyway,
36  * but we also need these declaratons.
37  */
38 enum code_type
39 {
40    CODE_ERR = 0, CODE_NUMB, CODE_STRG, CODE_NAME, CODE_TUPLE,
41    CODE_SET, CODE_TERM, CODE_BOOL, CODE_SIZE,
42    CODE_IDXSET, CODE_LIST, CODE_VOID, CODE_ENTRY, CODE_VARCLASS, CODE_CONTYPE,
43    CODE_RDEF, CODE_RPAR, CODE_BITS, CODE_SYM, CODE_DEF, CODE_BOUND
44 };
45 
46 enum symbol_type     { SYM_ERR = 0, SYM_NUMB, SYM_STRG, SYM_SET, SYM_VAR };
47 
48 typedef enum symbol_type         SymbolType;
49 typedef struct symbol            Symbol;
50 typedef enum code_type           CodeType;
51 typedef struct code_node         CodeNode;
52 
53 typedef CodeNode*              (*Inst)(CodeNode* self);
54 
55 typedef struct entry             Entry;
56 
57 typedef struct list_element      ListElem;
58 typedef struct list              List;
59 
60 typedef enum   var_type      VarType;  /* From ratlptypes.h */
61 typedef struct mono          Mono;     /* From mono.h */
62 
63 
64 #define SYMBOL_NAME_INTERNAL  "@@"
65 
66 #define VERB_QUIET    0
67 #define VERB_NORMAL   1
68 #define VERB_VERBOSE  2
69 #define VERB_CHATTER  3
70 #define VERB_DEBUG    5
71 
72 /* zimpllib.c
73  */
74 extern int          verbose;
75 /*lint -function(exit,zpl_exit) */
76 extern void         zpl_exit(int retval);
77 
78 /* source.c
79  */
80 /*lint -sem(        show_source, nulterm(2), 1p == 1 && 2p) */
81 extern void         show_source(FILE* fp, const char* text, int column);
82 
83 /* vinst.c
84  */
85 extern void interns_init(void);
86 extern void interns_exit(void);
87 
88 #define Min(a, b)    (((a) <= (b)) ? (a) : (b))
89 #define Sgn(a)       (((a) > 0) ? 1 : (((a) < 0) ? -1 : 0))
90 
91 /* Directory separator, so we could redefine it for Windoof.
92  */
93 #ifndef DIRSEP
94 #define DIRSEP '/'
95 #endif /* DIRSEP */
96 
97 #ifndef NDEBUG
98 #define SID unsigned int sid;
99 #define SID_set(p, id)  (p->sid = id)
100 #define SID_del(p)      (p->sid = 0xffffffff)
101 #define SID_ok(p, id)   (p->sid == id)
102 #define SID_set2(p, id) (p.sid = id)
103 #define SID_del2(p)     (p.sid = 0xffffffff)
104 #define SID_ok2(p, id)  (p.sid == id)
105 #else /* NDEBUG */
106 #define SID              /* */
107 #define SID_set(p, sid)  /* */
108 #define SID_del(p)       /* */
109 #define SID_ok(p, id)    true
110 #define SID_set2(p, sid) /* */
111 #define SID_del2(p)      /* */
112 #define SID_ok2(p, id)   true
113 #endif /* NDEBUG */
114 
115 #define DISPERSE(x) (1664525U * (x) + 1013904223U)
116 
117 #ifdef TRACE
118 #define Trace(fname) fprintf(stderr, "Trace: %s\n", fname);
119 #else
120 #define Trace(fname) /* */
121 #endif /* TRACE */
122 
123 #if defined(__GNUC__) || defined(__CLANG__)
124 #define UNUSED __attribute__ ((unused))
125 #define NORETURN __attribute__ ((noreturn))
126 #else
127 #define UNUSED
128 #define NORETURN
129 #endif /* __GNUC__ || __CLANG__ */
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _MME_H_ */
136