305 |
305 |
306 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
306 /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */ |
307 //void *visit(input_declaration_list_c *symbol) {// iterate through list} |
307 //void *visit(input_declaration_list_c *symbol) {// iterate through list} |
308 |
308 |
309 void *visit(edge_declaration_c *symbol) { |
309 void *visit(edge_declaration_c *symbol) { |
|
310 {STAGE4_ERROR(symbol, symbol, "R_EDGE and F_EDGE declarations are not currently supported"); ERROR;} |
|
311 /* |
310 current_type = &tmp_bool; |
312 current_type = &tmp_bool; |
311 symbol->var1_list->accept(*this); |
313 symbol->var1_list->accept(*this); |
312 current_type = NULL; |
314 current_type = NULL; |
|
315 */ |
313 return NULL; |
316 return NULL; |
314 } |
317 } |
315 |
318 |
316 /* We do NOT print out EN and ENO parameters! */ |
319 /* We do NOT print out EN and ENO parameters! */ |
317 void *visit(en_param_declaration_c *symbol) {return NULL;} |
320 void *visit(en_param_declaration_c *symbol) {return NULL;} |
2315 |
2318 |
2316 /* generate the backup/restore function for a CONFIGURATION */ |
2319 /* generate the backup/restore function for a CONFIGURATION */ |
2317 /* the generated function will backup/restore the global variables declared in the |
2320 /* the generated function will backup/restore the global variables declared in the |
2318 * configuration, and call the backup/restore functions of each embedded resource to do |
2321 * configuration, and call the backup/restore functions of each embedded resource to do |
2319 * the same for the global variables declared inside each resource. |
2322 * the same for the global variables declared inside each resource. |
|
2323 * |
|
2324 * The matiec compiler will now generate two additional functions which |
|
2325 * will backup and restore the PLC internal state to a void *buffer. |
|
2326 * config_backup__(void **buffer, int *maxsize) |
|
2327 * config_restore__(void **buffer, int *maxsize) |
|
2328 * |
|
2329 * Both functions will backup/restore the internal state from the memory |
|
2330 * pointed to by *buffer, up to a maximum of *maxsize bytes. |
|
2331 * Both functions will return with buffer pointing to the first unused |
|
2332 * byte in the buffer, and maxsize with the number of remaining bytes. If |
|
2333 * the buffer is not sufficient to store all the internal state, maxsize |
|
2334 * will return with a negative number, equal to the number of missing |
|
2335 * bytes. |
|
2336 * |
|
2337 * In other words, to know the exact size of the buffer required to store |
|
2338 * the PLC internal state, malloc() that memory, and do the backup: |
|
2339 * int maxsize = 0; |
|
2340 * config_backup__(NULL, &maxsize); |
|
2341 * void *buffer = malloc(-1 * maxsize); |
|
2342 * // and now to really back the internal state... |
|
2343 * config_backup__(&buffer, &maxsize); |
2320 */ |
2344 */ |
2321 class generate_c_backup_config_c: public generate_c_base_and_typeid_c { |
2345 class generate_c_backup_config_c: public generate_c_base_and_typeid_c { |
2322 private: |
2346 private: |
2323 const char *func_to_call; // parameter to pass data from: void *visit(configuration_declaration_c *) |
2347 const char *func_to_call; // parameter to pass data from: void *visit(configuration_declaration_c *) |
2324 // to: void *visit(resource_declaration_c *) |
2348 // to: void *visit(resource_declaration_c *) |