absyntax_utils/search_var_instance_decl.cc
author mjsousa
Fri, 23 Aug 2013 12:33:12 +0100
changeset 848 db78824cec23
parent 812 6679b6b21214
child 851 2c59c2b8fca4
permissions -rw-r--r--
Use get_datatype_info_c::is_type_valid() to determine datatype validity
(some datatype bugs in source code were going unreported!)
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     1
/*
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     3
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     4
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 265
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     6
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    10
 *  (at your option) any later version.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    11
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    15
 *  GNU General Public License for more details.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    16
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    19
 *
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    20
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    23
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    24
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    25
/*
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 226
diff changeset
    26
 * An IEC 61131-3 compiler.
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    27
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    28
 * Based on the
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    30
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    31
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    32
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    33
/* Search in a VAR* END_VAR declaration for the delcration of the specified variable instance. 
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    34
 * Will return:
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    35
 *     - the declaration itself (get_decl() )
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    36
 *     - the type of declaration in which the variable was declared (get_vartype() )
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    37
 *
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    38
 * The variable instance may NOT be a member of a structure of a memeber
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    39
 * of a structure of an element of an array of ...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    40
 *
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    41
 * For example, considering the following 'variables':
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    42
 *    window.points[1].coordinate.x
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    43
 *    window.points[1].colour
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    44
 *    offset[99]
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    45
 *
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    46
 *   passing a reference to 'points', 'points[1]', 'points[1].colour', 'colour'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    47
 *    ARE NOT ALLOWED!
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    48
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    49
 * This class must only be passed the name of the variable that will appear
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    50
 * in the variable declaration. In the above examples, this would be
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    51
 *   'window.points[1].coordinate.x'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    52
 *   'window.points[1].coordinate'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    53
 *   'window.points[1]'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    54
 *   'window'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    55
 *   'window.points[1].colour'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    56
 *   'offset'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    57
 *   'offset[99]'
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    58
 *
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    59
 *
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    60
 */
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    61
 
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    62
/* Note: 
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    63
 * Determining the declaration type of a specific variable instance (including
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    64
 * function block instances) really means determining whether the variable was declared in a
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    65
 *  VAR_INPUT
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    66
 *  VAR_OUTPUT
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    67
 *  VAR_IN_OUT
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    68
 *  VAR
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    69
 *  VAR_TEMP
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    70
 *  VAR_EXTERNAL
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    71
 *  VAR_GLOBAL
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    72
 *  VAR <var_name> AT <location>   -> Located variable!
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    73
 * 
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    74
 */
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    75
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    76
/* Note:
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    77
 *  The current_type_decl that this class returns may reference the
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    78
 * name of a type, or the type declaration itself!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    79
 * For an example of the first, consider a variable declared as ...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    80
 * x : AAA;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    81
 * where the AAA type is previously declared as whatever.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    82
 * For an example of the second, consider a variable declared as ...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    83
 * x : array of int [10];  ---->  is allowed
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    84
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    85
 * If it is the first, we will return a reference to the name, if the second
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    86
 * we return a reference to the declaration!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    87
 */
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    88
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    89
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    90
#include "absyntax_utils.hh"
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    91
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    92
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    93
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    94
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
    95
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    96
search_var_instance_decl_c::search_var_instance_decl_c(symbol_c *search_scope) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    97
  this->current_vartype = none_vt;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    98
  this->search_scope = search_scope;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    99
  this->search_name = NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   100
  this->current_type_decl = NULL;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   101
  this->current_option = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   102
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   103
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   104
symbol_c *search_var_instance_decl_c::get_decl(symbol_c *variable) {
217
f5dfadf5de54 Adding support for declare, init, get and set macros
laurent
parents: 202
diff changeset
   105
  this->current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   106
  this->current_option  = none_opt;
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   107
  this->search_name = get_var_name_c::get_name(variable);
812
6679b6b21214 Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents: 810
diff changeset
   108
  if (NULL == search_scope) return NULL; // NOTE: This is not an ERROR! declaration_check_c, for e.g., relies on this returning NULL!
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   109
  return (symbol_c *)search_scope->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   110
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   111
536
563b013ec670 Change constants into enums.
Mario de Sousa <msousa@fe.up.pt>
parents: 531
diff changeset
   112
search_var_instance_decl_c::vt_t search_var_instance_decl_c::get_vartype(symbol_c *variable) {
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   113
  this->current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   114
  this->current_option  = none_opt;
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   115
  this->search_name = get_var_name_c::get_name(variable);
812
6679b6b21214 Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents: 810
diff changeset
   116
  if (NULL == search_scope) ERROR;
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   117
  search_scope->accept(*this);
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   118
  return this->current_vartype;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   119
}
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   120
536
563b013ec670 Change constants into enums.
Mario de Sousa <msousa@fe.up.pt>
parents: 531
diff changeset
   121
search_var_instance_decl_c::opt_t search_var_instance_decl_c::get_option(symbol_c *variable) {
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   122
  this->current_vartype = none_vt;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   123
  this->current_option  = none_opt;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   124
  this->search_name = get_var_name_c::get_name(variable);
812
6679b6b21214 Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents: 810
diff changeset
   125
  if (NULL == search_scope) ERROR;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   126
  search_scope->accept(*this);
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   127
  return this->current_option;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   128
}
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   129
531
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   130
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   131
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   132
/* This is a temporary fix. Hopefully, once I clean up stage4 code, and I change the way
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   133
 * we generate C code, this function will no longer be needed!
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   134
 */
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   135
#include <typeinfo>  /* required for typeid() */
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   136
bool search_var_instance_decl_c::type_is_complex(symbol_c *symbol) {
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   137
  symbol_c *decl;
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   138
  
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   139
  decl = this->get_decl(symbol);
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   140
  if (NULL == decl) ERROR;
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 625
diff changeset
   141
  decl = search_base_type_c::get_basetype_decl(decl);
531
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   142
  if (NULL == decl) ERROR;
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   143
  
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   144
  return ((typeid( *(decl) ) == typeid( array_specification_c                )) ||
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   145
//        (typeid( *(decl) ) == typeid( array_spec_init_c                    )) ||  /* does not seem to be necessary */
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   146
          (typeid( *(decl) ) == typeid( structure_type_declaration_c         )) ||  
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   147
          (typeid( *(decl) ) == typeid( structure_element_declaration_list_c )) ||
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   148
//        (typeid( *(decl) ) == typeid( structure_type_declaration_c         )) ||  /* does not seem to be necessary */
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   149
          (typeid( *(decl) ) == typeid( initialized_structure_c              )) ||
793
268bf4ca5fa1 grand merge
Mario de Sousa <msousa@fe.up.pt>
parents: 718 706
diff changeset
   150
          (search_base_type_c::type_is_fb(decl) && current_vartype == external_vt)
531
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   151
         );
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   152
}
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   153
706
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   154
bool search_var_instance_decl_c::type_is_fb(symbol_c *symbol) {
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   155
    symbol_c *decl;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   156
    search_base_type_c search_base_type;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   157
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   158
    decl = this->get_decl(symbol);
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   159
    if (NULL == decl) ERROR;
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   160
    return search_base_type.type_is_fb(decl);
31553c22f318 Adding support for declaring function block instances as global and external variables
Laurent Bessard
parents: 625
diff changeset
   161
}
531
e7d6f28fc882 Make temporary fix to is_complex() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 511
diff changeset
   162
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   163
/***************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   164
/* B 0 - Programming Model */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   165
/***************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   166
void *search_var_instance_decl_c::visit(library_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   167
  /* we do not want to search multiple declaration scopes,
217
f5dfadf5de54 Adding support for declare, init, get and set macros
laurent
parents: 202
diff changeset
   168
   * so we do not visit all the functions, function blocks, etc...
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   169
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   170
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   171
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   172
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   173
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   174
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   175
/******************************************/
217
f5dfadf5de54 Adding support for declare, init, get and set macros
laurent
parents: 202
diff changeset
   176
/* B 1.4.3 - Declaration & Initialization */
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   177
/******************************************/
217
f5dfadf5de54 Adding support for declare, init, get and set macros
laurent
parents: 202
diff changeset
   178
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   179
/* edge -> The F_EDGE or R_EDGE directive */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   180
// SYM_REF2(edge_declaration_c, edge, var1_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   181
// TODO
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   182
void *search_var_instance_decl_c::visit(constant_option_c *symbol) {
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   183
  current_option = constant_opt;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   184
  return NULL;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   185
}
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   186
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   187
void *search_var_instance_decl_c::visit(retain_option_c *symbol) {
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   188
  current_option = retain_opt;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   189
  return NULL;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   190
}
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   191
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   192
void *search_var_instance_decl_c::visit(non_retain_option_c *symbol) {
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   193
  current_option = non_retain_opt;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   194
  return NULL;
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   195
}
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   196
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   197
void *search_var_instance_decl_c::visit(input_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   198
  current_vartype = input_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   199
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   200
  if (NULL != symbol->option)  
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   201
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   202
  void *res = symbol->input_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   203
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   204
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   205
    current_option  = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   206
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   207
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   208
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   209
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   210
/* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   211
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   212
void *search_var_instance_decl_c::visit(output_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   213
  current_vartype = output_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   214
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   215
  if (NULL != symbol->option)
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   216
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   217
  void *res = symbol->var_init_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   218
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   219
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   220
    current_option  = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   221
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   222
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   223
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   224
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   225
/*  VAR_IN_OUT var_declaration_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   226
void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   227
  current_vartype = inoutput_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   228
  current_option  = none_opt; /* not really required. Just to make the code more readable */
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   229
  void *res = symbol->var_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   230
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   231
    current_vartype = none_vt;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   232
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   233
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   234
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   235
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   236
/* ENO : BOOL */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   237
void *search_var_instance_decl_c::visit(eno_param_declaration_c *symbol) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   238
  if (compare_identifiers(symbol->name, search_name) == 0)
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   239
    return symbol->type;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   240
  return NULL;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   241
}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   242
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   243
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   244
/* VAR [CONSTANT] var_init_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   245
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   246
/* helper symbol for input_declarations */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   247
void *search_var_instance_decl_c::visit(var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   248
  current_vartype = private_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   249
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   250
  if (NULL != symbol->option)
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   251
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   252
  void *res = symbol->var_init_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   253
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   254
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   255
    current_option = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   256
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   257
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   258
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   259
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   260
/*  VAR RETAIN var_init_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   261
void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   262
  current_vartype = private_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   263
  current_option  = retain_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   264
  void *res = symbol->var_init_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   265
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   266
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   267
    current_option = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   268
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   269
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   270
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   271
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   272
/*  VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   273
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   274
//SYM_REF2(located_var_declarations_c, option, located_var_decl_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   275
void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   276
  current_vartype = located_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   277
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   278
  if (NULL != symbol->option)
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   279
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   280
  void *res = symbol->located_var_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   281
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   282
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   283
    current_option  = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   284
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   285
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   286
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   287
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   288
/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   289
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   290
//SYM_REF2(external_var_declarations_c, option, external_declaration_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   291
void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   292
  current_vartype = external_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   293
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   294
  if (NULL != symbol->option)
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   295
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   296
  void *res = symbol->external_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   297
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   298
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   299
    current_option = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   300
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   301
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   302
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   303
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   304
/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   305
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   306
//SYM_REF2(global_var_declarations_c, option, global_var_decl_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   307
void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   308
  current_vartype = global_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   309
  current_option  = none_opt; /* not really required. Just to make the code more readable */
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   310
  if (NULL != symbol->option)
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   311
    symbol->option->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   312
  void *res = symbol->global_var_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   313
  if (res == NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   314
    current_vartype = none_vt;
507
30b31d8f6d0f Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents: 504
diff changeset
   315
    current_option = none_opt;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   316
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   317
  return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   318
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   319
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   320
/* var1_list is one of the following...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   321
 *    simple_spec_init_c *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   322
 *    subrange_spec_init_c *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   323
 *    enumerated_spec_init_c *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   324
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   325
// SYM_REF2(var1_init_decl_c, var1_list, spec_init)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   326
void *search_var_instance_decl_c::visit(var1_init_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   327
  current_type_decl = symbol->spec_init;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   328
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   329
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   330
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   331
/* var1_list ',' variable_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   332
// SYM_LIST(var1_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   333
void *search_var_instance_decl_c::visit(var1_list_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   334
  list_c *list = symbol;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   335
  for(int i = 0; i < list->n; i++) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   336
    if (compare_identifiers(list->elements[i], search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   337
   /* by now, current_type_decl should be != NULL */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   338
      return current_type_decl;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   339
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   340
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   341
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   342
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   343
/* name_list ':' function_block_type_name ASSIGN structure_initialization */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   344
/* structure_initialization -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   345
void *search_var_instance_decl_c::visit(fb_name_decl_c *symbol) {
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: 793
diff changeset
   346
  // TODO: The following line is wrong! It should be
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: 793
diff changeset
   347
  // current_type_decl = symbol->fb_spec_init;
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: 793
diff changeset
   348
  //  However, this change will require a check of all callers, to see if they would handle this correctly.
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: 793
diff changeset
   349
  //  For now, just keep what we have had historically, and seems to be working.
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: 793
diff changeset
   350
  current_type_decl = spec_init_sperator_c::get_spec(symbol->fb_spec_init);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   351
  return symbol->fb_name_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   352
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   353
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   354
/* name_list ',' fb_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   355
void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   356
  list_c *list = symbol;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   357
  for(int i = 0; i < list->n; i++) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   358
    if (compare_identifiers(list->elements[i], search_name) == 0)
504
f8d422b98315 Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   359
    /* by now, current_fb_declaration should be != NULL */
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   360
      return current_type_decl;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   361
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   362
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   363
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   364
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   365
/* var1_list ':' array_spec_init */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   366
// SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   367
void *search_var_instance_decl_c::visit(array_var_init_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   368
  current_type_decl = symbol->array_spec_init;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   369
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   370
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   371
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   372
/*  var1_list ':' initialized_structure */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   373
// SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   374
void *search_var_instance_decl_c::visit(structured_var_init_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   375
  current_type_decl = symbol->initialized_structure;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   376
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   377
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   378
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   379
/*  var1_list ':' array_specification */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   380
// SYM_REF2(array_var_declaration_c, var1_list, array_specification)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   381
void *search_var_instance_decl_c::visit(array_var_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   382
  current_type_decl = symbol->array_specification;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   383
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   384
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   385
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   386
/*  var1_list ':' structure_type_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   387
// SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   388
void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   389
  current_type_decl = symbol->structure_type_name;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   390
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   391
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   392
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   393
/*  [variable_name] location ':' located_var_spec_init */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   394
/* variable_name -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   395
// SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   396
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   397
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   398
/*  global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   399
// SYM_REF2(external_declaration_c, global_var_name, specification)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   400
void *search_var_instance_decl_c::visit(external_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   401
  if (compare_identifiers(symbol->global_var_name, search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   402
      return symbol->specification;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   403
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   404
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   405
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   406
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   407
/* type_specification ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   408
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   409
void *search_var_instance_decl_c::visit(global_var_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   410
  if (symbol->type_specification != NULL) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   411
    current_type_decl = symbol->type_specification;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   412
    return symbol->global_var_spec->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   413
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   414
  else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   415
    return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   416
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   417
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   418
/*| global_var_name location */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   419
//SYM_REF2(global_var_spec_c, global_var_name, location)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   420
void *search_var_instance_decl_c::visit(global_var_spec_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   421
  if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   422
      return current_type_decl;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   423
  else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   424
    return symbol->location->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   425
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   426
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   427
/*| global_var_list ',' global_var_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   428
//SYM_LIST(global_var_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   429
void *search_var_instance_decl_c::visit(global_var_list_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   430
  list_c *list = symbol;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   431
  for(int i = 0; i < list->n; i++) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   432
    if (compare_identifiers(list->elements[i], search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   433
      /* by now, current_type_decl should be != NULL */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   434
      return current_type_decl;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   435
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   436
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   437
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   438
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   439
/*  [variable_name] location ':' located_var_spec_init */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   440
/* variable_name -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   441
//SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   442
void *search_var_instance_decl_c::visit(located_var_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   443
  if (symbol->variable_name != NULL && compare_identifiers(symbol->variable_name, search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   444
    return symbol->located_var_spec_init;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   445
  else {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   446
    current_type_decl = symbol->located_var_spec_init;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   447
    return symbol->location->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   448
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   449
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   450
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   451
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   452
/* type_specification ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   453
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   454
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   455
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   456
/*  AT direct_variable */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   457
// SYM_REF2(location_c, direct_variable, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   458
void *search_var_instance_decl_c::visit(location_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   459
  if (compare_identifiers(symbol->direct_variable, search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   460
    return current_type_decl;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   461
  else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   462
    return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   463
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   464
        
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   465
/*| global_var_list ',' global_var_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   466
// SYM_LIST(global_var_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   467
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   468
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   469
/*  var1_list ':' single_byte_string_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   470
// SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   471
void *search_var_instance_decl_c::visit(single_byte_string_var_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   472
  current_type_decl = symbol->single_byte_string_spec;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   473
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   474
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   475
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   476
/*  STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   477
/* integer ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   478
/* single_byte_character_string ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   479
// SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   480
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   481
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   482
/*  var1_list ':' double_byte_string_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   483
// SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   484
void *search_var_instance_decl_c::visit(double_byte_string_var_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   485
  current_type_decl = symbol->double_byte_string_spec;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   486
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   487
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   488
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   489
/*  WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   490
/* integer ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   491
/* double_byte_character_string ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   492
// SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   493
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   494
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   495
/*  variable_name incompl_location ':' var_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   496
// SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   497
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   498
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   499
/*  AT incompl_location_token */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   500
// SYM_TOKEN(incompl_location_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   501
// TODO!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   502
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   503
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   504
/**************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   505
/* B.1.5 - Program organization units */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   506
/**************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   507
/***********************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   508
/* B 1.5.1 - Functions */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   509
/***********************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   510
// SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   511
void *search_var_instance_decl_c::visit(function_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   512
  /* functions have a variable named after themselves, to store
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   513
   * the variable that will be returned!!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   514
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   515
  if (compare_identifiers(symbol->derived_function_name, search_name) == 0)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   516
      return symbol->type_name;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   517
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   518
  /* no need to search through all the body, so we only
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   519
   * visit the variable declarations...!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   520
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   521
  return symbol->var_declarations_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   522
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   523
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   524
/*****************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   525
/* B 1.5.2 - Function Blocks */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   526
/*****************************/
619
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   527
/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   528
// SYM_REF3(function_block_declaration_c, fblock_name, var_declarations, fblock_body)
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   529
void *search_var_instance_decl_c::visit(function_block_declaration_c *symbol) {
619
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   530
  /* visit the variable declarations...! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   531
  void *res = symbol->var_declarations->accept(*this);
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   532
  if (NULL != res)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   533
    return res;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   534
  
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   535
  /* not yet found, so we look into the body, to see if it is an SFC step! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   536
  return symbol->fblock_body->accept(*this);
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   537
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   538
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   539
/**********************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   540
/* B 1.5.3 - Programs */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   541
/**********************/
619
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   542
/*  PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   543
// SYM_REF3(program_declaration_c, program_type_name, var_declarations, function_block_body)
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   544
void *search_var_instance_decl_c::visit(program_declaration_c *symbol) {
619
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   545
  /* visit the variable declarations...! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   546
  void *res = symbol->var_declarations->accept(*this);
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   547
  if (NULL != res)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   548
    return res;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   549
  
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   550
  /* not yet found, so we look into the body, to see if it is an SFC step! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   551
  return symbol->function_block_body->accept(*this);
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   552
}
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   553
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   554
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   555
/*********************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   556
/* B.1.6  Sequential function chart elements */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   557
/*********************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   558
/* | sequential_function_chart sfc_network */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   559
// SYM_LIST(sequential_function_chart_c)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   560
/* search_var_instance_decl_c inherits from serach_visitor_c, so no need to implement the following method. */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   561
// void *search_var_instance_decl_c::visit(sequential_function_chart_c *symbol) {...}
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   562
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   563
/* initial_step {step | transition | action} */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   564
// SYM_LIST(sfc_network_c)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   565
/* search_var_instance_decl_c inherits from serach_visitor_c, so no need to implement the following method. */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   566
// void *search_var_instance_decl_c::visit(sfc_network_c *symbol) {...}
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   567
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   568
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   569
/* INITIAL_STEP step_name ':' action_association_list END_STEP */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   570
// SYM_REF2(initial_step_c, step_name, action_association_list)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   571
void *search_var_instance_decl_c::visit(initial_step_c *symbol) {
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   572
  if (compare_identifiers(symbol->step_name, search_name) == 0)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   573
      return symbol;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   574
  return NULL;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   575
}
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   576
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   577
/* STEP step_name ':' action_association_list END_STEP */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   578
// SYM_REF2(step_c, step_name, action_association_list)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   579
void *search_var_instance_decl_c::visit(step_c *symbol) {
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   580
  if (compare_identifiers(symbol->step_name, search_name) == 0)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   581
      return symbol;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   582
  return NULL;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   583
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   584
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   585
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   586
/********************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   587
/* B 1.7 Configuration elements */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   588
/********************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   589
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   590
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   591
CONFIGURATION configuration_name
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   592
   optional_global_var_declarations
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   593
   (resource_declaration_list | single_resource_declaration)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   594
   optional_access_declarations
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   595
   optional_instance_specific_initializations
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   596
END_CONFIGURATION
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   597
*/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   598
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   599
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   600
*/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   601
void *search_var_instance_decl_c::visit(configuration_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   602
  /* no need to search through all the configuration, so we only
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   603
   * visit the global variable declarations...!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   604
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   605
  if (symbol->global_var_declarations != NULL)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   606
    return symbol->global_var_declarations->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   607
  else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   608
    return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   609
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   610
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   611
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   612
RESOURCE resource_name ON resource_type_name
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   613
   optional_global_var_declarations
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   614
   single_resource_declaration
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   615
END_RESOURCE
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   616
*/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   617
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   618
void *search_var_instance_decl_c::visit(resource_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   619
  /* no need to search through all the resource, so we only
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   620
   * visit the global variable declarations...!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   621
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   622
  if (symbol->global_var_declarations != NULL)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   623
    return symbol->global_var_declarations->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   624
  else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   625
    return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   626
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   627
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   628
/* task_configuration_list program_configuration_list */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   629
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   630
void *search_var_instance_decl_c::visit(single_resource_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   631
  /* no need to search through all the resource,
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   632
   * and there is no global variable declarations...!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   633
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   634
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   635
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   636
619
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   637
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   638
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   639
/****************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   640
/* B.2 - Language IL (Instruction List) */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   641
/****************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   642
/***********************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   643
/* B 2.1 Instructions and Operands */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   644
/***********************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   645
/*| instruction_list il_instruction */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   646
// SYM_LIST(instruction_list_c)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   647
void *search_var_instance_decl_c::visit(instruction_list_c *symbol) {
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   648
  /* IL code does not contain any variable declarations! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   649
  return NULL;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   650
}
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   651
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   652
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   653
/***************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   654
/* B.3 - Language ST (Structured Text) */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   655
/***************************************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   656
/********************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   657
/* B 3.2 Statements */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   658
/********************/
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   659
// SYM_LIST(statement_list_c)
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   660
void *search_var_instance_decl_c::visit(statement_list_c *symbol) {
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   661
  /* ST code does not contain any variable declarations! */
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   662
  return NULL;
f8c9ac5c529a Support for data types of STEP.T and STEP.X in SFCs
Mario de Sousa <msousa@fe.up.pt>
parents: 536
diff changeset
   663
}