40 */ |
40 */ |
41 |
41 |
42 #include <vector> |
42 #include <vector> |
43 #include "../absyntax_utils/absyntax_utils.hh" |
43 #include "../absyntax_utils/absyntax_utils.hh" |
44 |
44 |
45 |
|
46 class convert_c : public iterator_visitor_c { |
|
47 std::string text; |
|
48 |
|
49 public: |
|
50 convert_c(symbol_c *symbol = NULL) { |
|
51 text = ""; |
|
52 } |
|
53 |
|
54 std::string toString(symbol_c *symbol) { |
|
55 symbol->accept(*this); |
|
56 return text; |
|
57 } |
|
58 |
|
59 void *visit(identifier_c *symbol) { |
|
60 text = symbol->value; |
|
61 return NULL; |
|
62 } |
|
63 |
|
64 void *visit(symbolic_variable_c *symbol) { |
|
65 symbol->var_name->accept(*this); |
|
66 return NULL; |
|
67 } |
|
68 }; |
|
69 |
45 |
70 class constant_folding_c : public iterator_visitor_c { |
46 class constant_folding_c : public iterator_visitor_c { |
71 search_varfb_instance_type_c *search_varfb_instance_type; |
47 search_varfb_instance_type_c *search_varfb_instance_type; |
72 int error_count; |
48 int error_count; |
73 bool warning_found; |
49 bool warning_found; |
74 int current_display_error_level; |
50 int current_display_error_level; |
75 /* Pointer to the previous IL instruction, which contains the current cvalue of the data stored in the IL stack, i.e. the default variable, a.k.a. accumulator */ |
51 /* Pointer to the previous IL instruction, which contains the current cvalue of the data stored in the IL stack, i.e. the default variable, a.k.a. accumulator */ |
76 symbol_c *prev_il_instruction; |
52 symbol_c *prev_il_instruction; |
77 /* the current IL operand being analyzed */ |
53 /* the current IL operand being analyzed */ |
78 symbol_c *il_operand; |
54 symbol_c *il_operand; |
79 convert_c convert; |
|
80 |
55 |
81 public: |
56 public: |
82 constant_folding_c(symbol_c *symbol = NULL); |
57 constant_folding_c(symbol_c *symbol = NULL); |
83 virtual ~constant_folding_c(void); |
58 virtual ~constant_folding_c(void); |
84 int get_error_count(); |
59 int get_error_count(); |