stage3/flow_control_analysis.hh
changeset 443 ff4d26b7e51d
child 452 79ac274d1cc4
equal deleted inserted replaced
442:bd5998ee8876 443:ff4d26b7e51d
       
     1 /*
       
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
       
     3  *
       
     4  *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
       
     5  *
       
     6  *
       
     7  *  This program is free software: you can redistribute it and/or modify
       
     8  *  it under the terms of the GNU General Public License as published by
       
     9  *  the Free Software Foundation, either version 3 of the License, or
       
    10  *  (at your option) any later version.
       
    11  *
       
    12  *  This program is distributed in the hope that it will be useful,
       
    13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15  *  GNU General Public License for more details.
       
    16  *
       
    17  *  You should have received a copy of the GNU General Public License
       
    18  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    19  *
       
    20  *
       
    21  * This code is made available on the understanding that it will not be
       
    22  * used in safety-critical situations without a full and competent review.
       
    23  */
       
    24 
       
    25 /*
       
    26  * An IEC 61131-3 compiler.
       
    27  *
       
    28  * Based on the
       
    29  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    30  *
       
    31  */
       
    32 
       
    33 
       
    34 /*
       
    35  *  Do flow control analysis of the IEC 61131-3 code.
       
    36  *
       
    37  *  We currently only do this for IL code.
       
    38  *  This class will annotate the abstract syntax tree, by filling in the
       
    39  *  prev_il_instruction variable in the il_instruction_c, so it points to
       
    40  *  the previous il_instruction_c object in the instruction list instruction_list_c.
       
    41  */
       
    42 
       
    43 
       
    44 
       
    45 #include "../absyntax_utils/absyntax_utils.hh"
       
    46 
       
    47 
       
    48 class flow_control_analysis_c: public iterator_visitor_c {
       
    49 
       
    50   private:
       
    51     search_varfb_instance_type_c *search_varfb_instance_type;
       
    52     symbol_c *prev_il_instruction;
       
    53 
       
    54   public:
       
    55     flow_control_analysis_c(symbol_c *ignore);
       
    56     virtual ~flow_control_analysis_c(void);
       
    57 
       
    58     /**************************************/
       
    59     /* B 1.5 - Program organization units */
       
    60     /**************************************/
       
    61     /***********************/
       
    62     /* B 1.5.1 - Functions */
       
    63     /***********************/
       
    64     void *visit(function_declaration_c *symbol);
       
    65 
       
    66     /*****************************/
       
    67     /* B 1.5.2 - Function blocks */
       
    68     /*****************************/
       
    69     void *visit(function_block_declaration_c *symbol);
       
    70 
       
    71     /**********************/
       
    72     /* B 1.5.3 - Programs */
       
    73     /**********************/
       
    74     void *visit(program_declaration_c *symbol);
       
    75 
       
    76     /********************************/
       
    77     /* B 1.7 Configuration elements */
       
    78     /********************************/
       
    79     void *visit(configuration_declaration_c *symbol);
       
    80     
       
    81     /****************************************/
       
    82     /* B.2 - Language IL (Instruction List) */
       
    83     /****************************************/
       
    84     /***********************************/
       
    85     /* B 2.1 Instructions and Operands */
       
    86     /***********************************/
       
    87     void *visit(instruction_list_c *symbol);
       
    88     void *visit(il_instruction_c *symbol);
       
    89 //     void *visit(il_simple_operation_c *symbol);
       
    90 //     void *visit(il_function_call_c *symbol);
       
    91 //     void *visit(il_expression_c *symbol);
       
    92 //     void *visit(il_fb_call_c *symbol);
       
    93 //     void *visit(il_formal_funct_call_c *symbol);
       
    94     /*
       
    95         void *visit(il_operand_list_c *symbol);
       
    96         void *visit(simple_instr_list_c *symbol);
       
    97         void *visit(il_param_list_c *symbol);
       
    98         void *visit(il_param_assignment_c *symbol);
       
    99         void *visit(il_param_out_assignment_c *symbol);
       
   100      */
       
   101 
       
   102     /*******************/
       
   103     /* B 2.2 Operators */
       
   104     /*******************/
       
   105     /*
       
   106     void *visit(LD_operator_c *symbol);
       
   107     void *visit(LDN_operator_c *symbol);
       
   108     void *visit(ST_operator_c *symbol);
       
   109     void *visit(STN_operator_c *symbol);
       
   110     void *visit(NOT_operator_c *symbol);
       
   111     void *visit(S_operator_c *symbol);
       
   112     void *visit(R_operator_c *symbol);
       
   113     void *visit(S1_operator_c *symbol);
       
   114     void *visit(R1_operator_c *symbol);
       
   115     void *visit(CLK_operator_c *symbol);
       
   116     void *visit(CU_operator_c *symbol);
       
   117     void *visit(CD_operator_c *symbol);
       
   118     void *visit(PV_operator_c *symbol);
       
   119     void *visit(IN_operator_c *symbol);
       
   120     void *visit(PT_operator_c *symbol);
       
   121     void *visit(AND_operator_c *symbol);
       
   122     void *visit(OR_operator_c *symbol);
       
   123     void *visit(XOR_operator_c *symbol);
       
   124     void *visit(ANDN_operator_c *symbol);
       
   125     void *visit(ORN_operator_c *symbol);
       
   126     void *visit(XORN_operator_c *symbol);
       
   127     void *visit(ADD_operator_c *symbol);
       
   128     void *visit(SUB_operator_c *symbol);
       
   129     void *visit(MUL_operator_c *symbol);
       
   130     void *visit(DIV_operator_c *symbol);
       
   131     void *visit(MOD_operator_c *symbol);
       
   132     void *visit(GT_operator_c *symbol);
       
   133     void *visit(GE_operator_c *symbol);
       
   134     void *visit(EQ_operator_c *symbol);
       
   135     void *visit(LT_operator_c *symbol);
       
   136     void *visit(LE_operator_c *symbol);
       
   137     void *visit(NE_operator_c *symbol);
       
   138     void *visit(CAL_operator_c *symbol);
       
   139     void *visit(CALC_operator_c *symbol);
       
   140     void *visit(CALCN_operator_c *symbol);
       
   141     void *visit(RET_operator_c *symbol);
       
   142     void *visit(RETC_operator_c *symbol);
       
   143     void *visit(RETCN_operator_c *symbol);
       
   144     void *visit(JMP_operator_c *symbol);
       
   145     void *visit(JMPC_operator_c *symbol);
       
   146     void *visit(JMPCN_operator_c *symbol);
       
   147     */
       
   148     /* Symbol class handled together with function call checks */
       
   149     // void *visit(il_assign_operator_c *symbol, variable_name);
       
   150     /* Symbol class handled together with function call checks */
       
   151     // void *visit(il_assign_operator_c *symbol, option, variable_name);
       
   152 
       
   153 }; // flow_control_analysis_c
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159 
       
   160 
       
   161