Skip to content

Commit 7aef0a1

Browse files
author
kroening
committed
beautification of ssa_exprt
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@4652 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent ee5a025 commit 7aef0a1

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/goto-symex/ssa_expr.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Author: Daniel Kroening, [email protected]
77
\*******************************************************************/
88

99
#include <sstream>
10+
#include <cassert>
1011

1112
#include <util/arith_tools.h>
1213

@@ -28,21 +29,22 @@ static void build_ssa_identifier_rec(
2829
const exprt &expr,
2930
const irep_idt &l0,
3031
const irep_idt &l1,
32+
const irep_idt &l2,
3133
std::ostream &os)
3234
{
3335
if(expr.id()==ID_member)
3436
{
3537
const member_exprt &member=to_member_expr(expr);
3638

37-
build_ssa_identifier_rec(member.struct_op(), l0, l1, os);
39+
build_ssa_identifier_rec(member.struct_op(), l0, l1, l2, os);
3840

3941
os << '.' << member.get_component_name();
4042
}
4143
else if(expr.id()==ID_index)
4244
{
4345
const index_exprt &index=to_index_expr(expr);
4446

45-
build_ssa_identifier_rec(index.array(), l0, l1, os);
47+
build_ssa_identifier_rec(index.array(), l0, l1, l2, os);
4648

4749
mp_integer idx;
4850
if(to_integer(to_constant_expr(index.index()), idx))
@@ -59,14 +61,17 @@ static void build_ssa_identifier_rec(
5961

6062
if(!l1.empty())
6163
os << '@' << l1;
64+
65+
if(!l2.empty())
66+
os << '#' << l2;
6267
}
6368
else
6469
assert(false);
6570
}
6671

6772
/*******************************************************************\
6873
69-
Function: ssa_exprt::update_identifier
74+
Function: ssa_exprt::build_identifier
7075
7176
Inputs:
7277
@@ -76,18 +81,16 @@ Function: ssa_exprt::update_identifier
7681
7782
\*******************************************************************/
7883

79-
void ssa_exprt::update_identifier()
84+
irep_idt ssa_exprt::build_identifier(
85+
const exprt &expr,
86+
const irep_idt &l0,
87+
const irep_idt &l1,
88+
const irep_idt &l2)
8089
{
8190
std::ostringstream oss;
8291

83-
const irep_idt &l0=get_level_0();
84-
const irep_idt &l1=get_level_1();
85-
const irep_idt &l2=get_level_2();
92+
build_ssa_identifier_rec(expr, l0, l1, l2, oss);
8693

87-
build_ssa_identifier_rec(get_original_expr(), l0, l1, oss);
88-
89-
if(!l2.empty())
90-
oss << '#' << l2;
91-
92-
set_identifier(oss.str());
94+
return oss.str();
9395
}
96+

src/goto-symex/ssa_expr.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,20 @@ class ssa_exprt:public symbol_exprt
102102
return get(ID_L2);
103103
}
104104

105-
void update_identifier();
105+
void update_identifier()
106+
{
107+
const irep_idt &l0=get_level_0();
108+
const irep_idt &l1=get_level_1();
109+
const irep_idt &l2=get_level_2();
110+
111+
set_identifier(build_identifier(get_original_expr(), l0, l1, l2));
112+
}
113+
114+
static irep_idt build_identifier(
115+
const exprt &src,
116+
const irep_idt &l0,
117+
const irep_idt &l1,
118+
const irep_idt &l2);
106119
};
107120

108121
/*! \brief Cast a generic exprt to an \ref ssa_exprt

0 commit comments

Comments
 (0)