stage3/datatype_functions.hh
author Mario de Sousa <msousa@fe.up.pt>
Thu, 04 Oct 2012 15:10:45 +0100
changeset 667 bd1360f29f15
parent 666 8ba9ec4bae50
child 676 ca4f17211251
permissions -rw-r--r--
Merge
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2009-2012  Mario de Sousa (msousa@fe.up.pt)
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *  Copyright (C) 2012       Manuele Conti  (conti.ma@alice.it)
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  (at your option) any later version.
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  GNU General Public License for more details.
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 *
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
 */
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
#ifndef _HELPER_FUNCTIONS_HH_
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
#define _HELPER_FUNCTIONS_HH_
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
#include "../absyntax/visitor.hh"
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
#include <typeinfo>
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
434
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    31
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    32
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    33
438
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    34
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    35
typedef struct {
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    36
  symbol_c *function_name;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    37
  symbol_c *nonformal_operand_list;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    38
  symbol_c *   formal_operand_list;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    39
441
e8de43eefcc5 Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
    40
  enum {POU_FB, POU_function} POU_type;
438
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    41
//symbol_c &*datatype;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    42
//std::vector <symbol_c *> &candidate_datatypes;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    43
  std::vector <symbol_c *> &candidate_functions;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    44
  symbol_c *&called_function_declaration;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    45
  int      &extensible_param_count;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    46
} generic_function_call_t;
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    47
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    48
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 436
diff changeset
    49
434
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    50
/* A small helper class, to transform elementary data type to string.
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    51
 * this allows us to generate more relevant error messages...
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    52
 */
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    53
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    54
class elementary_type_c: public null_visitor_c {
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    55
  protected:
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    56
    elementary_type_c(void)  {};
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    57
    ~elementary_type_c(void) {};
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    58
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    59
  private:
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    60
    /* singleton class! */
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    61
    static elementary_type_c *singleton;
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    62
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    63
  public:
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    64
    static const char * to_string(symbol_c *symbol);
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    65
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    66
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    67
    /***********************************/
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    68
    /* B 1.3.1 - Elementary Data Types */
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
    69
    /***********************************/
478
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    70
    void *visit(time_type_name_c        *symbol) {return (void *)"TIME";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    71
    void *visit(bool_type_name_c        *symbol) {return (void *)"BOOL";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    72
    void *visit(sint_type_name_c        *symbol) {return (void *)"SINT";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    73
    void *visit(int_type_name_c         *symbol) {return (void *)"INT";         };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    74
    void *visit(dint_type_name_c        *symbol) {return (void *)"DINT";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    75
    void *visit(lint_type_name_c        *symbol) {return (void *)"LINT";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    76
    void *visit(usint_type_name_c       *symbol) {return (void *)"USINT";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    77
    void *visit(uint_type_name_c        *symbol) {return (void *)"UINT";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    78
    void *visit(udint_type_name_c       *symbol) {return (void *)"UDINT";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    79
    void *visit(ulint_type_name_c       *symbol) {return (void *)"ULINT";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    80
    void *visit(real_type_name_c        *symbol) {return (void *)"REAL";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    81
    void *visit(lreal_type_name_c       *symbol) {return (void *)"LREAL";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    82
    void *visit(date_type_name_c        *symbol) {return (void *)"DATE";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    83
    void *visit(tod_type_name_c         *symbol) {return (void *)"TOD";         };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    84
    void *visit(dt_type_name_c          *symbol) {return (void *)"DT";          };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    85
    void *visit(byte_type_name_c        *symbol) {return (void *)"BYTE";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    86
    void *visit(word_type_name_c        *symbol) {return (void *)"WORD";        };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    87
    void *visit(lword_type_name_c       *symbol) {return (void *)"LWORD";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    88
    void *visit(dword_type_name_c       *symbol) {return (void *)"DWORD";       };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    89
    void *visit(string_type_name_c      *symbol) {return (void *)"STRING";      };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    90
    void *visit(wstring_type_name_c     *symbol) {return (void *)"WSTRING";     };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    91
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    92
    void *visit(safetime_type_name_c    *symbol) {return (void *)"SAFETIME";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    93
    void *visit(safebool_type_name_c    *symbol) {return (void *)"SAFEBOOL";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    94
    void *visit(safesint_type_name_c    *symbol) {return (void *)"SAFESINT";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    95
    void *visit(safeint_type_name_c     *symbol) {return (void *)"SAFEINT";     };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    96
    void *visit(safedint_type_name_c    *symbol) {return (void *)"SAFEDINT";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    97
    void *visit(safelint_type_name_c    *symbol) {return (void *)"SAFELINT";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    98
    void *visit(safeusint_type_name_c   *symbol) {return (void *)"SAFEUSINT";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
    99
    void *visit(safeuint_type_name_c    *symbol) {return (void *)"SAFEUINT";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   100
    void *visit(safeudint_type_name_c   *symbol) {return (void *)"SAFEUDINT";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   101
    void *visit(safeulint_type_name_c   *symbol) {return (void *)"SAFEULINT";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   102
    void *visit(safereal_type_name_c    *symbol) {return (void *)"SAFEREAL";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   103
    void *visit(safelreal_type_name_c   *symbol) {return (void *)"SAFELREAL";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   104
    void *visit(safedate_type_name_c    *symbol) {return (void *)"SAFEDATE";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   105
    void *visit(safetod_type_name_c     *symbol) {return (void *)"SAFETOD";     };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   106
    void *visit(safedt_type_name_c      *symbol) {return (void *)"SAFEDT";      };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   107
    void *visit(safebyte_type_name_c    *symbol) {return (void *)"SAFEBYTE";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   108
    void *visit(safeword_type_name_c    *symbol) {return (void *)"SAFEWORD";    };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   109
    void *visit(safelword_type_name_c   *symbol) {return (void *)"SAFELWORD";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   110
    void *visit(safedword_type_name_c   *symbol) {return (void *)"SAFEDWORD";   };
b13feab3b918 Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents: 472
diff changeset
   111
    void *visit(safestring_type_name_c  *symbol) {return (void *)"SAFESTRING";  };
434
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   112
    void *visit(safewstring_type_name_c *symbol) {return (void *)"SAFEWSTRING"; };
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   113
};
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   114
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   115
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   116
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   117
c1278e52bcbc Move elementary_c::to_string() to datatype_functions.cc/hh
Mario de Sousa <msousa@fe.up.pt>
parents: 425
diff changeset
   118
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   119
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   120
/* Widening Primitive Conversion */
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   121
struct widen_entry {
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   122
	symbol_c *left;
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   123
	symbol_c *right;
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   124
	symbol_c *result;
458
587884880be6 iAdd warning for deprecated operations.
Conti Manuele <conti.ma@alice.it>
parents: 457
diff changeset
   125
	enum {ok, deprecated} status;
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   126
};
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   127
/*
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   128
 * 2.5.1.5.6 Functions of time data types
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   129
 * Table 30 - page 64
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   130
 */
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   131
extern const struct widen_entry widen_ADD_table[];
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   132
extern const struct widen_entry widen_SUB_table[];
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   133
extern const struct widen_entry widen_MUL_table[];
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   134
extern const struct widen_entry widen_DIV_table[];
480
8a58d7b8b26c Add MOD widening table, and some code clean-ups.
Mario de Sousa <msousa@fe.up.pt>
parents: 478
diff changeset
   135
extern const struct widen_entry widen_MOD_table[];
490
29f6ab0bf954 Add EXPT widen table.
Mario de Sousa <msousa@fe.up.pt>
parents: 484
diff changeset
   136
extern const struct widen_entry widen_EXPT_table[];
481
16f943328696 Add 'widen' tables for AND, OR and XOR operations.
Mario de Sousa <msousa@fe.up.pt>
parents: 480
diff changeset
   137
extern const struct widen_entry widen_AND_table[];
16f943328696 Add 'widen' tables for AND, OR and XOR operations.
Mario de Sousa <msousa@fe.up.pt>
parents: 480
diff changeset
   138
extern const struct widen_entry widen_OR_table[];
16f943328696 Add 'widen' tables for AND, OR and XOR operations.
Mario de Sousa <msousa@fe.up.pt>
parents: 480
diff changeset
   139
extern const struct widen_entry widen_XOR_table[];
484
f78750994a82 Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents: 481
diff changeset
   140
extern const struct widen_entry widen_CMP_table[];
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   141
425
c8e6cf57324a Print error messages when datatype erros found in ST function/FB calls.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   142
/* Search for a datatype inside a candidate_datatypes list.
c8e6cf57324a Print error messages when datatype erros found in ST function/FB calls.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   143
 * Returns: position of datatype in the list, or -1 if not found.
c8e6cf57324a Print error messages when datatype erros found in ST function/FB calls.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   144
 */
606
d2122a32ec86 Cleaning up the code.
Mario de Sousa <msousa@fe.up.pt>
parents: 603
diff changeset
   145
int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector <symbol_c *> &candidate_datatypes);
425
c8e6cf57324a Print error messages when datatype erros found in ST function/FB calls.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   146
603
a45a62dd6df9 Add remove_from_candidate_datatype_list method using constant_folding results.
Manuele Conti <conti.ma@alice.it>
parents: 490
diff changeset
   147
/* Remove a datatype inside a candidate_datatypes list.
a45a62dd6df9 Add remove_from_candidate_datatype_list method using constant_folding results.
Manuele Conti <conti.ma@alice.it>
parents: 490
diff changeset
   148
 * Returns: If successful it returns true, false otherwise.
a45a62dd6df9 Add remove_from_candidate_datatype_list method using constant_folding results.
Manuele Conti <conti.ma@alice.it>
parents: 490
diff changeset
   149
 */
a45a62dd6df9 Add remove_from_candidate_datatype_list method using constant_folding results.
Manuele Conti <conti.ma@alice.it>
parents: 490
diff changeset
   150
bool remove_from_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> &candidate_datatypes);
a45a62dd6df9 Add remove_from_candidate_datatype_list method using constant_folding results.
Manuele Conti <conti.ma@alice.it>
parents: 490
diff changeset
   151
457
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   152
/* Intersect two candidate_datatype_lists.
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   153
 * Remove from list1 (origin, dest.) all elements that are not found in list2 (with).
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   154
 * In essence, list1 will contain the result of the intersection of list1 with list2.
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   155
 * In other words, modify list1 so it only contains the elelements that are simultaneously in list1 and list2!
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   156
 */
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   157
void intersect_candidate_datatype_list(symbol_c *list1 /*origin, dest.*/, symbol_c *list2 /*with*/);
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 445
diff changeset
   158
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   159
/* intersect the candidate_datatype lists of all prev_il_intructions, and set the local candidate_datatype list to the result! */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   160
void intersect_prev_candidate_datatype_lists(il_instruction_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   161
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   162
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents: 441
diff changeset
   163
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   164
425
c8e6cf57324a Print error messages when datatype erros found in ST function/FB calls.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   165
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   166
bool is_type_equal(symbol_c *first_type, symbol_c *second_type);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   167
bool is_type_valid(symbol_c *type);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   168
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 458
diff changeset
   169
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   170
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   171
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   172
#endif /* _HELPER_FUNCTIONS_HH_ */