1313 /********************************/ |
1313 /********************************/ |
1314 void *constant_folding_c::visit(for_statement_c *symbol) { |
1314 void *constant_folding_c::visit(for_statement_c *symbol) { |
1315 std::map <std::string, symbol_c::const_value_t> values_incoming; |
1315 std::map <std::string, symbol_c::const_value_t> values_incoming; |
1316 std::map <std::string, symbol_c::const_value_t> values_statement_result; |
1316 std::map <std::string, symbol_c::const_value_t> values_statement_result; |
1317 std::map <std::string, symbol_c::const_value_t>::iterator itr; |
1317 std::map <std::string, symbol_c::const_value_t>::iterator itr; |
|
1318 std::string varName; |
1318 |
1319 |
1319 values_incoming = values; /* save incoming status */ |
1320 values_incoming = values; /* save incoming status */ |
|
1321 symbol->beg_expression->accept(*this); |
|
1322 symbol->end_expression->accept(*this); |
|
1323 varName = convert.toString(symbol->control_variable); |
|
1324 values[varName] = symbol->beg_expression->const_value; |
|
1325 |
|
1326 /* Optimize dead code */ |
|
1327 if (VALID_CVALUE(int64, symbol->beg_expression) && VALID_CVALUE(int64, symbol->end_expression) && |
|
1328 GET_CVALUE(int64, symbol->beg_expression) > GET_CVALUE(int64, symbol->end_expression)) |
|
1329 return NULL; |
|
1330 |
1320 symbol->statement_list->accept(*this); |
1331 symbol->statement_list->accept(*this); |
1321 values_statement_result = values; |
1332 values_statement_result = values; |
1322 values.clear(); |
1333 values.clear(); |
1323 itr = values_statement_result.begin(); |
1334 itr = values_statement_result.begin(); |
1324 for ( ; itr != values_statement_result.end(); ++itr) { |
1335 for ( ; itr != values_statement_result.end(); ++itr) { |