28 if(type.
id() == ID_struct_tag)
30 return type.
id() == ID_array &&
36 return type.
id() == ID_pointer &&
59 std::wstring out(length,
'?');
61 for(std::size_t i = 0; i < arr.
operands().size() && i < length; i++)
69 auto ref = std::ref(
static_cast<const exprt &
>(expr));
72 const auto &with_expr = expr_dynamic_cast<with_exprt>(ref.get());
73 const auto current_index =
75 entries[current_index] = with_expr.new_value();
76 ref = with_expr.old();
81 default_value = expr_dynamic_cast<array_of_exprt>(ref.get()).what();
90 return std::accumulate(
96 const std::pair<std::size_t, exprt> &entry) {
97 const exprt entry_index = from_integer(entry.first, index.type());
98 const exprt &then_expr = entry.second;
99 CHECK_RETURN(then_expr.type() == if_expr.type());
100 const equal_exprt index_equal(index, entry_index);
101 return if_exprt(index_equal, then_expr, if_expr, if_expr.type());
107 return std::accumulate(
113 const std::pair<std::size_t, exprt> &entry) {
114 const exprt entry_index = from_integer(entry.first, index.type());
115 const exprt &then_expr = entry.second;
116 CHECK_RETURN(then_expr.type() == if_expr.type());
117 const binary_relation_exprt index_small_eq(index, ID_le, entry_index);
118 return if_exprt(index_small_eq, then_expr, if_expr, if_expr.type());
124 const exprt &extra_value)
127 const auto &operands = expr.
operands();
128 exprt last_added = extra_value;
129 for(std::size_t i = 0; i < operands.size(); ++i)
131 const std::size_t index = operands.size() - 1 - i;
132 if(operands[index].
id() != ID_unknown && operands[index] != last_added)
134 entries[index] = operands[index];
135 last_added = operands[index];
142 const exprt &extra_value)
146 for(std::size_t i = 0; i < expr.
operands().size(); i += 2)
148 const auto index = numeric_cast<std::size_t>(expr.
operands()[i]);
151 "all values in array should have the same type");
152 if(index.has_value() && expr.
operands()[i + 1].id() != ID_unknown)
157 std::optional<interval_sparse_arrayt>
160 if(
const auto &array_expr = expr_try_dynamic_cast<array_exprt>(expr))
162 if(
const auto &with_expr = expr_try_dynamic_cast<with_exprt>(expr))
164 if(
const auto &array_list = expr_try_dynamic_cast<array_list_exprt>(expr))
172 const auto it =
entries.lower_bound(index);
178 const typet &index_type)
const
186 for(; it !=
entries.end() && it->first < size; ++it)
187 array.operands().resize(it->first + 1, it->second);
189 array.operands().resize(
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
Array constructor from list of elements.
Array constructor from a list of index-element pairs Operands are index/value pairs,...
std::size_t get_width() const
Base class for all expressions.
typet & type()
Return the type of the expression.
Represents arrays by the indexes up to which the value remains the same.
exprt to_if_expression(const exprt &index) const
static std::optional< interval_sparse_arrayt > of_expr(const exprt &expr, const exprt &extra_value)
If the expression is an array_exprt or a with_exprt uses the appropriate constructor,...
array_exprt concretize(std::size_t size, const typet &index_type) const
Convert to an array representation, ignores elements at index >= size.
interval_sparse_arrayt(const with_exprt &expr)
An expression of the form array_of(x) with {i:=a} with {j:=b} is converted to an array arr where for ...
exprt at(std::size_t index) const
Get the value at the specified index.
const irep_idt & id() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Represents arrays of the form array_of(x) with {i:=a} with {j:=b} ... by a default value x and a list...
std::map< std::size_t, exprt > entries
static exprt to_if_expression(const with_exprt &expr, const exprt &index)
Creates an if_expr corresponding to the result of accessing the array at the given index.
sparse_arrayt(const with_exprt &expr)
Initialize a sparse array from an expression of the form array_of(x) with {i:=a} with {j:=b} ....
The type of an expression, extends irept.
Operator to update elements in structs and arrays.
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
bool has_subtype(const typet &type, const std::function< bool(const typet &)> &pred, const namespacet &ns)
returns true if any of the contained types satisfies pred
Deprecated expression utility functions.
Magic numbers used throughout the codebase.
const std::size_t STRING_REFINEMENT_MAX_CHAR_WIDTH
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
#define PRECONDITION(CONDITION)
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
bool can_cast_expr< with_exprt >(const exprt &base)
bool can_cast_expr< constant_exprt >(const exprt &base)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
std::string utf16_constant_array_to_java(const array_exprt &arr, std::size_t length)
Construct a string from a constant array.
bool is_char_type(const typet &type)
For now, any unsigned bitvector type of width smaller or equal to 16 is considered a character.
bool has_char_pointer_subtype(const typet &type, const namespacet &ns)
bool is_char_array_type(const typet &type, const namespacet &ns)
Distinguish char array from other types.
bool has_char_array_subexpr(const exprt &expr, const namespacet &ns)
bool is_char_pointer_type(const typet &type)
For now, any unsigned bitvector type is considered a character.
static void utf16_native_endian_to_java_string(const wchar_t ch, std::ostringstream &result, const std::locale &loc)
Escapes non-printable characters, whitespace except for spaces, double quotes and backslashes.