720 update_type_init(symbol->located_var_spec_init); |
720 update_type_init(symbol->located_var_spec_init); |
721 |
721 |
722 /* now to produce the c equivalent... */ |
722 /* now to produce the c equivalent... */ |
723 switch(wanted_varformat) { |
723 switch(wanted_varformat) { |
724 case local_vf: |
724 case local_vf: |
725 /* NOTE: located variables must be declared static, as the connection to the |
725 s4o.print(s4o.indent_spaces); |
726 * MatPLC point must be initialised at program startup, and not whenever |
|
727 * a new function block is instantiated! |
|
728 * Since they always refer to the same MatPLC point, it is OK to let several |
|
729 * function block instances share the same located variable! |
|
730 * If the IEC compiler maps IEC tasks to Linux threads, with tasks/threads |
|
731 * running simultaneously, then we must make sure the MatPLC IO library |
|
732 * is thread safe! |
|
733 */ |
|
734 s4o.print(s4o.indent_spaces + "static __plc_pt_c<"); |
|
735 this->current_var_type_symbol->accept(*this); |
726 this->current_var_type_symbol->accept(*this); |
736 s4o.print(", 8*sizeof("); |
727 s4o.print(" *"); |
737 this->current_var_type_symbol->accept(*this); |
|
738 s4o.print(")> "); |
|
739 if (symbol->variable_name != NULL) |
728 if (symbol->variable_name != NULL) |
740 symbol->variable_name->accept(*this); |
729 symbol->variable_name->accept(*this); |
741 else |
730 else |
742 symbol->location->accept(*this); |
731 symbol->location->accept(*this); |
743 s4o.print(";\n"); |
732 s4o.print(";\n"); |
|
733 break; |
|
734 |
|
735 case constructorinit_vf: |
|
736 s4o.print(nv->get()); |
|
737 s4o.print("{extern "); |
|
738 symbol->location->accept(*this); |
|
739 s4o.print(";"); |
|
740 print_variable_prefix(); |
|
741 if (symbol->variable_name != NULL) |
|
742 symbol->variable_name->accept(*this); |
|
743 else |
|
744 symbol->location->accept(*this); |
|
745 s4o.print(" = &"); |
|
746 symbol->location->accept(*this); |
|
747 s4o.print(";}"); |
744 break; |
748 break; |
745 |
749 |
746 case globalinit_vf: |
750 case globalinit_vf: |
747 s4o.print(s4o.indent_spaces + "__plc_pt_c<"); |
751 s4o.print(s4o.indent_spaces + "__plc_pt_c<"); |
748 this->current_var_type_symbol->accept(*this); |
752 this->current_var_type_symbol->accept(*this); |
856 s4o.print("{extern "); |
860 s4o.print("{extern "); |
857 symbol->global_var_name->accept(*this); |
861 symbol->global_var_name->accept(*this); |
858 s4o.print(";"); |
862 s4o.print(";"); |
859 print_variable_prefix(); |
863 print_variable_prefix(); |
860 symbol->global_var_name->accept(*this); |
864 symbol->global_var_name->accept(*this); |
861 s4o.print(" = &"); |
865 s4o.print(" = "); |
862 symbol->global_var_name->accept(*this); |
866 symbol->global_var_name->accept(*this); |
863 s4o.print(";}"); |
867 s4o.print(";}"); |
864 break; |
868 break; |
865 |
869 |
866 case finterface_vf: |
870 case finterface_vf: |
1439 symbol_c *param_type = fp_iterator.param_type(); |
1443 symbol_c *param_type = fp_iterator.param_type(); |
1440 if (param_type == NULL) ERROR; |
1444 if (param_type == NULL) ERROR; |
1441 |
1445 |
1442 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
1446 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
1443 |
1447 |
|
1448 #if 0 |
1444 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
1449 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
1445 symbol_c *param_value = function_call_param_iterator.search(param_name); |
1450 symbol_c *param_value = function_call_param_iterator.search(param_name); |
|
1451 #endif |
1446 |
1452 |
1447 switch (param_direction) { |
1453 switch (param_direction) { |
1448 case function_param_iterator_c::direction_in: |
1454 case function_param_iterator_c::direction_in: |
1449 case function_param_iterator_c::direction_out: |
1455 case function_param_iterator_c::direction_out: |
1450 case function_param_iterator_c::direction_inout: |
1456 case function_param_iterator_c::direction_inout: |