stage3/stage3.cc
changeset 564 dabffc3086dc
parent 560 13b5b7faa3d7
child 611 8e81d7db54be
equal deleted inserted replaced
563:61410284a9b4 564:dabffc3086dc
    38 #include "fill_candidate_datatypes.hh"
    38 #include "fill_candidate_datatypes.hh"
    39 #include "narrow_candidate_datatypes.hh"
    39 #include "narrow_candidate_datatypes.hh"
    40 #include "print_datatypes_error.hh"
    40 #include "print_datatypes_error.hh"
    41 #include "lvalue_check.hh"
    41 #include "lvalue_check.hh"
    42 #include "array_range_check.hh"
    42 #include "array_range_check.hh"
       
    43 #include "constant_folding.hh"
    43 
    44 
       
    45 static int constant_check(symbol_c *tree_root){
       
    46     constant_folding_c constant_folding(tree_root);
       
    47     tree_root->accept(constant_folding);
       
    48     return constant_folding.get_error_count();
       
    49 }
    44 
    50 
    45 static int flow_control_analysis(symbol_c *tree_root){
    51 static int flow_control_analysis(symbol_c *tree_root){
    46   flow_control_analysis_c flow_control_analysis(tree_root);
    52     flow_control_analysis_c flow_control_analysis(tree_root);
    47   tree_root->accept(flow_control_analysis);
    53     tree_root->accept(flow_control_analysis);
    48   return 0;
    54     return 0;
    49 }
    55 }
    50 
    56 
    51 
    57 
    52 /* Type safety analysis assumes that flow control analysis has already been completed,
    58 /* Type safety analysis assumes that flow control analysis has already been completed,
    53  * so be sure to call flow_control_analysis() before calling this function
    59  * so be sure to call flow_control_analysis() before calling this function
    79 }
    85 }
    80 
    86 
    81 
    87 
    82 int stage3(symbol_c *tree_root){
    88 int stage3(symbol_c *tree_root){
    83 	int error_count = 0;
    89 	int error_count = 0;
       
    90 	error_count += constant_check(tree_root);
    84 	error_count += flow_control_analysis(tree_root);
    91 	error_count += flow_control_analysis(tree_root);
    85 	error_count += type_safety(tree_root);
    92 	error_count += type_safety(tree_root);
    86 	error_count += lvalue_check(tree_root);
    93 	error_count += lvalue_check(tree_root);
    87 	error_count += range_check(tree_root);
    94 	error_count += range_check(tree_root);
    88 	
    95