ccb@204: /* msousa@267: * matiec - a compiler for the programming languages defined in IEC 61131-3 ccb@204: * msousa@417: * Copyright (C) 2009-2012 Mario de Sousa (msousa@fe.up.pt) Edouard@279: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant msousa@417: * Copyright (C) 2012 Manuele Conti (manuele.conti@sirius-es.it) msousa@417: * Copyright (C) 2012 Matteo Facchinetti (matteo.facchinetti@sirius-es.it) ccb@204: * msousa@267: * This program is free software: you can redistribute it and/or modify msousa@267: * it under the terms of the GNU General Public License as published by msousa@267: * the Free Software Foundation, either version 3 of the License, or msousa@267: * (at your option) any later version. msousa@267: * msousa@267: * This program is distributed in the hope that it will be useful, msousa@267: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@267: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@267: * GNU General Public License for more details. msousa@267: * msousa@267: * You should have received a copy of the GNU General Public License msousa@267: * along with this program. If not, see . msousa@267: * ccb@204: * ccb@204: * This code is made available on the understanding that it will not be ccb@204: * used in safety-critical situations without a full and competent review. ccb@204: */ ccb@204: ccb@204: /* msousa@267: * An IEC 61131-3 compiler. ccb@204: * ccb@204: * Based on the msousa@267: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) ccb@204: * ccb@204: */ ccb@204: ccb@204: #include "stage3.hh" ccb@204: msousa@417: #include "fill_candidate_datatypes.hh" msousa@417: #include "narrow_candidate_datatypes.hh" msousa@417: #include "print_datatypes_error.hh" msousa@417: msousa@417: ccb@204: int type_safety(symbol_c *tree_root){ msousa@417: fill_candidate_datatypes_c fill_candidate_datatypes(tree_root); msousa@417: tree_root->accept(fill_candidate_datatypes); msousa@417: narrow_candidate_datatypes_c narrow_candidate_datatypes(tree_root); msousa@417: tree_root->accept(narrow_candidate_datatypes); msousa@417: print_datatypes_error_c print_datatypes_error(tree_root); msousa@417: tree_root->accept(print_datatypes_error); msousa@417: if (print_datatypes_error.get_error_found()) msousa@417: return -1; ccb@204: return 0; ccb@204: } ccb@204: ccb@204: int stage3(symbol_c *tree_root){ ccb@204: return type_safety(tree_root); ccb@204: }