128 |
128 |
129 |
129 |
130 void *print_getter(symbol_c *symbol) { |
130 void *print_getter(symbol_c *symbol) { |
131 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
131 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
132 if (wanted_variablegeneration == fparam_output_vg) { |
132 if (wanted_variablegeneration == fparam_output_vg) { |
133 if (vartype == search_var_instance_decl_c::external_vt) |
133 if (vartype == search_var_instance_decl_c::external_vt) { |
134 s4o.print(GET_EXTERNAL_BY_REF); |
134 if (search_var_instance_decl->type_is_fb(symbol)) |
|
135 s4o.print(GET_EXTERNAL_FB_BY_REF); |
|
136 else |
|
137 s4o.print(GET_EXTERNAL_BY_REF); |
|
138 } |
135 else if (vartype == search_var_instance_decl_c::located_vt) |
139 else if (vartype == search_var_instance_decl_c::located_vt) |
136 s4o.print(GET_LOCATED_BY_REF); |
140 s4o.print(GET_LOCATED_BY_REF); |
137 else |
141 else |
138 s4o.print(GET_VAR_BY_REF); |
142 s4o.print(GET_VAR_BY_REF); |
139 } |
143 } |
140 else { |
144 else { |
141 if (vartype == search_var_instance_decl_c::external_vt) |
145 if (vartype == search_var_instance_decl_c::external_vt) { |
142 s4o.print(GET_EXTERNAL); |
146 if (search_var_instance_decl->type_is_fb(symbol)) |
|
147 s4o.print(GET_EXTERNAL_FB); |
|
148 else |
|
149 s4o.print(GET_EXTERNAL); |
|
150 } |
143 else if (vartype == search_var_instance_decl_c::located_vt) |
151 else if (vartype == search_var_instance_decl_c::located_vt) |
144 s4o.print(GET_LOCATED); |
152 s4o.print(GET_LOCATED); |
145 else |
153 else |
146 s4o.print(GET_VAR); |
154 s4o.print(GET_VAR); |
147 } |
155 } |
158 wanted_variablegeneration = old_wanted_variablegeneration; |
166 wanted_variablegeneration = old_wanted_variablegeneration; |
159 return NULL; |
167 return NULL; |
160 } |
168 } |
161 |
169 |
162 void *print_setter(symbol_c* symbol, |
170 void *print_setter(symbol_c* symbol, |
163 symbol_c* type, |
171 symbol_c* type, |
164 symbol_c* value, |
172 symbol_c* value, |
165 symbol_c* fb_symbol = NULL, |
173 symbol_c* fb_symbol = NULL, |
166 symbol_c* fb_value = NULL) { |
174 symbol_c* fb_value = NULL) { |
167 |
175 |
168 bool type_is_complex = false; |
176 bool type_is_complex = false; |
169 if (fb_symbol == NULL) { |
177 if (fb_symbol == NULL) { |
170 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
178 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
171 type_is_complex = search_var_instance_decl->type_is_complex(symbol); |
179 type_is_complex = search_var_instance_decl->type_is_complex(symbol); |
172 if (vartype == search_var_instance_decl_c::external_vt) |
180 if (vartype == search_var_instance_decl_c::external_vt) { |
173 s4o.print(SET_EXTERNAL); |
181 if (search_var_instance_decl->type_is_fb(symbol)) |
|
182 s4o.print(SET_EXTERNAL_FB); |
|
183 else |
|
184 s4o.print(SET_EXTERNAL); |
|
185 } |
174 else if (vartype == search_var_instance_decl_c::located_vt) |
186 else if (vartype == search_var_instance_decl_c::located_vt) |
175 s4o.print(SET_LOCATED); |
187 s4o.print(SET_LOCATED); |
176 else |
188 else |
177 s4o.print(SET_VAR); |
189 s4o.print(SET_VAR); |
178 } |
190 } |
179 else |
191 else { |
180 s4o.print(SET_VAR); |
192 unsigned int vartype = search_var_instance_decl->get_vartype(fb_symbol); |
|
193 if (vartype == search_var_instance_decl_c::external_vt) |
|
194 s4o.print(SET_EXTERNAL_FB); |
|
195 else |
|
196 s4o.print(SET_VAR); |
|
197 } |
181 s4o.print("("); |
198 s4o.print("("); |
182 |
199 |
183 if (fb_symbol != NULL) { |
200 if (fb_symbol != NULL) { |
184 print_variable_prefix(); |
201 print_variable_prefix(); |
185 fb_symbol->accept(*this); |
202 fb_symbol->accept(*this); |
272 TRACE("direct_variable_c"); |
289 TRACE("direct_variable_c"); |
273 /* Do not use print_token() as it will change everything into uppercase */ |
290 /* Do not use print_token() as it will change everything into uppercase */ |
274 if (strlen(symbol->value) == 0) ERROR; |
291 if (strlen(symbol->value) == 0) ERROR; |
275 if (this->is_variable_prefix_null()) { |
292 if (this->is_variable_prefix_null()) { |
276 if (wanted_variablegeneration != fparam_output_vg) |
293 if (wanted_variablegeneration != fparam_output_vg) |
277 s4o.print("*("); |
294 s4o.print("*("); |
278 } |
295 } |
279 else { |
296 else { |
280 switch (wanted_variablegeneration) { |
297 switch (wanted_variablegeneration) { |
281 case expression_vg: |
298 case expression_vg: |
282 s4o.print(GET_LOCATED); |
299 s4o.print(GET_LOCATED); |
283 s4o.print("("); |
300 s4o.print("("); |
284 break; |
301 break; |
285 case fparam_output_vg: |
302 case fparam_output_vg: |
286 s4o.print(GET_LOCATED_BY_REF); |
303 s4o.print(GET_LOCATED_BY_REF); |
287 s4o.print("("); |
304 s4o.print("("); |
288 break; |
305 break; |
289 default: |
306 default: |
291 } |
308 } |
292 } |
309 } |
293 this->print_variable_prefix(); |
310 this->print_variable_prefix(); |
294 s4o.printlocation(symbol->value + 1); |
311 s4o.printlocation(symbol->value + 1); |
295 if ((this->is_variable_prefix_null() && wanted_variablegeneration != fparam_output_vg) || |
312 if ((this->is_variable_prefix_null() && wanted_variablegeneration != fparam_output_vg) || |
296 wanted_variablegeneration != assignment_vg) |
313 wanted_variablegeneration != assignment_vg) |
297 s4o.print(")"); |
314 s4o.print(")"); |
298 return NULL; |
315 return NULL; |
299 } |
316 } |
300 |
317 |
301 /*************************************/ |
318 /*************************************/ |
309 switch (wanted_variablegeneration) { |
326 switch (wanted_variablegeneration) { |
310 case complextype_base_vg: |
327 case complextype_base_vg: |
311 case complextype_base_assignment_vg: |
328 case complextype_base_assignment_vg: |
312 symbol->record_variable->accept(*this); |
329 symbol->record_variable->accept(*this); |
313 if (!type_is_complex) { |
330 if (!type_is_complex) { |
314 s4o.print("."); |
331 s4o.print("."); |
315 symbol->field_selector->accept(*this); |
332 symbol->field_selector->accept(*this); |
316 } |
333 } |
317 break; |
334 break; |
318 case complextype_suffix_vg: |
335 case complextype_suffix_vg: |
319 symbol->record_variable->accept(*this); |
336 symbol->record_variable->accept(*this); |
320 if (type_is_complex) { |
337 if (type_is_complex) { |
327 s4o.print("."); |
344 s4o.print("."); |
328 symbol->field_selector->accept(*this); |
345 symbol->field_selector->accept(*this); |
329 break; |
346 break; |
330 default: |
347 default: |
331 if (this->is_variable_prefix_null()) { |
348 if (this->is_variable_prefix_null()) { |
332 symbol->record_variable->accept(*this); |
349 symbol->record_variable->accept(*this); |
333 s4o.print("."); |
350 s4o.print("."); |
334 symbol->field_selector->accept(*this); |
351 symbol->field_selector->accept(*this); |
335 } |
352 } |
336 else |
353 else |
337 print_getter(symbol); |
354 print_getter(symbol); |
338 break; |
355 break; |
339 } |
356 } |
340 return NULL; |
357 return NULL; |
341 } |
358 } |
342 |
359 |
361 |
378 |
362 current_array_type = NULL; |
379 current_array_type = NULL; |
363 break; |
380 break; |
364 default: |
381 default: |
365 if (this->is_variable_prefix_null()) { |
382 if (this->is_variable_prefix_null()) { |
366 symbol->subscripted_variable->accept(*this); |
383 symbol->subscripted_variable->accept(*this); |
367 |
384 |
368 current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable); |
385 current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable); |
369 if (current_array_type == NULL) ERROR; |
386 if (current_array_type == NULL) ERROR; |
370 |
387 |
371 s4o.print(".table"); |
388 s4o.print(".table"); |
372 symbol->subscript_list->accept(*this); |
389 symbol->subscript_list->accept(*this); |
373 |
390 |
374 current_array_type = NULL; |
391 current_array_type = NULL; |
375 } |
392 } |
376 else |
393 else |
377 print_getter(symbol); |
394 print_getter(symbol); |
378 break; |
395 break; |
379 } |
396 } |
380 return NULL; |
397 return NULL; |
381 } |
398 } |
382 |
399 |
383 /* subscript_list ',' subscript */ |
400 /* subscript_list ',' subscript */ |
384 void *visit(subscript_list_c *symbol) { |
401 void *visit(subscript_list_c *symbol) { |
385 array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type); |
402 array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type); |
386 for (int i = 0; i < symbol->n; i++) { |
403 for (int i = 0; i < symbol->n; i++) { |
387 symbol_c* dimension = array_dimension_iterator->next(); |
404 symbol_c* dimension = array_dimension_iterator->next(); |
388 if (dimension == NULL) ERROR; |
405 if (dimension == NULL) ERROR; |
389 |
406 |
390 s4o.print("[("); |
407 s4o.print("[("); |
391 symbol->elements[i]->accept(*this); |
408 symbol->elements[i]->accept(*this); |
392 s4o.print(") - ("); |
409 s4o.print(") - ("); |
393 dimension->accept(*this); |
410 dimension->accept(*this); |
394 s4o.print(")]"); |
411 s4o.print(")]"); |
395 } |
412 } |
817 symbol->l_exp->accept(*this); |
834 symbol->l_exp->accept(*this); |
818 s4o.print(" = "); |
835 s4o.print(" = "); |
819 print_check_function(left_type, symbol->r_exp); |
836 print_check_function(left_type, symbol->r_exp); |
820 } |
837 } |
821 else { |
838 else { |
822 print_setter(symbol->l_exp, left_type, symbol->r_exp); |
839 print_setter(symbol->l_exp, left_type, symbol->r_exp); |
823 } |
840 } |
824 return NULL; |
841 return NULL; |
825 } |
842 } |
826 |
843 |
827 /*****************************************/ |
844 /*****************************************/ |
892 } /* for(...) */ |
909 } /* for(...) */ |
893 |
910 |
894 /* now call the function... */ |
911 /* now call the function... */ |
895 function_block_type_name->accept(*this); |
912 function_block_type_name->accept(*this); |
896 s4o.print(FB_FUNCTION_SUFFIX); |
913 s4o.print(FB_FUNCTION_SUFFIX); |
897 s4o.print("(&"); |
914 s4o.print("("); |
|
915 if (search_var_instance_decl->get_vartype(symbol->fb_name) != search_var_instance_decl_c::external_vt) |
|
916 s4o.print("&"); |
898 print_variable_prefix(); |
917 print_variable_prefix(); |
899 symbol->fb_name->accept(*this); |
918 symbol->fb_name->accept(*this); |
900 s4o.print(")"); |
919 s4o.print(")"); |
901 |
920 |
902 /* loop through each function parameter, find the variable to which |
921 /* loop through each function parameter, find the variable to which |
1083 switch (wanted_casegeneration) { |
1102 switch (wanted_casegeneration) { |
1084 case single_cg: |
1103 case single_cg: |
1085 case_element_iterator = new case_element_iterator_c(symbol->case_list, case_element_iterator_c::element_single); |
1104 case_element_iterator = new case_element_iterator_c(symbol->case_list, case_element_iterator_c::element_single); |
1086 for (element = case_element_iterator->next(); element != NULL; element = case_element_iterator->next()) { |
1105 for (element = case_element_iterator->next(); element != NULL; element = case_element_iterator->next()) { |
1087 if (first_element) first_element = false; |
1106 if (first_element) first_element = false; |
1088 s4o.print(s4o.indent_spaces + "case "); |
1107 s4o.print(s4o.indent_spaces + "case "); |
1089 element->accept(*this); |
1108 element->accept(*this); |
1090 s4o.print(":\n"); |
1109 s4o.print(":\n"); |
1091 } |
1110 } |
1092 delete case_element_iterator; |
1111 delete case_element_iterator; |
1093 break; |
1112 break; |