author | etisserant |
Tue, 17 Jul 2007 12:19:59 +0200 | |
changeset 42 | b45c7f34dec1 |
parent 38 | 6cce7d14647e |
child 65 | c6d41c1287de |
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 |
||
38
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
130 |
bool is_nbinary_type(symbol_c *type_symbol) { |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
131 |
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
|
132 |
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
|
133 |
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
|
134 |
if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
32 | 135 |
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
|
136 |
return false; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
137 |
} |
38
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
138 |
|
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
139 |
bool is_binary_type(symbol_c *type_symbol) { |
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
140 |
if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
141 |
return is_nbinary_type(type_symbol); |
6cce7d14647e
Stage4 changes according to new STD lib implementation
etisserant
parents:
35
diff
changeset
|
142 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
143 |
|
32 | 144 |
bool is_same_type(symbol_c *first_type, symbol_c *second_type) { |
145 |
if (typeid(*first_type) == typeid(*second_type)) {return true;} |
|
146 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
147 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
|
148 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
|
149 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
|
150 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
|
151 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
|
152 |
return false; |
|
153 |
} |
|
154 |
||
155 |
symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
|
156 |
if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
|
157 |
if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
158 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return second_type;} |
|
159 |
if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
|
160 |
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return second_type;} |
|
161 |
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;} |
|
162 |
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return second_type;} |
|
163 |
return NULL; |
|
164 |
} |
|
35 | 165 |
|
166 |
#include "search_type_code.c" |
|
167 |
||
168 |
#if 0 |
|
32 | 169 |
void *compute_standard_function_st(function_invocation_c *symbol) { |
170 |
symbol_c *current_type = NULL; |
|
171 |
symbol_c *return_type = NULL; |
|
33 | 172 |
|
32 | 173 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
174 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
33 | 175 |
search_expression_type_c* search_expression_type = this; |
35 | 176 |
|
32 | 177 |
for(int current_param = 0; current_param < ((list_c *)symbol->parameter_assignment_list)->n; current_param++) { |
178 |
symbol_c *param_name = NULL; |
|
179 |
switch (current_function_type) { |
|
180 |
case function_add: |
|
181 |
case function_and: |
|
182 |
case function_or: |
|
183 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
184 |
break; |
|
185 |
case function_sub: |
|
186 |
if (current_param < 2) |
|
187 |
param_name = generate_param_name("IN%d", current_param + 1); |
|
188 |
else ERROR; |
|
189 |
break; |
|
190 |
default: ERROR; |
|
191 |
} |
|
192 |
||
193 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
194 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
195 |
delete param_name; |
|
196 |
||
197 |
/* Get the value from a foo(<param_value>) style call */ |
|
198 |
if (param_value == NULL) |
|
199 |
param_value = function_call_param_iterator.next(); |
|
200 |
||
201 |
if (param_value == NULL) ERROR; |
|
202 |
||
203 |
symbol_c *param_type = (symbol_c *)param_value->accept(*this); |
|
204 |
||
205 |
switch (current_function_type) { |
|
206 |
case function_add: |
|
207 |
if (current_param == 0) |
|
208 |
current_type = param_type; |
|
209 |
else if (current_param == 1) { |
|
210 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
211 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) { |
|
212 |
current_type = common_type(current_type, param_type); |
|
213 |
return_type = current_type; |
|
214 |
} |
|
215 |
else if (is_time_type(current_type)) { |
|
216 |
if ((typeid(*current_type) == typeid(time_type_name_c)) && (typeid(*param_type) == typeid(time_type_name_c))) {return_type = (symbol_c *)&time_type_name;} |
|
217 |
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;} |
|
218 |
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;} |
|
219 |
else ERROR; |
|
220 |
} |
|
221 |
else ERROR; |
|
222 |
} |
|
223 |
else if (!is_time_type(current_type) && is_same_type(current_type, param_type)) { |
|
224 |
current_type = common_type(current_type, param_type); |
|
225 |
return_type = current_type; |
|
226 |
} |
|
227 |
else ERROR; |
|
228 |
break; |
|
229 |
case function_sub: |
|
230 |
if (current_param == 0) |
|
231 |
current_type = param_type; |
|
232 |
else if (current_param == 1) { |
|
233 |
if ((is_integer_type(current_type) && is_same_type(current_type, param_type)) || |
|
234 |
(is_real_type(current_type) && is_same_type(current_type, param_type))) |
|
235 |
return_type = common_type(current_type, param_type); |
|
236 |
else if (is_time_type(current_type)) { |
|
237 |
if (typeid(*current_type) == typeid(time_type_name_c) && typeid(*param_type) == typeid(time_type_name_c)) {return_type = (symbol_c *)&time_type_name;} |
|
238 |
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;} |
|
239 |
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;} |
|
240 |
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;} |
|
241 |
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;} |
|
242 |
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;} |
|
243 |
else ERROR; |
|
244 |
} |
|
245 |
else ERROR; |
|
246 |
} |
|
247 |
else ERROR; |
|
248 |
break; |
|
249 |
case function_and: |
|
250 |
case function_or: |
|
251 |
if (current_param == 0) |
|
252 |
if (is_binary_type(param_type)) |
|
253 |
current_type = param_type; |
|
254 |
else ERROR; |
|
255 |
else if (is_same_type(current_type, param_type)) |
|
256 |
return_type = common_type(current_type, param_type); |
|
257 |
else ERROR; |
|
258 |
break; |
|
259 |
default: ERROR; |
|
260 |
} |
|
261 |
} |
|
262 |
return (void *)return_type; |
|
35 | 263 |
} |
32 | 264 |
|
265 |
void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_type) { |
|
33 | 266 |
/*symbol_c *current_type = NULL;*/ |
32 | 267 |
symbol_c *return_type = NULL; |
268 |
function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
|
269 |
if (current_function_type == function_none) ERROR; |
|
270 |
||
271 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
272 |
||
273 |
int nb_param = 1; |
|
274 |
if (symbol->il_operand_list != NULL) |
|
275 |
nb_param += ((list_c *)symbol->il_operand_list)->n; |
|
276 |
||
277 |
for(int current_param = 0; current_param < nb_param; current_param++) { |
|
278 |
||
279 |
if (current_param != 0) { |
|
280 |
symbol_c *param_name = NULL; |
|
281 |
switch (current_function_type) { |
|
282 |
default: ERROR; |
|
283 |
} |
|
284 |
||
285 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
286 |
symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
287 |
delete param_name; |
|
288 |
||
289 |
/* Get the value from a foo(<param_value>) style call */ |
|
290 |
if (param_value == NULL) |
|
291 |
param_value = function_call_param_iterator.next(); |
|
292 |
||
293 |
if (param_value == NULL) ERROR; |
|
294 |
||
295 |
param_type = (symbol_c *)param_value->accept(*this); |
|
296 |
} |
|
297 |
||
298 |
switch (current_function_type) { |
|
299 |
case function_sqrt: |
|
300 |
if (current_param == 0 && is_real_type(param_type)) |
|
301 |
return_type = param_type; |
|
302 |
else ERROR; |
|
303 |
break; |
|
304 |
default: ERROR; |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
return (void *)return_type; |
|
309 |
} |
|
35 | 310 |
#endif |
32 | 311 |
|
33 | 312 |
/*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
|
313 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
314 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
315 |
void *compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 316 |
if (!is_same_type(left_type, right_type)) |
317 |
ERROR; |
|
318 |
if (!is_bool_type(left_type) && !is_binary_type(left_type)) |
|
319 |
ERROR; |
|
320 |
if (typeid(*left_type) == typeid(constant_int_type_name_c)) {return (void *)right_type;} |
|
321 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
322 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
323 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
324 |
/* A helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
325 |
void *compute_numeric_expression(symbol_c *left_type, symbol_c *right_type) { |
32 | 326 |
if (!is_same_type(left_type, right_type)) |
327 |
ERROR; |
|
328 |
if (!is_integer_type(left_type) && !is_real_type(left_type)) |
|
329 |
ERROR; |
|
330 |
if ((typeid(*left_type) == typeid(constant_int_type_name_c)) || (typeid(*left_type) == typeid(constant_real_type_name_c))) {return (void *)right_type;} |
|
331 |
else {return (void *)left_type;} |
|
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
332 |
return NULL; |
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 |
/* a helper function... */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
336 |
symbol_c *base_type(symbol_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
337 |
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
|
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 |
/*********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
341 |
/* B 1.4 - Variables */ |
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 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
344 |
void *visit(symbolic_variable_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
345 |
symbol_c *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 |
/* 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
|
348 |
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
|
349 |
if (NULL != res) return res; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
350 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
351 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
352 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
353 |
|
22
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
354 |
/*************************************/ |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
355 |
/* 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
|
356 |
/*************************************/ |
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 |
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
|
359 |
symbol_c *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 |
/* 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
|
362 |
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
|
363 |
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
|
364 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
365 |
return NULL; |
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 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
368 |
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
|
369 |
symbol_c *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 |
/* 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
|
372 |
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
|
373 |
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
|
374 |
|
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
375 |
return NULL; |
08bcc40be1fa
Bugs on SFC transition list generation and search expression type with structured_variables corrected
lbessard
parents:
17
diff
changeset
|
376 |
} |
16
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 |
/***************************************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
379 |
/* B.3 - Language ST (Structured Text) */ |
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 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
382 |
/* B 3.1 - Expressions */ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
383 |
/***********************/ |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
384 |
void *visit(or_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
385 |
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
|
386 |
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
|
387 |
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
|
388 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
389 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
390 |
void *visit(xor_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
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
|
394 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
395 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
396 |
void *visit(and_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
397 |
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
|
398 |
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
|
399 |
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
|
400 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
401 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
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
|
407 |
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
|
408 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
409 |
void *visit(add_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(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
414 |
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
|
415 |
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
|
416 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
417 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
418 |
void *visit(sub_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
419 |
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
|
420 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
32 | 421 |
if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
422 |
if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;} |
|
423 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
|
424 |
if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_type_name;} |
|
425 |
if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
|
426 |
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
|
427 |
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
|
428 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
429 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
430 |
void *visit(mul_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
431 |
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
|
432 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
42
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
433 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_num_type(right_type)) { |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
434 |
return (void *)&time_type_name; |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
435 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
436 |
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
|
437 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
438 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
439 |
void *visit(div_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
440 |
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
|
441 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
42
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
442 |
if (typeid(*left_type) == typeid(time_type_name_c) && is_num_type(right_type)){ |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
443 |
return (void *)&time_type_name; |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
444 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
445 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
446 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
447 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
448 |
void *visit(mod_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
449 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
450 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
451 |
return compute_numeric_expression(left_type, right_type); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
452 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
453 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
454 |
void *visit(power_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
455 |
symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
456 |
symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
42
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
457 |
if (is_real_type(left_type) && is_num_type(right_type)) { |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
458 |
return (void *)left_type; |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
459 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
460 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
461 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
462 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
463 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
464 |
void *visit(neg_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
465 |
symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this)); |
42
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
466 |
if (is_num_type(exp_type) || typeid(*exp_type) == typeid(time_type_name_c)){ |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
467 |
return (void *)exp_type; |
b45c7f34dec1
IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents:
38
diff
changeset
|
468 |
} |
16
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
469 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
470 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
471 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
472 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
473 |
void *visit(not_expression_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
ERROR; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
477 |
return NULL; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
478 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
479 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
480 |
void *visit(function_invocation_c *symbol) { |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
481 |
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
|
482 |
|
32 | 483 |
if (f_decl == function_symtable.end_value()) { |
484 |
void *res = compute_standard_function_st(symbol); |
|
485 |
if (res == NULL) |
|
486 |
ERROR; |
|
487 |
return res; |
|
488 |
} |
|
16
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 |
return base_type(f_decl->type_name); |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
491 |
} |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
492 |
|
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
493 |
}; |
e8b99f896416
Support for struct Time data Types manipulation into ST and IL added
lbessard
parents:
diff
changeset
|
494 |
|
33 | 495 |
/*bool_type_name_c search_expression_type_c::bool_type_name;*/ |
496 |