stage3/stage3.cc
changeset 417 d48f53715f77
parent 279 c0453b7f99df
child 443 ff4d26b7e51d
equal deleted inserted replaced
416:0c2ef191b22a 417:d48f53715f77
     1 /*
     1 /*
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
     3  *
     3  *
     4  *  Copyright (C) 2009-2011  Mario de Sousa (msousa@fe.up.pt)
     4  *  Copyright (C) 2009-2012  Mario de Sousa (msousa@fe.up.pt)
     5  *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
     5  *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
       
     6  *  Copyright (C) 2012       Manuele Conti (manuele.conti@sirius-es.it)
       
     7  *  Copyright (C) 2012       Matteo Facchinetti (matteo.facchinetti@sirius-es.it)
     6  *
     8  *
     7  *  This program is free software: you can redistribute it and/or modify
     9  *  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
    10  *  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
    11  *  the Free Software Foundation, either version 3 of the License, or
    10  *  (at your option) any later version.
    12  *  (at your option) any later version.
    30  *
    32  *
    31  */
    33  */
    32 
    34 
    33 #include "stage3.hh"
    35 #include "stage3.hh"
    34 
    36 
       
    37 #include "fill_candidate_datatypes.hh"
       
    38 #include "narrow_candidate_datatypes.hh"
       
    39 #include "print_datatypes_error.hh"
       
    40 
       
    41 
    35 int type_safety(symbol_c *tree_root){
    42 int type_safety(symbol_c *tree_root){
    36 	visit_expression_type_c visit_expression_type(tree_root);
    43 	fill_candidate_datatypes_c fill_candidate_datatypes(tree_root);
    37 
    44 	tree_root->accept(fill_candidate_datatypes);
    38 	(*tree_root).accept(visit_expression_type);
    45 	narrow_candidate_datatypes_c narrow_candidate_datatypes(tree_root);
    39 
    46 	tree_root->accept(narrow_candidate_datatypes);
    40 	if (visit_expression_type.get_error_found())
    47 	print_datatypes_error_c print_datatypes_error(tree_root);
    41 	  return -1;
    48 	tree_root->accept(print_datatypes_error);
    42 	
    49 	if (print_datatypes_error.get_error_found())
       
    50 		return -1;
    43 	return 0;
    51 	return 0;
    44 }
    52 }
    45 
    53 
    46 int stage3(symbol_c *tree_root){
    54 int stage3(symbol_c *tree_root){
    47 	return type_safety(tree_root);
    55 	return type_safety(tree_root);