80 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
80 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
81 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
81 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
82 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
82 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
83 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
83 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
84 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
84 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
85 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
|
86 return false; |
85 return false; |
87 } |
86 } |
88 |
87 |
89 bool search_expression_type_c::is_real_type(symbol_c *type_symbol) { |
88 bool search_expression_type_c::is_real_type(symbol_c *type_symbol) { |
90 if (type_symbol == NULL) {return true;} |
89 if (type_symbol == NULL) {return true;} |
91 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
90 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
92 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
91 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
93 if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
92 if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
94 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
|
95 return false; |
93 return false; |
96 } |
94 } |
97 |
95 |
98 bool search_expression_type_c::is_num_type(symbol_c *type_symbol) { |
96 bool search_expression_type_c::is_num_type(symbol_c *type_symbol) { |
99 if (type_symbol == NULL) {return true;} |
97 if (type_symbol == NULL) {return true;} |
105 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
103 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
106 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
104 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
107 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
105 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
108 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
106 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
109 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
107 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
110 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
|
111 return false; |
108 return false; |
112 } |
109 } |
113 |
110 |
114 bool search_expression_type_c::is_binary_type(symbol_c *type_symbol) { |
111 bool search_expression_type_c::is_binary_type(symbol_c *type_symbol) { |
115 if (type_symbol == NULL) {return true;} |
112 if (type_symbol == NULL) {return true;} |
124 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
121 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
125 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
122 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
126 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
123 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
127 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
124 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;} |
128 if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
125 if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;} |
129 if (typeid(*first_type) == typeid(direct_variable_type_name_c)) {return true;} |
|
130 if (typeid(*second_type) == typeid(direct_variable_type_name_c)) {return true;} |
|
131 return false; |
126 return false; |
132 } |
127 } |
133 |
128 |
134 symbol_c* search_expression_type_c::common_type(symbol_c *first_type, symbol_c *second_type) { |
129 symbol_c* search_expression_type_c::common_type(symbol_c *first_type, symbol_c *second_type) { |
135 if (first_type == NULL && second_type == NULL) {return NULL;} |
130 if (first_type == NULL && second_type == NULL) {return NULL;} |
136 if (first_type == NULL) {return second_type;} |
131 if (first_type == NULL) {return second_type;} |
137 if (second_type == NULL) {return first_type;} |
132 if (second_type == NULL) {return first_type;} |
138 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
133 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
139 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;} |
134 if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
140 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;} |
135 if ((typeid(*first_type) == typeid(constant_int_type_name_c)) && is_integer_type(second_type)) {return second_type;} |
141 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;} |
136 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;} |
142 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;} |
137 if ((typeid(*first_type) == typeid(constant_int_type_name_c)) && is_binary_type(second_type)) {return second_type;} |
143 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;} |
138 if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;} |
144 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;} |
139 if ((typeid(*first_type) == typeid(constant_real_type_name_c)) && is_real_type(second_type)) {return second_type;} |
145 return NULL; |
140 return NULL; |
146 } |
141 } |
147 |
142 |
148 #define compute_standard_function_default search_expression_type_c::compute_standard_function_default |
143 #define compute_standard_function_default search_expression_type_c::compute_standard_function_default |
149 #define compute_standard_function_il search_expression_type_c::compute_standard_function_il |
144 #define compute_standard_function_il search_expression_type_c::compute_standard_function_il |
196 /********************************************/ |
191 /********************************************/ |
197 /* B 1.4.1 - Directly Represented Variables */ |
192 /* B 1.4.1 - Directly Represented Variables */ |
198 /********************************************/ |
193 /********************************************/ |
199 void *search_expression_type_c::visit(direct_variable_c *symbol) { |
194 void *search_expression_type_c::visit(direct_variable_c *symbol) { |
200 switch (symbol->value[2]) { |
195 switch (symbol->value[2]) { |
201 case 'X': // bit |
196 case 'X': // bit - 1 bit |
202 return (void *)&bool_type_name; |
197 return (void *)&bool_type_name; |
203 default: |
198 case 'B': // byte - 8 bits |
204 return (void *)&direct_variable_type_name; |
199 return (void *)&byte_type_name; |
205 } |
200 case 'W': // word - 16 bits |
|
201 return (void *)&word_type_name; |
|
202 case 'D': // double word - 32 bits |
|
203 return (void *)&dword_type_name; |
|
204 case 'L': // long word - 64 bits |
|
205 return (void *)&lword_type_name; |
|
206 default: // if none of the above, then the empty string was used <=> boolean |
|
207 return (void *)&bool_type_name; |
|
208 } |
206 } |
209 } |
207 |
210 |
208 /*************************************/ |
211 /*************************************/ |
209 /* B 1.4.2 - Multi-element variables */ |
212 /* B 1.4.2 - Multi-element variables */ |
210 /*************************************/ |
213 /*************************************/ |