54 tree_root->accept(fill_candidate_datatypes); |
54 tree_root->accept(fill_candidate_datatypes); |
55 narrow_candidate_datatypes_c narrow_candidate_datatypes(tree_root); |
55 narrow_candidate_datatypes_c narrow_candidate_datatypes(tree_root); |
56 tree_root->accept(narrow_candidate_datatypes); |
56 tree_root->accept(narrow_candidate_datatypes); |
57 print_datatypes_error_c print_datatypes_error(tree_root); |
57 print_datatypes_error_c print_datatypes_error(tree_root); |
58 tree_root->accept(print_datatypes_error); |
58 tree_root->accept(print_datatypes_error); |
59 if (print_datatypes_error.get_error_found()) |
59 return print_datatypes_error.get_error_count(); |
60 return -1; |
|
61 lvalue_check_c lvalue_check(tree_root); |
|
62 tree_root->accept(lvalue_check); |
|
63 if (lvalue_check.get_error_found()) |
|
64 return -1; |
|
65 return 0; |
|
66 } |
60 } |
67 |
61 |
68 |
62 |
|
63 /* Type safety analysis assumes that flow control analysis has already been completed, |
|
64 * so be sure to call flow_control_analysis() before calling this function |
|
65 */ |
|
66 static int lvalue_check(symbol_c *tree_root){ |
|
67 lvalue_check_c lvalue_check(tree_root); |
|
68 tree_root->accept(lvalue_check); |
|
69 return lvalue_check.get_error_count(); |
|
70 } |
|
71 |
69 |
72 |
70 int stage3(symbol_c *tree_root){ |
73 int stage3(symbol_c *tree_root){ |
71 flow_control_analysis(tree_root); |
74 int error_count = 0; |
72 return type_safety(tree_root); |
75 error_count += flow_control_analysis(tree_root); |
|
76 error_count += type_safety(tree_root); |
|
77 error_count += lvalue_check(tree_root); |
|
78 |
|
79 if (error_count > 0) { |
|
80 fprintf(stderr, "%d errors found. Bailing out!\n", error_count); |
|
81 return -1; |
|
82 } |
|
83 return 0; |
73 } |
84 } |