118 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
118 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
119 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
119 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
120 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
120 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
121 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
121 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
122 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
122 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
|
123 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
123 return false; |
124 return false; |
124 } |
125 } |
125 |
126 |
126 bool is_real_type(symbol_c *type_symbol) { |
127 bool is_real_type(symbol_c *type_symbol) { |
127 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
128 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
128 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
129 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
129 if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
130 if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
|
131 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
130 return false; |
132 return false; |
131 } |
133 } |
132 |
134 |
133 bool is_num_type(symbol_c *type_symbol) { |
135 bool is_num_type(symbol_c *type_symbol) { |
134 return is_real_type(type_symbol) || is_integer_type(type_symbol); |
136 return is_real_type(type_symbol) || is_integer_type(type_symbol); |
138 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
140 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
139 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
141 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
140 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
142 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
141 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
143 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
142 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
144 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
|
145 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
143 return false; |
146 return false; |
144 } |
147 } |
145 |
148 |
146 bool is_binary_type(symbol_c *type_symbol) { |
149 bool is_binary_type(symbol_c *type_symbol) { |
147 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
150 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
154 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
157 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
155 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
158 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
156 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
159 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
157 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
160 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
158 if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
161 if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
|
162 if (typeid(*first_type) == typeid(direct_variable_type_name_c)) {return true;} |
|
163 if (typeid(*second_type) == typeid(direct_variable_type_name_c)) {return true;} |
159 return false; |
164 return false; |
160 } |
165 } |
161 |
166 |
162 symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
167 symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
163 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
168 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
164 if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
169 if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;} |
165 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return second_type;} |
170 if ((typeid(*first_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_integer_type(second_type)) {return second_type;} |
166 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
171 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;} |
167 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return second_type;} |
172 if ((typeid(*first_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_binary_type(second_type)) {return second_type;} |
168 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;} |
173 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;} |
169 if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return second_type;} |
174 if ((typeid(*first_type) == typeid(constant_real_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_real_type(second_type)) {return second_type;} |
170 return NULL; |
175 return NULL; |
171 } |
176 } |
172 |
177 |
173 #include "search_type_code.c" |
178 #include "search_type_code.c" |
174 |
179 |
212 if (NULL != res) return res; |
217 if (NULL != res) return res; |
213 |
218 |
214 return NULL; |
219 return NULL; |
215 } |
220 } |
216 |
221 |
|
222 /********************************************/ |
|
223 /* B 1.4.1 - Directly Represented Variables */ |
|
224 /********************************************/ |
|
225 void *visit(direct_variable_c *symbol) { |
|
226 switch (symbol->value[2]) { |
|
227 case 'X': // bit |
|
228 return (void *)&bool_type_name; |
|
229 default: |
|
230 return (void *)&direct_variable_type_name; |
|
231 } |
|
232 } |
|
233 |
217 /*************************************/ |
234 /*************************************/ |
218 /* B 1.4.2 - Multi-element variables */ |
235 /* B 1.4.2 - Multi-element variables */ |
219 /*************************************/ |
236 /*************************************/ |
220 |
237 |
221 void *visit(array_variable_c *symbol) { |
238 void *visit(array_variable_c *symbol) { |