lbessard@111: /* lbessard@111: * (c) 2003 Mario de Sousa lbessard@111: * lbessard@111: * Offered to the public under the terms of the GNU General Public License lbessard@111: * as published by the Free Software Foundation; either version 2 of the lbessard@111: * License, or (at your option) any later version. lbessard@111: * lbessard@111: * This program is distributed in the hope that it will be useful, but lbessard@111: * WITHOUT ANY WARRANTY; without even the implied warranty of lbessard@111: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General lbessard@111: * Public License for more details. lbessard@111: * lbessard@111: * This code is made available on the understanding that it will not be lbessard@111: * used in safety-critical situations without a full and competent review. lbessard@111: */ lbessard@111: lbessard@111: /* lbessard@111: * An IEC 61131-3 IL and ST compiler. lbessard@111: * lbessard@111: * Based on the lbessard@111: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) lbessard@111: * lbessard@111: */ lbessard@111: lbessard@111: lbessard@111: /* Returns the function block declaration symbol lbessard@111: * of a specific function block type. lbessard@111: */ lbessard@111: lbessard@111: class search_fb_typedecl_c: public search_visitor_c { lbessard@111: lbessard@111: private: lbessard@111: symbol_c *search_scope; lbessard@111: lbessard@111: symbol_c *search_name; lbessard@111: lbessard@111: public: lbessard@111: search_fb_typedecl_c(symbol_c *search_scope) { lbessard@111: this->search_scope = search_scope; lbessard@111: } lbessard@111: lbessard@111: symbol_c *get_decl(symbol_c *fb_type_name) { lbessard@111: this->search_name = fb_type_name; lbessard@111: return (symbol_c *)search_scope->accept(*this); lbessard@111: } lbessard@111: lbessard@111: public: lbessard@111: /**************************************/ lbessard@111: /* B.1.5 - Program organization units */ lbessard@111: /**************************************/ lbessard@111: lbessard@111: /*****************************/ lbessard@111: /* B 1.5.2 - Function Blocks */ lbessard@111: /*****************************/ lbessard@111: void *visit(function_block_declaration_c *symbol) { lbessard@111: if (compare_identifiers(symbol->fblock_name, search_name) == 0) lbessard@111: return symbol; lbessard@111: return NULL; lbessard@111: } lbessard@111: lbessard@111: /**********************/ lbessard@111: /* B 1.5.3 - Programs */ lbessard@111: /**********************/ lbessard@111: void *visit(program_declaration_c *symbol) { lbessard@111: if (compare_identifiers(symbol->program_type_name, search_name) == 0) lbessard@111: return symbol; lbessard@111: return NULL; lbessard@111: } lbessard@111: }; lbessard@111: lbessard@111: lbessard@111: lbessard@111: