88 delete search_varfb_instance_type; |
88 delete search_varfb_instance_type; |
89 } |
89 } |
90 |
90 |
91 /* A helper function... */ |
91 /* A helper function... */ |
92 bool is_bool_type(symbol_c *type_symbol) { |
92 bool is_bool_type(symbol_c *type_symbol) { |
|
93 if (type_symbol == NULL) {return true;} |
93 return (typeid(*type_symbol) == typeid(bool_type_name_c)); |
94 return (typeid(*type_symbol) == typeid(bool_type_name_c)); |
94 } |
95 } |
95 |
96 |
96 /* A helper function... */ |
97 /* A helper function... */ |
97 bool is_time_type(symbol_c *type_symbol) { |
98 bool is_time_type(symbol_c *type_symbol) { |
|
99 if (type_symbol == NULL) {return true;} |
98 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
100 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
99 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
101 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
100 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
102 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
101 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
103 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
102 return false; |
104 return false; |
103 } |
105 } |
104 |
106 |
105 /* A helper function... */ |
107 /* A helper function... */ |
106 bool is_string_type(symbol_c *type_symbol) { |
108 bool is_string_type(symbol_c *type_symbol) { |
|
109 if (type_symbol == NULL) {return true;} |
107 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
110 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
108 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
111 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
109 return false; |
112 return false; |
110 } |
113 } |
111 |
114 |
112 /* A helper function... */ |
115 /* A helper function... */ |
113 bool is_integer_type(symbol_c *type_symbol) { |
116 bool is_integer_type(symbol_c *type_symbol) { |
|
117 if (type_symbol == NULL) {return true;} |
114 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
118 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
115 if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
119 if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
116 if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
120 if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
117 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
121 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
118 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
122 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
123 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
127 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
124 return false; |
128 return false; |
125 } |
129 } |
126 |
130 |
127 bool is_real_type(symbol_c *type_symbol) { |
131 bool is_real_type(symbol_c *type_symbol) { |
|
132 if (type_symbol == NULL) {return true;} |
128 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
133 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
129 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
134 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
130 if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;} |
135 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;} |
136 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
132 return false; |
137 return false; |
133 } |
138 } |
134 |
139 |
135 bool is_num_type(symbol_c *type_symbol) { |
140 bool is_num_type(symbol_c *type_symbol) { |
|
141 if (type_symbol == NULL) {return true;} |
136 return is_real_type(type_symbol) || is_integer_type(type_symbol); |
142 return is_real_type(type_symbol) || is_integer_type(type_symbol); |
137 } |
143 } |
138 |
144 |
139 bool is_nbinary_type(symbol_c *type_symbol) { |
145 bool is_nbinary_type(symbol_c *type_symbol) { |
|
146 if (type_symbol == NULL) {return true;} |
140 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
147 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
141 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
148 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
142 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
149 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
143 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
150 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
144 if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;} |
151 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;} |
152 if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;} |
146 return false; |
153 return false; |
147 } |
154 } |
148 |
155 |
149 bool is_binary_type(symbol_c *type_symbol) { |
156 bool is_binary_type(symbol_c *type_symbol) { |
|
157 if (type_symbol == NULL) {return true;} |
150 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
158 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
151 return is_nbinary_type(type_symbol); |
159 return is_nbinary_type(type_symbol); |
152 } |
160 } |
153 |
161 |
154 bool is_same_type(symbol_c *first_type, symbol_c *second_type) { |
162 bool is_same_type(symbol_c *first_type, symbol_c *second_type) { |
|
163 if (first_type == NULL || second_type == NULL) {return true;} |
155 if (typeid(*first_type) == typeid(*second_type)) {return true;} |
164 if (typeid(*first_type) == typeid(*second_type)) {return true;} |
156 if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
165 if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
157 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
166 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return true;} |
158 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
167 if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return true;} |
159 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
168 if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;} |
163 if (typeid(*second_type) == typeid(direct_variable_type_name_c)) {return true;} |
172 if (typeid(*second_type) == typeid(direct_variable_type_name_c)) {return true;} |
164 return false; |
173 return false; |
165 } |
174 } |
166 |
175 |
167 symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
176 symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) { |
|
177 if (first_type == NULL && second_type == NULL) {return NULL;} |
|
178 if (first_type == NULL) {return second_type;} |
|
179 if (second_type == NULL) {return first_type;} |
168 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
180 if (typeid(*first_type) == typeid(*second_type)) {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;} |
181 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;} |
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;} |
182 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;} |
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;} |
183 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;} |
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;} |
184 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;} |