33 if(src.
id() == ID_typecast)
37 else if(src.
id() == ID_address_of)
41 if(
object.
id() == ID_symbol)
47 object.
id() == ID_member &&
63 src.
id() == ID_member &&
84 if(type.
id() == ID_unsignedbv)
90 else if(type.
id() == ID_signedbv)
96 else if(type.
id() == ID_floatbv)
102 else if(type.
id() == ID_bv)
108 else if(type.
id() == ID_c_bit_field)
114 else if(type.
id() == ID_c_enum_tag)
120 else if(type.
id() == ID_fixedbv)
126 else if(type.
id() == ID_pointer)
131 else if(type.
id() == ID_bool)
135 else if(type.
id() == ID_array)
141 else if(type.
id() == ID_vector)
147 else if(type.
id() == ID_struct)
160 else if(type.
id() == ID_struct_tag)
164 else if(type.
id() == ID_union)
177 else if(type.
id() == ID_union_tag)
190 if(src.
type().
id() == ID_c_enum)
215 std::unique_ptr<languaget> lang;
216 if(mode != ID_unknown)
221 const typet &underlying_type =
225 std::string type_string;
226 bool error = lang->from_type(underlying_type, type_string, ns);
229 std::string value_string;
230 lang->from_expr(expr, value_string, ns);
233 type.
id() == ID_unsignedbv || type.
id() == ID_signedbv ||
234 type.
id() == ID_c_bit_field || type.
id() == ID_c_bool)
244 else if(type.
id() == ID_c_enum)
253 else if(type.
id() == ID_c_enum_tag)
257 return json(tmp, ns, mode);
259 else if(type.
id() == ID_bv)
264 else if(type.
id() == ID_fixedbv)
272 else if(type.
id() == ID_floatbv)
281 else if(type.
id() == ID_pointer)
288 else if(type.
id() == ID_bool)
294 else if(type.
id() == ID_string)
304 else if(expr.
id() == ID_annotated_pointer_constant)
310 if(simpl_expr.
id() == ID_symbol)
316 std::unique_ptr<languaget> lang;
317 if(mode != ID_unknown)
322 const typet &underlying_type =
323 type.
id() == ID_c_bit_field
327 std::string type_string;
328 bool error = lang->from_type(underlying_type, type_string, ns);
336 "pointer identifier should have non-empty components");
340 return json(simpl_expr, ns, mode);
344 else if(expr.
id() == ID_array)
349 std::size_t index = 0;
351 for(
const auto &op : expr.
operands())
355 {
"value",
json(op, ns, mode)}};
360 else if(expr.
id() == ID_struct)
365 expr.
type().
id() == ID_struct_tag
370 components.size() == expr.
operands().size(),
371 "number of struct components should match with its type");
374 for(std::size_t m = 0; m < expr.
operands().size(); m++)
382 else if(expr.
id() == ID_union)
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
const bv_typet & to_bv_type(const typet &type)
Cast a typet to a bv_typet.
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
Pointer-typed bitvector constant annotated with the pointer expression that the bitvector is the nume...
exprt & symbolic_pointer()
std::size_t get_width() const
const typet & underlying_type() const
const typet & underlying_type() const
A constant literal expression.
const irep_idt & get_value() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
bool is_true() const
Return whether the expression is a constant representing true.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
const irep_idt & id() const
jsont & push_back(const jsont &json)
json_arrayt & make_array()
static jsont json_boolean(bool value)
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...
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
const irep_idt & get_identifier() const
The type of an expression, extends irept.
Union constructor from single element.
irep_idt get_component_name() const
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
Deprecated expression utility functions.
const std::string & id2string(const irep_idt &d)
static std::string binary(const constant_exprt &src)
static exprt simplify_json_expr(const exprt &src)
json_objectt json(const typet &type, const namespacet &ns, const irep_idt &mode)
Output a CBMC type in json.
Abstract interface to support a programming language.
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
std::unique_ptr< languaget > get_default_language()
Returns the default language.
const std::string integer2binary(const mp_integer &n, std::size_t width)
API to expression classes for Pointers.
const annotated_pointer_constant_exprt & to_annotated_pointer_constant_expr(const exprt &expr)
Cast an exprt to an annotated_pointer_constant_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
#define CHECK_RETURN(CONDITION)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
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 to_string(const string_not_contains_constraintt &expr)
Used for debug printing.