equal
deleted
inserted
replaced
47 |
47 |
48 #define ERROR error_exit(__FILE__,__LINE__) |
48 #define ERROR error_exit(__FILE__,__LINE__) |
49 /* function defined in main.cc */ |
49 /* function defined in main.cc */ |
50 extern void error_exit(const char *file_name, int line_no); |
50 extern void error_exit(const char *file_name, int line_no); |
51 |
51 |
|
52 |
|
53 #define STAGE4_ERROR(symbol1, symbol2, ...) {stage4err("while generating C code", symbol1, symbol2, __VA_ARGS__); exit(EXIT_FAILURE);} |
|
54 |
|
55 |
|
56 |
52 /***********************************************************************/ |
57 /***********************************************************************/ |
53 |
58 |
54 /* Unlike Programs and Configurations which get mapped onto C++ classes, |
59 /* Unlike Programs and Configurations which get mapped onto C++ classes, |
55 * Function Blocks are mapped onto a C structure containing the variables, and |
60 * Function Blocks are mapped onto a C structure containing the variables, and |
56 * a C function containing the code in the FB's body. This is to allow direct allocation |
61 * a C function containing the code in the FB's body. This is to allow direct allocation |
373 /************************/ |
378 /************************/ |
374 |
379 |
375 /* SYM_REF2(duration_c, neg, interval) */ |
380 /* SYM_REF2(duration_c, neg, interval) */ |
376 void *visit(duration_c *symbol) { |
381 void *visit(duration_c *symbol) { |
377 if (symbol->neg != NULL) |
382 if (symbol->neg != NULL) |
378 ERROR; |
383 {STAGE4_ERROR(symbol, symbol, "Negative TIME literals are not currently supported"); ERROR;} |
379 symbol->interval->accept(*this); |
384 symbol->interval->accept(*this); |
380 return NULL; |
385 return NULL; |
381 } |
386 } |
382 |
387 |
383 /* SYM_TOKEN(fixed_point_c) */ |
388 /* SYM_TOKEN(fixed_point_c) */ |
2482 case pous_gm: |
2487 case pous_gm: |
2483 static int configuration_count = 0; |
2488 static int configuration_count = 0; |
2484 |
2489 |
2485 if (configuration_count++) { |
2490 if (configuration_count++) { |
2486 /* the first configuration is the one we will use!! */ |
2491 /* the first configuration is the one we will use!! */ |
|
2492 STAGE4_ERROR(symbol, symbol, "A previous CONFIGURATION has already been declared (C code generation currently only allows a single configuration)."); |
2487 ERROR; |
2493 ERROR; |
2488 } |
2494 } |
2489 |
2495 |
2490 current_configuration = symbol; |
2496 current_configuration = symbol; |
2491 |
2497 |
2492 { |
2498 { |
2493 calculate_common_ticktime_c calculate_common_ticktime; |
2499 calculate_common_ticktime_c calculate_common_ticktime; |
2494 symbol->accept(calculate_common_ticktime); |
2500 symbol->accept(calculate_common_ticktime); |
2495 common_ticktime = calculate_common_ticktime.get_common_ticktime(); |
2501 common_ticktime = calculate_common_ticktime.get_common_ticktime(); |
2496 if (common_ticktime == 0) { |
2502 if (common_ticktime == 0) { |
2497 fprintf(stderr, "\nYou must at least define a periodic task to set cycle period!"); |
2503 STAGE4_ERROR(symbol, symbol, "You must define at least one periodic task (to set cycle period)!"); |
2498 ERROR; |
2504 ERROR; |
2499 } |
2505 } |
2500 |
2506 |
2501 symbol->configuration_name->accept(*this); |
2507 symbol->configuration_name->accept(*this); |
2502 |
2508 |