author | lbessard |
Thu, 21 Jun 2007 10:22:32 +0200 | |
changeset 35 | 9f3d6c089533 |
parent 33 | 4507beb2aac6 |
child 38 | 6cce7d14647e |
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 |
} |
|
35 | 161 |
|
162 |
#include "search_type_code.c" |
|
163 |
||
164 |
#if 0 |
|
32 | 165 |
void *compute_standard_function_st(function_invocation_c *symbol) { |
166 |
symbol_c *current_type = NULL; |
|
167 |
symbol_c *return_type = NULL; |
|
33 | 168 |
|
32 | 169 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
170 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
33 | 171 |
search_expression_type_c* search_expression_type = this; |
35 | 172 |
|
32 | 173 |
for(int current_param = 0; current_param < ((list_c *)symbol->parameter_assignment_list)->n; current_param++) { |
174 |
symbol_c *param_name = NULL; |
|
175 |
switch (current_function_type) { |
|
176 |
case function_add: |
|
177 |
case function_and: |
|
178 |
case function_or: |
|
179 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
180 |
break; |
|
181 |
case function_sub: |
|
182 |
if (current_param < 2) |
|
183 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
184 |
else ERROR; |
|
185 |
break; |
|
186 |
default: ERROR; |
|
187 |
} |
|
188 |
||
189 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
190 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
191 |
delete param_name; |
|
192 |
||
193 |
/* Get the value from a foo(<param_value>) style call */ |
|
194 |
if (param_value == NULL) |
|
195 |
param_value = function_call_param_iterator.next(); |
|
196 |
||
197 |
if (param_value == NULL) ERROR; |
|
198 |
||
199 |
symbol_c *param_type = (symbol_c *)param_value->accept(*this); |
|
200 |
||
201 |
switch (current_function_type) { |
|
202 |
case function_add: |
|
203 |
if (current_param == 0) |
|
204 |
current_type = param_type; |
|
205 |
else if (current_param == 1) { |
|
206 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
207 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) { |
|
208 |
current_type = common_type(current_type, param_type); |
|
209 |
return_type = current_type; |
|
210 |
} |
|
211 |
else if (is_time_type(current_type)) { |
|
212 |
if ((typeid(*current_type) == typeid(time_type_name_c)) && (typeid(*param_type) == typeid(time_type_name_c))) {return_type = (symbol_c *)&time_type_name;} |
|
213 |
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;} |
|
214 |
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;} |
|
215 |
else ERROR; |
|
216 |
} |
|
217 |
else ERROR; |
|
218 |
} |
|
219 |
else if (!is_time_type(current_type) && is_same_type(current_type, param_type)) { |
|
220 |
current_type = common_type(current_type, param_type); |
|
221 |
return_type = current_type; |
|
222 |
} |
|
223 |
else ERROR; |
|
224 |
break; |
|
225 |
case function_sub: |
|
226 |
if (current_param == 0) |
|
227 |
current_type = param_type; |
|
228 |
else if (current_param == 1) { |
|
229 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
230 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) |
|
231 |
return_type = common_type(current_type, param_type); |
|
232 |
else if (is_time_type(current_type)) { |
|
233 |
if (typeid(*current_type) == typeid(time_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
234 |
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;} |
|
235 |
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;} |
|
236 |
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;} |
|
237 |
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;} |
|
238 |
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;} |
|
239 |
else ERROR; |
|
240 |
} |
|
241 |
else ERROR; |
|
242 |
} |
|
243 |
else ERROR; |
|
244 |
break; |
|
245 |
case function_and: |
|
246 |
case function_or: |
|
247 |
if (current_param == 0) |
|
248 |
if (is_binary_type(param_type)) |
|
249 |
current_type = param_type; |
|
250 |
else ERROR; |
|
251 |
else if (is_same_type(current_type, param_type)) |
|
252 |
return_type = common_type(current_type, param_type); |
|
253 |
else ERROR; |
|
254 |
break; |
|
255 |
default: ERROR; |
|
256 |
} |
|
257 |
} |
|
258 |
return (void *)return_type; |
|
35 | 259 |
} |
32 | 260 |
|
261 |
void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_type) { |
|
33 | 262 |
/*symbol_c *current_type = NULL;*/ |
32 | 263 |
symbol_c *return_type = NULL; |
264 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
|
265 |
if (current_function_type == function_none) ERROR; |
|
266 |
||
267 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
268 |
||
269 |
int nb_param = 1; |
|
270 |
if (symbol->il_operand_list != NULL) |
|
271 |
nb_param += ((list_c *)symbol->il_operand_list)->n; |
|
272 |
||
273 |
for(int current_param = 0; current_param < nb_param; current_param++) { |
|
274 |
||
275 |
if (current_param != 0) { |
|
276 |
symbol_c *param_name = NULL; |
|
277 |
switch (current_function_type) { |
|
278 |
default: ERROR; |
|
279 |
} |
|
280 |
||
281 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
282 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
283 |
delete param_name; |
|
284 |
||
285 |
/* Get the value from a foo(<param_value>) style call */ |
|
286 |
if (param_value == NULL) |
|
287 |
param_value = function_call_param_iterator.next(); |
|
288 |
||
289 |
if (param_value == NULL) ERROR; |
|
290 |
||
291 |
param_type = (symbol_c *)param_value->accept(*this); |
|
292 |
} |
|
293 |
||
294 |
switch (current_function_type) { |
|
295 |
case function_sqrt: |
|
296 |
if (current_param == 0 && is_real_type(param_type)) |
|
297 |
return_type = param_type; |
|
298 |
else ERROR; |
|
299 |
break; |
|
300 |
default: ERROR; |
|
301 |
} |
|
302 |
} |
|
303 |
||
304 |
return (void *)return_type; |
|
305 |
} |
|
35 | 306 |
#endif |
32 | 307 |
|
33 | 308 |
/*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
|
309 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
310 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
311 |
void *compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 312 |
if (!is_same_type(left_type, right_type)) |
313 |
ERROR; |
|
314 |
if (!is_bool_type(left_type) && !is_binary_type(left_type)) |
|
315 |
ERROR; |
|
316 |
if (typeid(*left_type) == typeid(constant_int_type_name_c)) {return (void *)right_type;} |
|
317 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
318 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
319 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
320 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
321 |
void *compute_numeric_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 322 |
if (!is_same_type(left_type, right_type)) |
323 |
ERROR; |
|
324 |
if (!is_integer_type(left_type) && !is_real_type(left_type)) |
|
325 |
ERROR; |
|
326 |
if ((typeid(*left_type) == typeid(constant_int_type_name_c)) || (typeid(*left_type) == typeid(constant_real_type_name_c))) {return (void *)right_type;} |
|
327 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
328 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
329 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
330 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
331 |
/* a helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
332 |
symbol_c *base_type(symbol_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
333 |
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
|
334 |
} |
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 |
/* B 1.4 - Variables */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
338 |
/*********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
339 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
340 |
void *visit(symbolic_variable_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
341 |
symbol_c *res; |
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 |
/* 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
|
344 |
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
|
345 |
if (NULL != res) return res; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
346 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
347 |
return NULL; |
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 |
|
22
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
350 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
351 |
/* 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
|
352 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
353 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
354 |
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
|
355 |
symbol_c *res; |
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 |
/* 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
|
358 |
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
|
359 |
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
|
360 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
361 |
return NULL; |
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 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
364 |
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
|
365 |
symbol_c *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 |
/* 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
|
368 |
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
|
369 |
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
|
370 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
371 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
372 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
373 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
374 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
375 |
/* B.3 - Language ST (Structured Text) */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
376 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
377 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
378 |
/* B 3.1 - Expressions */ |
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 |
void *visit(or_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
} |
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(xor_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(and_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(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
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
405 |
void *visit(add_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
406 |
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
|
407 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 408 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
409 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
410 |
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
|
411 |
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
|
412 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
413 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
414 |
void *visit(sub_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
415 |
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
|
416 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 417 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
418 |
if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;} |
|
419 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
420 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_type_name;} |
|
421 |
if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
|
422 |
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
|
423 |
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
|
424 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
425 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
426 |
void *visit(mul_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
427 |
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
|
428 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 429 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
430 |
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
|
431 |
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
|
432 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
433 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
434 |
void *visit(div_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
435 |
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
|
436 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 437 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
438 |
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
|
439 |
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
|
440 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
441 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
442 |
void *visit(mod_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
443 |
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
|
444 |
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
|
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(power_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 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
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
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
468 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
469 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
470 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
471 |
void *visit(neg_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
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
|
481 |
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
|
482 |
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
|
483 |
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
|
484 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
485 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
486 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
487 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
488 |
void *visit(not_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
492 |
return NULL; |
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 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
495 |
void *visit(function_invocation_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
496 |
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
|
497 |
|
32 | 498 |
if (f_decl == function_symtable.end_value()) { |
499 |
void *res = compute_standard_function_st(symbol); |
|
500 |
if (res == NULL) |
|
501 |
ERROR; |
|
502 |
return res; |
|
503 |
} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
504 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
505 |
return base_type(f_decl->type_name); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
506 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
507 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
508 |
}; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
509 |
|
33 | 510 |
/*bool_type_name_c search_expression_type_c::bool_type_name;*/ |
511 |