stage4/generate_c/generate_c_sfcdecl.cc
author mjsousa
Sat, 29 Mar 2014 22:46:09 +0000
changeset 885 b2604fc6d25c
parent 861 443e8243f289
child 897 8c3e91c385f5
permissions -rwxr-xr-x
Change order of SET_xxx() macros. (this will allow me to simplify the print_setter() methods later on)
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
     1
/*
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     3
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     4
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     6
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    10
 *  (at your option) any later version.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    11
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    15
 *  GNU General Public License for more details.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    16
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 244
diff changeset
    19
 *
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    20
 *
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    23
 */
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    24
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    25
typedef struct
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    26
{
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    27
  identifier_c *symbol;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    28
} VARIABLE;
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    29
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    30
/***********************************************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    31
/***********************************************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    32
/***********************************************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    33
/***********************************************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    34
861
443e8243f289 Code cleanup (part 3): generate_c_typedecl_c is no longer needed for code generation in POUS.c It is now only needed for datatype declaration in POUS.h
mjsousa
parents: 630
diff changeset
    35
class generate_c_sfcdecl_c: protected generate_c_base_c {
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    36
  
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    37
  public:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    38
      typedef enum {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    39
        sfcdecl_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    40
        sfcinit_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    41
        stepcount_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    42
        stepdef_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    43
        stepundef_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    44
        actiondef_sd,
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    45
        actionundef_sd,
229
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
    46
        actioncount_sd,
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
    47
        transitioncount_sd
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    48
       } sfcdeclaration_t;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    49
  
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    50
  private:
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    51
    int step_number;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    52
    int action_number;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    53
    int transition_number;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    54
    std::list<VARIABLE> variable_list;
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    55
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    56
    sfcdeclaration_t wanted_sfcdeclaration;
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    57
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    58
    search_var_instance_decl_c *search_var_instance_decl;
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    59
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    60
  public:
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    61
    generate_c_sfcdecl_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
861
443e8243f289 Code cleanup (part 3): generate_c_typedecl_c is no longer needed for code generation in POUS.c It is now only needed for datatype declaration in POUS.h
mjsousa
parents: 630
diff changeset
    62
    : generate_c_base_c(s4o_ptr) {
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    63
      this->set_variable_prefix(variable_prefix);
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    64
      search_var_instance_decl = new search_var_instance_decl_c(scope);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    65
    }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    66
    ~generate_c_sfcdecl_c(void) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    67
      variable_list.clear();
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    68
      delete search_var_instance_decl;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    69
    }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    70
    
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    71
    void generate(symbol_c *symbol, sfcdeclaration_t declaration_type) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    72
      wanted_sfcdeclaration = declaration_type;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    73
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    74
      symbol->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    75
    }
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
    76
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    77
/*********************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    78
/* B.1.6  Sequential function chart elements */
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    79
/*********************************************/
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    80
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    81
    void *visit(sequential_function_chart_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    82
      step_number = 0;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    83
      action_number = 0;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    84
      transition_number = 0;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    85
      switch (wanted_sfcdeclaration) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    86
        case sfcdecl_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    87
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    88
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    89
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    90
          /* steps table declaration */
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
    91
          s4o.print(s4o.indent_spaces + "STEP __step_list[");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
    92
          s4o.print(step_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    93
          s4o.print("];\n");
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
    94
          s4o.print(s4o.indent_spaces + "UINT __nb_steps;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    95
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    96
          /* actions table declaration */
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
    97
          s4o.print(s4o.indent_spaces + "ACTION __action_list[");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
    98
          s4o.print(action_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
    99
          s4o.print("];\n");
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   100
          s4o.print(s4o.indent_spaces + "UINT __nb_actions;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   101
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   102
          /* transitions table declaration */
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 160
diff changeset
   103
          s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __transition_list[");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   104
          s4o.print(transition_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   105
          s4o.print("];\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   106
          
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   107
          /* transitions debug table declaration */
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 160
diff changeset
   108
          s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __debug_transition_list[");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   109
          s4o.print(transition_number);
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   110
          s4o.print("];\n");
229
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   111
          s4o.print(s4o.indent_spaces + "UINT __nb_transitions;\n");
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   112
          
125
7ec16536bc87 Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents: 120
diff changeset
   113
          /* last_ticktime declaration */
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   114
          s4o.print(s4o.indent_spaces + "TIME __lasttick_time;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   115
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   116
        case sfcinit_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   117
          s4o.print(s4o.indent_spaces);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   118
          s4o.print("UINT i;\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   119
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   120
          /* steps table count */
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   121
          wanted_sfcdeclaration = stepcount_sd;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   122
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   123
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   124
          s4o.print(s4o.indent_spaces);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   125
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   126
          s4o.print("__nb_steps = ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   127
          s4o.print(step_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   128
          s4o.print(";\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   129
          step_number = 0;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   130
          wanted_sfcdeclaration = sfcinit_sd;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   131
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   132
          /* steps table initialisation */
401
7f052bd3508a Fix STEP and ACTION structure initialization value in SFC
laurent
parents: 392
diff changeset
   133
          s4o.print(s4o.indent_spaces + "static const STEP temp_step = {{0, 0}, 0, {0, 0}};\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   134
          s4o.print(s4o.indent_spaces + "for(i = 0; i < ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   135
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   136
          s4o.print("__nb_steps; i++) {\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   137
          s4o.indent_right();
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   138
          s4o.print(s4o.indent_spaces);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   139
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   140
          s4o.print("__step_list[i] = temp_step;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   141
          s4o.indent_left();
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   142
          s4o.print(s4o.indent_spaces + "}\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   143
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   144
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   145
          
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   146
          /* actions table count */
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   147
          wanted_sfcdeclaration = actioncount_sd;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   148
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   149
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   150
          s4o.print(s4o.indent_spaces);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   151
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   152
          s4o.print("__nb_actions = ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   153
          s4o.print(action_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   154
          s4o.print(";\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   155
          action_number = 0;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   156
          wanted_sfcdeclaration = sfcinit_sd;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   157
          
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   158
          /* actions table initialisation */
628
fe0d516fe291 Fix bug in SFC generated code. Action state was declared in the list of variables to debug, but wasn't stored using structure with flags. This error had side effects that makes Beremiz debug crash.
Laurent Bessard
parents: 594
diff changeset
   159
          s4o.print(s4o.indent_spaces + "static const ACTION temp_action = {0, {0, 0}, 0, 0, {0, 0}, {0, 0}};\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   160
          s4o.print(s4o.indent_spaces + "for(i = 0; i < ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   161
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   162
          s4o.print("__nb_actions; i++) {\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   163
          s4o.indent_right();
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   164
          s4o.print(s4o.indent_spaces);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   165
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   166
          s4o.print("__action_list[i] = temp_action;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   167
          s4o.indent_left();
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   168
          s4o.print(s4o.indent_spaces + "}\n");
125
7ec16536bc87 Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents: 120
diff changeset
   169
          
229
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   170
          /* transitions table count */
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   171
          wanted_sfcdeclaration = transitioncount_sd;
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   172
          for(int i = 0; i < symbol->n; i++)
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   173
            symbol->elements[i]->accept(*this);
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   174
          s4o.print(s4o.indent_spaces);
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   175
          print_variable_prefix();
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   176
          s4o.print("__nb_transitions = ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   177
          s4o.print(transition_number);
229
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   178
          s4o.print(";\n");
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   179
          transition_number = 0;
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   180
          wanted_sfcdeclaration = sfcinit_sd;
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   181
125
7ec16536bc87 Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents: 120
diff changeset
   182
          /* last_ticktime initialisation */
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 141
diff changeset
   183
          s4o.print(s4o.indent_spaces);
125
7ec16536bc87 Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents: 120
diff changeset
   184
          print_variable_prefix();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 125
diff changeset
   185
          s4o.print("__lasttick_time = __CURRENT_TIME;\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   186
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   187
        case stepdef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   188
          s4o.print("// Steps definitions\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   189
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   190
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   191
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   192
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   193
        case actiondef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   194
          s4o.print("// Actions definitions\n");
630
5250fbf20999 Fix bug SFC action index declarations were different in POUS.c and VARIABLES.csv when boolean variables are used as action name in step action association
Laurent Bessard
parents: 628
diff changeset
   195
          for(int i = 0; i < symbol->n; i++)
5250fbf20999 Fix bug SFC action index declarations were different in POUS.c and VARIABLES.csv when boolean variables are used as action name in step action association
Laurent Bessard
parents: 628
diff changeset
   196
             symbol->elements[i]->accept(*this);
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   197
          {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   198
            std::list<VARIABLE>::iterator pt;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   199
            for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   200
              s4o.print("#define ");
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   201
              s4o.print(SFC_STEP_ACTION_PREFIX);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   202
              pt->symbol->accept(*this);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   203
              s4o.print(" ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   204
              s4o.print(action_number);
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   205
              s4o.print("\n");
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   206
              action_number++;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   207
            }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   208
          }
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   209
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   210
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   211
        case stepundef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   212
          s4o.print("// Steps undefinitions\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   213
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   214
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   215
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   216
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   217
        case actionundef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   218
          s4o.print("// Actions undefinitions\n");
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   219
          {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   220
            std::list<VARIABLE>::iterator pt;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   221
            for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   222
              s4o.print("#undef ");
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   223
              s4o.print(SFC_STEP_ACTION_PREFIX);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   224
              pt->symbol->accept(*this);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   225
              s4o.print("\n");
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   226
            }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   227
          }
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   228
          for(int i = 0; i < symbol->n; i++)
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   229
            symbol->elements[i]->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   230
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   231
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   232
        default:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   233
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   234
      }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   235
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   236
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   237
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   238
    void *visit(initial_step_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   239
      switch (wanted_sfcdeclaration) {
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   240
        case actioncount_sd:
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   241
          symbol->action_association_list->accept(*this);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   242
          break;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   243
        case sfcdecl_sd:
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   244
          symbol->action_association_list->accept(*this);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   245
        case stepcount_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   246
          step_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   247
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   248
        case sfcinit_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   249
          s4o.print(s4o.indent_spaces);
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 160
diff changeset
   250
          s4o.print(SET_VAR);
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 160
diff changeset
   251
          s4o.print("(");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   252
          print_variable_prefix();
392
9b88b8b6bccd Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents: 279
diff changeset
   253
          s4o.print(",__step_list[");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   254
          s4o.print(step_number);
885
b2604fc6d25c Change order of SET_xxx() macros. (this will allow me to simplify the print_setter() methods later on)
mjsousa
parents: 861
diff changeset
   255
          s4o.print("].state,,1);\n");
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   256
          step_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   257
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   258
        case stepdef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   259
          s4o.print("#define ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   260
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   261
          symbol->step_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   262
          s4o.print(" ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   263
          s4o.print(step_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   264
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   265
          step_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   266
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   267
        case stepundef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   268
          s4o.print("#undef ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   269
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   270
          symbol->step_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   271
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   272
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   273
        default:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   274
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   275
      }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   276
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   277
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   278
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   279
    void *visit(step_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   280
      switch (wanted_sfcdeclaration) {
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   281
        case actioncount_sd:
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   282
          symbol->action_association_list->accept(*this);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   283
          break;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   284
        case sfcdecl_sd:
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   285
          symbol->action_association_list->accept(*this);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   286
        case stepcount_sd:
119
4cbf71106b66 Bug with C code generation for SFC when more than one sfc_network in one sequential_function_chart fixed
lbessard
parents: 116
diff changeset
   287
        case sfcinit_sd:
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   288
          step_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   289
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   290
        case stepdef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   291
          s4o.print("#define ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   292
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   293
          symbol->step_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   294
          s4o.print(" ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   295
          s4o.print(step_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   296
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   297
          step_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   298
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   299
        case stepundef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   300
          s4o.print("#undef ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   301
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   302
          symbol->step_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   303
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   304
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   305
        default:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   306
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   307
      }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   308
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   309
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   310
244
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   311
    void *visit(action_association_c *symbol) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   312
      /* we try to find the variable instance declaration, to determine if symbol is variable... */
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   313
      symbol_c *var_decl = search_var_instance_decl->get_decl(symbol->action_name);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   314
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   315
      if (var_decl != NULL) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   316
    	std::list<VARIABLE>::iterator pt;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   317
        for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   318
          if (!compare_identifiers(pt->symbol, symbol->action_name))
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   319
            return NULL;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   320
        }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   321
        VARIABLE *variable;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   322
        variable = new VARIABLE;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   323
        variable->symbol = (identifier_c*)(symbol->action_name);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   324
        variable_list.push_back(*variable);
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   325
        action_number++;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   326
      }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   327
      return NULL;
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   328
    }
3a478229db8b Adding support for generating code for variable in step action association instead of action
laurent
parents: 229
diff changeset
   329
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   330
    void *visit(transition_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   331
      switch (wanted_sfcdeclaration) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   332
        case sfcdecl_sd:
229
ca7bc1324540 Bug on SFC debugging fixed
laurent
parents: 221
diff changeset
   333
        case transitioncount_sd:
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   334
          transition_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   335
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   336
        default:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   337
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   338
      }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   339
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   340
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   341
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   342
    void *visit(action_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   343
      switch (wanted_sfcdeclaration) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   344
        case actiondef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   345
          s4o.print("#define ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   346
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   347
          symbol->action_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   348
          s4o.print(" ");
594
c8092e909886 Clean up code (remove parsing of integers in stage 4).
Mario de Sousa <msousa@fe.up.pt>
parents: 401
diff changeset
   349
          s4o.print(action_number);
70
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   350
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   351
          action_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   352
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   353
        case actionundef_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   354
          s4o.print("#undef ");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   355
          s4o.print(SFC_STEP_ACTION_PREFIX);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   356
          symbol->action_name->accept(*this);
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   357
          s4o.print("\n");
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   358
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   359
        case actioncount_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   360
        case sfcdecl_sd:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   361
          action_number++;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   362
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   363
        default:
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   364
          break;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   365
      }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   366
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   367
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   368
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   369
    void *visit(instruction_list_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   370
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   371
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   372
    
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   373
    void *visit(statement_list_c *symbol) {
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   374
      return NULL;
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   375
    }
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   376
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   377
}; /* generate_c_sfcdecl_c */
e1f0ebd2d9ec Change generate_cc to generate_c
lbessard
parents:
diff changeset
   378