Skip to content

Commit

Permalink
Make build_offset_map return an offset_mapt
Browse files Browse the repository at this point in the history
  • Loading branch information
romainbrenguier committed Jun 4, 2018
1 parent 2dc7bee commit 52d0fe4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
19 changes: 9 additions & 10 deletions src/solvers/flattening/boolbv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,17 +660,16 @@ void boolbvt::print_assignment(std::ostream &out) const
out << pair.first << "=" << pair.second.get_value(prop) << '\n';
}

void boolbvt::build_offset_map(const struct_typet &src, offset_mapt &dest)
boolbvt::offset_mapt boolbvt::build_offset_map(const struct_typet &src)
{
const struct_typet::componentst &components=
src.components();

dest.resize(components.size());
std::size_t offset=0;
for(std::size_t i=0; i<components.size(); i++)
const struct_typet::componentst &components = src.components();
offset_mapt dest;
dest.reserve(components.size());
std::size_t offset = 0;
for(const auto &comp : components)
{
std::size_t comp_width=boolbv_width(components[i].type());
dest[i]=offset;
offset+=comp_width;
dest.push_back(offset);
offset += boolbv_width(comp.type());
}
return dest;
}
2 changes: 1 addition & 1 deletion src/solvers/flattening/boolbv.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class boolbvt:public arrayst
void post_process_quantifiers();

typedef std::vector<std::size_t> offset_mapt;
void build_offset_map(const struct_typet &src, offset_mapt &dest);
offset_mapt build_offset_map(const struct_typet &src);

// strings
numbering<irep_idt> string_numbering;
Expand Down
6 changes: 2 additions & 4 deletions src/solvers/flattening/boolbv_typecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,8 @@ bool boolbvt::type_conversion(
op_struct.components();

// build offset maps
offset_mapt op_offsets, dest_offsets;

build_offset_map(op_struct, op_offsets);
build_offset_map(dest_struct, dest_offsets);
const offset_mapt op_offsets = build_offset_map(op_struct);
const offset_mapt dest_offsets = build_offset_map(dest_struct);

// build name map
typedef std::map<irep_idt, std::size_t> op_mapt;
Expand Down

0 comments on commit 52d0fe4

Please sign in to comment.