Skip to content

Commit a54746f

Browse files
author
svorenova
committed
Add documentation to typet
1 parent dbd6988 commit a54746f

File tree

2 files changed

+27
-42
lines changed

2 files changed

+27
-42
lines changed

src/util/type.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
/*******************************************************************\
22
3-
Module:
3+
Module: Implementations of some functions of typet
44
55
Author: Daniel Kroening, [email protected]
6+
Maria Svorenova, [email protected]
67
78
\*******************************************************************/
89

10+
/// \file
11+
/// Implementations of some functions of typet
12+
913
#include "type.h"
1014
#include "std_types.h"
1115
#include "namespace.h"
1216

17+
/// Copy the provided type to the subtypes of this type.
18+
/// \param type The type to add to subtypes
1319
void typet::copy_to_subtypes(const typet &type)
1420
{
1521
subtypes().push_back(type);
1622
}
1723

24+
/// Move the provided type to the subtypes of this type. Destroys the
25+
/// provided type.
26+
/// \param type The type to add to subtypes
1827
void typet::move_to_subtypes(typet &type)
1928
{
2029
subtypest &sub=subtypes();
2130
sub.push_back(static_cast<const typet &>(get_nil_irep()));
2231
sub.back().swap(type);
2332
}
2433

34+
/// Returns true if the type is a rational, real, integer, natural, complex,
35+
/// unsignedbv, signedbv, floatbv or fixedbv.
2536
bool is_number(const typet &type)
2637
{
2738
const irep_idt &id=type.id();
@@ -36,8 +47,9 @@ bool is_number(const typet &type)
3647
id==ID_fixedbv;
3748
}
3849

39-
/// Identify if a given type is constant itself or
40-
/// contains constant components. Examples include:
50+
/// Identify whether a given type is constant itself or contains constant
51+
/// components.
52+
/// Examples include:
4153
/// - const int a;
4254
/// - struct contains_constant_pointer { int x; int * const p; };
4355
/// - const int b[3];

src/util/type.h

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/*******************************************************************\
22
3-
Module:
3+
Module: Defines typet, type_with_subtypet and type_with_subtypest
44
55
Author: Daniel Kroening, [email protected]
6+
Maria Svorenova, [email protected]
67
78
\*******************************************************************/
89

10+
/// \file
11+
/// Defines typet, type_with_subtypet and type_with_subtypest
912

1013
#ifndef CPROVER_UTIL_TYPE_H
1114
#define CPROVER_UTIL_TYPE_H
@@ -17,8 +20,11 @@ Author: Daniel Kroening, [email protected]
1720

1821
class namespacet;
1922

20-
/*! \brief The type of an expression
21-
*/
23+
/// The type of an expression, extends irept. Types may have subtypes. This is
24+
/// modeled with two subs named “subtype” (a single type) and “subtypes”
25+
/// (a vector of types). The class typet only adds specialized methods
26+
/// for accessing the subtype information to the interface of irept.
27+
/// For pre-defined types see `std_types.h`.
2228
class typet:public irept
2329
{
2430
public:
@@ -90,7 +96,7 @@ class typet:public irept
9096
{ remove(ID_subtype); }
9197
#endif
9298

93-
void move_to_subtypes(typet &type); // destroys expr
99+
void move_to_subtypes(typet &type);
94100

95101
void copy_to_subtypes(const typet &type);
96102

@@ -115,6 +121,7 @@ class typet:public irept
115121
}
116122
};
117123

124+
/// Type with a single subtype.
118125
class type_with_subtypet:public typet
119126
{
120127
public:
@@ -136,6 +143,7 @@ class type_with_subtypet:public typet
136143
#endif
137144
};
138145

146+
/// Type with multiple subtypes.
139147
class type_with_subtypest:public typet
140148
{
141149
public:
@@ -169,43 +177,8 @@ class type_with_subtypest:public typet
169177
for(typet::subtypest::iterator it=(type).subtypes().begin(); \
170178
it!=(type).subtypes().end(); ++it)
171179

172-
/*
173-
174-
pre-defined types:
175-
universe // super type
176-
type // another type
177-
predicate // predicate expression (subtype and predicate)
178-
uninterpreted // uninterpreted type with identifier
179-
empty // void
180-
bool // true or false
181-
abstract // abstract super type
182-
struct // with components: each component has name and type
183-
// the ordering matters
184-
rational
185-
real
186-
integer
187-
complex
188-
string
189-
enum // with elements
190-
// the ordering does not matter
191-
tuple // with components: each component has type
192-
// the ordering matters
193-
mapping // domain -> range
194-
bv // no interpretation
195-
unsignedbv
196-
signedbv // two's complement
197-
floatbv // IEEE floating point format
198-
code
199-
pointer // for ANSI-C (subtype)
200-
symbol // look in symbol table (identifier)
201-
number // generic number super type
202-
203-
*/
204-
205180
bool is_number(const typet &type);
206-
// rational, real, integer, complex, unsignedbv, signedbv, floatbv
207181

208-
// Is the passed in type const qualified?
209182
bool is_constant_or_has_constant_components(
210183
const typet &type,
211184
const namespacet &ns);

0 commit comments

Comments
 (0)