1196 TRACE("global_var_spec_c"); |
1195 TRACE("global_var_spec_c"); |
1197 |
1196 |
1198 /* now to produce the c equivalent... */ |
1197 /* now to produce the c equivalent... */ |
1199 switch(wanted_varformat) { |
1198 switch(wanted_varformat) { |
1200 case local_vf: |
1199 case local_vf: |
1201 case localstatic_vf: |
|
1202 /* NOTE: located variables must be declared static, as the connection to the |
|
1203 * MatPLC point must be initialised at program startup, and not whenever |
|
1204 * a new function block is instantiated! |
|
1205 * Nevertheless, this construct never occurs inside a Function Block, but |
|
1206 * only inside a configuration. In this case, only a single instance will |
|
1207 * be created, directly at startup, so it is not necessary that the variables |
|
1208 * be declared static. |
|
1209 */ |
|
1210 s4o.print(s4o.indent_spaces); |
1200 s4o.print(s4o.indent_spaces); |
1211 if (symbol->global_var_name != NULL) { |
1201 if (symbol->global_var_name != NULL) { |
1212 s4o.print("extern "); |
1202 s4o.print("extern "); |
1213 this->current_var_type_symbol->accept(*this); |
1203 this->current_var_type_symbol->accept(*this); |
1214 s4o.print("* "); |
1204 s4o.print("* "); |
1215 symbol->location->accept(*this); |
1205 symbol->location->accept(*this); |
1216 s4o.print(";\n"); |
1206 s4o.print(";\n"); |
1217 if (wanted_varformat == localstatic_vf) |
|
1218 s4o.print("static "); |
|
1219 this->current_var_type_symbol->accept(*this); |
1207 this->current_var_type_symbol->accept(*this); |
1220 s4o.print(" *"); |
1208 s4o.print(" *"); |
1221 symbol->global_var_name->accept(*this); |
1209 symbol->global_var_name->accept(*this); |
1222 s4o.print(" = "); |
|
1223 symbol->location->accept(*this); |
|
1224 s4o.print(";\n"); |
1210 s4o.print(";\n"); |
1225 } |
1211 } |
1226 break; |
1212 break; |
1227 |
1213 |
1228 case constructorinit_vf: |
1214 case constructorinit_vf: |
1229 s4o.print(nv->get()); |
1215 s4o.print(nv->get()); |
1230 |
1216 |
1231 if (symbol->global_var_name != NULL) { |
1217 if (symbol->global_var_name != NULL) { |
1232 s4o.print("*"); |
1218 symbol->global_var_name->accept(*this); |
|
1219 s4o.print(" = "); |
|
1220 symbol->location->accept(*this); |
|
1221 s4o.print(";"); |
|
1222 s4o.print(nv->get()); |
|
1223 s4o.print("*"); |
1233 symbol->global_var_name->accept(*this); |
1224 symbol->global_var_name->accept(*this); |
1234 } |
1225 } |
1235 else |
1226 else |
1236 symbol->location->accept(*this); |
1227 symbol->location->accept(*this); |
1237 s4o.print(" = "); |
1228 s4o.print(" = "); |