stage3/array_range_check.hh
changeset 625 c0bda77b37a0
parent 598 0b1ee7e7123b
child 664 199a9f84e64c
equal deleted inserted replaced
412:aad38592bdde 625:c0bda77b37a0
       
     1 /*
       
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
       
     3  *
       
     4  *  Copyright (C) 2009-2012  Mario de Sousa (msousa@fe.up.pt)
       
     5  *  Copyright (C) 2012       Manuele Conti  (conti.ma@alice.it)
       
     6  *
       
     7  *
       
     8  *  This program is free software: you can redistribute it and/or modify
       
     9  *  it under the terms of the GNU General Public License as published by
       
    10  *  the Free Software Foundation, either version 3 of the License, or
       
    11  *  (at your option) any later version.
       
    12  *
       
    13  *  This program is distributed in the hope that it will be useful,
       
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16  *  GNU General Public License for more details.
       
    17  *
       
    18  *  You should have received a copy of the GNU General Public License
       
    19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    20  *
       
    21  *
       
    22  * This code is made available on the understanding that it will not be
       
    23  * used in safety-critical situations without a full and competent review.
       
    24  */
       
    25 
       
    26 /*
       
    27  * An IEC 61131-3 compiler.
       
    28  *
       
    29  * Based on the
       
    30  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    31  *
       
    32  */
       
    33 
       
    34 // #include <vector>
       
    35 #include "../absyntax_utils/absyntax_utils.hh"
       
    36 // #include "datatype_functions.hh"
       
    37 
       
    38 
       
    39 
       
    40 class array_range_check_c: public iterator_visitor_c {
       
    41 
       
    42   private:
       
    43     search_varfb_instance_type_c *search_varfb_instance_type;
       
    44     // search_var_instance_decl_c *search_var_instance_decl;
       
    45     search_base_type_c search_base_type;
       
    46     int error_count;
       
    47     int current_display_error_level;
       
    48 
       
    49     void check_dimension_count(array_variable_c *symbol);
       
    50     void check_bounds(array_variable_c *symbol);
       
    51 
       
    52   public:
       
    53     array_range_check_c(symbol_c *ignore);
       
    54     virtual ~array_range_check_c(void);
       
    55     int get_error_count();
       
    56 
       
    57     /*************************/
       
    58     /* B.1 - Common elements */
       
    59     /*************************/
       
    60     /**********************/
       
    61     /* B.1.3 - Data types */
       
    62     /**********************/
       
    63     /********************************/
       
    64     /* B 1.3.3 - Derived data types */
       
    65     /********************************/
       
    66     /* NOTE: we may later want to move the following 2 methods to a visitor that will focus on analysing the data type declarations! */
       
    67     void *visit(subrange_c *symbol);
       
    68     void *visit(array_initial_elements_c *symbol);
       
    69   
       
    70     /*********************/
       
    71     /* B 1.4 - Variables */
       
    72     /*********************/
       
    73     /*************************************/
       
    74     /* B 1.4.2 - Multi-element variables */
       
    75     /*************************************/
       
    76     void *visit(array_variable_c *symbol);
       
    77 
       
    78     /**************************************/
       
    79     /* B 1.5 - Program organisation units */
       
    80     /**************************************/
       
    81     /***********************/
       
    82     /* B 1.5.1 - Functions */
       
    83     /***********************/
       
    84     void *visit(function_declaration_c *symbol);
       
    85 
       
    86     /*****************************/
       
    87     /* B 1.5.2 - Function blocks */
       
    88     /*****************************/
       
    89     void *visit(function_block_declaration_c *symbol);
       
    90 
       
    91     /**********************/
       
    92     /* B 1.5.3 - Programs */
       
    93     /**********************/
       
    94     void *visit(program_declaration_c *symbol);
       
    95 
       
    96 }; /* array_range_check_c */
       
    97 
       
    98 
       
    99 
       
   100 
       
   101 
       
   102 
       
   103