absyntax_utils/get_datatype_info.cc
author mjsousa
Thu, 27 Nov 2014 13:26:58 +0000
changeset 950 935c8b6ba3c5
parent 946 c012a64dc2fa
child 958 7474d2cd1d6e
permissions -rw-r--r--
Update the comments in source code.
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
     6
 *  Copyright (C) 2012       Manuele Conti  (conti.ma@alice.it)
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *  (at your option) any later version.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *  GNU General Public License for more details.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 * This code is made available on the understanding that it will not be
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
 * used in safety-critical situations without a full and competent review.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
 */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
/*
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 * An IEC 61131-3 compiler.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 * Based on the
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
 */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
/* Determine the characteristics of a specific data type
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *  e.g., is it an enumeration, is it an array, is it ANY_INT, etc...
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 * The methods of this class may be passed either:
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
 *  - a data type declaration symbol_c, 
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
 *   OR
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
 *  - the name of a data type (identifier_c)
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
 *    In this case, we shall first serach for the basetype declaration using search_base_type_c, and then 
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
 *    run the normal process.
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
 */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
#include "absyntax_utils.hh"
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
    46
#include "../main.hh" // required for ERROR() and ERROR_MSG() macros, as well as the runtime_options global variable
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    49
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    50
#include <typeinfo>  // required for typeid
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    53
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    54
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    55
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    56
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    57
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    58
/*****           Some helper classes                  *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    59
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    60
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    61
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    62
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    63
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    64
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
    65
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
    66
/****************************************************************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
    67
/****************************************************************************************************/
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    68
/* Return the identifier (name) of a datatype, typically declared in a TYPE .. END_TYPE declaration */
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
    69
/****************************************************************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
    70
/****************************************************************************************************/
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    71
class get_datatype_id_c: null_visitor_c {
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    72
  private:
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    73
    static get_datatype_id_c *singleton;
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    74
    
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    75
  public:
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    76
    static symbol_c *get_id(symbol_c *symbol) {
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    77
      if (NULL == singleton) singleton = new  get_datatype_id_c();
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    78
      if (NULL == singleton) ERROR;
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    79
      return (symbol_c *)symbol->accept(*singleton);
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    80
    }
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    81
    
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
    82
  protected:
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    83
    /***********************************/
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    84
    /* B 1.3.1 - Elementary Data Types */
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    85
    /***********************************/
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    86
    void *visit(time_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    87
    void *visit(bool_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    88
    void *visit(sint_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    89
    void *visit(int_type_name_c         *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    90
    void *visit(dint_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    91
    void *visit(lint_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    92
    void *visit(usint_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    93
    void *visit(uint_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    94
    void *visit(udint_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    95
    void *visit(ulint_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    96
    void *visit(real_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    97
    void *visit(lreal_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    98
    void *visit(date_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
    99
    void *visit(tod_type_name_c         *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   100
    void *visit(dt_type_name_c          *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   101
    void *visit(byte_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   102
    void *visit(word_type_name_c        *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   103
    void *visit(lword_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   104
    void *visit(dword_type_name_c       *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   105
    void *visit(string_type_name_c      *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   106
    void *visit(wstring_type_name_c     *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   107
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   108
    void *visit(safetime_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   109
    void *visit(safebool_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   110
    void *visit(safesint_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   111
    void *visit(safeint_type_name_c     *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   112
    void *visit(safedint_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   113
    void *visit(safelint_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   114
    void *visit(safeusint_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   115
    void *visit(safeuint_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   116
    void *visit(safeudint_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   117
    void *visit(safeulint_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   118
    void *visit(safereal_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   119
    void *visit(safelreal_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   120
    void *visit(safedate_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   121
    void *visit(safetod_type_name_c     *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   122
    void *visit(safedt_type_name_c      *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   123
    void *visit(safebyte_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   124
    void *visit(safeword_type_name_c    *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   125
    void *visit(safelword_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   126
    void *visit(safedword_type_name_c   *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   127
    void *visit(safestring_type_name_c  *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   128
    void *visit(safewstring_type_name_c *symbol) {return (void *)symbol;};
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   129
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   130
    /********************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   131
    /* B 1.3.3 - Derived data types */
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   132
    /********************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   133
    /*  simple_type_name ':' simple_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   134
    void *visit(simple_type_declaration_c     *symbol)  {return symbol->simple_type_name;}
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   135
    /*  subrange_type_name ':' subrange_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   136
    void *visit(subrange_type_declaration_c   *symbol)  {return symbol->subrange_type_name;}
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   137
    /*  enumerated_type_name ':' enumerated_spec_init */
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   138
    void *visit(enumerated_type_declaration_c *symbol)  {return symbol->enumerated_type_name;}
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   139
    /*  identifier ':' array_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   140
    void *visit(array_type_declaration_c      *symbol)  {return symbol->identifier;}
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   141
    /*  structure_type_name ':' structure_specification */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   142
    void *visit(structure_type_declaration_c  *symbol)  {return symbol->structure_type_name;}
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   143
    /*  string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   144
    void *visit(string_type_declaration_c     *symbol)  {return symbol->string_type_name;}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   145
    /* ref_type_decl: identifier ':' ref_spec_init */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   146
    void *visit(ref_type_decl_c               *symbol)  {return symbol->ref_type_name;}
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   147
    /* NOTE: DO NOT place any code here that references symbol->anotations_map["generate_c_annotaton__implicit_type_id"] !!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   148
     *       All anotations in the symbol->anotations_map[] are considered a stage4 construct. In the above example,
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   149
     *       That anotation is specific to the generate_c stage4 code, and must therefore NOT be referenced
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   150
     *       in the absyntax_utils code, as this last code should be independent of the stage4 version!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   151
     */ 
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   152
    
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   153
    /*****************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   154
    /* B 1.5.2 - Function Blocks */
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   155
    /*****************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   156
    /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   157
    void *visit(function_block_declaration_c  *symbol)  {return symbol->fblock_name;}
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   158
}; // get_datatype_id_c 
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   159
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   160
get_datatype_id_c *get_datatype_id_c::singleton = NULL;
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   161
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   162
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   163
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   164
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   165
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   166
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   167
/**************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   168
/**************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   169
/* transform elementary data type class to string */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   170
/**************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   171
/**************************************************/
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   172
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   173
/* A small helper class, to transform elementary data type to string.
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   174
 * this allows us to generate more relevant error messages...
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   175
 */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   176
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   177
class get_datatype_id_str_c: public null_visitor_c {
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   178
  protected:
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   179
     get_datatype_id_str_c(void)  {};
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   180
    ~get_datatype_id_str_c(void) {};
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   181
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   182
  private:
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   183
    /* singleton class! */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   184
    static get_datatype_id_str_c *singleton;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   185
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   186
  public:
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   187
    static const char *get_id_str(symbol_c *symbol) {
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   188
      if (NULL == singleton)    singleton = new get_datatype_id_str_c;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   189
      if (NULL == singleton)    ERROR;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   190
      const char *res           = (const char *)symbol->accept(*singleton);
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   191
      if (NULL == res)          ERROR;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   192
      return res;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   193
    }
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   194
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   195
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   196
    /*************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   197
    /* B.1 - Common elements */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   198
    /*************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   199
    /*******************************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   200
    /* B 1.1 - Letters, digits and identifiers */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   201
    /*******************************************/
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   202
    void *visit(                 identifier_c *symbol) {return (void *)symbol->value;};
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   203
    void *visit(derived_datatype_identifier_c *symbol) {return (void *)symbol->value;};
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   204
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   205
    /***********************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   206
    /* B 1.3.1 - Elementary Data Types */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   207
    /***********************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   208
    void *visit(time_type_name_c        *symbol) {return (void *)"TIME";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   209
    void *visit(bool_type_name_c        *symbol) {return (void *)"BOOL";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   210
    void *visit(sint_type_name_c        *symbol) {return (void *)"SINT";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   211
    void *visit(int_type_name_c         *symbol) {return (void *)"INT";         };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   212
    void *visit(dint_type_name_c        *symbol) {return (void *)"DINT";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   213
    void *visit(lint_type_name_c        *symbol) {return (void *)"LINT";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   214
    void *visit(usint_type_name_c       *symbol) {return (void *)"USINT";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   215
    void *visit(uint_type_name_c        *symbol) {return (void *)"UINT";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   216
    void *visit(udint_type_name_c       *symbol) {return (void *)"UDINT";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   217
    void *visit(ulint_type_name_c       *symbol) {return (void *)"ULINT";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   218
    void *visit(real_type_name_c        *symbol) {return (void *)"REAL";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   219
    void *visit(lreal_type_name_c       *symbol) {return (void *)"LREAL";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   220
    void *visit(date_type_name_c        *symbol) {return (void *)"DATE";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   221
    void *visit(tod_type_name_c         *symbol) {return (void *)"TOD";         };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   222
    void *visit(dt_type_name_c          *symbol) {return (void *)"DT";          };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   223
    void *visit(byte_type_name_c        *symbol) {return (void *)"BYTE";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   224
    void *visit(word_type_name_c        *symbol) {return (void *)"WORD";        };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   225
    void *visit(lword_type_name_c       *symbol) {return (void *)"LWORD";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   226
    void *visit(dword_type_name_c       *symbol) {return (void *)"DWORD";       };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   227
    void *visit(string_type_name_c      *symbol) {return (void *)"STRING";      };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   228
    void *visit(wstring_type_name_c     *symbol) {return (void *)"WSTRING";     };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   229
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   230
    void *visit(safetime_type_name_c    *symbol) {return (void *)"SAFETIME";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   231
    void *visit(safebool_type_name_c    *symbol) {return (void *)"SAFEBOOL";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   232
    void *visit(safesint_type_name_c    *symbol) {return (void *)"SAFESINT";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   233
    void *visit(safeint_type_name_c     *symbol) {return (void *)"SAFEINT";     };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   234
    void *visit(safedint_type_name_c    *symbol) {return (void *)"SAFEDINT";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   235
    void *visit(safelint_type_name_c    *symbol) {return (void *)"SAFELINT";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   236
    void *visit(safeusint_type_name_c   *symbol) {return (void *)"SAFEUSINT";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   237
    void *visit(safeuint_type_name_c    *symbol) {return (void *)"SAFEUINT";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   238
    void *visit(safeudint_type_name_c   *symbol) {return (void *)"SAFEUDINT";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   239
    void *visit(safeulint_type_name_c   *symbol) {return (void *)"SAFEULINT";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   240
    void *visit(safereal_type_name_c    *symbol) {return (void *)"SAFEREAL";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   241
    void *visit(safelreal_type_name_c   *symbol) {return (void *)"SAFELREAL";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   242
    void *visit(safedate_type_name_c    *symbol) {return (void *)"SAFEDATE";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   243
    void *visit(safetod_type_name_c     *symbol) {return (void *)"SAFETOD";     };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   244
    void *visit(safedt_type_name_c      *symbol) {return (void *)"SAFEDT";      };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   245
    void *visit(safebyte_type_name_c    *symbol) {return (void *)"SAFEBYTE";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   246
    void *visit(safeword_type_name_c    *symbol) {return (void *)"SAFEWORD";    };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   247
    void *visit(safelword_type_name_c   *symbol) {return (void *)"SAFELWORD";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   248
    void *visit(safedword_type_name_c   *symbol) {return (void *)"SAFEDWORD";   };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   249
    void *visit(safestring_type_name_c  *symbol) {return (void *)"SAFESTRING";  };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   250
    void *visit(safewstring_type_name_c *symbol) {return (void *)"SAFEWSTRING"; };
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   251
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   252
    /********************************/
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   253
    /* B.1.3.2 - Generic data types */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   254
    /********************************/
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   255
    void *visit(generic_type_any_c *symbol) {return (void *)"ANY"; };
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   256
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   257
    /********************************/
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   258
    /* B 1.3.3 - Derived data types */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   259
    /********************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   260
    /*  simple_type_name ':' simple_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   261
    void *visit(simple_type_declaration_c     *symbol)  {return symbol->simple_type_name->accept(*this);}
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   262
    /*  subrange_type_name ':' subrange_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   263
    void *visit(subrange_type_declaration_c   *symbol)  {return symbol->subrange_type_name->accept(*this);}
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   264
    /*  enumerated_type_name ':' enumerated_spec_init */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   265
    void *visit(enumerated_type_declaration_c *symbol)  {return symbol->enumerated_type_name->accept(*this);}
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   266
    /*  identifier ':' array_spec_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   267
    void *visit(array_type_declaration_c      *symbol)  {return symbol->identifier->accept(*this);}
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   268
    /*  structure_type_name ':' structure_specification */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   269
    void *visit(structure_type_declaration_c  *symbol)  {return symbol->structure_type_name->accept(*this);}
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   270
    /*  string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   271
    void *visit(string_type_declaration_c     *symbol)  {return symbol->string_type_name->accept(*this);}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   272
    /* ref_type_decl: identifier ':' ref_spec_init */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   273
    void *visit(ref_type_decl_c               *symbol)  {return symbol->ref_type_name->accept(*this);}
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   274
    /* NOTE: DO NOT place any code here that references symbol->anotations_map["generate_c_annotaton__implicit_type_id"] !!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   275
     *       All anotations in the symbol->anotations_map[] are considered a stage4 construct. In the above example,
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   276
     *       That anotation is specific to the generate_c stage4 code, and must therefore NOT be referenced
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   277
     *       in the absyntax_utils code, as this last code should be independent of the stage4 version!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   278
     */ 
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   279
    
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   280
    /*****************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   281
    /* B 1.5.2 - Function Blocks */
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   282
    /*****************************/
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   283
    /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   284
    void *visit(function_block_declaration_c  *symbol)  {return symbol->fblock_name->accept(*this);}    
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   285
};
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   286
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   287
get_datatype_id_str_c *get_datatype_id_str_c::singleton = NULL;
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   288
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   289
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   290
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   291
/*********************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   292
/*********************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   293
/* get the datatype of a field inside a struct data type */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   294
/*********************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   295
/*********************************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   296
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   297
class get_struct_info_c : null_visitor_c {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   298
  private:
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   299
    symbol_c *current_field;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   300
    /* singleton class! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   301
    static get_struct_info_c *singleton;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   302
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   303
  public:
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   304
    get_struct_info_c(void) {current_field = NULL;}
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   305
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   306
    static symbol_c *get_field_type_id(symbol_c *struct_type, symbol_c *field_name) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   307
      if (NULL == singleton)    singleton = new get_struct_info_c;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   308
      if (NULL == singleton)    ERROR;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   309
      singleton->current_field = field_name;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   310
      return (symbol_c *)struct_type->accept(*singleton);
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   311
    }
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   312
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   313
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   314
  private:
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   315
    /*************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   316
    /* B.1 - Common elements */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   317
    /*************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   318
    /********************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   319
    /* B 1.3.3 - Derived data types */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   320
    /********************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   321
    /*  structure_type_name ':' structure_specification */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   322
    /* NOTE: this is only used inside a TYPE ... END_TYPE declaration.  It is never used directly when declaring a new variable! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   323
    /* NOTE: structure_specification will point to either initialized_structure_c  OR  structure_element_declaration_list_c */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   324
    void *visit(structure_type_declaration_c *symbol) {return symbol->structure_specification->accept(*this);}
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   325
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   326
    /* structure_type_name ASSIGN structure_initialization */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   327
    /* structure_initialization may be NULL ! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   328
    // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   329
    /* NOTE: only the initialized structure is never used when declaring a new variable instance */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   330
    void *visit(initialized_structure_c *symbol) {return symbol->structure_type_name->accept(*this);}
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   331
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   332
    /* helper symbol for structure_declaration */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   333
    /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   334
    /* structure_element_declaration_list structure_element_declaration ';' */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   335
    void *visit(structure_element_declaration_list_c *symbol) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   336
      /* now search the structure declaration */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   337
      for(int i = 0; i < symbol->n; i++) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   338
        void *tmp = symbol->elements[i]->accept(*this);
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   339
        if (NULL != tmp) return tmp;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   340
      }
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   341
      return NULL; // not found!!
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   342
    }  
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   343
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   344
    /*  structure_element_name ':' spec_init */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   345
    void *visit(structure_element_declaration_c *symbol) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   346
      if (compare_identifiers(symbol->structure_element_name, current_field) == 0)
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   347
        return symbol->spec_init; /* found the type of the element we were looking for! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   348
      return NULL;   /* not the element we are looking for! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   349
    }
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   350
      
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   351
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   352
    /* helper symbol for structure_initialization */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   353
    /* structure_initialization: '(' structure_element_initialization_list ')' */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   354
    /* structure_element_initialization_list ',' structure_element_initialization */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   355
    void *visit(structure_element_initialization_list_c *symbol) {ERROR; return NULL;} /* should never get called... */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   356
    /*  structure_element_name ASSIGN value */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   357
    void *visit(structure_element_initialization_c *symbol) {ERROR; return NULL;} /* should never get called... */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   358
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   359
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   360
    /**************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   361
    /* B.1.5 - Program organization units */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   362
    /**************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   363
    /*****************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   364
    /* B 1.5.2 - Function Blocks */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   365
    /*****************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   366
    /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   367
    // SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused)
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   368
    void *visit(function_block_declaration_c *symbol) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   369
      /* now search the function block declaration for the variable... */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   370
      search_var_instance_decl_c search_decl(symbol);
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   371
      return search_decl.get_decl(current_field);
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   372
    }
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   373
      
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   374
    /*********************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   375
    /* B.1.6  Sequential function chart elements */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   376
    /*********************************************/
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   377
    /* INITIAL_STEP step_name ':' action_association_list END_STEP */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   378
    // SYM_REF2(initial_step_c, step_name, action_association_list)
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   379
    void *visit(initial_step_c *symbol) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   380
      identifier_c T("T");  identifier_c X("X");
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   381
      /* Hard code the datatypes of the implicit variables Stepname.X and Stepname.T */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   382
      if (compare_identifiers(&T, current_field) == 0)  return &get_datatype_info_c::time_type_name;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   383
      if (compare_identifiers(&X, current_field) == 0)  return &get_datatype_info_c::bool_type_name;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   384
      return NULL;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   385
    }
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   386
      
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   387
    /* STEP step_name ':' action_association_list END_STEP */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   388
    // SYM_REF2(step_c, step_name, action_association_list)
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   389
    /* The code here should be identicial to the code in the visit(initial_step_c *) visitor! So we simply call the other visitor! */
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   390
    void *visit(step_c *symbol) {initial_step_c initial_step(NULL, NULL); return initial_step.accept(*this);}
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   391
      
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   392
}; // get_struct_info_c
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   393
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   394
get_struct_info_c *get_struct_info_c::singleton = NULL;
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   395
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   396
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   397
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   398
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   399
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   400
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   401
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   402
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   403
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   404
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   405
/*****        GET_DATATYPE_INFO_C                     *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   406
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   407
/*****                                                *****/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   408
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   409
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   410
/**********************************************************/
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   411
778
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   412
const char *get_datatype_info_c::get_id_str(symbol_c *datatype) {
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   413
  return get_datatype_id_str_c::get_id_str(datatype);
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   414
}
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   415
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   416
44e02a88f1e7 moved class to obtain datatype name (in char *) to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 727
diff changeset
   417
symbol_c *get_datatype_info_c::get_id(symbol_c *datatype) {
727
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   418
  return get_datatype_id_c::get_id(datatype);
db5881e6facd Add method to determine the id (name) of a datatype.
Mario de Sousa <msousa@fe.up.pt>
parents: 718
diff changeset
   419
}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   420
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   421
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   422
symbol_c *get_datatype_info_c::get_struct_field_type_id(symbol_c *struct_datatype, symbol_c *struct_fieldname) {
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   423
  return get_struct_info_c::get_field_type_id(struct_datatype, struct_fieldname);
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   424
}
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 929
diff changeset
   425
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   426
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   427
939
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   428
symbol_c *get_datatype_info_c::get_array_storedtype_id(symbol_c *type_symbol) {
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   429
  // returns the datatype of the variables stored in the array
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   430
  array_specification_c *symbol = NULL;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   431
  if (NULL == symbol)  symbol = dynamic_cast<array_specification_c *>(type_symbol);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   432
  if (NULL == symbol)  symbol = dynamic_cast<array_specification_c *>(search_base_type_c::get_basetype_decl(type_symbol));
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   433
  if (NULL != symbol)  
939
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   434
    return symbol->non_generic_type_name;
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   435
  return NULL; // this is not an array!
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   436
}
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   437
  
5074236fb3c4 fill_candidate_datatypes_c now uses search_varinstance_decl_c instead of search_varfb_instance_type_c (moving towards deprecation of search_varfb_instance_type_c)
mjsousa
parents: 938
diff changeset
   438
  
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   439
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   440
922
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   441
/* Returns true if both datatypes are equivalent (not necessarily equal!).
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   442
 * WARNING: May return true even though the datatypes are not the same/identicial!!!
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   443
 *          This occurs when at least one of the datatypes is of a generic
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   444
 *          datatype (or a REF_TO a generic datatype). 
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   445
 *          (Generic dataypes: ANY, ANY_INT, ANY_NUM, ...)
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   446
 * NOTE: Currently only the ANY generic datatype is implemented!
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   447
 * NOTE: Currently stage1_2 only allows the use of the ANY keyword when in conjuntion with
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   448
 *       the REF_TO keyword (i.e. REF_TO ANY), so when handling non REF_TO datatypes,
1ba7a814098d Update some comments. (No changes to code)
mjsousa
parents: 921
diff changeset
   449
 *       this function will currently only return true if the dataypes are identicial.
921
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   450
 */
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   451
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   452
/* NOTE: matiec supports a strict and a relaxed data type model. Which datatype model to use is chosen
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   453
 *       as a command line option.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   454
 * 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   455
 * 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   456
 *       The Strict Datatype Model
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   457
 *       =========================
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   458
 *       The strict datatype model used by matiec considers any implicitly defined datatype
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   459
 *       (e.g. an array datatype defined in the variable declaration itself, instead of inside a TYPE ... END_TYPE
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   460
 *       construct) to be different (i.e. not the same datatype, and therefore not compatible) to any other
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   461
 *       datatype, including with datatypes declared identically to the implicit datatype.
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   462
 *       e.g.
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   463
 *         TYPE my_array_t: ARRAY [1..3] OF INT; END_TYPE;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   464
 *         FUNCTION_BLOCK FOO
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   465
 *          VAR my_array:  ARRAY [1..3] OF INT; END_VAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   466
 *         ...
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   467
 *         END_FUNCTION_BLOCK
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   468
 * 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   469
 *         In the abive code, my_array is NOT considered to te compatible with my_Array_t !!!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   470
 * 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   471
 *       In essence, the currently supported datatype model considers all datatypes to be different to each other,
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   472
 *       even though the stored data is the same (Let us call this rule (0))!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   473
 *       There are 2 exceptions to the above rule:
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   474
 *        (1) Datatypes that are directly derived from other datatypes.
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   475
 *              (this rule is specified in the standard, so we follow it!)
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   476
 *        (2) REF_TO datatypes that reference the same datatype
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   477
 *              (I dont think the standard says anything about this!)
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   478
 *              (This rule should actually be part of the relaxed datatype model, but for now we
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   479
 *               will leave it in the strict datatype model) 
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   480
 *
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   481
 *         TYPE 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   482
 *          my_array_1_t: ARRAY [1..3] OF INT; 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   483
 *          my_array_2_t: ARRAY [1..3] OF INT; 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   484
 *          my_array_3_t: my_array_1_t; 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   485
 *          A_ref_t: REF_TO my_array_1_t;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   486
 *          B_ref_t: REF_TO my_array_1_t;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   487
 *          C_ref_t: A_ref_t;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   488
 *         END_TYPE;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   489
 *                 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   490
 *         In the above code, my_array_1_t is a distinct datatype to my_array_2_t
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   491
 *           (this is different to C and C++, where they would be considered the same datatype!)
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   492
 *           (following rule (0))
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   493
 *         In the above code, my_array_3_t is the same datatype as my_array_1_t
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   494
 *           (following rule (1))
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   495
 *         In the above code, A_ref_t is the same datatype as B_ref_t
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   496
 *           (following rule (2))
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   497
 *         In the above code, A_ref_t is the same datatype as C_ref_t
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   498
 *           (following rule (1))
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   499
 *
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   500
 *       Note that rule (0) means that a function/FB with a parameter whose datatype is implicitly defined
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   501
 *       can never be passed a value!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   502
 *         FUNCTION_BLOCK FOO
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   503
 *          VAR_INPUT my_array:  ARRAY [1..3] OF INT; END_VAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   504
 *         ...
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   505
 *         END_FUNCTION_BLOCK
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   506
 *
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   507
 *       Any call to FB foo can never pass a value to parameter my_array, as its datatype is distinct
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   508
 *       to all other datatypes, and therefore passing any other variable to my_array will result in an
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   509
 *       'incompatible datatypes' error!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   510
 *       The above seems natural o me (Mario) in a programming language that is very strongly typed.
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   511
 * 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   512
 *       However, if we did not have exception (2), the following would also be invalid:
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   513
 *         TYPE my_array_t: ARRAY [1..3] OF INT; END_TYPE;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   514
 *         FUNCTION_BLOCK FOO_t
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   515
 *          VAR_INPUT my_array: REF_TO my_array_t; END_VAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   516
 *         ...
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   517
 *         END_FUNCTION_BLOCK
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   518
 * 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   519
 *         FUNCTION_BLOCK BAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   520
 *          VAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   521
 *            my_array: my_array_t; 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   522
 *            foo: FOO_t;
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   523
 *          END_VAR
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   524
 *          foo(REF(my_array));  <----- invalid, without rule 2!!
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   525
 *         ...
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   526
 *         END_FUNCTION_BLOCK
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   527
 * 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   528
 *       Rule/exception (2) goes against the datatype model used for all other datatypes.
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   529
 *       This rule was adopted as without it, the datatype of the value returned by the REF() 
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   530
 *       operator would be considered distinct to all other datatypes, and therefore the
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   531
 *       REF() operator would be essentially useless.
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   532
 * 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   533
 * 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   534
 *       The Relaxed Datatype Model
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   535
 *       ==========================
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   536
 *       In the relaxed datatype model, the same rules as the strict datatype model are followed, with the
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   537
 *       exception of implicitly defined array datatypes, which are now considered equal if they define
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   538
 *       identical datatypes.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   539
 *       This means that in the following example
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   540
 *         TYPE 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   541
 *          array_t: ARRAY [1..3] OF INT; 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   542
 *         END_TYPE;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   543
 *         VAR
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   544
 *          array_var1: array_t; 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   545
 *          array_var2: ARRAY [1..3] OF INT; 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   546
 *          array_var3: ARRAY [1..3] OF INT; 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   547
 *         END_VAR
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   548
 * 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   549
 *       all three variables (array_var1, array_var2, and array_var3) are considered as being of the
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   550
 *       same datatype.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   551
 *      
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   552
 *       Note that the strict datatype model currently actually uses a relaxed datatype model for 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   553
 *       REF_TO datatypes, so in both the relaxed and strict datatype models matiec currently uses a 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   554
 *       relaxed datatype equivalince for REF_TO datatypes.
929
469de0f54b0e Add comments, and make get_datatype_id_str_c equivalent to get_datatype_id_c
mjsousa
parents: 922
diff changeset
   555
 */
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   556
bool get_datatype_info_c::is_type_equal(symbol_c *first_type, symbol_c *second_type) {
921
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   557
  if (!is_type_valid( first_type))                                   {return false;}
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   558
  if (!is_type_valid(second_type))                                   {return false;}
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   559
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   560
  /* GENERIC DATATYPES */
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   561
  /* For the moment, we only support the ANY generic datatype! */
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   562
  if ((is_ANY_generic_type( first_type)) ||
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   563
      (is_ANY_generic_type(second_type)))                            {return true;}
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   564
      
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   565
  /* ANY_ELEMENTARY */
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   566
  if ((is_ANY_ELEMENTARY_compatible(first_type)) &&
695
5760f1043ba4 Code formating only.
Mario de Sousa <msousa@fe.up.pt>
parents: 693
diff changeset
   567
      (typeid(*first_type) == typeid(*second_type)))                 {return true;}
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   568
  if (   is_ANY_ELEMENTARY_compatible(first_type) 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   569
      || is_ANY_ELEMENTARY_compatible(second_type))                  {return false;}  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   570
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   571
  /* ANY_DERIVED  */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   572
  // from now on, we are sure both datatypes are derived...
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   573
  if (is_ref_to(first_type) && is_ref_to(second_type)) {
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   574
    return is_type_equal(search_base_type_c::get_basetype_decl(get_ref_to(first_type )),
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   575
                         search_base_type_c::get_basetype_decl(get_ref_to(second_type)));
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   576
  }
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   577
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   578
    // check for same datatype
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
   579
  if (first_type == second_type)                                     {return true;}
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   580
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   581
    // remaining type equivalence rules are not applied in the strict datatype model
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
   582
  if (false == runtime_options.relaxed_datatype_model)               {return false;}
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   583
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   584
    // check for array equivalence usig the relaxed datatype model
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
   585
  if (is_arraytype_equal_relaxed(first_type, second_type))           {return true;}
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   586
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   587
  return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   588
}
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   589
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   590
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   591
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   592
/* A local helper function that transforms strings conatining signed_integers into a normalized
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   593
 * form, so they can be compared for equality.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   594
 *   examples:
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   595
 *     82  ->  82 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   596
 *     8_2 ->  82 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   597
 *    +82  ->  82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   598
 *    082  ->  82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   599
 *   +082  ->  82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   600
 *    -82  -> -82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   601
 *    -8_2 -> -82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   602
 *   -082  -> -82
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   603
 */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   604
#include <string.h>  /* required for strlen() */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   605
static std::string normalize_integer(symbol_c *symbol) {
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   606
  integer_c *token = dynamic_cast<integer_c *>(symbol);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   607
  if (NULL == token) ERROR;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   608
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   609
  std::string str = "";
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   610
  bool leading_zero = true;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   611
  unsigned int offset = 0;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   612
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   613
  // handle any possible leading '-' or '+'
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   614
  if        (token->value[0] == '-') {
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   615
      //    '-' -> retained
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   616
      str += token->value[0];
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   617
      offset++;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   618
  } else if (token->value[0] == '+')
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   619
      //    '+' -> skip, so '+8' and '8' will both result in '8'
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   620
      offset++;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   621
    
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   622
  for (unsigned int i = offset; i < strlen(token->value); i++) {
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   623
    if (leading_zero && (token->value[i] != '0'))
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   624
      leading_zero = false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   625
    if (!leading_zero && token->value[i] != '_')
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   626
      str += token->value[i];
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   627
  }
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   628
  return str;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   629
}
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   630
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   631
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   632
/* A helper method to get_datatype_info_c::is_type_equal()
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   633
 *  Assuming the relaxed datatype model, determine whether the two array datatypes are equal/equivalent
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   634
 */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   635
bool get_datatype_info_c::is_arraytype_equal_relaxed(symbol_c *first_type, symbol_c *second_type) {
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   636
  symbol_c *basetype_1 = search_base_type_c::get_basetype_decl( first_type);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   637
  symbol_c *basetype_2 = search_base_type_c::get_basetype_decl(second_type);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   638
  array_specification_c *array_1 = dynamic_cast<array_specification_c *>(basetype_1);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   639
  array_specification_c *array_2 = dynamic_cast<array_specification_c *>(basetype_2);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   640
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   641
  // are they both array datatypes? 
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   642
  if ((NULL == array_1) || (NULL == array_2))
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   643
    return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   644
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   645
  // number of subranges
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   646
  array_subrange_list_c *subrange_list_1 = dynamic_cast<array_subrange_list_c *>(array_1->array_subrange_list);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   647
  array_subrange_list_c *subrange_list_2 = dynamic_cast<array_subrange_list_c *>(array_2->array_subrange_list);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   648
  if ((NULL == subrange_list_1) || (NULL == subrange_list_2)) ERROR;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   649
  if (subrange_list_1->n != subrange_list_2->n)
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   650
    return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   651
  
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   652
  // comparison of each subrange start and end elements
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   653
  for (int i = 0; i < subrange_list_1->n; i++) {
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   654
    subrange_c *subrange_1 = dynamic_cast<subrange_c *>(subrange_list_1->elements[i]);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   655
    subrange_c *subrange_2 = dynamic_cast<subrange_c *>(subrange_list_2->elements[i]);
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   656
    if ((NULL == subrange_1) || (NULL == subrange_2)) ERROR;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   657
    #if 0
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   658
    /* An alternative method of checking whether the subranges have the same values, using the result of the constant folding agorithm.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   659
     * This method has the drawback that it inserts a dependency on having to run the constant folding algorithm before
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   660
     *  the get_datatype_info_c::is_type_equal() method is called.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   661
     * The probably slower alternative of comparing the strings themselves is therefor used.
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   662
     */
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   663
    if (!constant_folding_c::is_equal_cvalue(subrange_1->lower_limit, subrange_2->lower_limit)) return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   664
    if (!constant_folding_c::is_equal_cvalue(subrange_1->upper_limit, subrange_2->upper_limit)) return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   665
    #endif
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   666
    if (normalize_integer(subrange_1->lower_limit) != normalize_integer(subrange_2->lower_limit)) return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   667
    if (normalize_integer(subrange_1->upper_limit) != normalize_integer(subrange_2->upper_limit)) return false;
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   668
  }
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   669
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   670
  return is_type_equal(search_base_type_c::get_basetype_decl(array_1->non_generic_type_name),
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   671
                       search_base_type_c::get_basetype_decl(array_2->non_generic_type_name));
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   672
}
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   673
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   674
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 939
diff changeset
   675
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   677
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   678
bool get_datatype_info_c::is_type_valid(symbol_c *type) {
695
5760f1043ba4 Code formating only.
Mario de Sousa <msousa@fe.up.pt>
parents: 693
diff changeset
   679
  if (NULL == type)                                                  {return false;}
5760f1043ba4 Code formating only.
Mario de Sousa <msousa@fe.up.pt>
parents: 693
diff changeset
   680
  if (typeid(*type) == typeid(invalid_type_name_c))                  {return false;}
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   681
  return true;
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   682
}
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   683
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   684
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   685
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   686
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   687
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   688
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   689
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   690
/* returns the datatype the REF_TO datatype references/points to... */ 
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   691
symbol_c *get_datatype_info_c::get_ref_to(symbol_c *type_symbol) {
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   692
  ref_type_decl_c *type1 = dynamic_cast<ref_type_decl_c *>(type_symbol);
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   693
  if (NULL != type1) type_symbol = type1->ref_spec_init;
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   694
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   695
  ref_spec_init_c *type2 = dynamic_cast<ref_spec_init_c *>(type_symbol);
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   696
  if (NULL != type2) type_symbol = type2->ref_spec;
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   697
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   698
  ref_spec_c      *type3 = dynamic_cast<ref_spec_c      *>(type_symbol);
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   699
  if (NULL != type3) return type3->type_name;
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   700
  
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   701
  return NULL; /* this is not a ref datatype!! */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   702
}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   703
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   704
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   705
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   706
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   707
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   708
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   709
bool get_datatype_info_c::is_ref_to(symbol_c *type_symbol) {
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   710
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   711
  if (NULL == type_decl)                                                       {return false;}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   712
  
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   713
  if (typeid(*type_decl) == typeid(ref_type_decl_c))                           {return true;}   /* identifier ':' ref_spec_init */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   714
  if (typeid(*type_decl) == typeid(ref_spec_init_c))                           {return true;}   /* ref_spec [ ASSIGN ref_initialization ]; */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   715
  if (typeid(*type_decl) == typeid(ref_spec_c))                                {return true;}   /* REF_TO (non_generic_type_name | function_block_type_name) */
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   716
  return false;
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   717
}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   718
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   719
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   720
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 858
diff changeset
   721
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   722
bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   723
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   724
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   725
  if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   726
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   727
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   728
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   729
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   730
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   731
bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   732
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   733
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   734
  if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   735
  if (typeid(*type_decl) == typeid(        step_c))                  {return true;}   /*         STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   736
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   737
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   738
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   739
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   740
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   741
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   742
bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   743
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   744
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   745
  if (typeid(*type_decl) == typeid(function_block_declaration_c))    {return true;}   /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   746
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   747
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   748
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   749
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   750
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   751
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   752
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   753
bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) {
858
c5f145364a4f Fix get_datatype_info_c::is_subrange(), which did not work when using base type! (we now use get_equivtype() instead of get_base_type() )
mjsousa
parents: 832
diff changeset
   754
  symbol_c *type_decl = search_base_type_c::get_equivtype_decl(type_symbol); /* NOTE: do NOT call search_base_type_c !! */
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   755
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   756
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   757
  if (typeid(*type_decl) == typeid(subrange_type_declaration_c))     {return true;}   /*  subrange_type_name ':' subrange_spec_init */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   758
  if (typeid(*type_decl) == typeid(subrange_spec_init_c))            {return true;}   /* subrange_specification ASSIGN signed_integer */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   759
  if (typeid(*type_decl) == typeid(subrange_specification_c))        {return true;}   /*  integer_type_name '(' subrange')' */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   760
    
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   761
  if (typeid(*type_decl) == typeid(subrange_c))                      {ERROR;}         /*  signed_integer DOTDOT signed_integer */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   762
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   763
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   764
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   765
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   766
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   767
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   768
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   769
bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   770
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   771
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   772
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   773
  if (typeid(*type_decl) == typeid(enumerated_type_declaration_c))   {return true;}   /*  enumerated_type_name ':' enumerated_spec_init */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   774
  if (typeid(*type_decl) == typeid(enumerated_spec_init_c))          {return true;}   /* enumerated_specification ASSIGN enumerated_value */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   775
  if (typeid(*type_decl) == typeid(enumerated_value_list_c))         {return true;}   /* enumerated_value_list ',' enumerated_value */        /* once we change the way we handle enums, this will probably become an ERROR! */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   776
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   777
  if (typeid(*type_decl) == typeid(enumerated_value_c))              {ERROR;}         /* enumerated_type_name '#' identifier */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   778
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   779
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   780
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   781
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   782
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   783
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   784
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   785
bool get_datatype_info_c::is_array(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   786
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   787
  if (NULL == type_decl)                                             {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   788
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   789
  if (typeid(*type_decl) == typeid(array_type_declaration_c))        {return true;}   /*  identifier ':' array_spec_init */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   790
  if (typeid(*type_decl) == typeid(array_spec_init_c))               {return true;}   /* array_specification [ASSIGN array_initialization} */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   791
  if (typeid(*type_decl) == typeid(array_specification_c))           {return true;}   /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   792
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   793
  if (typeid(*type_decl) == typeid(array_subrange_list_c))           {ERROR;}         /* array_subrange_list ',' subrange */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   794
  if (typeid(*type_decl) == typeid(array_initial_elements_list_c))   {ERROR;}         /* array_initialization:  '[' array_initial_elements_list ']' */  /* array_initial_elements_list ',' array_initial_elements */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   795
  if (typeid(*type_decl) == typeid(array_initial_elements_c))        {ERROR;}         /* integer '(' [array_initial_element] ')' */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   796
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   797
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   798
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   799
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   800
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   801
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   802
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   803
bool get_datatype_info_c::is_structure(symbol_c *type_symbol) {
718
a9f8cc778444 Make search_base_type_c a singleton!
Mario de Sousa <msousa@fe.up.pt>
parents: 699
diff changeset
   804
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
832
8cd104e483c6 Allow get_datatype_info_c to be called with NULL parameters.
mjsousa
parents: 778
diff changeset
   805
  if (NULL == type_decl)                                                       {return false;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   806
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   807
  if (typeid(*type_decl) == typeid(structure_type_declaration_c))              {return true;}   /*  structure_type_name ':' structure_specification */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   808
  if (typeid(*type_decl) == typeid(initialized_structure_c))                   {return true;}   /* structure_type_name ASSIGN structure_initialization */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   809
  if (typeid(*type_decl) == typeid(structure_element_declaration_list_c))      {return true;}   /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */ /* structure_element_declaration_list structure_element_declaration ';' */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   810
  
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   811
  if (typeid(*type_decl) == typeid(structure_element_declaration_c))           {ERROR;}         /*  structure_element_name ':' *_spec_init */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   812
  if (typeid(*type_decl) == typeid(structure_element_initialization_list_c))   {ERROR;}         /* structure_initialization: '(' structure_element_initialization_list ')' */  /* structure_element_initialization_list ',' structure_element_initialization */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   813
  if (typeid(*type_decl) == typeid(structure_element_initialization_c))        {ERROR;}         /*  structure_element_name ASSIGN value */
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   814
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   815
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   816
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   817
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   818
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   819
921
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   820
bool get_datatype_info_c::is_ANY_generic_type(symbol_c *type_symbol) {
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   821
  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   822
  if (NULL == type_decl)                                             {return false;}  
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   823
  if (typeid(*type_decl) == typeid(generic_type_any_c))              {return true;}   /*  The ANY keyword! */
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   824
  return false;
d228aaa4d616 Introduce absyntax class for keyword ANY, and use REF_TO(ANY) as datatype of NULL literal.
mjsousa
parents: 919
diff changeset
   825
}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   826
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   827
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   828
bool get_datatype_info_c::is_ANY_ELEMENTARY(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   829
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   830
  if (is_ANY_MAGNITUDE(type_symbol))                           {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   831
  if (is_ANY_BIT      (type_symbol))                           {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   832
  if (is_ANY_STRING   (type_symbol))                           {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   833
  if (is_ANY_DATE     (type_symbol))                           {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   834
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   835
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   836
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   837
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   838
bool get_datatype_info_c::is_ANY_SAFEELEMENTARY(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   839
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   840
  if (is_ANY_SAFEMAGNITUDE(type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   841
  if (is_ANY_SAFEBIT      (type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   842
  if (is_ANY_SAFESTRING   (type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   843
  if (is_ANY_SAFEDATE     (type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   844
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   845
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   846
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   847
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   848
bool get_datatype_info_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   849
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   850
  if (is_ANY_ELEMENTARY    (type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   851
  if (is_ANY_SAFEELEMENTARY(type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   852
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   853
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   854
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   855
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   856
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   857
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   858
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   859
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   860
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   861
bool get_datatype_info_c::is_ANY_MAGNITUDE(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   862
  if (type_symbol == NULL)                                     {return false;}
668
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
   863
  if (is_TIME(type_symbol))                                    {return true;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   864
  if (is_ANY_NUM(type_symbol))                                 {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   865
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   866
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   867
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   868
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   869
bool get_datatype_info_c::is_ANY_SAFEMAGNITUDE(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   870
  if (type_symbol == NULL)                                     {return false;}
668
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
   871
  if (is_SAFETIME(type_symbol))                                {return true;}
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   872
  if (is_ANY_SAFENUM(type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   873
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   874
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   875
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   876
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   877
bool get_datatype_info_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   878
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   879
  if (is_ANY_MAGNITUDE    (type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   880
  if (is_ANY_SAFEMAGNITUDE(type_symbol))                       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   881
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   882
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   883
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   884
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   885
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   886
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   887
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   888
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   889
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   890
bool get_datatype_info_c::is_ANY_signed_MAGNITUDE(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   891
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   892
  if (typeid(*type_symbol) == typeid(time_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   893
  if (is_ANY_signed_NUM(type_symbol))                          {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   894
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   895
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   896
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   897
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   898
bool get_datatype_info_c::is_ANY_signed_SAFEMAGNITUDE(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   899
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   900
  if (typeid(*type_symbol) == typeid(safetime_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   901
  return is_ANY_signed_SAFENUM(type_symbol);
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   902
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   903
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   904
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   905
bool get_datatype_info_c::is_ANY_signed_MAGNITUDE_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   906
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   907
  if (is_ANY_signed_MAGNITUDE    (type_symbol))                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   908
  if (is_ANY_signed_SAFEMAGNITUDE(type_symbol))                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   909
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   910
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   911
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   912
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   913
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   914
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   915
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   916
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   917
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   918
bool get_datatype_info_c::is_ANY_NUM(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   919
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   920
  if (is_ANY_REAL(type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   921
  if (is_ANY_INT (type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   922
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   923
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   924
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   925
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   926
bool get_datatype_info_c::is_ANY_SAFENUM(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   927
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   928
  if (is_ANY_SAFEREAL(type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   929
  if (is_ANY_SAFEINT (type_symbol))                            {return true;}
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   930
  return false;
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   931
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   932
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   933
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   934
bool get_datatype_info_c::is_ANY_NUM_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   935
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   936
  if (is_ANY_NUM    (type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   937
  if (is_ANY_SAFENUM(type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   938
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   939
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   940
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   941
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   942
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   943
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   944
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   945
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   946
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   947
bool get_datatype_info_c::is_ANY_signed_NUM(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   948
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   949
  if (is_ANY_REAL      (type_symbol))                          {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   950
  if (is_ANY_signed_INT(type_symbol))                          {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   951
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   952
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   953
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   954
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   955
bool get_datatype_info_c::is_ANY_signed_SAFENUM(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   956
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   957
  if (is_ANY_SAFEREAL      (type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   958
  if (is_ANY_signed_SAFEINT(type_symbol))                      {return true;}
676
ca4f17211251 Move is_datatype_valid/equal() to get_datatype_info_c
Mario de Sousa <msousa@fe.up.pt>
parents: 668
diff changeset
   959
  return false;
666
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   960
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   961
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   962
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   963
bool get_datatype_info_c::is_ANY_signed_NUM_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   964
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   965
  if (is_ANY_signed_NUM    (type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   966
  if (is_ANY_signed_SAFENUM(type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   967
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   968
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   969
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   970
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   971
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   972
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   973
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   974
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   975
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   976
bool get_datatype_info_c::is_ANY_INT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   977
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   978
  if (is_ANY_signed_INT  (type_symbol))                        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   979
  if (is_ANY_unsigned_INT(type_symbol))                        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   980
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   981
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   982
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   983
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   984
bool get_datatype_info_c::is_ANY_SAFEINT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   985
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   986
  if (is_ANY_signed_SAFEINT  (type_symbol))                    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   987
  if (is_ANY_unsigned_SAFEINT(type_symbol))                    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   988
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   989
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   990
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   991
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   992
bool get_datatype_info_c::is_ANY_INT_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   993
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   994
  if (is_ANY_INT    (type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   995
  if (is_ANY_SAFEINT(type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   996
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   997
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   998
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   999
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1000
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1001
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1002
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1003
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1004
bool get_datatype_info_c::is_ANY_signed_INT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1005
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1006
  if (typeid(*type_symbol) == typeid(sint_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1007
  if (typeid(*type_symbol) == typeid(int_type_name_c))         {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1008
  if (typeid(*type_symbol) == typeid(dint_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1009
  if (typeid(*type_symbol) == typeid(lint_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1010
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1011
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1012
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1013
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1014
bool get_datatype_info_c::is_ANY_signed_SAFEINT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1015
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1016
  if (typeid(*type_symbol) == typeid(safesint_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1017
  if (typeid(*type_symbol) == typeid(safeint_type_name_c))     {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1018
  if (typeid(*type_symbol) == typeid(safedint_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1019
  if (typeid(*type_symbol) == typeid(safelint_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1020
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1021
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1022
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1023
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1024
bool get_datatype_info_c::is_ANY_signed_INT_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1025
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1026
  if (is_ANY_signed_INT    (type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1027
  if (is_ANY_signed_SAFEINT(type_symbol))                      {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1028
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1029
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1030
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1031
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1032
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1033
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1034
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1035
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1036
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1037
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1038
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1039
bool get_datatype_info_c::is_ANY_unsigned_INT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1040
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1041
  if (typeid(*type_symbol) == typeid(usint_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1042
  if (typeid(*type_symbol) == typeid(uint_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1043
  if (typeid(*type_symbol) == typeid(udint_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1044
  if (typeid(*type_symbol) == typeid(ulint_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1045
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1046
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1047
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1048
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1049
bool get_datatype_info_c::is_ANY_unsigned_SAFEINT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1050
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1051
  if (typeid(*type_symbol) == typeid(safeusint_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1052
  if (typeid(*type_symbol) == typeid(safeuint_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1053
  if (typeid(*type_symbol) == typeid(safeudint_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1054
  if (typeid(*type_symbol) == typeid(safeulint_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1055
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1056
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1057
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1058
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1059
bool get_datatype_info_c::is_ANY_unsigned_INT_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1060
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1061
  if (is_ANY_unsigned_INT    (type_symbol))                    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1062
  if (is_ANY_unsigned_SAFEINT(type_symbol))                    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1063
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1064
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1065
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1066
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1067
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1068
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1069
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1070
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1071
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1072
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1073
bool get_datatype_info_c::is_ANY_REAL(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1074
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1075
  if (typeid(*type_symbol) == typeid(real_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1076
  if (typeid(*type_symbol) == typeid(lreal_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1077
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1078
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1079
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1080
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1081
bool get_datatype_info_c::is_ANY_SAFEREAL(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1082
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1083
  if (typeid(*type_symbol) == typeid(safereal_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1084
  if (typeid(*type_symbol) == typeid(safelreal_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1085
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1086
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1087
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1088
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1089
bool get_datatype_info_c::is_ANY_REAL_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1090
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1091
  if (is_ANY_REAL    (type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1092
  if (is_ANY_SAFEREAL(type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1093
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1094
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1095
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1096
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1097
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1098
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1099
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1100
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1101
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1102
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1103
bool get_datatype_info_c::is_ANY_nBIT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1104
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1105
  if (typeid(*type_symbol) == typeid(byte_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1106
  if (typeid(*type_symbol) == typeid(word_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1107
  if (typeid(*type_symbol) == typeid(dword_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1108
  if (typeid(*type_symbol) == typeid(lword_type_name_c))       {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1109
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1110
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1111
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1112
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1113
bool get_datatype_info_c::is_ANY_SAFEnBIT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1114
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1115
  if (typeid(*type_symbol) == typeid(safebyte_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1116
  if (typeid(*type_symbol) == typeid(safeword_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1117
  if (typeid(*type_symbol) == typeid(safedword_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1118
  if (typeid(*type_symbol) == typeid(safelword_type_name_c))   {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1119
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1120
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1121
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1122
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1123
bool get_datatype_info_c::is_ANY_nBIT_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1124
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1125
  if (is_ANY_nBIT    (type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1126
  if (is_ANY_SAFEnBIT(type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1127
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1128
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1129
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1130
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1131
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1132
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1133
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1134
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1135
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1136
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1137
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1138
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1139
bool get_datatype_info_c::is_BOOL(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1140
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1141
  if (typeid(*type_symbol) == typeid(bool_type_name_c))        {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1142
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1143
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1144
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1145
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1146
bool get_datatype_info_c::is_SAFEBOOL(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1147
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1148
  if (typeid(*type_symbol) == typeid(safebool_type_name_c))    {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1149
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1150
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1151
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1152
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1153
bool get_datatype_info_c::is_BOOL_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1154
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1155
  if (is_BOOL    (type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1156
  if (is_SAFEBOOL(type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1157
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1158
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1159
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1160
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1161
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1162
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1163
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1164
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1165
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1166
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1167
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1168
bool get_datatype_info_c::is_ANY_BIT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1169
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1170
  if (is_BOOL    (type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1171
  if (is_ANY_nBIT(type_symbol))                                {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1172
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1173
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1174
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1175
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1176
bool get_datatype_info_c::is_ANY_SAFEBIT(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1177
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1178
  if (is_SAFEBOOL    (type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1179
  if (is_ANY_SAFEnBIT(type_symbol))                            {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1180
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1181
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1182
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1183
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1184
bool get_datatype_info_c::is_ANY_BIT_compatible(symbol_c *type_symbol) {
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1185
  if (type_symbol == NULL)                                     {return false;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1186
  if (is_ANY_BIT    (type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1187
  if (is_ANY_SAFEBIT(type_symbol))                             {return true;}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1188
  return false;
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1189
}
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1190
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1191
8ba9ec4bae50 Add new get_datatype_info_c (preparing to remove search_expression_type_c)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
  1192
668
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1193
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1194
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1195
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1196
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1197
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1198
bool get_datatype_info_c::is_TIME(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1199
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1200
  if (typeid(*type_symbol) == typeid(time_type_name_c))        {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1201
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1202
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1203
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1204
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1205
bool get_datatype_info_c::is_SAFETIME(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1206
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1207
  if (typeid(*type_symbol) == typeid(safetime_type_name_c))    {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1208
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1209
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1210
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1211
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1212
bool get_datatype_info_c::is_TIME_compatible(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1213
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1214
  if (is_TIME    (type_symbol))                                {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1215
  if (is_SAFETIME(type_symbol))                                {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1216
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1217
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1218
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1219
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1220
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1221
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1222
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1223
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1224
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1225
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1226
bool get_datatype_info_c::is_ANY_DATE(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1227
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1228
  if (typeid(*type_symbol) == typeid(date_type_name_c))        {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1229
  if (typeid(*type_symbol) == typeid(tod_type_name_c))         {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1230
  if (typeid(*type_symbol) == typeid(dt_type_name_c))          {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1231
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1232
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1233
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1234
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1235
bool get_datatype_info_c::is_ANY_SAFEDATE(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1236
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1237
  if (typeid(*type_symbol) == typeid(safedate_type_name_c))    {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1238
  if (typeid(*type_symbol) == typeid(safetod_type_name_c))     {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1239
  if (typeid(*type_symbol) == typeid(safedt_type_name_c))      {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1240
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1241
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1242
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1243
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1244
bool get_datatype_info_c::is_ANY_DATE_compatible(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1245
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1246
  if (is_ANY_DATE    (type_symbol))                            {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1247
  if (is_ANY_SAFEDATE(type_symbol))                            {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1248
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1249
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1250
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1251
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1252
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1253
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1254
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1255
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1256
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1257
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1258
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1259
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1260
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1261
bool get_datatype_info_c::is_ANY_STRING(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1262
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1263
  if (typeid(*type_symbol) == typeid(string_type_name_c))      {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1264
  if (typeid(*type_symbol) == typeid(wstring_type_name_c))     {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1265
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1266
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1267
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1268
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1269
bool get_datatype_info_c::is_ANY_SAFESTRING(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1270
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1271
  if (typeid(*type_symbol) == typeid(safestring_type_name_c))  {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1272
  if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1273
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1274
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1275
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1276
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1277
bool get_datatype_info_c::is_ANY_STRING_compatible(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1278
  if (type_symbol == NULL)                                     {return false;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1279
  if (is_ANY_STRING    (type_symbol))                          {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1280
  if (is_ANY_SAFESTRING(type_symbol))                          {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1281
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1282
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1283
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1284
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1285
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1286
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1287
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1288
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1289
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1290
/* Can't we do away with this?? */
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1291
bool get_datatype_info_c::is_ANY_REAL_literal(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1292
  if (type_symbol == NULL)                              {return true;} /* Please make sure things will work correctly before changing this to false!! */
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1293
  if (typeid(*type_symbol) == typeid(real_c))           {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1294
  if (typeid(*type_symbol) == typeid(neg_real_c))       {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1295
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1296
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1297
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1298
/* Can't we do away with this?? */
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1299
bool get_datatype_info_c::is_ANY_INT_literal(symbol_c *type_symbol) {
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1300
  if (type_symbol == NULL)                              {return true;} /* Please make sure things will work correctly before changing this to false!! */
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1301
  if (typeid(*type_symbol) == typeid(integer_c))        {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1302
  if (typeid(*type_symbol) == typeid(neg_integer_c))    {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1303
  if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1304
  if (typeid(*type_symbol) == typeid(octal_integer_c))  {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1305
  if (typeid(*type_symbol) == typeid(hex_integer_c))    {return true;}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1306
  return false;
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1307
}
90b6eb7f1775 Deprecating use of search_expression_type_c, so it may later be deleted!
Mario de Sousa <msousa@fe.up.pt>
parents: 666
diff changeset
  1308
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: 676
diff changeset
  1309
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: 676
diff changeset
  1310
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: 676
diff changeset
  1311
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: 676
diff changeset
  1312
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: 676
diff changeset
  1313
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: 676
diff changeset
  1314
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: 676
diff changeset
  1315
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: 676
diff changeset
  1316
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: 676
diff changeset
  1317
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: 676
diff changeset
  1318
invalid_type_name_c      get_datatype_info_c::invalid_type_name;
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: 676
diff changeset
  1319
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: 676
diff changeset
  1320
/**********************/
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: 676
diff changeset
  1321
/* B.1.3 - Data types */
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: 676
diff changeset
  1322
/**********************/
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: 676
diff changeset
  1323
/***********************************/
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: 676
diff changeset
  1324
/* B 1.3.1 - Elementary Data Types */
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: 676
diff changeset
  1325
/***********************************/
699
0307fa16db3f Fix typo.
Mario de Sousa <msousa@fe.up.pt>
parents: 695
diff changeset
  1326
lreal_type_name_c        get_datatype_info_c::lreal_type_name;
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: 676
diff changeset
  1327
real_type_name_c         get_datatype_info_c::real_type_name;
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: 676
diff changeset
  1328
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: 676
diff changeset
  1329
lint_type_name_c         get_datatype_info_c::lint_type_name;
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: 676
diff changeset
  1330
dint_type_name_c         get_datatype_info_c::dint_type_name;
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: 676
diff changeset
  1331
int_type_name_c          get_datatype_info_c::int_type_name;
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: 676
diff changeset
  1332
sint_type_name_c         get_datatype_info_c::sint_type_name;
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: 676
diff changeset
  1333
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: 676
diff changeset
  1334
ulint_type_name_c        get_datatype_info_c::ulint_type_name;
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: 676
diff changeset
  1335
udint_type_name_c        get_datatype_info_c::udint_type_name;
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: 676
diff changeset
  1336
uint_type_name_c         get_datatype_info_c::uint_type_name;
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: 676
diff changeset
  1337
usint_type_name_c        get_datatype_info_c::usint_type_name;
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: 676
diff changeset
  1338
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: 676
diff changeset
  1339
lword_type_name_c        get_datatype_info_c::lword_type_name;
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: 676
diff changeset
  1340
dword_type_name_c        get_datatype_info_c::dword_type_name;
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: 676
diff changeset
  1341
word_type_name_c         get_datatype_info_c::word_type_name;
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: 676
diff changeset
  1342
byte_type_name_c         get_datatype_info_c::byte_type_name;
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: 676
diff changeset
  1343
bool_type_name_c         get_datatype_info_c::bool_type_name;
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: 676
diff changeset
  1344
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: 676
diff changeset
  1345
wstring_type_name_c      get_datatype_info_c::wstring_type_name;
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: 676
diff changeset
  1346
string_type_name_c       get_datatype_info_c::string_type_name;
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: 676
diff changeset
  1347
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: 676
diff changeset
  1348
dt_type_name_c           get_datatype_info_c::dt_type_name;
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: 676
diff changeset
  1349
date_type_name_c         get_datatype_info_c::date_type_name;
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: 676
diff changeset
  1350
tod_type_name_c          get_datatype_info_c::tod_type_name;
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: 676
diff changeset
  1351
time_type_name_c         get_datatype_info_c::time_type_name;
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: 676
diff changeset
  1352
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: 676
diff changeset
  1353
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: 676
diff changeset
  1354
/******************************************************/
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: 676
diff changeset
  1355
/* Extensions to the base standard as defined in      */
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: 676
diff changeset
  1356
/* "Safety Software Technical Specification,          */
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: 676
diff changeset
  1357
/*  Part 1: Concepts and Function Blocks,             */
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: 676
diff changeset
  1358
/*  Version 1.0 – Official Release"                   */
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: 676
diff changeset
  1359
/* by PLCopen - Technical Committee 5 - 2006-01-31    */
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: 676
diff changeset
  1360
/******************************************************/  
699
0307fa16db3f Fix typo.
Mario de Sousa <msousa@fe.up.pt>
parents: 695
diff changeset
  1361
safelreal_type_name_c    get_datatype_info_c::safelreal_type_name;
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: 676
diff changeset
  1362
safereal_type_name_c     get_datatype_info_c::safereal_type_name;
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: 676
diff changeset
  1363
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: 676
diff changeset
  1364
safelint_type_name_c     get_datatype_info_c::safelint_type_name;
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: 676
diff changeset
  1365
safedint_type_name_c     get_datatype_info_c::safedint_type_name;
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: 676
diff changeset
  1366
safeint_type_name_c      get_datatype_info_c::safeint_type_name;
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: 676
diff changeset
  1367
safesint_type_name_c     get_datatype_info_c::safesint_type_name;
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: 676
diff changeset
  1368
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: 676
diff changeset
  1369
safeulint_type_name_c    get_datatype_info_c::safeulint_type_name;
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: 676
diff changeset
  1370
safeudint_type_name_c    get_datatype_info_c::safeudint_type_name;
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: 676
diff changeset
  1371
safeuint_type_name_c     get_datatype_info_c::safeuint_type_name;
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: 676
diff changeset
  1372
safeusint_type_name_c    get_datatype_info_c::safeusint_type_name;
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: 676
diff changeset
  1373
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: 676
diff changeset
  1374
safelword_type_name_c    get_datatype_info_c::safelword_type_name;
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: 676
diff changeset
  1375
safedword_type_name_c    get_datatype_info_c::safedword_type_name;
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: 676
diff changeset
  1376
safeword_type_name_c     get_datatype_info_c::safeword_type_name;
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: 676
diff changeset
  1377
safebyte_type_name_c     get_datatype_info_c::safebyte_type_name;
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: 676
diff changeset
  1378
safebool_type_name_c     get_datatype_info_c::safebool_type_name;
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: 676
diff changeset
  1379
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: 676
diff changeset
  1380
safewstring_type_name_c  get_datatype_info_c::safewstring_type_name;
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: 676
diff changeset
  1381
safestring_type_name_c   get_datatype_info_c::safestring_type_name;
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: 676
diff changeset
  1382
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: 676
diff changeset
  1383
safedt_type_name_c       get_datatype_info_c::safedt_type_name;
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: 676
diff changeset
  1384
safedate_type_name_c     get_datatype_info_c::safedate_type_name;
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: 676
diff changeset
  1385
safetod_type_name_c      get_datatype_info_c::safetod_type_name;
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: 676
diff changeset
  1386
safetime_type_name_c     get_datatype_info_c::safetime_type_name;
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: 676
diff changeset
  1387
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: 676
diff changeset
  1388
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: 676
diff changeset
  1389
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: 676
diff changeset
  1390
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: 676
diff changeset
  1391