absyntax_utils/function_param_iterator.cc
author Mario de Sousa <msousa@fe.up.pt>
Mon, 11 Jun 2012 18:48:58 +0100
changeset 580 b6350d9f204d
parent 547 dab341e80664
child 587 1ecf916cc397
permissions -rw-r--r--
Code for debugging const_value annotations in abstract syntax tree.
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: 237
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: 237
diff changeset
     3
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 237
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: 237
diff changeset
     6
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 237
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: 237
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: 237
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: 237
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: 237
diff changeset
    11
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 237
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: 237
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: 237
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: 237
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: 237
diff changeset
    16
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 237
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: 237
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: 237
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: 237
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
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    33
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    34
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    35
 * Function parameter iterator.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    36
 * Iterate through the in/out parameters of a function declaration.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    37
 * Function blocks are also suported.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    38
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    39
 * This is part of the 4th stage that generates
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    40
 * a c++ source program equivalent to the IL and ST
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    41
 * code.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    42
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    43
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    44
/* Given a function_declaration_c, iterate through each
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    45
 * function in/out/inout parameter, returning the name
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    46
 * of each parameter...function_param_iterator_c
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    47
 */
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
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    50
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    51
#include "absyntax_utils.hh"  /* required for extract_integer() */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    52
// #include "function_param_iterator.hh"  /* no longer required, aready included by absyntax_utils.hh */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    53
// #include "spec_init_separator.hh"  /* no longer required, aready included by absyntax_utils.hh */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    54
#include <stdlib.h>  /* required for strtol() */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    55
#include <string.h>
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    56
#include <strings.h>
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    57
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    58
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    59
//#define DEBUG
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    60
#ifdef DEBUG
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    61
#define TRACE(classname) printf("\n____%s____\n",classname);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    62
#else
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    63
#define TRACE(classname)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    64
#endif
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    65
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    66
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    67
#define ERROR error_exit(__FILE__,__LINE__)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    68
/* function defined in main.cc */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    69
extern void error_exit(const char *file_name, int line_no);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    70
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    71
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    72
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    73
/* compare the name of two __extensible__ function parameters.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    74
 * The usual use case is to have one of the parameters as used
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    75
 * in the function declaration, and another as used in a formal function call.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    76
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    77
 * Will return:
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    78
 *         < 0 : if two parameters are not compatible, or one is invalid
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    79
 *        >= 0 : if both parameters ..........
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    80
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    81
/*
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    82
 *   ("in", "i0")      -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    83
 *   ("in1", "in")     -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    84
 *   ("in", "in")      -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    85
 *   ("in", "inw")     -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    86
 *   ("in", "in10.4")  -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    87
 *   ("in", "in10e")   -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    88
 *   ("in", "")        -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    89
 *   ("", "in10e")     -> returns error (<0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    90
 *   ("in", "in0")     -> returns 0
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    91
 *   ("in", "in9")     -> returns 9
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    92
 *   ("in", "in42")    -> returns 42
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    93
 *   ("in", "in-42")   -> returns -42 (error!)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    94
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    95
int function_param_iterator_c::cmp_extparam_names(const char* s1, const char* s2) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    96
  int res;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    97
  char *endptr;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    98
  int len;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
    99
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   100
  if ((s1 == NULL) || (s2 == NULL) || (*s1 == '\0') || (*s2 == '\0')) return -1;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   101
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   102
  len = strlen(s1);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   103
  if (strncasecmp(s1, s2, len)) return -2;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   104
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   105
  s1 = &s2[len];
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   106
  if (*s1 == '\0') return -3;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   107
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   108
  res = strtol(s1, &endptr, 10);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   109
  if (*endptr != '\0') return -4;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   110
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   111
  return res;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   112
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   113
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   114
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   115
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   116
void* function_param_iterator_c::handle_param_list(list_c *list) {
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   117
  switch (current_operation) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   118
    case iterate_op:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   119
      if (next_param <= param_count + list->n)
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   120
        return list->elements[next_param - param_count - 1];
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   121
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   122
      /* the desired param is not on this list... */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   123
      param_count += list->n;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   124
      break;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   125
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   126
    case search_op:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   127
      for(int i = 0; i < list->n; i++) {
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   128
        symbol_c *sym = list->elements[i];
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   129
        extensible_input_parameter_c *extensible_parameter = dynamic_cast<extensible_input_parameter_c *>(sym);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   130
        if (extensible_parameter != NULL) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   131
          sym = extensible_parameter->var_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   132
          current_param_is_extensible = true;
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 448
diff changeset
   133
          _first_extensible_param_index = extract_integer_value(extensible_parameter->first_index);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   134
        }
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   135
        identifier_c *variable_name = dynamic_cast<identifier_c *>(sym);
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   136
        if (variable_name == NULL) ERROR;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   137
        
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   138
        if (!current_param_is_extensible)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   139
          if (strcasecmp(search_param_name->value, variable_name->value) == 0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   140
            /* FOUND! This is the same parameter!! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   141
            return (void *)variable_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   142
  
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   143
        if (current_param_is_extensible) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   144
          current_extensible_param_index = cmp_extparam_names(variable_name->value, search_param_name->value);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   145
          if (current_extensible_param_index >= 0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   146
            /* FOUND! This is a compatible extensible parameter!! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   147
            return (void *)variable_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   148
        }  
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   149
      }
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   150
      break;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   151
  } /* switch */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   152
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   153
  /* Not found! */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   154
  return NULL;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   155
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   156
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   157
void* function_param_iterator_c::handle_single_param(symbol_c *var_name) {
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   158
  switch (current_operation) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   159
    case iterate_op:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   160
      param_count++;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   161
      if (next_param == param_count)
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   162
        return var_name;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   163
      break;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   164
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   165
    case search_op:
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   166
      extensible_input_parameter_c *extensible_parameter = dynamic_cast<extensible_input_parameter_c *>(var_name);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   167
      if (extensible_parameter != NULL) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   168
        var_name = extensible_parameter->var_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   169
        current_param_is_extensible = true;
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 448
diff changeset
   170
        _first_extensible_param_index = extract_integer_value(extensible_parameter->first_index);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   171
      }
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   172
      identifier_c *variable_name = dynamic_cast<identifier_c *>(var_name);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   173
      if (variable_name == NULL) ERROR;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   174
      
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   175
      if (!current_param_is_extensible)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   176
        if (strcasecmp(search_param_name->value, variable_name->value) == 0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   177
          /* FOUND! This is the same parameter!! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   178
          return (void *)variable_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   179
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   180
      if (current_param_is_extensible) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   181
        current_extensible_param_index = cmp_extparam_names(variable_name->value, search_param_name->value);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   182
        if (current_extensible_param_index >= 0)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   183
          /* FOUND! This is a compatible extensible parameter!! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   184
          return (void *)variable_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   185
      }  
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   186
      break;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   187
  } /* switch */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   188
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   189
  /* Not found! */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   190
  return NULL;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   191
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   192
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   193
void* function_param_iterator_c::iterate_list(list_c *list) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   194
  void *res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   195
  for (int i = 0; i < list->n; i++) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   196
    res = list->elements[i]->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   197
    if (res != NULL)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   198
        return res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   199
  }
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   200
  return NULL;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   201
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   202
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   203
/* start off at the first parameter once again... */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   204
void function_param_iterator_c::reset(void) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   205
  next_param = param_count = 0;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   206
  _first_extensible_param_index = -1;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   207
  current_param_is_extensible = false;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   208
  current_param_name = NULL;
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   209
  current_param_type = NULL;
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   210
  current_param_default_value = NULL;
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   211
  last_returned_parameter = NULL; /* the last parameter returned by search() or next() */
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   212
}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   213
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   214
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   215
/* initialise the iterator object.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   216
 * We must be given a reference to one of the following
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   217
 *     - function_declaration_c
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   218
 *     - function_block_declaration_c
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   219
 *     - program_declaration_c
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   220
 * that will be analysed...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   221
 */
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   222
function_param_iterator_c::function_param_iterator_c(symbol_c *pou_decl) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   223
  /* do some consistency checks... */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   224
  function_declaration_c       * f_decl = dynamic_cast<function_declaration_c       *>(pou_decl);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   225
  function_block_declaration_c *fb_decl = dynamic_cast<function_block_declaration_c *>(pou_decl);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   226
  program_declaration_c        * p_decl = dynamic_cast<program_declaration_c        *>(pou_decl);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   227
426
78f31e12fc52 Better identification of erros in function/FB invocations.
Mario de Sousa <msousa@fe.up.pt>
parents: 424
diff changeset
   228
  if ((NULL == f_decl) && (NULL == fb_decl) && (NULL == p_decl)) 
78f31e12fc52 Better identification of erros in function/FB invocations.
Mario de Sousa <msousa@fe.up.pt>
parents: 424
diff changeset
   229
    ERROR;
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   230
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   231
  /* OK. Now initialise this object... */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   232
  this->f_decl = pou_decl;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   233
  reset();
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
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   237
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   238
/* Skip to the next parameter. After object creation,
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   239
 * the object references on parameter _before_ the first, so
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   240
 * this function must be called once to get the object to
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   241
 * reference the first parameter...
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   242
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   243
 * Returns the parameter's name!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   244
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   245
identifier_c *function_param_iterator_c::next(void) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   246
  void *res;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   247
  identifier_c *identifier;
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   248
 
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   249
  if (current_param_is_extensible) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   250
    current_extensible_param_index++;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   251
    return current_param_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   252
  }
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   253
  
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   254
  last_returned_parameter = NULL; 
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   255
  param_count = 0;
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   256
  en_eno_param_implicit = false;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   257
  next_param++;
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   258
  current_operation = function_param_iterator_c::iterate_op;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   259
  res = f_decl->accept(*this);
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   260
  if (res == NULL) 
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   261
    return NULL;
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   262
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   263
  symbol_c *sym = (symbol_c *)res;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   264
  extensible_input_parameter_c *extensible_parameter = dynamic_cast<extensible_input_parameter_c *>(sym);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   265
  if (extensible_parameter != NULL) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   266
    sym = extensible_parameter->var_name;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   267
    current_param_is_extensible = true;
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 448
diff changeset
   268
    _first_extensible_param_index = extract_integer_value(extensible_parameter->first_index);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   269
    current_extensible_param_index = _first_extensible_param_index;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   270
  }
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   271
  identifier = dynamic_cast<identifier_c *>(sym);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   272
  if (identifier == NULL)
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   273
    ERROR;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   274
  current_param_name = identifier;
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   275
  last_returned_parameter = current_param_name; 
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   276
  return current_param_name;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   277
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   278
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   279
/* Search for the value passed to the parameter named <param_name>...  */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   280
identifier_c *function_param_iterator_c::search(symbol_c *param_name) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   281
  if (NULL == param_name) ERROR;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   282
  search_param_name = dynamic_cast<identifier_c *>(param_name);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   283
  if (NULL == search_param_name) ERROR;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   284
  en_eno_param_implicit = false;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   285
  current_param_is_extensible = false;
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   286
  current_operation = function_param_iterator_c::search_op;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   287
  void *res = f_decl->accept(*this);
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   288
  identifier_c *res_param_name = dynamic_cast<identifier_c *>((symbol_c *)res);
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   289
  last_returned_parameter = res_param_name; 
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   290
  return res_param_name;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   291
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   292
448
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   293
identifier_c *function_param_iterator_c::search(const char *param_name) {
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   294
  identifier_c   param_name_id(param_name);
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   295
  return search(&param_name_id);
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   296
}
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   297
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   298
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 426
diff changeset
   299
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   300
/* Returns the currently referenced parameter's default value,
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   301
 * or NULL if none is specified in the function declrataion itself.
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
symbol_c *function_param_iterator_c::default_value(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   304
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   305
    return NULL;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   306
  return current_param_default_value;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   307
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   308
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   309
/* Returns the currently referenced parameter's type name. */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   310
symbol_c *function_param_iterator_c::param_type(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   311
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   312
    return NULL;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   313
  return current_param_type;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   314
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   315
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   316
/* Returns if currently referenced parameter is an implicit defined EN/ENO parameter. */
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   317
bool function_param_iterator_c::is_en_eno_param_implicit(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   318
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   319
    ERROR;
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   320
  return en_eno_param_implicit;
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   321
}
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   322
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   323
/* Returns if currently referenced parameter is an extensible parameter. */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   324
/* extensible paramters only occur in some standard functions, e.g. AND(word#34, word#44, word#65); */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   325
bool function_param_iterator_c::is_extensible_param(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   326
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   327
    ERROR;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   328
  return current_param_is_extensible;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   329
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   330
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   331
/* Returns the index of the current extensible parameter. */             
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   332
/* If the current parameter is not an extensible paramter, returns -1 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   333
int function_param_iterator_c::extensible_param_index(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   334
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   335
    ERROR;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   336
  return (current_param_is_extensible? current_extensible_param_index : -1);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   337
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   338
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   339
/* Returns the index of the first extensible parameter, or -1 if no extensible parameter found. */             
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   340
/* WARNING: Will only return the correct value _after_ an extensible parameter has been found! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   341
int function_param_iterator_c::first_extensible_param_index(void) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   342
  return _first_extensible_param_index;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   343
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   344
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   345
/* Returns the currently referenced parameter's data passing direction.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   346
 * i.e. VAR_INPUT, VAR_OUTPUT or VAR_INOUT
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   347
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   348
function_param_iterator_c::param_direction_t function_param_iterator_c::param_direction(void) {
424
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   349
  if (NULL == last_returned_parameter) 
43d73e28eca8 Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   350
    ERROR;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   351
  return current_param_direction;
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
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   354
void *function_param_iterator_c::visit(implicit_definition_c *symbol) {
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   355
	en_eno_param_implicit = true;
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   356
	return NULL;
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   357
}
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 202
diff changeset
   358
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   359
/****************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   360
/* 1.4.3 - Declaration & Initialisation */
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
void *function_param_iterator_c::visit(input_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   363
  TRACE("input_declarations_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   364
  current_param_direction = direction_in;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   365
  return symbol->input_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   366
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   367
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   368
void *function_param_iterator_c::visit(input_declaration_list_c *symbol) {TRACE("input_declaration_list_c"); return iterate_list(symbol);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   369
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   370
void *function_param_iterator_c::visit(edge_declaration_c *symbol) {TRACE("edge_declaration_c"); return symbol->var1_list->accept(*this);}
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
void *function_param_iterator_c::visit(en_param_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   373
  TRACE("en_param_declaration_c");
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   374
  /* It is OK to store these values in the current_param_XXX
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   375
   * variables, because if the desired parameter is not in the
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   376
   * variable list we will be analysing, the current_param_XXXX
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   377
   * variables will get overwritten when we visit the next
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   378
   * var1_init_decl_c list!
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   379
   */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   380
  current_param_default_value = symbol->value;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   381
  current_param_type = symbol->type;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   382
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   383
  void *res = handle_single_param(symbol->name);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   384
  
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   385
    /* If we have found the parameter we will be returning, we set the en_eno_param_implicit to TRUE if implicitly defined */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   386
  if (res != NULL) symbol->method->accept(*this);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   387
  
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   388
  return res;
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   389
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   390
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   391
/* var1_list ':' array_spec_init */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   392
//SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init)
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   393
void *function_param_iterator_c::visit(array_var_init_decl_c *symbol) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   394
  TRACE("array_var_init_decl_c");
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   395
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   396
  current_param_default_value = spec_init_sperator_c::get_init(symbol->array_spec_init);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   397
  current_param_type = spec_init_sperator_c::get_spec(symbol->array_spec_init);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   398
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   399
  return symbol->var1_list->accept(*this);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   400
}
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   401
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   402
/*  var1_list ':' initialized_structure */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   403
//SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure)
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   404
void *function_param_iterator_c::visit(structured_var_init_decl_c *symbol) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   405
  TRACE("structured_var_init_decl_c");
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   406
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   407
  current_param_default_value = spec_init_sperator_c::get_init(symbol->initialized_structure);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   408
  current_param_type = spec_init_sperator_c::get_spec(symbol->initialized_structure);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   409
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   410
  return symbol->var1_list->accept(*this);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   411
}
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   412
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   413
void *function_param_iterator_c::visit(output_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   414
  TRACE("output_declarations_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   415
  current_param_direction = direction_out;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   416
  return symbol->var_init_decl_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   417
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   418
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   419
void *function_param_iterator_c::visit(eno_param_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   420
  TRACE("eno_param_declaration_c");
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   421
  /* It is OK to store these values in the current_param_XXX
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   422
   * variables, because if the desired parameter is not in the
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   423
   * variable list we will be analysing, the current_param_XXXX
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   424
   * variables will get overwritten when we visit the next
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   425
   * var1_init_decl_c list!
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   426
   */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   427
  current_param_default_value = NULL;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   428
  current_param_type = symbol->type;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 181
diff changeset
   429
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   430
  void *res = handle_single_param(symbol->name);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   431
  
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   432
    /* If we have found the parameter we will be returning, we set the en_eno_param_implicit to TRUE if implicitly defined */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   433
  if (res != NULL) symbol->method->accept(*this);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   434
  
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   435
  return res;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   436
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   437
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   438
void *function_param_iterator_c::visit(input_output_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   439
  TRACE("input_output_declarations_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   440
  current_param_direction = direction_inout;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   441
  return symbol->var_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   442
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   443
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   444
void *function_param_iterator_c::visit(var_declaration_list_c *symbol) {TRACE("var_declaration_list_c"); return iterate_list(symbol);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   445
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   446
/*  var1_list ':' array_specification */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   447
//SYM_REF2(array_var_declaration_c, var1_list, array_specification)
237
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   448
void *function_param_iterator_c::visit(array_var_declaration_c *symbol) {
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   449
	TRACE("array_var_declaration_c");
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   450
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   451
	current_param_default_value = NULL;
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   452
	current_param_type = symbol->array_specification;
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   453
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   454
	return symbol->var1_list->accept(*this);
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   455
}
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   456
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   457
/*  var1_list ':' structure_type_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   458
//SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name)
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   459
void *function_param_iterator_c::visit(structured_var_declaration_c *symbol) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   460
  TRACE("structured_var_declaration_c");
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   461
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   462
  current_param_default_value = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   463
  current_param_type = symbol->structure_type_name;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   464
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   465
  return symbol->var1_list->accept(*this);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 233
diff changeset
   466
}
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   467
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   468
/* VAR [CONSTANT] var_init_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   469
void *function_param_iterator_c::visit(var_declarations_c *symbol) {TRACE("var_declarations_c"); return NULL;}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   470
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   471
/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   472
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   473
// SYM_REF2(external_var_declarations_c, option, external_declaration_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   474
void *function_param_iterator_c::visit(external_var_declarations_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   475
  TRACE("external_var_declarations_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   476
  current_param_direction = direction_extref;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   477
  return symbol->external_declaration_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   478
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   479
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   480
/* helper symbol for external_var_declarations */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   481
/*| external_declaration_list external_declaration';' */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   482
// SYM_LIST(external_declaration_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   483
void *function_param_iterator_c::visit(external_declaration_list_c *symbol) {TRACE("external_declaration_list_c"); return iterate_list(symbol);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   484
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   485
/*  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
   486
//SYM_REF2(external_declaration_c, global_var_name, specification)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   487
void *function_param_iterator_c::visit(external_declaration_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   488
  TRACE("external_declaration_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   489
  /* It is OK to store these values in the current_param_XXX
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   490
   * variables, because if the desired parameter is not in the
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   491
   * variable list we will be analysing, the current_param_XXXX
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   492
   * variables will get overwritten when we visit the next
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   493
   * var1_init_decl_c list!
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
  current_param_default_value = spec_init_sperator_c::get_init(symbol->specification);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   496
  current_param_type = spec_init_sperator_c::get_spec(symbol->specification);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   497
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   498
  return handle_single_param(symbol->global_var_name);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   499
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   500
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   501
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   502
#if 0
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   503
/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   504
/* option -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   505
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
   506
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   507
/* helper symbol for global_var_declarations */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   508
/*| global_var_decl_list global_var_decl ';' */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   509
SYM_LIST(global_var_decl_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   510
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   511
/*| 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
   512
/* type_specification ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   513
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
   514
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   515
/*| global_var_name location */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   516
SYM_REF2(global_var_spec_c, global_var_name, location)
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
/*  AT direct_variable */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   519
SYM_REF2(location_c, direct_variable, unused)
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
/*| global_var_list ',' global_var_name */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   522
SYM_LIST(global_var_list_c)
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
/*  var1_list ':' single_byte_string_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   525
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
   526
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   527
/*  STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   528
/* integer ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   529
/* single_byte_character_string ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   530
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
   531
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   532
/*  var1_list ':' double_byte_string_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   533
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
   534
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   535
/*  WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   536
/* integer ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   537
/* double_byte_character_string ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   538
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
   539
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   540
/*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   541
/* option ->may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   542
SYM_REF2(incompl_located_var_declarations_c, option, incompl_located_var_decl_list)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   543
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   544
/* helper symbol for incompl_located_var_declarations */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   545
/*| incompl_located_var_decl_list incompl_located_var_decl ';' */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   546
SYM_LIST(incompl_located_var_decl_list_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   547
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   548
/*  variable_name incompl_location ':' var_spec */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   549
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
   550
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   551
/*  AT incompl_location_token */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   552
SYM_TOKEN(incompl_location_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   553
#endif
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   554
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   555
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   556
void *function_param_iterator_c::visit(var1_init_decl_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   557
  TRACE("var1_init_decl_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   558
  /* It is OK to store these values in the current_param_XXX
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   559
   * variables, because if the desired parameter is not in the
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   560
   * variable list we will be analysing, the current_param_XXXX
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   561
   * variables will get overwritten when we visit the next
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   562
   * var1_init_decl_c list!
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   563
   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   564
  current_param_default_value = spec_init_sperator_c::get_init(symbol->spec_init);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   565
  current_param_type = spec_init_sperator_c::get_spec(symbol->spec_init);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   566
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   567
  return symbol->var1_list->accept(*this);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   568
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   569
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   570
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   571
void *function_param_iterator_c::visit(var1_list_c *symbol) {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   572
  TRACE("var1_list_c");
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   573
  return handle_param_list(symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   574
}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   575
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   576
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   577
void *function_param_iterator_c::visit(var_init_decl_list_c *symbol) {TRACE("var_init_decl_list_c"); return iterate_list(symbol);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   578
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   579
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   580
/***********************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   581
/* B 1.5.1 - Functions */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   582
/***********************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   583
void *function_param_iterator_c::visit(function_declaration_c *symbol) {TRACE("function_declaration_c"); return symbol->var_declarations_list->accept(*this);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   584
/* intermediate helper symbol for function_declaration */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   585
void *function_param_iterator_c::visit(var_declarations_list_c *symbol) {TRACE("var_declarations_list_c"); return iterate_list(symbol);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   586
void *function_param_iterator_c::visit(function_var_decls_c *symbol) {TRACE("function_var_decls_c"); /* ignore */ return NULL;}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   587
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
/* B 1.5.2 - Function Blocks */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   591
/*****************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   592
/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   593
void *function_param_iterator_c::visit(function_block_declaration_c *symbol) {TRACE("function_block_declaration_c"); return symbol->var_declarations->accept(*this);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   594
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   595
/* intermediate helper symbol for function_declaration */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   596
/*  { io_var_declarations | other_var_declarations }   */
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
 * NOTE: we re-use the var_declarations_list_c
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   599
 */
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
/*  VAR_TEMP temp_var_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   602
void *function_param_iterator_c::visit(temp_var_decls_c *symbol) {TRACE("temp_var_decls_c"); /* ignore */ return NULL;}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   603
void *function_param_iterator_c::visit(temp_var_decls_list_c *symbol) {TRACE("temp_var_decls_list_c"); /* ignore */ return NULL;}
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
/*  VAR NON_RETAIN var_init_decl_list END_VAR */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   606
void *function_param_iterator_c::visit(non_retentive_var_decls_c *symbol) {TRACE("non_retentive_var_decls_c"); /* ignore */ return NULL;}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   607
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   608
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
/* B 1.5.3 - Programs */
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
/*  PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   613
// SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   614
void *function_param_iterator_c::visit(program_declaration_c *symbol) {TRACE("program_declaration_c"); return symbol->var_declarations->accept(*this);}
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   615
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   616
/* intermediate helper symbol for program_declaration_c */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   617
/*  { io_var_declarations | other_var_declarations }   */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   618
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   619
 * NOTE: we re-use the var_declarations_list_c
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   620
 */
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
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   623
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   624
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   625
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
   626