My Project
programmer's documentation
Loading...
Searching...
No Matches
mei_node.h
Go to the documentation of this file.
1#ifndef __MEI_NODE_H__
2#define __MEI_NODE_H__
3
10/*
11 This file is part of Code_Saturne, a general-purpose CFD tool.
12
13 Copyright (C) 1998-2019 EDF S.A.
14
15 This program is free software; you can redistribute it and/or modify it under
16 the terms of the GNU General Public License as published by the Free Software
17 Foundation; either version 2 of the License, or (at your option) any later
18 version.
19
20 This program is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 details.
24
25 You should have received a copy of the GNU General Public License along with
26 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27 Street, Fifth Floor, Boston, MA 02110-1301, USA.
28*/
29
30/*----------------------------------------------------------------------------*/
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36
37/*----------------------------------------------------------------------------
38 * Local headers
39 *----------------------------------------------------------------------------*/
40
41#include "mei_hash_table.h"
42
43/*============================================================================
44 * Type definitions
45 *============================================================================*/
46
51typedef struct
52{
53 double value;
55
60typedef struct
61{
62 char *i;
63 int l;
64 int c;
65} id_node_t;
66
71typedef struct
72{
73 char *name;
74 int l;
75 int c;
76 struct _mei_node_t *op;
78
83typedef struct
84{
85 char *name;
86 int l;
87 int c;
88 int nops;
89 struct _mei_node_t *op[];
91
96typedef struct
97{
98 int oper;
99 int nops;
100 struct _mei_node_t *op[];
101} opr_node_t;
102
107typedef union
108{
109 const_node_t con; /* constants */
110 id_node_t id; /* identifiers */
111 func_node_t func; /* function with one argument */
112 func2_node_t funcx; /* function with two, three, or four arguments */
113 opr_node_t opr; /* operators */
115
120/* union must be last entry in _mei_node_t */
121/* because operNodeType may dynamically increase */
122
124{
126 hash_table_t *ht;
128};
129
134typedef struct _mei_node_t mei_node_t;
135
136/*============================================================================
137 * Public function prototypes
138 *============================================================================*/
139
140/*----------------------------------------------------------------------------*/
141/* Build a node for a constant.
142 *
143 * param [in] value real value of the constant
144 *
145 * return built node
146 */
147/*----------------------------------------------------------------------------*/
148
149mei_node_t *
150mei_const_node(const double value);
151
152/*----------------------------------------------------------------------------*/
153/* Build a node for a variable.
154 *
155 * param [in] variable label of the variable
156 *
157 * return built node
158 */
159/*----------------------------------------------------------------------------*/
160
161mei_node_t *
162mei_id_node(const char *variable);
163
164/*----------------------------------------------------------------------------*/
165/* Build a node for a function of a single variable.
166 *
167 * param [in] function label of the function
168 * param [in] expr node that represents the variable of the function
169 *
170 * return built node
171 */
172/*----------------------------------------------------------------------------*/
173
174mei_node_t *
175mei_func_node(const char *const,
176 mei_node_t *const expr);
177
178/*----------------------------------------------------------------------------*/
179/* Build a node for a function of a several variables.
180 *
181 * param [in] function label of the function
182 * param [in] nops number of variables
183 * param [in] ... list of nodes which represent variables of the function
184 *
185 * return built node
186 */
187/*----------------------------------------------------------------------------*/
188
189mei_node_t *
190mei_funcx_node(const char *function,
191 const int nops,
192 ...);
193
194/*----------------------------------------------------------------------------*/
195/*
196 * Build a node for an operators and its operands.
197 *
198 * param [in] oper operator
199 * param [in] nops number of operand
200 * param [in] ... list of nodes which represent operands
201 *
202 * return built node
203 */
204/*----------------------------------------------------------------------------*/
205
206mei_node_t *
207mei_opr_node(const int oper,
208 const int nops,
209 ...);
210
211/*----------------------------------------------------------------------------*/
212/*
213 * Return label of a node.
214 *
215 * param [in] n node
216 *
217 * return label of a node
218 */
219/*----------------------------------------------------------------------------*/
220
221char *
222mei_label_node(mei_node_t *p);
223
224/*----------------------------------------------------------------------------*/
225/*
226 * Free memory.
227 *
228 * param [in] n node
229 */
230/*----------------------------------------------------------------------------*/
231
232void
233mei_free_node(mei_node_t *p);
234
235/*----------------------------------------------------------------------------*/
236
237#ifdef __cplusplus
238}
239 #endif /* __cplusplus */
240
241#endif /* __NODE_H__ */
242
@ p
Definition cs_field_pointer.h:67
Hash table, intended to provide a symbol table.
mei_flag_t
List of the different type of symbol.
Definition mei_hash_table.h:49
char * mei_label_node(mei_node_t *p)
Return label of a node.
Definition mei_node.c:273
mei_node_t * mei_id_node(const char *variable)
Build a node for a variable.
Definition mei_node.c:105
mei_node_t * mei_opr_node(const int oper, const int nops,...)
Build a node for an operators and its operands.
Definition mei_node.c:235
mei_node_t * mei_const_node(const double value)
Build a node for a constant.
Definition mei_node.c:79
mei_node_t * mei_func_node(const char *const, mei_node_t *const expr)
Build a node for a function of a single variable.
Definition mei_node.c:139
void mei_free_node(mei_node_t *p)
Free memory.
Definition mei_node.c:311
mei_node_t * mei_funcx_node(const char *function, const int nops,...)
Build a node for a function of a several variables.
Definition mei_node.c:178
General node definition.
Definition mei_node.h:124
node_type_t * type
Definition mei_node.h:127
hash_table_t * ht
Definition mei_node.h:126
mei_flag_t flag
Definition mei_node.h:125
Constants node.
Definition mei_node.h:52
double value
Definition mei_node.h:53
Function with two arguments node.
Definition mei_node.h:84
int c
Definition mei_node.h:87
char * name
Definition mei_node.h:85
int l
Definition mei_node.h:86
int nops
Definition mei_node.h:88
Function with single argument node.
Definition mei_node.h:72
int c
Definition mei_node.h:75
char * name
Definition mei_node.h:73
int l
Definition mei_node.h:74
struct _mei_node_t * op
Definition mei_node.h:76
Identifiers node.
Definition mei_node.h:61
int c
Definition mei_node.h:64
int l
Definition mei_node.h:63
char * i
Definition mei_node.h:62
Operators node.
Definition mei_node.h:97
int nops
Definition mei_node.h:99
int oper
Definition mei_node.h:98
Type of a node.
Definition mei_node.h:108
opr_node_t opr
Definition mei_node.h:113
func2_node_t funcx
Definition mei_node.h:112
id_node_t id
Definition mei_node.h:110
const_node_t con
Definition mei_node.h:109
func_node_t func
Definition mei_node.h:111