stage4/generate_c/search_fb_typedecl.cc
changeset 181 38d6eb056260
parent 180 64334c5a00b1
child 182 231633d1d2e4
equal deleted inserted replaced
180:64334c5a00b1 181:38d6eb056260
     1 /*
       
     2  * (c) 2003 Mario de Sousa
       
     3  *
       
     4  * Offered to the public under the terms of the GNU General Public License
       
     5  * as published by the Free Software Foundation; either version 2 of the
       
     6  * License, or (at your option) any later version.
       
     7  *
       
     8  * This program is distributed in the hope that it will be useful, but
       
     9  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
       
    11  * Public License for more details.
       
    12  *
       
    13  * This code is made available on the understanding that it will not be
       
    14  * used in safety-critical situations without a full and competent review.
       
    15  */
       
    16 
       
    17 /*
       
    18  * An IEC 61131-3 IL and ST compiler.
       
    19  *
       
    20  * Based on the
       
    21  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    22  *
       
    23  */
       
    24 
       
    25 
       
    26 /* Returns the function block declaration symbol
       
    27  * of a specific function block type.
       
    28  */
       
    29 
       
    30 class search_fb_typedecl_c: public search_visitor_c {
       
    31   
       
    32   private:
       
    33     symbol_c *search_scope;
       
    34 
       
    35     symbol_c *search_name;
       
    36     
       
    37   public:
       
    38     search_fb_typedecl_c(symbol_c *search_scope) {
       
    39       this->search_scope = search_scope;
       
    40     }
       
    41     
       
    42       symbol_c *get_decl(symbol_c *fb_type_name) {
       
    43       this->search_name = fb_type_name;
       
    44       return (symbol_c *)search_scope->accept(*this);
       
    45     }
       
    46 
       
    47   public:
       
    48 /**************************************/
       
    49 /* B.1.5 - Program organization units */
       
    50 /**************************************/
       
    51 
       
    52 /*****************************/
       
    53 /* B 1.5.2 - Function Blocks */
       
    54 /*****************************/
       
    55     void *visit(function_block_declaration_c *symbol) {
       
    56       if (compare_identifiers(symbol->fblock_name, search_name) == 0)
       
    57         return symbol;
       
    58       return NULL;
       
    59     }
       
    60 
       
    61 /**********************/
       
    62 /* B 1.5.3 - Programs */
       
    63 /**********************/
       
    64     void *visit(program_declaration_c *symbol) {
       
    65       if (compare_identifiers(symbol->program_type_name, search_name) == 0)
       
    66         return symbol;
       
    67       return NULL;
       
    68     }
       
    69 };
       
    70 
       
    71 
       
    72 
       
    73