absyntax_utils/get_datatype_info.hh
changeset 666 8ba9ec4bae50
child 668 90b6eb7f1775
equal deleted inserted replaced
665:50fca2d3abd9 666:8ba9ec4bae50
       
     1 /*
       
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
       
     3  *
       
     4  *  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
       
     5  *
       
     6  *  This program is free software: you can redistribute it and/or modify
       
     7  *  it under the terms of the GNU General Public License as published by
       
     8  *  the Free Software Foundation, either version 3 of the License, or
       
     9  *  (at your option) any later version.
       
    10  *
       
    11  *  This program is distributed in the hope that it will be useful,
       
    12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    14  *  GNU General Public License for more details.
       
    15  *
       
    16  *  You should have received a copy of the GNU General Public License
       
    17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    18  *
       
    19  *
       
    20  * This code is made available on the understanding that it will not be
       
    21  * used in safety-critical situations without a full and competent review.
       
    22  */
       
    23 
       
    24 /*
       
    25  * An IEC 61131-3 compiler.
       
    26  *
       
    27  * Based on the
       
    28  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    29  *
       
    30  */
       
    31 
       
    32 /* Determine the characteristics of a specific data type
       
    33  *  e.g., is it an enumeration, is it an array, is it ANY_INT, etc...
       
    34  *
       
    35  * The methods of this class may be passed either:
       
    36  *  - a data type declaration symbol_c, 
       
    37  *   OR
       
    38  *  - the name of a data type (identifier_c)
       
    39  *    In this case, we shall first serach for the basetype declaration using search_base_type_c, and then 
       
    40  *    run the normal process.
       
    41  */
       
    42 #include "absyntax_utils.hh"
       
    43 
       
    44 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
       
    45 
       
    46 
       
    47 
       
    48 
       
    49 
       
    50 
       
    51 class get_datatype_info_c { 
       
    52 
       
    53 
       
    54   private: // this is a purely static class. No need for constructors!
       
    55      get_datatype_info_c(void) {};
       
    56     ~get_datatype_info_c(void) {};
       
    57 
       
    58  
       
    59   public:
       
    60     static bool is_sfc_initstep                    (symbol_c *type_symbol);
       
    61     static bool is_sfc_step                        (symbol_c *type_symbol);
       
    62     static bool is_function_block                  (symbol_c *type_symbol);
       
    63     static bool is_subrange                        (symbol_c *type_symbol);
       
    64     static bool is_enumerated                      (symbol_c *type_symbol);
       
    65     static bool is_array                           (symbol_c *type_symbol);
       
    66     static bool is_structure                       (symbol_c *type_symbol);
       
    67 
       
    68   
       
    69   
       
    70     static bool is_ANY_ELEMENTARY                  (symbol_c *type_symbol);
       
    71     static bool is_ANY_SAFEELEMENTARY              (symbol_c *type_symbol);
       
    72     static bool is_ANY_ELEMENTARY_compatible       (symbol_c *type_symbol);
       
    73 
       
    74     static bool is_ANY_MAGNITUDE                   (symbol_c *type_symbol);
       
    75     static bool is_ANY_SAFEMAGNITUDE               (symbol_c *type_symbol);
       
    76     static bool is_ANY_MAGNITUDE_compatible        (symbol_c *type_symbol);
       
    77 
       
    78     static bool is_ANY_signed_MAGNITUDE            (symbol_c *type_symbol);
       
    79     static bool is_ANY_signed_SAFEMAGNITUDE        (symbol_c *type_symbol);
       
    80     static bool is_ANY_signed_MAGNITUDE_compatible (symbol_c *type_symbol);
       
    81 
       
    82     static bool is_ANY_NUM                         (symbol_c *type_symbol);
       
    83     static bool is_ANY_SAFENUM                     (symbol_c *type_symbol);
       
    84     static bool is_ANY_NUM_compatible              (symbol_c *type_symbol);
       
    85 
       
    86     static bool is_ANY_signed_NUM                  (symbol_c *type_symbol);
       
    87     static bool is_ANY_signed_SAFENUM              (symbol_c *type_symbol);
       
    88     static bool is_ANY_signed_NUM_compatible       (symbol_c *type_symbol);
       
    89 
       
    90     static bool is_ANY_DATE                        (symbol_c *type_symbol);
       
    91     static bool is_ANY_SAFEDATE                    (symbol_c *type_symbol);
       
    92     static bool is_ANY_DATE_compatible             (symbol_c *type_symbol);
       
    93 
       
    94     static bool is_ANY_STRING                      (symbol_c *type_symbol);
       
    95     static bool is_ANY_SAFESTRING                  (symbol_c *type_symbol);
       
    96     static bool is_ANY_STRING_compatible           (symbol_c *type_symbol);
       
    97 
       
    98     static bool is_ANY_INT                         (symbol_c *type_symbol);
       
    99     static bool is_ANY_SAFEINT                     (symbol_c *type_symbol);
       
   100     static bool is_ANY_INT_compatible              (symbol_c *type_symbol);
       
   101 
       
   102     static bool is_ANY_signed_INT                  (symbol_c *type_symbol);
       
   103     static bool is_ANY_signed_SAFEINT              (symbol_c *type_symbol);
       
   104     static bool is_ANY_signed_INT_compatible       (symbol_c *type_symbol);
       
   105 
       
   106     static bool is_ANY_unsigned_INT                (symbol_c *type_symbol);
       
   107     static bool is_ANY_unsigned_SAFEINT            (symbol_c *type_symbol);
       
   108     static bool is_ANY_unsigned_INT_compatible     (symbol_c *type_symbol);
       
   109 
       
   110     static bool is_ANY_REAL                        (symbol_c *type_symbol);
       
   111     static bool is_ANY_SAFEREAL                    (symbol_c *type_symbol);
       
   112     static bool is_ANY_REAL_compatible             (symbol_c *type_symbol);
       
   113 
       
   114     static bool is_ANY_nBIT                        (symbol_c *type_symbol);
       
   115     static bool is_ANY_SAFEnBIT                    (symbol_c *type_symbol);
       
   116     static bool is_ANY_nBIT_compatible             (symbol_c *type_symbol);
       
   117 
       
   118     static bool is_BOOL                            (symbol_c *type_symbol);
       
   119     static bool is_SAFEBOOL                        (symbol_c *type_symbol);
       
   120     static bool is_BOOL_compatible                 (symbol_c *type_symbol);
       
   121 
       
   122     static bool is_ANY_BIT                         (symbol_c *type_symbol);
       
   123     static bool is_ANY_SAFEBIT                     (symbol_c *type_symbol);
       
   124     static bool is_ANY_BIT_compatible              (symbol_c *type_symbol);
       
   125 };
       
   126