author | lbessard |
Thu, 14 Jun 2007 08:58:10 +0200 | |
changeset 32 | 289256ec66f1 |
parent 22 | 08bcc40be1fa |
child 33 | 4507beb2aac6 |
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 |
|
35 |
typedef enum {function_add, |
|
36 |
function_sub, |
|
37 |
function_and, |
|
38 |
function_or, |
|
39 |
function_sqrt, |
|
40 |
function_none} function_type_t; |
|
41 |
||
42 |
||
43 |
function_type_t get_function_type(identifier_c *function_name) { |
|
44 |
if (!strcasecmp(function_name->value, "ADD")) |
|
45 |
return function_add; |
|
46 |
else if (!strcasecmp(function_name->value, "SUB")) |
|
47 |
return function_sub; |
|
48 |
else if (!strcasecmp(function_name->value, "AND")) |
|
49 |
return function_and; |
|
50 |
else if (!strcasecmp(function_name->value, "OR")) |
|
51 |
return function_or; |
|
52 |
else if (!strcasecmp(function_name->value, "SQRT")) |
|
53 |
return function_sqrt; |
|
54 |
else return function_none; |
|
55 |
} |
|
56 |
||
57 |
||
58 |
symbol_c *generate_param_name(const char *name) { |
|
59 |
symbol_c *param_name = new identifier_c(name); |
|
60 |
return param_name; |
|
61 |
} |
|
62 |
||
63 |
||
64 |
symbol_c *generate_param_name(const char *format, int number) { |
|
65 |
char name[10]; |
|
66 |
sprintf(name, format, number); |
|
67 |
symbol_c *param_name = new identifier_c(name); |
|
68 |
return param_name; |
|
69 |
} |
|
70 |
||
71 |
||
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
72 |
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
|
73 |
private: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
74 |
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
|
75 |
search_base_type_c search_base_type; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
76 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
77 |
public: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
} |
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 |
virtual ~search_expression_type_c(void) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
83 |
delete search_varfb_instance_type; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
84 |
} |
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 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
87 |
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
|
88 |
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
|
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... */ |
32 | 92 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
return false; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
98 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
99 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
100 |
/* A helper function... */ |
32 | 101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
32 | 110 |
if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
111 |
return false; |
|
112 |
} |
|
113 |
||
114 |
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
|
115 |
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
|
116 |
if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
32 | 117 |
if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
118 |
return false; |
|
119 |
} |
|
120 |
||
121 |
bool is_num_type(symbol_c *type_symbol) { |
|
122 |
return is_real_type(type_symbol) || is_integer_type(type_symbol); |
|
123 |
} |
|
124 |
||
125 |
bool is_binary_type(symbol_c *type_symbol) { |
|
17
38754701ac41
SFC state machine first approach generator implemented
lbessard
parents:
16
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
32 | 131 |
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
|
132 |
return false; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
133 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
134 |
|
32 | 135 |
bool is_same_type(symbol_c *first_type, symbol_c *second_type) { |
136 |
if (typeid(*first_type) == typeid(*second_type)) {return true;} |
|
137 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
138 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
|
139 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
140 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
|
141 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
|
142 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
|
143 |
return false; |
|
144 |
} |
|
145 |
||
146 |
symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
|
147 |
if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
|
148 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
149 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return second_type;} |
|
150 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
151 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return second_type;} |
|
152 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;} |
|
153 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return second_type;} |
|
154 |
return NULL; |
|
155 |
} |
|
156 |
||
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
157 |
private: |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
158 |
|
32 | 159 |
void *compute_standard_function_st(function_invocation_c *symbol) { |
160 |
symbol_c *current_type = NULL; |
|
161 |
symbol_c *return_type = NULL; |
|
162 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
|
163 |
||
164 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
165 |
||
166 |
for(int current_param = 0; current_param < ((list_c *)symbol->parameter_assignment_list)->n; current_param++) { |
|
167 |
symbol_c *param_name = NULL; |
|
168 |
switch (current_function_type) { |
|
169 |
case function_add: |
|
170 |
case function_and: |
|
171 |
case function_or: |
|
172 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
173 |
break; |
|
174 |
case function_sub: |
|
175 |
if (current_param < 2) |
|
176 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
177 |
else ERROR; |
|
178 |
break; |
|
179 |
default: ERROR; |
|
180 |
} |
|
181 |
||
182 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
183 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
184 |
delete param_name; |
|
185 |
||
186 |
/* Get the value from a foo(<param_value>) style call */ |
|
187 |
if (param_value == NULL) |
|
188 |
param_value = function_call_param_iterator.next(); |
|
189 |
||
190 |
if (param_value == NULL) ERROR; |
|
191 |
||
192 |
symbol_c *param_type = (symbol_c *)param_value->accept(*this); |
|
193 |
||
194 |
switch (current_function_type) { |
|
195 |
case function_add: |
|
196 |
if (current_param == 0) |
|
197 |
current_type = param_type; |
|
198 |
else if (current_param == 1) { |
|
199 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
200 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) { |
|
201 |
current_type = common_type(current_type, param_type); |
|
202 |
return_type = current_type; |
|
203 |
} |
|
204 |
else if (is_time_type(current_type)) { |
|
205 |
if ((typeid(*current_type) == typeid(time_type_name_c)) && (typeid(*param_type) == typeid(time_type_name_c))) {return_type = (symbol_c *)&time_type_name;} |
|
206 |
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;} |
|
207 |
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;} |
|
208 |
else ERROR; |
|
209 |
} |
|
210 |
else ERROR; |
|
211 |
} |
|
212 |
else if (!is_time_type(current_type) && is_same_type(current_type, param_type)) { |
|
213 |
current_type = common_type(current_type, param_type); |
|
214 |
return_type = current_type; |
|
215 |
} |
|
216 |
else ERROR; |
|
217 |
break; |
|
218 |
case function_sub: |
|
219 |
if (current_param == 0) |
|
220 |
current_type = param_type; |
|
221 |
else if (current_param == 1) { |
|
222 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
223 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) |
|
224 |
return_type = common_type(current_type, param_type); |
|
225 |
else if (is_time_type(current_type)) { |
|
226 |
if (typeid(*current_type) == typeid(time_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
227 |
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;} |
|
228 |
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;} |
|
229 |
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;} |
|
230 |
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;} |
|
231 |
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;} |
|
232 |
else ERROR; |
|
233 |
} |
|
234 |
else ERROR; |
|
235 |
} |
|
236 |
else ERROR; |
|
237 |
break; |
|
238 |
case function_and: |
|
239 |
case function_or: |
|
240 |
if (current_param == 0) |
|
241 |
if (is_binary_type(param_type)) |
|
242 |
current_type = param_type; |
|
243 |
else ERROR; |
|
244 |
else if (is_same_type(current_type, param_type)) |
|
245 |
return_type = common_type(current_type, param_type); |
|
246 |
else ERROR; |
|
247 |
break; |
|
248 |
default: ERROR; |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
return (void *)return_type; |
|
253 |
} |
|
254 |
||
255 |
public: |
|
256 |
||
257 |
void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_type) { |
|
258 |
symbol_c *current_type = NULL; |
|
259 |
symbol_c *return_type = NULL; |
|
260 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
|
261 |
if (current_function_type == function_none) ERROR; |
|
262 |
||
263 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
264 |
||
265 |
int nb_param = 1; |
|
266 |
if (symbol->il_operand_list != NULL) |
|
267 |
nb_param += ((list_c *)symbol->il_operand_list)->n; |
|
268 |
||
269 |
for(int current_param = 0; current_param < nb_param; current_param++) { |
|
270 |
||
271 |
if (current_param != 0) { |
|
272 |
symbol_c *param_name = NULL; |
|
273 |
switch (current_function_type) { |
|
274 |
default: ERROR; |
|
275 |
} |
|
276 |
||
277 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
278 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
279 |
delete param_name; |
|
280 |
||
281 |
/* Get the value from a foo(<param_value>) style call */ |
|
282 |
if (param_value == NULL) |
|
283 |
param_value = function_call_param_iterator.next(); |
|
284 |
||
285 |
if (param_value == NULL) ERROR; |
|
286 |
||
287 |
param_type = (symbol_c *)param_value->accept(*this); |
|
288 |
} |
|
289 |
||
290 |
switch (current_function_type) { |
|
291 |
case function_sqrt: |
|
292 |
if (current_param == 0 && is_real_type(param_type)) |
|
293 |
return_type = param_type; |
|
294 |
else ERROR; |
|
295 |
break; |
|
296 |
default: ERROR; |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
return (void *)return_type; |
|
301 |
} |
|
302 |
||
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
303 |
static bool_type_name_c bool_type_name; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
304 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
305 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
306 |
void *compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 307 |
if (!is_same_type(left_type, right_type)) |
308 |
ERROR; |
|
309 |
if (!is_bool_type(left_type) && !is_binary_type(left_type)) |
|
310 |
ERROR; |
|
311 |
if (typeid(*left_type) == typeid(constant_int_type_name_c)) {return (void *)right_type;} |
|
312 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
313 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
314 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
315 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
316 |
void *compute_numeric_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 317 |
if (!is_same_type(left_type, right_type)) |
318 |
ERROR; |
|
319 |
if (!is_integer_type(left_type) && !is_real_type(left_type)) |
|
320 |
ERROR; |
|
321 |
if ((typeid(*left_type) == typeid(constant_int_type_name_c)) || (typeid(*left_type) == typeid(constant_real_type_name_c))) {return (void *)right_type;} |
|
322 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
323 |
return NULL; |
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 |
symbol_c *base_type(symbol_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
328 |
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
|
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 |
/*********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
332 |
/* B 1.4 - Variables */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
333 |
/*********************/ |
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 |
void *visit(symbolic_variable_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
336 |
symbol_c *res; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
337 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
338 |
/* 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
|
339 |
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
|
340 |
if (NULL != res) return res; |
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 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
343 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
344 |
|
22
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
345 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
346 |
/* 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
|
347 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
348 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
349 |
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
|
350 |
symbol_c *res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
351 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
352 |
/* 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
|
353 |
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
|
354 |
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
|
355 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
356 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
357 |
} |
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 |
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
|
360 |
symbol_c *res; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
361 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
362 |
/* 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
|
363 |
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
|
364 |
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
|
365 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
366 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
367 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
368 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
369 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
370 |
/* B.3 - Language ST (Structured Text) */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
371 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
372 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
373 |
/* B 3.1 - Expressions */ |
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 |
void *visit(or_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
376 |
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
|
377 |
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
|
378 |
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
|
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 |
void *visit(xor_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
386 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
387 |
void *visit(and_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
388 |
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
|
389 |
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
|
390 |
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
|
391 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
392 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
393 |
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
|
394 |
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
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
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
|
399 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
400 |
void *visit(add_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
401 |
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
|
402 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 403 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
404 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
405 |
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
|
406 |
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
|
407 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
408 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
409 |
void *visit(sub_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
410 |
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
|
411 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 412 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
413 |
if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;} |
|
414 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
415 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_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;} |
|
417 |
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
|
418 |
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
|
419 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
420 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
421 |
void *visit(mul_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
422 |
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
|
423 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 424 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
425 |
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
|
426 |
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
|
427 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
428 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
429 |
void *visit(div_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
430 |
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
|
431 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 432 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;} |
433 |
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
|
434 |
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
|
435 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
436 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
437 |
void *visit(mod_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
438 |
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
|
439 |
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
|
440 |
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
|
441 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
442 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
443 |
void *visit(power_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
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
|
461 |
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
|
462 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
463 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
464 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
465 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
466 |
void *visit(neg_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
467 |
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
|
468 |
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
|
469 |
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
|
470 |
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
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
480 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
481 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
482 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
483 |
void *visit(not_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
484 |
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
|
485 |
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
|
486 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
487 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
488 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
489 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
490 |
void *visit(function_invocation_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
491 |
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
|
492 |
|
32 | 493 |
if (f_decl == function_symtable.end_value()) { |
494 |
void *res = compute_standard_function_st(symbol); |
|
495 |
if (res == NULL) |
|
496 |
ERROR; |
|
497 |
return res; |
|
498 |
} |
|
16
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 |
return base_type(f_decl->type_name); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
501 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
502 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
503 |
}; |
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 |
bool_type_name_c search_expression_type_c::bool_type_name; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
506 |