325 for(int i = 0; i < list->n; i++) { |
326 for(int i = 0; i < list->n; i++) { |
326 if (is_fb) { |
327 if (is_fb) { |
327 s4o.print(nv->get()); |
328 s4o.print(nv->get()); |
328 this->current_var_type_symbol->accept(*this); |
329 this->current_var_type_symbol->accept(*this); |
329 s4o.print(FB_INIT_SUFFIX); |
330 s4o.print(FB_INIT_SUFFIX); |
330 s4o.print("("); |
331 s4o.print("(&"); |
331 this->print_variable_prefix(); |
332 this->print_variable_prefix(); |
332 list->elements[i]->accept(*this); |
333 list->elements[i]->accept(*this); |
333 s4o.print(");"); |
334 s4o.print(");"); |
334 } |
335 } |
335 else if (this->current_var_init_symbol != NULL) { |
336 else if (this->current_var_init_symbol != NULL) { |
859 |
860 |
860 case constructorinit_vf: |
861 case constructorinit_vf: |
861 s4o.print(nv->get()); |
862 s4o.print(nv->get()); |
862 s4o.print("{extern "); |
863 s4o.print("{extern "); |
863 this->current_var_type_symbol->accept(*this); |
864 this->current_var_type_symbol->accept(*this); |
864 s4o.print(" "); |
865 s4o.print(" *"); |
865 symbol->global_var_name->accept(*this); |
866 symbol->global_var_name->accept(*this); |
866 s4o.print("; "); |
867 s4o.print("; "); |
867 print_variable_prefix(); |
868 print_variable_prefix(); |
868 symbol->global_var_name->accept(*this); |
869 symbol->global_var_name->accept(*this); |
869 s4o.print(" = "); |
870 s4o.print(" = "); |
960 TRACE("global_var_spec_c"); |
961 TRACE("global_var_spec_c"); |
961 |
962 |
962 /* now to produce the c equivalent... */ |
963 /* now to produce the c equivalent... */ |
963 switch(wanted_varformat) { |
964 switch(wanted_varformat) { |
964 case local_vf: |
965 case local_vf: |
|
966 case localstatic_vf: |
965 /* NOTE: located variables must be declared static, as the connection to the |
967 /* NOTE: located variables must be declared static, as the connection to the |
966 * MatPLC point must be initialised at program startup, and not whenever |
968 * MatPLC point must be initialised at program startup, and not whenever |
967 * a new function block is instantiated! |
969 * a new function block is instantiated! |
968 * Nevertheless, this construct never occurs inside a Function Block, but |
970 * Nevertheless, this construct never occurs inside a Function Block, but |
969 * only inside a configuration. In this case, only a single instance will |
971 * only inside a configuration. In this case, only a single instance will |
970 * be created, directly at startup, so it is not necessary that the variables |
972 * be created, directly at startup, so it is not necessary that the variables |
971 * be declared static. |
973 * be declared static. |
972 */ |
974 */ |
973 s4o.print(s4o.indent_spaces); |
975 s4o.print(s4o.indent_spaces); |
974 if (symbol->global_var_name != NULL) { |
976 if (symbol->global_var_name != NULL) { |
975 s4o.print("{extern "); |
977 s4o.print("extern "); |
976 this->current_var_type_symbol->accept(*this); |
978 this->current_var_type_symbol->accept(*this); |
977 s4o.print(" "); |
979 s4o.print(" "); |
978 symbol->location->accept(*this); |
980 symbol->location->accept(*this); |
979 s4o.print("; "); |
981 s4o.print(";\n"); |
|
982 if (wanted_varformat == localstatic_vf) |
|
983 s4o.print("static "); |
980 this->current_var_type_symbol->accept(*this); |
984 this->current_var_type_symbol->accept(*this); |
981 s4o.print(" *"); |
985 s4o.print(" *"); |
982 symbol->global_var_name->accept(*this); |
986 symbol->global_var_name->accept(*this); |
983 s4o.print(" = &"); |
987 s4o.print(" = &"); |
984 symbol->location->accept(*this); |
988 symbol->location->accept(*this); |
985 s4o.print(";}\n"); |
989 s4o.print(";\n"); |
986 } |
990 } |
987 break; |
991 break; |
988 |
992 |
989 case constructorinit_vf: |
993 case constructorinit_vf: |
990 s4o.print(nv->get()); |
994 s4o.print(nv->get()); |