|
13 | 13 |
|
14 | 14 | #include <util/arith_tools.h>
|
15 | 15 |
|
| 16 | +/// If \p expr is: |
| 17 | +/// - a symbol_exprt "s" add "s" to the stream \p os |
| 18 | +/// - a member_exprt, apply recursively and add "..component_name" |
| 19 | +/// - an index_exprt where the index is a constant, apply recursively on the |
| 20 | +/// array and add "[[index]]" |
| 21 | +/// \return the stream \p os |
| 22 | +static std::ostream & |
| 23 | +initialize_ssa_identifier(std::ostream &os, const exprt &expr) |
| 24 | +{ |
| 25 | + if(auto member = expr_try_dynamic_cast<member_exprt>(expr)) |
| 26 | + { |
| 27 | + return initialize_ssa_identifier(os, member->struct_op()) |
| 28 | + << ".." << member->get_component_name(); |
| 29 | + } |
| 30 | + if(auto index = expr_try_dynamic_cast<index_exprt>(expr)) |
| 31 | + { |
| 32 | + const auto idx = |
| 33 | + numeric_cast_v<mp_integer>(to_constant_expr(index->index())); |
| 34 | + return initialize_ssa_identifier(os, index->array()) << "[[" << idx << "]]"; |
| 35 | + } |
| 36 | + if(auto symbol = expr_try_dynamic_cast<symbol_exprt>(expr)) |
| 37 | + return os << symbol->get_identifier(); |
| 38 | + |
| 39 | + UNREACHABLE; |
| 40 | +} |
| 41 | + |
16 | 42 | ssa_exprt::ssa_exprt(const exprt &expr) : symbol_exprt(expr.type())
|
17 | 43 | {
|
18 | 44 | set(ID_C_SSA_symbol, true);
|
19 | 45 | add(ID_expression, expr);
|
20 |
| - update_identifier(); |
| 46 | + std::ostringstream os; |
| 47 | + initialize_ssa_identifier(os, expr); |
| 48 | + const std::string id = os.str(); |
| 49 | + set_identifier(id); |
| 50 | + set(ID_L1_object_identifier, id); |
21 | 51 | }
|
22 | 52 |
|
23 | 53 | void ssa_exprt::set_expression(const exprt &expr)
|
|
0 commit comments