stage4/generate_c/generate_var_list.cc
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 26 Apr 2024 09:27:21 +0200
changeset 1105 8128cad6a6e3
parent 1099 cdb045e8be20
permissions -rw-r--r--
merge
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
     1
/*
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 232
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
     3
 *
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 232
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: 232
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
     6
 *
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 232
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: 232
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: 232
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: 232
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: 232
diff changeset
    11
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 232
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: 232
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: 232
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: 232
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: 232
diff changeset
    16
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 232
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: 232
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    19
 *
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    22
 *
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    23
 * Based on the
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    24
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    25
 *
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    26
 */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    27
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    28
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    29
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    30
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    31
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    32
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    33
/***********************************************************************/
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    34
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    35
class search_location_type_c: public iterator_visitor_c {
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    36
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    37
  public:
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    38
    typedef enum {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    39
      none_lt,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    40
      input_lt,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    41
      output_lt,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    42
      memory_lt
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    43
    } locationtype_t;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    44
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    45
    locationtype_t current_location_type;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    46
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    47
  public:
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    48
    search_location_type_c(void) {}
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    49
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    50
    virtual ~search_location_type_c(void) {}
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    51
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    52
    locationtype_t get_location_type(symbol_c *symbol) {
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    53
      current_location_type = none_lt;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    54
      symbol->accept(*this);
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    55
      if (current_location_type == none_lt) ERROR;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    56
      return current_location_type;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    57
    }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    58
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    59
  private:
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    60
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    61
    void *visit(incompl_location_c* symbol) {
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    62
      if (symbol->value[1] == 'I')
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    63
        current_location_type = input_lt;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    64
     else if (symbol->value[1] == 'Q')
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    65
        current_location_type = output_lt;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    66
     else if (symbol->value[1] == 'M')
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    67
        current_location_type = memory_lt;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    68
      return NULL;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    69
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    70
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    71
    void *visit(direct_variable_c *symbol) {
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    72
      if (symbol->value[1] == 'I')
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    73
        current_location_type = input_lt;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    74
     else if (symbol->value[1] == 'Q')
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    75
        current_location_type = output_lt;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    76
     else if (symbol->value[1] == 'M')
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    77
        current_location_type = memory_lt;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    78
      return NULL;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    79
    }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
    80
};
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    81
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
    82
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    83
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    84
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    85
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    86
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    87
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    88
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    89
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    90
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    91
/***********************************************************************/
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    92
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
    93
/* TODO: Delete this helper class search_type_symbol_c, as well as the search_fb_typedecl_c
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
    94
 *       in the absyntac_utils directory. They are no longer usefull, now that we have
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
    95
 *       datatype analysis working!
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
    96
 */
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    97
class search_type_symbol_c: public iterator_visitor_c {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    98
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
    99
  public:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   100
    typedef enum {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   101
      none_vtc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   102
      variable_vtc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   103
      array_vtc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   104
      structure_vtc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   105
      function_block_vtc
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   106
    } vartypecategory_t;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   107
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   108
    vartypecategory_t current_var_type_category;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   109
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   110
  private:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   111
    symbol_c *current_var_type_symbol;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   112
    symbol_c *current_var_type_name;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   113
    search_fb_typedecl_c *search_fb_typedecl;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   114
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   115
  public:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   116
    search_type_symbol_c(symbol_c *scope) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   117
      search_fb_typedecl = new search_fb_typedecl_c(scope);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   118
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   119
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   120
    virtual ~search_type_symbol_c(void) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   121
      delete search_fb_typedecl;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   122
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   123
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   124
    symbol_c *get_type_symbol(symbol_c* symbol) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   125
      this->current_var_type_category = variable_vtc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   126
      this->current_var_type_symbol = NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   127
      this->current_var_type_name = NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   128
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   129
      symbol_c* var_type_symbol = spec_init_sperator_c::get_spec(symbol);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   130
      if (var_type_symbol == NULL) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   131
        var_type_symbol = symbol;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   132
      }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   133
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   134
      var_type_symbol->accept(*this);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   135
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   136
      if (this->current_var_type_symbol == NULL)
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   137
        this->current_var_type_symbol = var_type_symbol;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   138
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   139
      return (this->current_var_type_symbol);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   140
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   141
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   142
    symbol_c *get_current_type_name(void) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   143
      if (this->current_var_type_name == NULL)
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   144
        return (this->current_var_type_symbol);
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   145
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   146
      return (this->current_var_type_name);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   147
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   148
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   149
    void *visit(derived_datatype_identifier_c* symbol) {
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   150
      if (this->current_var_type_name == NULL) {
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   151
        this->current_var_type_name = symbol;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   152
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   153
        this->current_var_type_symbol = search_fb_typedecl->get_decl(this->current_var_type_name);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   154
        if (this->current_var_type_symbol != NULL)
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   155
          this->current_var_type_category = function_block_vtc;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   156
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   157
        else {
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   158
          this->current_var_type_symbol = search_base_type_c::get_basetype_decl(this->current_var_type_name);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   159
          this->current_var_type_symbol->accept(*this);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   160
        }
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   161
      }
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   162
      return NULL;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   163
    }
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   164
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 945
diff changeset
   165
    void *visit(poutype_identifier_c* symbol) {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   166
      if (this->current_var_type_name == NULL) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   167
        this->current_var_type_name = symbol;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   168
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   169
        this->current_var_type_symbol = search_fb_typedecl->get_decl(this->current_var_type_name);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   170
        if (this->current_var_type_symbol != NULL)
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   171
          this->current_var_type_category = function_block_vtc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   172
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   173
        else {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
   174
          this->current_var_type_symbol = search_base_type_c::get_basetype_decl(this->current_var_type_name);
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   175
          this->current_var_type_symbol->accept(*this);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   176
        }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   177
      }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   178
      return NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   179
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   180
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   181
    void *visit(array_specification_c* symbol) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   182
      this->current_var_type_category = array_vtc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   183
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   184
      if (this->current_var_type_name == NULL)
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   185
        this->current_var_type_name = symbol->non_generic_type_name;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   186
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   187
      return NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   188
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   189
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   190
    void *visit(structure_element_declaration_list_c* symbol) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   191
      this->current_var_type_category = structure_vtc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   192
      return NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   193
    }
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   194
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   195
};
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   196
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   197
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   198
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   199
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   200
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   201
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   202
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   203
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   204
/***********************************************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   205
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 898
diff changeset
   206
class generate_var_list_c: protected generate_c_base_and_typeid_c {
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   207
  
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   208
  public:
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   209
    typedef struct {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   210
      symbol_c *symbol;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   211
    } SYMBOL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   212
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   213
    typedef enum {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   214
      none_dt,
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   215
      programs_dt,
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   216
      variables_dt
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   217
    } declarationtype_t;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   218
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   219
    declarationtype_t current_declarationtype;
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   220
    
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   221
    typedef enum {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   222
      none_vcc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   223
      external_vcc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   224
      located_input_vcc,
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   225
      located_memory_vcc,
661
f537c3315f83 Minor changes needed to build with pedantic flag.
Manuele Conti <conti.ma@alice.it>
parents: 641
diff changeset
   226
      located_output_vcc
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   227
    } varclasscategory_t;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   228
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   229
    varclasscategory_t current_var_class_category;
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   230
    
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   231
  private:
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   232
    symbol_c *current_var_type_symbol;
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   233
    symbol_c *current_var_type_name;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   234
    unsigned int current_var_number;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   235
    unsigned int step_number;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   236
    unsigned int transition_number;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   237
    unsigned int action_number;
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   238
    bool configuration_defined;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   239
    std::list<SYMBOL> current_symbol_list;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   240
    search_type_symbol_c *search_type_symbol;
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   241
    unsigned int is_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   242
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   243
  public:
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   244
    generate_var_list_c(stage4out_c *s4o_ptr, symbol_c *scope)
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 898
diff changeset
   245
    : generate_c_base_and_typeid_c(s4o_ptr) {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   246
      search_type_symbol = new search_type_symbol_c(scope);
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   247
      current_var_number = 0;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   248
      current_var_type_symbol = NULL;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   249
      current_var_type_name = NULL;
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   250
      current_declarationtype = none_dt;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   251
      current_var_class_category = none_vcc;
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   252
      is_retain = 0;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   253
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   254
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   255
    ~generate_var_list_c(void) {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   256
      delete search_type_symbol;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   257
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   258
    
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   259
    void update_var_type_symbol(symbol_c *symbol) {
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   260
      this->current_var_type_symbol = search_type_symbol->get_type_symbol(symbol);
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   261
      this->current_var_type_name = search_type_symbol->get_current_type_name();
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   262
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   263
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   264
    void reset_var_type_symbol(void) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   265
      this->current_var_type_symbol = NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   266
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   267
    
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   268
    void generate_programs(symbol_c *symbol) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   269
      s4o.print("// Programs\n");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   270
      current_var_number = 0;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   271
      configuration_defined = false;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   272
      current_declarationtype = programs_dt;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   273
      symbol->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   274
      current_declarationtype = none_dt;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   275
      s4o.print("\n");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   276
    }
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   277
    
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   278
    void generate_variables(symbol_c *symbol) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   279
      s4o.print("// Variables\n");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   280
      current_var_number = 0;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   281
      configuration_defined = false;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   282
      current_declarationtype = variables_dt;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   283
      symbol->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   284
      current_declarationtype = none_dt;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   285
      s4o.print("\n");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   286
    }
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   287
    
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   288
    void declare_variables(symbol_c *symbol) {
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   289
      list_c *list = dynamic_cast<list_c *>(symbol);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   290
      /* should NEVER EVER occur!! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   291
      if (list == NULL) ERROR;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   292
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   293
      for(int i = 0; i < list->n; i++) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 958
diff changeset
   294
        declare_variable(list->get_element(i));
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   295
      }
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   296
    }
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   297
    
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   298
    void declare_variable(symbol_c *symbol) {
317
5b687021c6e7 Fix bug in debugging variable list compilation with structure and array disabling
laurent
parents: 300
diff changeset
   299
      // Arrays and structures are not supported in debugging
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   300
      switch (search_type_symbol->current_var_type_category) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   301
          case search_type_symbol_c::array_vtc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   302
          case search_type_symbol_c::structure_vtc:
317
5b687021c6e7 Fix bug in debugging variable list compilation with structure and array disabling
laurent
parents: 300
diff changeset
   303
          return;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   304
          default:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   305
           break;
317
5b687021c6e7 Fix bug in debugging variable list compilation with structure and array disabling
laurent
parents: 300
diff changeset
   306
      }
157
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   307
      print_var_number();
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   308
      s4o.print(";");
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   309
      switch (search_type_symbol->current_var_type_category) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   310
        case search_type_symbol_c::array_vtc:
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   311
          s4o.print("ARRAY");
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   312
          break;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   313
        case search_type_symbol_c::structure_vtc:
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   314
          s4o.print("STRUCT");
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   315
          break;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   316
        case search_type_symbol_c::function_block_vtc:
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   317
          s4o.print("FB");
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   318
          break;
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   319
        default:
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   320
          switch (this->current_var_class_category) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   321
            case external_vcc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   322
             s4o.print("EXT");
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   323
             break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   324
            case located_input_vcc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   325
             s4o.print("IN");
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   326
             break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   327
            case located_memory_vcc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   328
             s4o.print("MEM");
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   329
             break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   330
            case located_output_vcc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   331
             s4o.print("OUT");
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   332
             break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   333
            default:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   334
             s4o.print("VAR");
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   335
             break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   336
          }
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   337
          break;
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   338
      }
157
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   339
      s4o.print(";");
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   340
      print_symbol_list();
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   341
      symbol->accept(*this);
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   342
      s4o.print(";");
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   343
      print_symbol_list();
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   344
      symbol->accept(*this);
3e12726f9d6b Adding Function Blocks in VARIABLES.csv
lbessard
parents: 141
diff changeset
   345
      s4o.print(";");
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   346
      switch (search_type_symbol->current_var_type_category) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   347
        case search_type_symbol_c::structure_vtc:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   348
        case search_type_symbol_c::function_block_vtc:
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   349
          this->current_var_type_name->accept(*this);
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   350
          s4o.print(";;");
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   351
          print_retain();
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   352
          s4o.print(";\n");
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   353
          if (this->current_var_class_category != external_vcc) {
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   354
              SYMBOL *current_name;
793
268bf4ca5fa1 grand merge
Mario de Sousa <msousa@fe.up.pt>
parents: 726 706
diff changeset
   355
              symbol_c *tmp_var_type;
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   356
              current_name = new SYMBOL;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   357
              current_name->symbol = symbol;
793
268bf4ca5fa1 grand merge
Mario de Sousa <msousa@fe.up.pt>
parents: 726 706
diff changeset
   358
              tmp_var_type = this->current_var_type_symbol;
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   359
              current_symbol_list.push_back(*current_name);
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   360
              this->current_var_type_symbol->accept(*this);
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   361
              current_symbol_list.pop_back();
793
268bf4ca5fa1 grand merge
Mario de Sousa <msousa@fe.up.pt>
parents: 726 706
diff changeset
   362
              this->current_var_type_symbol = tmp_var_type;
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   363
          }
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   364
          break;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   365
        case search_type_symbol_c::array_vtc:
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   366
          this->current_var_type_name->accept(*this);
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   367
          s4o.print(";;");
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   368
          print_retain();
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   369
          s4o.print(";\n");
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   370
          break;
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   371
        default:
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   372
          // base type name
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   373
          this->current_var_type_symbol->accept(*this);
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   374
          s4o.print(";");
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   375
          // type name (eventualy derived)
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   376
          this->current_var_type_name->accept(*this);
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   377
          s4o.print(";");
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   378
          print_retain();
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   379
          s4o.print(";\n");
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   380
          break;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   381
      }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   382
    }
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   383
    void print_retain() {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   384
      if(is_retain)
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   385
          s4o.print("1");
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   386
      else
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   387
          s4o.print("0");
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   388
    }
626
9f2cefb98e60 Fixed VARIABLES.csv, was broken when using enumrated types
Edouard Tisserant
parents: 409
diff changeset
   389
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   390
    void print_var_number(void) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   391
      char str[10];
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   392
      sprintf(str, "%d", current_var_number);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   393
      s4o.print(str);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   394
      current_var_number++;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   395
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   396
        
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   397
    void print_step_number(void) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   398
      char str[10];
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   399
      sprintf(str, "%d", step_number);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   400
      s4o.print(str);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   401
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   402
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   403
    void print_transition_number(void) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   404
      char str[10];
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   405
      sprintf(str, "%d", transition_number);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   406
      s4o.print(str);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   407
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   408
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   409
    void print_action_number(void) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   410
      char str[10];
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   411
      sprintf(str, "%d", action_number);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   412
      s4o.print(str);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   413
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   414
    
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   415
    void print_symbol_list() {
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   416
      std::list<SYMBOL>::iterator pt;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   417
      for(pt = current_symbol_list.begin(); pt != current_symbol_list.end(); pt++) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   418
        pt->symbol->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   419
        s4o.print(".");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   420
      }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   421
    }
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   422
726
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   423
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   424
/********************************/
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   425
/* B 1.3.3 - Derived data types */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   426
/********************************/
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   427
    /*  enumerated_type_name ':' enumerated_spec_init */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   428
    void *visit(enumerated_type_declaration_c *symbol) {
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   429
      this->current_var_type_name->accept(*this);
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   430
      return NULL;
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   431
    }
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   432
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   433
    /* enumerated_specification ASSIGN enumerated_value */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   434
    void *visit(enumerated_spec_init_c *symbol) {
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   435
      /* search_base_type_c now returns an enumerated_type_declaration_c as the base type of a non-anonymous enumerated type
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   436
       * (non-anonymous means it is declared inside a TYPE ... END_TYPE declaration, with a given name/identifier
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   437
       *  unlike implicitly defined anonymous datatypes declared inside VAR ... END_VAR declarations!).
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   438
       * This means that this method should not get called.
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   439
       */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   440
      ERROR;  
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   441
      this->current_var_type_name->accept(*this);
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   442
      return NULL;
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   443
    }
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   444
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   445
    /* enumerated_value_list ',' enumerated_value */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   446
    void *visit(enumerated_value_list_c *symbol) {
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   447
      /* search_base_type_c now returns an enumerated_type_declaration_c as the base type of a non-anonymous enumerated type
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   448
       * (non-anonymous means it is declared inside a TYPE ... END_TYPE declaration, with a given name/identifier
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   449
       *  unlike implicitly defined anonymous datatypes declared inside VAR ... END_VAR declarations!).
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   450
       * This means that this method should not get called.
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   451
       */
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   452
      ERROR;
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   453
      this->current_var_type_name->accept(*this);
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   454
      return NULL;
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   455
    }
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   456
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   457
/********************************************/
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   458
/* B.1.4.3 - Declaration and initialization */
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   459
/********************************************/
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   460
    
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   461
    void *visit(retain_option_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   462
      is_retain = 1;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   463
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   464
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   465
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   466
    void *visit(non_retain_option_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   467
      is_retain = 0;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   468
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   469
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   470
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   471
    /* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   472
    void *visit(output_declarations_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   473
      unsigned int was_retain = is_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   474
      if (symbol->option != NULL)
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   475
        symbol->option->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   476
      symbol->var_init_decl_list->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   477
      is_retain = was_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   478
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   479
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   480
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   481
    /*  VAR RETAIN var_init_decl_list END_VAR */
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   482
    void *visit(retentive_var_declarations_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   483
      unsigned int was_retain = is_retain;
1099
cdb045e8be20 In VARIABLES.CSV, RETAIN variable were only flagged as such for GLOBALS, now local POU variable shoud be as well.
Edouard Tisserant
parents: 1097
diff changeset
   484
      is_retain = 1;
1097
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   485
      symbol->var_init_decl_list->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   486
      is_retain = was_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   487
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   488
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   489
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   490
    /*  VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   491
    void *visit(located_var_declarations_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   492
      unsigned int was_retain = is_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   493
      if (symbol->option != NULL)
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   494
        symbol->option->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   495
      symbol->located_var_decl_list->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   496
      is_retain = was_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   497
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   498
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   499
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   500
    /* VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   501
    void *visit(global_var_declarations_c *symbol) {
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   502
      unsigned int was_retain = is_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   503
      if (symbol->option != NULL)
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   504
        symbol->option->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   505
      symbol->global_var_decl_list->accept(*this);
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   506
      is_retain = was_retain;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   507
      return NULL;
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   508
    }
520a4b937f13 Added RETAIN qualifier to VARIABLES.CSV
Edouard Tisserant
parents: 1088
diff changeset
   509
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   510
    /*  [variable_name] location ':' located_var_spec_init */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   511
    /* variable_name -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   512
    //SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   513
    void *visit(located_var_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   514
        /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   515
         * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   516
         */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   517
        update_var_type_symbol(symbol->located_var_spec_init);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   518
        
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   519
        search_location_type_c search_location_type;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   520
        switch (search_location_type.get_location_type(symbol->location)) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   521
          case search_location_type_c::input_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   522
            this->current_var_class_category = located_input_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   523
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   524
          case search_location_type_c::memory_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   525
            this->current_var_class_category = located_memory_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   526
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   527
          case search_location_type_c::output_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   528
              this->current_var_class_category = located_output_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   529
              break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   530
          default:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   531
            ERROR;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   532
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   533
        }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   534
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   535
        if (symbol->variable_name != NULL)
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   536
          declare_variable(symbol->variable_name);
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   537
        else
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   538
          declare_variable(symbol->location);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   539
        
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   540
        this->current_var_class_category = none_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   541
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   542
        /* Values no longer in scope, and therefore no longer used.
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   543
         * Make an effort to keep them set to NULL when not in use
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   544
         * in order to catch bugs as soon as possible...
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   545
         */
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   546
        reset_var_type_symbol();
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   547
        return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   548
    }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   549
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   550
    /* variable_name incompl_location ':' var_spec */
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   551
    /* variable_name -> may be NULL ! */
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   552
    //SYM_REF3(incompl_located_var_decl_c, variable_name, incompl_location, var_spec)
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   553
    void *visit(incompl_located_var_decl_c *symbol) {
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   554
        /* Start off by setting the current_var_type_symbol and
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   555
         * current_var_init_symbol private variables...
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   556
         */
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   557
        update_var_type_symbol(symbol->var_spec);
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   558
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   559
        search_location_type_c search_location_type;
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   560
        switch (search_location_type.get_location_type(symbol->incompl_location)) {
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   561
          case search_location_type_c::input_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   562
            this->current_var_class_category = located_input_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   563
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   564
          case search_location_type_c::memory_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   565
            this->current_var_class_category = located_memory_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   566
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   567
          case search_location_type_c::output_lt:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   568
            this->current_var_class_category = located_output_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   569
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   570
          default:
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   571
            ERROR;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   572
            break;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   573
        }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   574
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   575
        if (symbol->variable_name != NULL)
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   576
          declare_variable(symbol->variable_name);
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   577
        else
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   578
          declare_variable(symbol->incompl_location);
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   579
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   580
        this->current_var_class_category = none_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   581
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   582
        /* Values no longer in scope, and therefore no longer used.
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   583
        * Make an effort to keep them set to NULL when not in use
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   584
        * in order to catch bugs as soon as possible...
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   585
        */
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   586
       reset_var_type_symbol();
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   587
        return NULL;
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   588
    }
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   589
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   590
    /*  var1_list ':' array_spec_init */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   591
    // SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   592
    void *visit(array_var_init_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   593
      TRACE("array_var_init_decl_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   594
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   595
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   596
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   597
      update_var_type_symbol(symbol->array_spec_init);
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   598
      
317
5b687021c6e7 Fix bug in debugging variable list compilation with structure and array disabling
laurent
parents: 300
diff changeset
   599
      declare_variables(symbol->var1_list);
409
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   600
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   601
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   602
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   603
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   604
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   605
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   606
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   607
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   608
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   609
409
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   610
    /*  var1_list ':' array_specification */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   611
    //SYM_REF2(array_var_declaration_c, var1_list, array_specification)
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   612
    void *visit(array_var_declaration_c *symbol) {
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   613
       TRACE("array_var_declaration_c");
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   614
       /* Start off by setting the current_var_type_symbol and
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   615
        * current_var_init_symbol private variables...
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   616
        */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   617
       update_var_type_symbol(symbol->array_specification);
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   618
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   619
       declare_variables(symbol->var1_list);
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   620
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   621
       /* Values no longer in scope, and therefore no longer used.
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   622
        * Make an effort to keep them set to NULL when not in use
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   623
        * in order to catch bugs as soon as possible...
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   624
        */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   625
       reset_var_type_symbol();
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   626
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   627
       return NULL;
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   628
    }
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   629
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   630
    /*  var1_list ':' initialized_structure */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   631
    // SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   632
    void *visit(structured_var_init_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   633
      TRACE("structured_var_init_decl_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   634
      /* Please read the comments inside the var1_init_decl_c
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   635
       * visitor, as they apply here too.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   636
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   637
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   638
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   639
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   640
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   641
      update_var_type_symbol(symbol->initialized_structure);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   642
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   643
      /* now to produce the c equivalent... */
317
5b687021c6e7 Fix bug in debugging variable list compilation with structure and array disabling
laurent
parents: 300
diff changeset
   644
      declare_variables(symbol->var1_list);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   645
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   646
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   647
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   648
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   649
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   650
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   651
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   652
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   653
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   654
    
409
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   655
    /*  var1_list ':' structure_type_name */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   656
    //SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name)
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   657
    void *visit(structured_var_declaration_c *symbol) {
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   658
      TRACE("structured_var_declaration_c");
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   659
      /* Please read the comments inside the var1_init_decl_c
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   660
       * visitor, as they apply here too.
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   661
       */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   662
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   663
      /* Start off by setting the current_var_type_symbol and
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   664
       * current_var_init_symbol private variables...
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   665
       */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   666
      update_var_type_symbol(symbol->structure_type_name);
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   667
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   668
      /* now to produce the c equivalent... */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   669
      declare_variables(symbol->var1_list);
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   670
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   671
      /* Values no longer in scope, and therefore no longer used.
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   672
       * Make an effort to keep them set to NULL when not in use
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   673
       * in order to catch bugs as soon as possible...
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   674
       */
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   675
      reset_var_type_symbol();
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   676
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   677
      return NULL;
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   678
    }
8d876ad522f4 Fix bug with complex type inout variables while generating variable list
Laurent Bessard
parents: 377
diff changeset
   679
726
9b61eb4f00dc Change the base datatype of enumerations to an enumerated_type_declaration_c (for named types!)
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   680
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   681
    /* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   682
    /* structure_initialization -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   683
    void *visit(fb_name_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   684
      TRACE("fb_name_decl_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   685
      /* Please read the comments inside the var1_init_decl_c
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   686
       * visitor, as they apply here too.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   687
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   688
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   689
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   690
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   691
       */
810
d9c48ad646f1 Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents: 805
diff changeset
   692
      update_var_type_symbol(symbol->fb_spec_init);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   693
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   694
      /* now to produce the c equivalent... */
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   695
      declare_variables(symbol->fb_name_list);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   696
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   697
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   698
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   699
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   700
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   701
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   702
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   703
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   704
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   705
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   706
    /*  global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   707
    //SYM_REF2(external_declaration_c, global_var_name, specification)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   708
    void *visit(external_declaration_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   709
      TRACE("external_declaration_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   710
      /* Please read the comments inside the var1_init_decl_c
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   711
       * visitor, as they apply here too.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   712
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   713
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   714
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   715
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   716
       */
166
09004f402097 Bug with external variable declaration fixed
lbessard
parents: 160
diff changeset
   717
      update_var_type_symbol(symbol->specification);
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   718
      
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   719
      this->current_var_class_category = external_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   720
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   721
      /* now to produce the c equivalent... */
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   722
      declare_variable(symbol->global_var_name);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   723
      
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   724
      this->current_var_class_category = none_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   725
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   726
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   727
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   728
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   729
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   730
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   731
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   732
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   733
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   734
    /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   735
    /* type_specification ->may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   736
    // SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   737
    void *visit(global_var_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   738
      TRACE("global_var_decl_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   739
      /* Please read the comments inside the var1_init_decl_c
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   740
       * visitor, as they apply here too.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   741
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   742
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   743
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   744
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   745
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   746
      update_var_type_symbol(symbol->type_specification);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   747
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   748
      /* now to produce the c equivalent... */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   749
      symbol->global_var_spec->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   750
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   751
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   752
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   753
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   754
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   755
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   756
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   757
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   758
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   759
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   760
    void *visit(global_var_list_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   761
      declare_variables(symbol);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   762
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   763
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   764
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   765
    /*| global_var_name location */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   766
    // SYM_REF2(global_var_spec_c, global_var_name, location)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   767
    void *visit(global_var_spec_c *symbol) {
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   768
      search_location_type_c search_location_type;
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   769
      switch (search_location_type.get_location_type(symbol->location)) {
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   770
        case search_location_type_c::input_lt:
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   771
          this->current_var_class_category = located_input_vcc;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   772
          break;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   773
        case search_location_type_c::memory_lt:
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   774
          this->current_var_class_category = located_memory_vcc;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   775
          break;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   776
        case search_location_type_c::output_lt:
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   777
          this->current_var_class_category = located_output_vcc;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   778
          break;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   779
        default:
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   780
          ERROR;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   781
          break;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 626
diff changeset
   782
      }
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   783
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   784
      if (symbol->global_var_name != NULL)
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   785
        declare_variable(symbol->global_var_name);
232
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   786
      else
29ab33687333 Adding support for making distinction between external variables and located variables for forcing
laurent
parents: 229
diff changeset
   787
        declare_variable(symbol->location);
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   788
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   789
      this->current_var_class_category = none_vcc;
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   790
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   791
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   792
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   793
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   794
    void *visit(var1_init_decl_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   795
      TRACE("var1_init_decl_c");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   796
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   797
      /* Start off by setting the current_var_type_symbol and
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   798
       * current_var_init_symbol private variables...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   799
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   800
      update_var_type_symbol(symbol->spec_init);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   801
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   802
      /* now to produce the c equivalent... */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   803
      declare_variables(symbol->var1_list);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   804
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   805
      /* Values no longer in scope, and therefore no longer used.
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   806
       * Make an effort to keep them set to NULL when not in use
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   807
       * in order to catch bugs as soon as possible...
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   808
       */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   809
      reset_var_type_symbol();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   810
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   811
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   812
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   813
206
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   814
    void *visit(en_param_declaration_c *symbol) {
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   815
      TRACE("en_param_declaration_c");
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   816
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   817
      /* Start off by setting the current_var_type_symbol and
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   818
       * current_var_init_symbol private variables...
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   819
       */
805
b737cfc92614 Use simple_spec_init_c inside en_param_declaration_c (will reduce need to handle it as a special case in the future).
Mario de Sousa <msousa@fe.up.pt>
parents: 793
diff changeset
   820
      update_var_type_symbol(symbol->type_decl);
206
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   821
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   822
      /* now to produce the c equivalent... */
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   823
      declare_variable(symbol->name);
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   824
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   825
      /* Values no longer in scope, and therefore no longer used.
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   826
       * Make an effort to keep them set to NULL when not in use
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   827
       * in order to catch bugs as soon as possible...
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   828
       */
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   829
      reset_var_type_symbol();
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   830
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   831
      return NULL;
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   832
    }
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   833
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   834
    void *visit(eno_param_declaration_c *symbol) {
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   835
      TRACE("eno_param_declaration_c");
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   836
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   837
      /* Start off by setting the current_var_type_symbol and
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   838
       * current_var_init_symbol private variables...
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   839
       */
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 317
diff changeset
   840
      update_var_type_symbol(symbol->type);
206
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   841
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   842
      /* now to produce the c equivalent... */
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   843
      declare_variable(symbol->name);
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   844
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   845
      /* Values no longer in scope, and therefore no longer used.
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   846
       * Make an effort to keep them set to NULL when not in use
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   847
       * in order to catch bugs as soon as possible...
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   848
       */
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   849
      reset_var_type_symbol();
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   850
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   851
      return NULL;
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   852
    }
261beef39000 Bug with EN/ENO in generate_var_list that breaks parsing of variables.csv fixed
laurent
parents: 195
diff changeset
   853
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   854
/********************************/
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   855
/* B 1.3.3 - Derived data types */
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   856
/********************************/
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   857
    void *visit(data_type_declaration_c *symbol) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   858
      return NULL;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   859
    }
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   860
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   861
    void *visit(structure_element_declaration_list_c *symbol) {
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   862
      for(int i = 0; i < symbol->n; i++) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 958
diff changeset
   863
        symbol->get_element(i)->accept(*this);
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   864
      }
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   865
      return NULL;
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   866
    }
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   867
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   868
    void *visit(structure_element_declaration_c *symbol) {
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   869
      /* Start off by setting the current_var_type_symbol and
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   870
       * current_var_init_symbol private variables...
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   871
       */
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   872
      update_var_type_symbol(symbol->spec_init);
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   873
      
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   874
      /* now to produce the c equivalent... */
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   875
      declare_variable(symbol->structure_element_name);
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   876
      
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   877
      /* Values no longer in scope, and therefore no longer used.
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   878
       * Make an effort to keep them set to NULL when not in use
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   879
       * in order to catch bugs as soon as possible...
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   880
       */
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   881
      reset_var_type_symbol();
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   882
      
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   883
      return NULL;
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   884
    }
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
   885
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   886
/**************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   887
/* B.1.5 - Program organization units */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   888
/**************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   889
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   890
/***********************/
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   891
/* B 1.5.1 - Functions */
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   892
/***********************/
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   893
    void *visit(function_declaration_c *symbol) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   894
      return NULL;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   895
    }
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   896
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   897
/*****************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   898
/* B 1.5.2 - Function Blocks */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   899
/*****************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   900
    void *visit(function_block_declaration_c *symbol) {
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   901
      if (current_declarationtype == variables_dt && configuration_defined) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   902
        symbol->var_declarations->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   903
        symbol->fblock_body->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   904
      }
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   905
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   906
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   907
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   908
/**********************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   909
/* B 1.5.3 - Programs */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   910
/**********************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   911
    void *visit(program_declaration_c *symbol) {
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   912
      if (current_declarationtype == variables_dt && configuration_defined) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   913
        symbol->var_declarations->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   914
        symbol->function_block_body->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
   915
      }
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   916
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   917
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   918
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   919
/**********************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   920
/* B 1.6 - Sequential function chart elements */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   921
/**********************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   922
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   923
    /* | sequential_function_chart sfc_network */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   924
    //SYM_LIST(sequential_function_chart_c)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   925
    void *visit(sequential_function_chart_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   926
      step_number = 0;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   927
      transition_number = 0;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   928
      action_number = 0;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   929
      for(int i = 0; i < symbol->n; i++) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 958
diff changeset
   930
        symbol->get_element(i)->accept(*this);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   931
      }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   932
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   933
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   934
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   935
    /* INITIAL_STEP step_name ':' action_association_list END_STEP */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   936
    //SYM_REF2(initial_step_c, step_name, action_association_list)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   937
    void *visit(initial_step_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   938
      print_var_number();
115
3dd564ff94e4 Adding support to distinguish direct variables and pointed variables
lbessard
parents: 111
diff changeset
   939
      s4o.print(";VAR;");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   940
      print_symbol_list();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   941
      symbol->step_name->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   942
      s4o.print(".X;");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   943
      print_symbol_list();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 138
diff changeset
   944
      s4o.print("__step_list[");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   945
      print_step_number();
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   946
      s4o.print("].X;BOOL;BOOL;\n");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   947
      step_number++;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   948
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   949
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   950
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   951
    /* STEP step_name ':' action_association_list END_STEP */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   952
    //SYM_REF2(step_c, step_name, action_association_list)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   953
    void *visit(step_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   954
      print_var_number();
115
3dd564ff94e4 Adding support to distinguish direct variables and pointed variables
lbessard
parents: 111
diff changeset
   955
      s4o.print(";VAR;");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   956
      print_symbol_list();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   957
      symbol->step_name->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   958
      s4o.print(".X;");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   959
      print_symbol_list();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 138
diff changeset
   960
      s4o.print("__step_list[");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   961
      print_step_number();
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   962
      s4o.print("].X;BOOL;BOOL;\n");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   963
      step_number++;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   964
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   965
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   966
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   967
    /* TRANSITION [transition_name] ['(' PRIORITY ASSIGN integer ')'] 
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   968
     *   FROM steps TO steps 
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   969
     *   transition_condition 
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   970
     * END_TRANSITION
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   971
     */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   972
    /* transition_name -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   973
    /* integer -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   974
    //SYM_REF5(transition_c, transition_name, integer, from_steps, to_steps, transition_condition)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   975
    void *visit(transition_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   976
      print_var_number();
115
3dd564ff94e4 Adding support to distinguish direct variables and pointed variables
lbessard
parents: 111
diff changeset
   977
      s4o.print(";VAR;");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   978
      print_symbol_list();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   979
      symbol->from_steps->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   980
      s4o.print("->");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   981
      symbol->to_steps->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   982
      s4o.print(";");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   983
      print_symbol_list();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 138
diff changeset
   984
      s4o.print("__debug_transition_list[");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   985
      print_transition_number();
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
   986
      s4o.print("];BOOL;BOOL;\n");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   987
      transition_number++;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   988
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   989
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   990
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   991
    /* step_name | '(' step_name_list ')' */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   992
    /* step_name      -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   993
    /* step_name_list -> may be NULL ! */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   994
    //SYM_REF2(steps_c, step_name, step_name_list)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   995
    void *visit(steps_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   996
      if (symbol->step_name != NULL)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   997
        symbol->step_name->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   998
      if (symbol->step_name_list != NULL)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
   999
        symbol->step_name_list->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1000
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1001
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1002
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1003
    /* | step_name_list ',' step_name */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1004
    //SYM_LIST(step_name_list_c)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1005
    void *visit(step_name_list_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1006
      for(int i = 0; i < symbol->n; i++) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 958
diff changeset
  1007
        symbol->get_element(i)->accept(*this);
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1008
        if (i < symbol->n - 1)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1009
          s4o.print(",");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1010
      }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1011
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1012
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1013
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1014
    /* ACTION action_name ':' function_block_body END_ACTION */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1015
    //SYM_REF2(action_c, action_name, function_block_body)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1016
    void *visit(action_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1017
      print_var_number();
115
3dd564ff94e4 Adding support to distinguish direct variables and pointed variables
lbessard
parents: 111
diff changeset
  1018
      s4o.print(";VAR;");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1019
      print_symbol_list();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1020
      symbol->action_name->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1021
      s4o.print(".Q;");
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1022
      print_symbol_list();
141
d2dc99c319b6 Adding support for transition debugging
lbessard
parents: 138
diff changeset
  1023
      s4o.print("__action_list[");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1024
      print_action_number();
1088
9cb7c8bf7dbc Add a column to VARIABLES.CSV, containing variable (derived) type name, additionally to current last column contyaining base type name
Edouard Tisserant
parents: 1041
diff changeset
  1025
      s4o.print("].state;BOOL;BOOL;\n");
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1026
      action_number++;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1027
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1028
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1029
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1030
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1031
/**************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1032
/* B.1.7 - Configuration elements     */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1033
/**************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1034
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1035
    /*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1036
    //SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1037
    void *visit(program_configuration_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1038
      
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1039
      switch (current_declarationtype) {
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1040
        case programs_dt:
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1041
          print_var_number();
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1042
          s4o.print(";");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1043
          print_symbol_list();
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1044
          symbol->program_name->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1045
          s4o.print(";");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1046
          symbol->program_type_name->accept(*this);
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1047
          s4o.print(";\n");
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1048
          break;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1049
        case variables_dt:
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1050
          /* Start off by setting the current_var_type_symbol and
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1051
           * current_var_init_symbol private variables...
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1052
           */
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
  1053
          update_var_type_symbol(symbol->program_type_name);
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1054
          
160
59d58f5e6caa Adding support for compiling struct data types
lbessard
parents: 158
diff changeset
  1055
          declare_variable(symbol->program_name);
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1056
          
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1057
          /* Values no longer in scope, and therefore no longer used.
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1058
           * Make an effort to keep them set to NULL when not in use
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1059
           * in order to catch bugs as soon as possible...
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1060
           */
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1061
          reset_var_type_symbol();
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1062
          
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1063
          break;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1064
        default:
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1065
          break;
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1066
      }
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1067
      
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1068
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1069
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1070
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1071
    /* CONFIGURATION configuration_name
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1072
     *   optional_global_var_declarations
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1073
     *   (resource_declaration_list | single_resource_declaration)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1074
     *   optional_access_declarations
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1075
     *   optional_instance_specific_initializations
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1076
     * END_CONFIGURATION
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1077
     */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1078
    //SYM_REF5(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1079
    void *visit(configuration_declaration_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1080
      SYMBOL *current_name;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1081
      current_name = new SYMBOL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1082
      current_name->symbol = symbol->configuration_name;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1083
      current_symbol_list.push_back(*current_name);
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1084
      configuration_defined = true;
135
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1085
      
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1086
      switch (current_declarationtype) {
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1087
        case variables_dt:
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1088
          if (symbol->global_var_declarations != NULL)
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1089
            symbol->global_var_declarations->accept(*this);
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1090
          break;
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1091
        default:
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1092
          break;
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1093
      }
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1094
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1095
      symbol->resource_declarations->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1096
      current_symbol_list.pop_back();
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 115
diff changeset
  1097
      configuration_defined = false;
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1098
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1099
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1100
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1101
    /* RESOURCE resource_name ON resource_type_name
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1102
     *   optional_global_var_declarations
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1103
     *   single_resource_declaration
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1104
     * END_RESOURCE
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1105
     */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1106
    //SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1107
    void *visit(resource_declaration_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1108
      SYMBOL *current_name;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1109
      current_name = new SYMBOL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1110
      current_name->symbol = symbol->resource_name;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1111
      current_symbol_list.push_back(*current_name);
135
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1112
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1113
      switch (current_declarationtype) {
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1114
        case variables_dt:
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1115
          if (symbol->global_var_declarations != NULL)
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1116
            symbol->global_var_declarations->accept(*this);
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1117
          break;
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1118
        default:
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1119
          break;
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1120
      }
0f3f6714b938 Fixed generation of VARIABLES.csv, some variables appeared in program section
etisserant
parents: 121
diff changeset
  1121
      
111
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1122
      
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1123
      symbol->resource_declaration->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1124
      
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1125
      current_symbol_list.pop_back();
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1126
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1127
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1128
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1129
    /* task_configuration_list program_configuration_list */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1130
    //SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list)
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1131
    void *visit(single_resource_declaration_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1132
      symbol->program_configuration_list->accept(*this);
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1133
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1134
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1135
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1136
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1137
/*************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1138
/* B 2.1 - Instructions and operands */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1139
/*************************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1140
    void *visit(instruction_list_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1141
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1142
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1143
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1144
/************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1145
/* B 3.2 - Statements   */
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1146
/************************/
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1147
    void *visit(statement_list_c *symbol) {
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1148
      return NULL;
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1149
    }
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1150
    
ee31ee39eaf6 Adding structure variable list generation module
lbessard
parents:
diff changeset
  1151
};