author | etisserant |
Mon, 18 Jun 2007 14:45:03 +0200 | |
changeset 33 | 4507beb2aac6 |
parent 32 | 289256ec66f1 |
child 35 | 9f3d6c089533 |
permissions | -rw-r--r-- |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
1 |
/* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
2 |
* (c) 2003 Mario de Sousa |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
3 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
4 |
* Offered to the public under the terms of the GNU General Public License |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
5 |
* as published by the Free Software Foundation; either version 2 of the |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
6 |
* License, or (at your option) any later version. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
7 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
8 |
* This program is distributed in the hope that it will be useful, but |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
9 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
11 |
* Public License for more details. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
12 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
13 |
* This code is made available on the understanding that it will not be |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
14 |
* used in safety-critical situations without a full and competent review. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
15 |
*/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
16 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
17 |
/* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
18 |
* An IEC 61131-3 IL and ST compiler. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
19 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
20 |
* Based on the |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
21 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
22 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
23 |
*/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
24 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
25 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
26 |
/* Determine the data type of an ST expression. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
27 |
* A reference to the relevant type definition is returned. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
28 |
* |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
29 |
* For example: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
30 |
* 2 + 3 -> returns reference to a int_type_name_c object. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
31 |
* 22.2 - 5 -> returns reference to a real_type_name_c object. |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
32 |
* etc... |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
33 |
*/ |
32 | 34 |
|
33 | 35 |
#include "function_type_decl.h" |
36 |
#include "get_function_type_decl.c" |
|
37 |
||
38 |
#if 0 |
|
32 | 39 |
typedef enum {function_add, |
40 |
function_sub, |
|
41 |
function_and, |
|
42 |
function_or, |
|
43 |
function_sqrt, |
|
44 |
function_none} function_type_t; |
|
45 |
||
46 |
||
47 |
function_type_t get_function_type(identifier_c *function_name) { |
|
48 |
if (!strcasecmp(function_name->value, "ADD")) |
|
49 |
return function_add; |
|
50 |
else if (!strcasecmp(function_name->value, "SUB")) |
|
51 |
return function_sub; |
|
52 |
else if (!strcasecmp(function_name->value, "AND")) |
|
53 |
return function_and; |
|
54 |
else if (!strcasecmp(function_name->value, "OR")) |
|
55 |
return function_or; |
|
56 |
else if (!strcasecmp(function_name->value, "SQRT")) |
|
57 |
return function_sqrt; |
|
58 |
else return function_none; |
|
59 |
} |
|
33 | 60 |
#endif |
32 | 61 |
|
62 |
||
63 |
symbol_c *generate_param_name(const char *name) { |
|
64 |
symbol_c *param_name = new identifier_c(name); |
|
65 |
return param_name; |
|
66 |
} |
|
67 |
||
68 |
||
69 |
symbol_c *generate_param_name(const char *format, int number) { |
|
70 |
char name[10]; |
|
71 |
sprintf(name, format, number); |
|
72 |
symbol_c *param_name = new identifier_c(name); |
|
73 |
return param_name; |
|
74 |
} |
|
75 |
||
76 |
||
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
77 |
class search_expression_type_c: public search_constant_type_c { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
78 |
private: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
79 |
search_varfb_instance_type_c *search_varfb_instance_type; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
80 |
search_base_type_c search_base_type; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
81 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
82 |
public: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
83 |
search_expression_type_c(symbol_c *search_scope) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
84 |
search_varfb_instance_type = new search_varfb_instance_type_c(search_scope); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
85 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
86 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
87 |
virtual ~search_expression_type_c(void) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
88 |
delete search_varfb_instance_type; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
89 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
90 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
91 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
92 |
bool is_bool_type(symbol_c *type_symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
93 |
return (typeid(*type_symbol) == typeid(bool_type_name_c)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
94 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
95 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
96 |
/* A helper function... */ |
32 | 97 |
bool is_time_type(symbol_c *type_symbol) { |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
98 |
if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
99 |
if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
100 |
if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
101 |
if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
102 |
return false; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
103 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
104 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
105 |
/* A helper function... */ |
32 | 106 |
bool is_integer_type(symbol_c *type_symbol) { |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
107 |
if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
108 |
if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
109 |
if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
110 |
if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
111 |
if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
112 |
if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
113 |
if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
114 |
if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
32 | 115 |
if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
116 |
return false; |
|
117 |
} |
|
118 |
||
119 |
bool is_real_type(symbol_c *type_symbol) { |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
120 |
if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
121 |
if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
32 | 122 |
if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
123 |
return false; |
|
124 |
} |
|
125 |
||
126 |
bool is_num_type(symbol_c *type_symbol) { |
|
127 |
return is_real_type(type_symbol) || is_integer_type(type_symbol); |
|
128 |
} |
|
129 |
||
130 |
bool is_binary_type(symbol_c *type_symbol) { |
|
17
38754701ac41
SFC state machine first approach generator implemented
lbessard
parents:
16
diff
changeset
|
131 |
if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
132 |
if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
133 |
if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
134 |
if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
135 |
if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
32 | 136 |
if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
137 |
return false; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
138 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
139 |
|
32 | 140 |
bool is_same_type(symbol_c *first_type, symbol_c *second_type) { |
141 |
if (typeid(*first_type) == typeid(*second_type)) {return true;} |
|
142 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
143 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
|
144 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
145 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
|
146 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
|
147 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
|
148 |
return false; |
|
149 |
} |
|
150 |
||
151 |
symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
|
152 |
if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
|
153 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
154 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return second_type;} |
|
155 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
156 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return second_type;} |
|
157 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;} |
|
158 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return second_type;} |
|
159 |
return NULL; |
|
160 |
} |
|
161 |
||
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
162 |
private: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
163 |
|
32 | 164 |
void *compute_standard_function_st(function_invocation_c *symbol) { |
33 | 165 |
#if 0 |
32 | 166 |
symbol_c *current_type = NULL; |
167 |
symbol_c *return_type = NULL; |
|
33 | 168 |
#endif |
169 |
||
32 | 170 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
171 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
33 | 172 |
search_expression_type_c* search_expression_type = this; |
173 |
#include "search_type_code.c" |
|
174 |
||
175 |
#if 0 |
|
32 | 176 |
for(int current_param = 0; current_param < ((list_c *)symbol->parameter_assignment_list)->n; current_param++) { |
177 |
symbol_c *param_name = NULL; |
|
178 |
switch (current_function_type) { |
|
179 |
case function_add: |
|
180 |
case function_and: |
|
181 |
case function_or: |
|
182 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
183 |
break; |
|
184 |
case function_sub: |
|
185 |
if (current_param < 2) |
|
186 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
187 |
else ERROR; |
|
188 |
break; |
|
189 |
default: ERROR; |
|
190 |
} |
|
191 |
||
192 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
193 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
194 |
delete param_name; |
|
195 |
||
196 |
/* Get the value from a foo(<param_value>) style call */ |
|
197 |
if (param_value == NULL) |
|
198 |
param_value = function_call_param_iterator.next(); |
|
199 |
||
200 |
if (param_value == NULL) ERROR; |
|
201 |
||
202 |
symbol_c *param_type = (symbol_c *)param_value->accept(*this); |
|
203 |
||
204 |
switch (current_function_type) { |
|
205 |
case function_add: |
|
206 |
if (current_param == 0) |
|
207 |
current_type = param_type; |
|
208 |
else if (current_param == 1) { |
|
209 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
210 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) { |
|
211 |
current_type = common_type(current_type, param_type); |
|
212 |
return_type = current_type; |
|
213 |
} |
|
214 |
else if (is_time_type(current_type)) { |
|
215 |
if ((typeid(*current_type) == typeid(time_type_name_c)) && (typeid(*param_type) == typeid(time_type_name_c))) {return_type = (symbol_c *)&time_type_name;} |
|
216 |
else if (typeid(*current_type) == typeid(tod_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&tod_type_name;} |
|
217 |
else if (typeid(*current_type) == typeid(dt_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&dt_type_name;} |
|
218 |
else ERROR; |
|
219 |
} |
|
220 |
else ERROR; |
|
221 |
} |
|
222 |
else if (!is_time_type(current_type) && is_same_type(current_type, param_type)) { |
|
223 |
current_type = common_type(current_type, param_type); |
|
224 |
return_type = current_type; |
|
225 |
} |
|
226 |
else ERROR; |
|
227 |
break; |
|
228 |
case function_sub: |
|
229 |
if (current_param == 0) |
|
230 |
current_type = param_type; |
|
231 |
else if (current_param == 1) { |
|
232 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
233 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) |
|
234 |
return_type = common_type(current_type, param_type); |
|
235 |
else if (is_time_type(current_type)) { |
|
236 |
if (typeid(*current_type) == typeid(time_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
237 |
else if (typeid(*current_type) == typeid(date_type_name_c) && typeid(*param_type) == typeid(date_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
238 |
else if (typeid(*current_type) == typeid(tod_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&tod_type_name;} |
|
239 |
else if (typeid(*current_type) == typeid(tod_type_name_c) && typeid(*param_type) == typeid(tod_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
240 |
else if (typeid(*current_type) == typeid(dt_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&dt_type_name;} |
|
241 |
else if (typeid(*current_type) == typeid(dt_type_name_c) && typeid(*param_type) == typeid(dt_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
242 |
else ERROR; |
|
243 |
} |
|
244 |
else ERROR; |
|
245 |
} |
|
246 |
else ERROR; |
|
247 |
break; |
|
248 |
case function_and: |
|
249 |
case function_or: |
|
250 |
if (current_param == 0) |
|
251 |
if (is_binary_type(param_type)) |
|
252 |
current_type = param_type; |
|
253 |
else ERROR; |
|
254 |
else if (is_same_type(current_type, param_type)) |
|
255 |
return_type = common_type(current_type, param_type); |
|
256 |
else ERROR; |
|
257 |
break; |
|
258 |
default: ERROR; |
|
259 |
} |
|
260 |
} |
|
261 |
return (void *)return_type; |
|
33 | 262 |
#endif |
263 |
||
32 | 264 |
} |
265 |
||
266 |
public: |
|
267 |
||
268 |
void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_type) { |
|
33 | 269 |
/*symbol_c *current_type = NULL;*/ |
32 | 270 |
symbol_c *return_type = NULL; |
271 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
|
272 |
if (current_function_type == function_none) ERROR; |
|
273 |
||
274 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
275 |
||
276 |
int nb_param = 1; |
|
277 |
if (symbol->il_operand_list != NULL) |
|
278 |
nb_param += ((list_c *)symbol->il_operand_list)->n; |
|
279 |
||
280 |
for(int current_param = 0; current_param < nb_param; current_param++) { |
|
281 |
||
282 |
if (current_param != 0) { |
|
283 |
symbol_c *param_name = NULL; |
|
284 |
switch (current_function_type) { |
|
285 |
default: ERROR; |
|
286 |
} |
|
287 |
||
288 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
289 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
290 |
delete param_name; |
|
291 |
||
292 |
/* Get the value from a foo(<param_value>) style call */ |
|
293 |
if (param_value == NULL) |
|
294 |
param_value = function_call_param_iterator.next(); |
|
295 |
||
296 |
if (param_value == NULL) ERROR; |
|
297 |
||
298 |
param_type = (symbol_c *)param_value->accept(*this); |
|
299 |
} |
|
300 |
||
301 |
switch (current_function_type) { |
|
302 |
case function_sqrt: |
|
303 |
if (current_param == 0 && is_real_type(param_type)) |
|
304 |
return_type = param_type; |
|
305 |
else ERROR; |
|
306 |
break; |
|
307 |
default: ERROR; |
|
308 |
} |
|
309 |
} |
|
310 |
||
311 |
return (void *)return_type; |
|
312 |
} |
|
313 |
||
33 | 314 |
/*static bool_type_name_c bool_type_name;*/ |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
315 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
316 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
317 |
void *compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 318 |
if (!is_same_type(left_type, right_type)) |
319 |
ERROR; |
|
320 |
if (!is_bool_type(left_type) && !is_binary_type(left_type)) |
|
321 |
ERROR; |
|
322 |
if (typeid(*left_type) == typeid(constant_int_type_name_c)) {return (void *)right_type;} |
|
323 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
324 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
325 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
326 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
327 |
void *compute_numeric_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 328 |
if (!is_same_type(left_type, right_type)) |
329 |
ERROR; |
|
330 |
if (!is_integer_type(left_type) && !is_real_type(left_type)) |
|
331 |
ERROR; |
|
332 |
if ((typeid(*left_type) == typeid(constant_int_type_name_c)) || (typeid(*left_type) == typeid(constant_real_type_name_c))) {return (void *)right_type;} |
|
333 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
334 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
335 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
336 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
337 |
/* a helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
338 |
symbol_c *base_type(symbol_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
339 |
return (symbol_c *)symbol->accept(search_base_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
340 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
341 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
342 |
/*********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
343 |
/* B 1.4 - Variables */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
344 |
/*********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
345 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
346 |
void *visit(symbolic_variable_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
347 |
symbol_c *res; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
348 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
349 |
/* Nope, now we assume it is a variable, and determine its type... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
350 |
res = search_varfb_instance_type->get_type(symbol); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
351 |
if (NULL != res) return res; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
352 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
353 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
354 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
355 |
|
22
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
356 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
357 |
/* B 1.4.2 - Multi-element variables */ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
358 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
359 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
360 |
void *visit(array_variable_c *symbol) { |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
361 |
symbol_c *res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
362 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
363 |
/* Nope, now we assume it is a variable, and determine its type... */ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
364 |
res = search_varfb_instance_type->get_type(symbol); |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
365 |
if (NULL != res) return res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
366 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
367 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
368 |
} |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
369 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
370 |
void *visit(structured_variable_c *symbol) { |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
371 |
symbol_c *res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
372 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
373 |
/* Nope, now we assume it is a variable, and determine its type... */ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
374 |
res = search_varfb_instance_type->get_type(symbol); |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
375 |
if (NULL != res) return res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
376 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
377 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
378 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
379 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
380 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
381 |
/* B.3 - Language ST (Structured Text) */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
382 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
383 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
384 |
/* B 3.1 - Expressions */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
385 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
386 |
void *visit(or_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
387 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
388 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
389 |
return compute_boolean_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
390 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
391 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
392 |
void *visit(xor_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
393 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
394 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
395 |
return compute_boolean_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
396 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
397 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
398 |
void *visit(and_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
399 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
400 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
401 |
return compute_boolean_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
402 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
403 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
404 |
void *visit(equ_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
405 |
void *visit(notequ_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
406 |
void *visit(lt_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
407 |
void *visit(gt_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
408 |
void *visit(le_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
409 |
void *visit(ge_expression_c *symbol) {return (void *)&bool_type_name;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
410 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
411 |
void *visit(add_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
412 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
413 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 414 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
415 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
416 |
if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
417 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
418 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
419 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
420 |
void *visit(sub_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
421 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
422 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 423 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
424 |
if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;} |
|
425 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
426 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_type_name;} |
|
427 |
if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
|
428 |
if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)) {return (void *)&time_type_name;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
429 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
430 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
431 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
432 |
void *visit(mul_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
433 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
434 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 435 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
436 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_real_type(right_type)) {return (void *)&time_type_name;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
437 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
438 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
439 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
440 |
void *visit(div_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
441 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
442 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 443 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
444 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_real_type(right_type)) {return (void *)&time_type_name;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
445 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
446 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
447 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
448 |
void *visit(mod_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
449 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
450 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
451 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
452 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
453 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
454 |
void *visit(power_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
455 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
456 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
457 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(sint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
458 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(int_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
459 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(dint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
460 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(lint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
461 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(usint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
462 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(uint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
463 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(udint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
464 |
if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(ulint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
465 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(sint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
466 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(int_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
467 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(dint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
468 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(lint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
469 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(usint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
470 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(uint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
471 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(udint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
472 |
if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(ulint_type_name_c)) {return (void *)left_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
473 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
474 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
475 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
476 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
477 |
void *visit(neg_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
478 |
symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
479 |
if (typeid(*exp_type) == typeid(sint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
480 |
if (typeid(*exp_type) == typeid(int_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
481 |
if (typeid(*exp_type) == typeid(dint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
482 |
if (typeid(*exp_type) == typeid(lint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
483 |
if (typeid(*exp_type) == typeid(usint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
484 |
if (typeid(*exp_type) == typeid(uint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
485 |
if (typeid(*exp_type) == typeid(udint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
486 |
if (typeid(*exp_type) == typeid(ulint_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
487 |
if (typeid(*exp_type) == typeid(real_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
488 |
if (typeid(*exp_type) == typeid(lreal_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
489 |
if (typeid(*exp_type) == typeid(time_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
490 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
491 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
492 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
493 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
494 |
void *visit(not_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
495 |
symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
496 |
if (typeid(*exp_type) == typeid(bool_type_name_c)) {return (void *)exp_type;} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
497 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
498 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
499 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
500 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
501 |
void *visit(function_invocation_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
502 |
function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
503 |
|
32 | 504 |
if (f_decl == function_symtable.end_value()) { |
505 |
void *res = compute_standard_function_st(symbol); |
|
506 |
if (res == NULL) |
|
507 |
ERROR; |
|
508 |
return res; |
|
509 |
} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
510 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
511 |
return base_type(f_decl->type_name); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
512 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
513 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
514 |
}; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
515 |
|
33 | 516 |
/*bool_type_name_c search_expression_type_c::bool_type_name;*/ |
517 |