cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
refined_string_type.h
Go to the documentation of this file.
1
/********************************************************************\
2
3
Module: Type for string expressions used by the string solver.
4
These string expressions contain a field `length`, of type
5
`index_type`, a field `content` of type `content_type`.
6
This module also defines functions to recognise the C and java
7
string types.
8
9
Author: Romain Brenguier, romain.brenguier@diffblue.com
10
11
\*******************************************************************/
12
18
19
#ifndef CPROVER_UTIL_REFINED_STRING_TYPE_H
20
#define CPROVER_UTIL_REFINED_STRING_TYPE_H
21
22
#include "
cprover_prefix.h
"
23
#include "
std_types.h
"
24
25
class
pointer_typet
;
26
27
// Internal type used for string refinement
28
class
refined_string_typet
:
public
struct_typet
29
{
30
public
:
31
refined_string_typet
(
32
const
typet
&index_type,
33
const
pointer_typet
&content_type);
34
35
// Type for the content (list of characters) of a string
36
const
array_typet
&
get_content_type
()
const
37
{
38
PRECONDITION
(
components
().size()==2);
39
return
to_array_type
(
components
()[1].type());
40
}
41
42
const
typet
&
get_char_type
()
const
43
{
44
return
get_content_type
().
element_type
();
45
}
46
47
const
typet
&
get_index_type
()
const
48
{
49
PRECONDITION
(
components
().size()==2);
50
return
components
()[0].type();
51
}
52
};
53
54
inline
bool
is_refined_string_type
(
const
typet
&type)
55
{
56
return
57
type.
id
()==ID_struct &&
58
to_struct_type
(type).
get_tag
()==
CPROVER_PREFIX
"refined_string_type"
;
59
}
60
61
extern
inline
const
refined_string_typet
&
to_refined_string_type
(
62
const
typet
&type)
63
{
64
PRECONDITION
(
is_refined_string_type
(type));
65
return
static_cast<
const
refined_string_typet
&
>
(type);
66
}
67
68
#endif
array_typet
Arrays with given size.
Definition
std_types.h:807
array_typet::element_type
const typet & element_type() const
The type of the elements of the array.
Definition
std_types.h:827
irept::id
const irep_idt & id() const
Definition
irep.h:388
pointer_typet
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition
pointer_expr.h:24
refined_string_typet
Definition
refined_string_type.h:29
refined_string_typet::get_index_type
const typet & get_index_type() const
Definition
refined_string_type.h:47
refined_string_typet::get_content_type
const array_typet & get_content_type() const
Definition
refined_string_type.h:36
refined_string_typet::refined_string_typet
refined_string_typet(const typet &index_type, const pointer_typet &content_type)
Definition
refined_string_type.cpp:23
refined_string_typet::get_char_type
const typet & get_char_type() const
Definition
refined_string_type.h:42
struct_typet::struct_typet
struct_typet()
Definition
std_types.h:233
struct_union_typet::get_tag
irep_idt get_tag() const
Definition
std_types.h:168
struct_union_typet::components
const componentst & components() const
Definition
std_types.h:147
typet
The type of an expression, extends irept.
Definition
type.h:29
typet::typet
typet()
Definition
type.h:31
cprover_prefix.h
CPROVER_PREFIX
#define CPROVER_PREFIX
Definition
cprover_prefix.h:14
is_refined_string_type
bool is_refined_string_type(const typet &type)
Definition
refined_string_type.h:54
to_refined_string_type
const refined_string_typet & to_refined_string_type(const typet &type)
Definition
refined_string_type.h:61
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
std_types.h
Pre-defined types.
to_struct_type
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition
std_types.h:308
to_array_type
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition
std_types.h:888
util
refined_string_type.h
Generated by
1.17.0