Skip to content

Commit 47f4b35

Browse files
interval_sparse_arrayt constructor from array-list
It was not possible to declare such a constructor before because the array_list_exprt class did not exist.
1 parent 026c4ca commit 47f4b35

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/solvers/refinement/string_refinement_util.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,21 @@ interval_sparse_arrayt::interval_sparse_arrayt(
164164
}
165165
}
166166

167-
interval_sparse_arrayt interval_sparse_arrayt::of_array_list(
168-
const exprt &expr,
167+
interval_sparse_arrayt::interval_sparse_arrayt(
168+
const array_list_exprt &expr,
169169
const exprt &extra_value)
170+
: interval_sparse_arrayt(extra_value)
170171
{
171172
PRECONDITION(expr.operands().size() % 2 == 0);
172-
interval_sparse_arrayt sparse_array(extra_value);
173173
for(std::size_t i = 0; i < expr.operands().size(); i += 2)
174174
{
175175
const auto index = numeric_cast<std::size_t>(expr.operands()[i]);
176176
INVARIANT(
177177
expr.operands()[i + 1].type() == extra_value.type(),
178178
"all values in array should have the same type");
179179
if(index.has_value() && expr.operands()[i + 1].id() != ID_unknown)
180-
sparse_array.entries[*index] = expr.operands()[i + 1];
180+
entries[*index] = expr.operands()[i + 1];
181181
}
182-
return sparse_array;
183182
}
184183

185184
optionalt<interval_sparse_arrayt>
@@ -189,8 +188,8 @@ interval_sparse_arrayt::of_expr(const exprt &expr, const exprt &extra_value)
189188
return interval_sparse_arrayt(*array_expr, extra_value);
190189
if(const auto &with_expr = expr_try_dynamic_cast<with_exprt>(expr))
191190
return interval_sparse_arrayt(*with_expr);
192-
if(expr.id() == ID_array_list)
193-
return of_array_list(expr, extra_value);
191+
if(const auto &array_list = expr_try_dynamic_cast<array_list_exprt>(expr))
192+
return interval_sparse_arrayt(*array_list, extra_value);
194193
return {};
195194
}
196195

src/solvers/refinement/string_refinement_util.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ class interval_sparse_arrayt final : public sparse_arrayt
131131
/// Initialize a sparse array from an array represented by a list of
132132
/// index-value pairs, and setting the default to `extra_value`.
133133
/// Indexes must be constant expressions, and negative indexes are ignored.
134-
static interval_sparse_arrayt
135-
of_array_list(const exprt &expr, const exprt &extra_value);
134+
interval_sparse_arrayt(
135+
const array_list_exprt &expr,
136+
const exprt &extra_value);
136137

137138
exprt to_if_expression(const exprt &index) const override;
138139

0 commit comments

Comments
 (0)