stage3/forced_narrow_candidate_datatypes.cc
author Mario de Sousa <msousa@fe.up.pt>
Mon, 03 Apr 2017 22:18:22 +0100
changeset 1041 56ebe2a31b5b
parent 693 51a2fa6441b9
child 1054 57c08195c962
permissions -rw-r--r--
Access elements[] in list_c through a new get_element() method.
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *  This program is free software: you can redistribute it and/or modify
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  it under the terms of the GNU General Public License as published by
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  the Free Software Foundation, either version 3 of the License, or
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  (at your option) any later version.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *  This program is distributed in the hope that it will be useful,
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  GNU General Public License for more details.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *  You should have received a copy of the GNU General Public License
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
 * An IEC 61131-3 compiler.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 * Based on the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
 *  Data type analysis of IL code may leave some IL instructions with an undefined datatype.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *  This visitor will set the datatype for all these symbols, so that all symbols have a well 
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *  defined datatype when we reach stage4.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
 *  Example:
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
 * =========
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
 *  VAR 
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
 *     N   : INT := 99 ;    
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
 *     tonv: TON;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
 *     byte_var: BYTE;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
 *     tonv : TON;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
 *     a : BYTE;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
 *     t : time;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
 *     tod1: tod;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    49
 *  END_VAR
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    50
 *  
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
 * (0) --> Data type before executing forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
 * (1) --> Data type after executing 1st pass of forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    53
 * (2) --> Data type after executing 2nd pass of forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    54
 * 
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    55
 * --- --> NULL (undefined datatype)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    56
 * *** --> invalid_type_name_c (invalid datatype)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    57
 *
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    58
 * (0)   PASS1   (1)    PASS2   (2)
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    59
 *      
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    60
 * ---     (e)   ***            ***       CAL tonv (                          
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    61
 *                                               PT := T#1s                   
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    62
 *                                            )                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    63
 * ---     (e)   ***            ***       JMP l4                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    64
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    65
 * ---     (e)   sint           sint  l0: LD  1                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    66
 * ---     (e)   sint           sint      ADD 2                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    67
 * ---  (c)      sint           sint      CAL tonv (                          
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    68
 *                                            PT := T#1s                      
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    69
 *                                            )                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    70
 *                                                                            
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    71
 * ---     (e)   sint           sint      LD  45                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    72
 * ---  (c)      sint           sint      ADD 45                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    73
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    74
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    75
 * ---     (e)   sint           sint      LD  3                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    76
 * ---     (e)   sint           sint  l1:                                     
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    77
 * ---  (c)      sint           sint  l2: ADD 4                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    78
 * int           int            int       LD  5                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    79
 * int           int            int       ST  n                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    80
 * int           int            int       JMP l3                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    81
 *                                                                            
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    82
 * ---  (d)      ---      (e)   sint      LD  5                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    83
 * ---  (d)      ---      (e)   sint      SUB 6                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    84
 * ---  (d)(e)   sint           sint      JMP l1                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    85
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    86
 * ---     (e)   bool           bool      LD  FALSE                           
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    87
 * ---     (e)   bool           bool      NOT                                 
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    88
 * ---  (b)      bool           bool      RET                                 
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    89
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    90
 * int           int            int   l3:                                     
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    91
 * int           int            int       ST  n                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    92
 * ---  (b)      int            int       RET                                 
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    93
 *
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    94
 * ---     (e)   ***            ***   l4:                                     
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    95
 * ---     (e)   ***            ***       CAL tonv (                          
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    96
 *                                               PT := T#1s                   
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    97
 *                                            )                               
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    98
 * ---  (a)      ***            ***       JMP l0                              
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
    99
 * ---  (b)      byte           byte      LD  88                              
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   100
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   101
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   102
 *   
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   103
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   104
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   105
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   106
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   107
#include "forced_narrow_candidate_datatypes.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   108
#include "datatype_functions.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   109
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   110
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   111
/* set to 1 to see debug info during execution */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   112
static int debug = 0;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   113
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   114
forced_narrow_candidate_datatypes_c::forced_narrow_candidate_datatypes_c(symbol_c *ignore) 
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   115
 :narrow_candidate_datatypes_c(ignore) {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   116
}
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   117
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   118
forced_narrow_candidate_datatypes_c::~forced_narrow_candidate_datatypes_c(void) {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   119
}
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   120
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   121
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   122
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   123
void forced_narrow_candidate_datatypes_c::forced_narrow_il_instruction(symbol_c *symbol, std::vector <symbol_c *> &next_il_instruction) {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   124
  if (NULL == symbol->datatype) {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   125
    if (symbol->candidate_datatypes.empty()) {
693
51a2fa6441b9 Prepare to delete search_constant_type_c -> Move the static variables from search_constant_type_c to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 691
diff changeset
   126
      symbol->datatype = &(get_datatype_info_c::invalid_type_name); // This will occur in the situations (a) in the above example
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   127
      // return NULL; // No need to return control to the visit() method of the base class... But we do so, just to be safe (called at the end of this function)!
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   128
    } else {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   129
      if (next_il_instruction.empty()) {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   130
        symbol->datatype = symbol->candidate_datatypes[0]; // This will occur in the situations (b) in the above example
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   131
      } else {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   132
        symbol_c *next_datatype = NULL;
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   133
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   134
        /* find the datatype of the following IL instructions (they should all be identical by now, but we don't have an assertion checking for this. */
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   135
        for (unsigned int i=0; i < next_il_instruction.size(); i++)
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   136
          if (NULL != next_il_instruction[i]->datatype)
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   137
            next_datatype = next_il_instruction[i]->datatype;
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   138
        if (get_datatype_info_c::is_type_valid(next_datatype)) {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   139
          //  This will occur in the situations (c) in the above example
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   140
          symbol->datatype = symbol->candidate_datatypes[0]; 
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   141
        } else {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   142
          //  This will occur in the situations (d) in the above example
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   143
          // it is not possible to determine the exact situation in the current pass, so we can't do anything just yet. Leave it for the next time around!
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   144
        }
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   145
      }
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   146
    }
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   147
  }
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   148
}
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   149
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   150
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   151
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   152
/****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   153
/* B.2 - Language IL (Instruction List) */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   154
/****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   155
/***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   156
/* B 2.1 Instructions and Operands */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   157
/***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   158
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   159
/*| instruction_list il_instruction */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   160
// SYM_LIST(instruction_list_c)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   161
void *forced_narrow_candidate_datatypes_c::visit(instruction_list_c *symbol) {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   162
  for(int j = 0; j < 2; j++) {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   163
    for(int i = symbol->n-1; i >= 0; i--) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 693
diff changeset
   164
      symbol->get_element(i)->accept(*this);
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   165
    }
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   166
  }
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   167
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   168
  /* Assert that this algorithm managed to remove all NULL datatypes! */
684
0e417d42cf6a Comment out invalid assertion.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
   169
  /* NOTE: The forced_narrow_candidate_datatypes_c assumes that the original IEC 61131-3 source code does not have any bugs!
0e417d42cf6a Comment out invalid assertion.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
   170
   *       This means we cannot run this assertion here, as the compiler will bork in the presence of bug in the code being compiled! Not good!!
0e417d42cf6a Comment out invalid assertion.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
   171
   */
0e417d42cf6a Comment out invalid assertion.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
   172
  /*
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   173
  for(int i = symbol->n-1; i >= 0; i--) {
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 693
diff changeset
   174
    if (NULL == symbol->get_element(i)->datatype)
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   175
      ERROR;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   176
  }
684
0e417d42cf6a Comment out invalid assertion.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
   177
  */
686
9b87606d4c07 Fix processing of TIME literals (submited by Andreas)
Mario de Sousa <msousa@fe.up.pt>
parents: 684
diff changeset
   178
  
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   179
  return NULL;
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   180
}
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   181
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   182
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   183
  
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   184
/* | label ':' [il_incomplete_instruction] eol_list */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   185
// SYM_REF2(il_instruction_c, label, il_instruction)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   186
// void *visit(instruction_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   187
void *forced_narrow_candidate_datatypes_c::visit(il_instruction_c *symbol) {
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   188
  forced_narrow_il_instruction(symbol, symbol->next_il_instruction);
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   189
  
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   190
  /* return control to the visit() method of the base class! */
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   191
  return narrow_candidate_datatypes_c::visit(symbol);  //  This handles the situations (e) in the above example
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   192
}
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   193
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   194
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   195
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   196
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   197
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   198
/* | il_simple_operator [il_operand] */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   199
// SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   200
// void *forced_narrow_candidate_datatypes_c::visit(il_simple_operation_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   201
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   202
/* | function_name [il_operand_list] */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   203
/* NOTE: The parameters 'called_function_declaration' and 'extensible_param_count' are used to pass data between the stage 3 and stage 4. */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   204
// SYM_REF2(il_function_call_c, function_name, il_operand_list, symbol_c *called_function_declaration; int extensible_param_count;)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   205
// void *forced_narrow_candidate_datatypes_c::visit(il_function_call_c *symbol) 
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   206
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   207
/* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   208
// SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   209
// void *forced_narrow_candidate_datatypes_c::visit(il_expression_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   210
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   211
/*  il_jump_operator label */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   212
// SYM_REF2(il_jump_operation_c, il_jump_operator, label)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   213
// void *forced_narrow_candidate_datatypes_c::visit(il_jump_operation_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   214
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   215
/*   il_call_operator prev_declared_fb_name
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   216
 * | il_call_operator prev_declared_fb_name '(' ')'
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   217
 * | il_call_operator prev_declared_fb_name '(' eol_list ')'
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   218
 * | il_call_operator prev_declared_fb_name '(' il_operand_list ')'
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   219
 * | il_call_operator prev_declared_fb_name '(' eol_list il_param_list ')'
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   220
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   221
/* NOTE: The parameter 'called_fb_declaration'is used to pass data between stage 3 and stage4 (although currently it is not used in stage 4 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   222
// SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list, symbol_c *called_fb_declaration)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   223
// void *forced_narrow_candidate_datatypes_c::visit(il_fb_call_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   224
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   225
/* | function_name '(' eol_list [il_param_list] ')' */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   226
/* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   227
// SYM_REF2(il_formal_funct_call_c, function_name, il_param_list, symbol_c *called_function_declaration; int extensible_param_count;)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   228
// void *forced_narrow_candidate_datatypes_c::visit(il_formal_funct_call_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   229
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   230
// void *visit(il_operand_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   231
// void *forced_narrow_candidate_datatypes_c::visit(simple_instr_list_c *symbol)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   232
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   233
// SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   234
void *forced_narrow_candidate_datatypes_c::visit(il_simple_instruction_c*symbol) {
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   235
  forced_narrow_il_instruction(symbol, symbol->next_il_instruction);
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   236
  
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   237
  /* return control to the visit() method of the base class! */
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   238
  return narrow_candidate_datatypes_c::visit(symbol);  //  This handle the situations (e) in the above example
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   239
}
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 688
diff changeset
   240
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   241
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   242
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   243
    void *visit(il_param_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   244
    void *visit(il_param_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   245
    void *visit(il_param_out_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   246
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   247
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   248
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   249
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   250
/***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   251
/* B.3 - Language ST (Structured Text) */
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   252
/***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   253
// SYM_LIST(statement_list_c)
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   254
/* The normal narrow_candidate_datatypes_c algorithm does not leave any symbol, in an ST code, with an undefined datatype.
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   255
 * There is therefore no need to re-run the narrow algorithm here, so we overide the narrow_candidate_datatypes_c visitor,
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   256
 * and simply bug out!
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   257
 */
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   258
void *forced_narrow_candidate_datatypes_c::visit(statement_list_c *symbol) {return NULL;}
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 679
diff changeset
   259