Skip to content

Commit 5b701e2

Browse files
author
svorenova
committed
Move mathematical types from std_types
1 parent f0dbb8b commit 5b701e2

File tree

6 files changed

+5
-200
lines changed

6 files changed

+5
-200
lines changed

src/util/c_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected]
1010
#ifndef CPROVER_UTIL_C_TYPES_H
1111
#define CPROVER_UTIL_C_TYPES_H
1212

13+
#include "mathematical_types.h"
1314
#include "std_types.h"
1415

1516
bitvector_typet index_type();

src/util/simplify_expr_int.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include "fixedbv.h"
1919
#include "ieee_float.h"
2020
#include "invariant.h"
21+
#include "mathematical_types.h"
2122
#include "namespace.h"
2223
#include "pointer_offset_size.h"
2324
#include "rational.h"

src/util/std_expr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Author: Daniel Kroening, [email protected]
1717
* \date Sun Jul 31 21:54:44 BST 2011
1818
*/
1919

20+
#include "expr_cast.h"
2021
#include "invariant.h"
22+
#include "mathematical_types.h"
2123
#include "std_types.h"
22-
#include "expr_cast.h"
23-
2424

2525
/*! \brief A transition system, consisting of
2626
state invariant, initial state predicate,

src/util/std_types.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,6 @@ constant_exprt unsignedbv_typet::largest_expr() const
197197
return from_integer(largest(), *this);
198198
}
199199

200-
/// Returns true if the type is a rational, real, integer, natural, complex,
201-
/// unsignedbv, signedbv, floatbv or fixedbv.
202-
bool is_number(const typet &type)
203-
{
204-
const irep_idt &id = type.id();
205-
return id == ID_rational || id == ID_real || id == ID_integer ||
206-
id == ID_natural || id == ID_complex || id == ID_unsignedbv ||
207-
id == ID_signedbv || id == ID_floatbv || id == ID_fixedbv;
208-
}
209-
210200
/// Identify whether a given type is constant itself or contains constant
211201
/// components.
212202
/// Examples include:

src/util/std_types.h

Lines changed: 0 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,6 @@ class void_typet:public empty_typet
5656
{
5757
};
5858

59-
/// Unbounded, signed integers (mathematical integers, not bitvectors)
60-
class integer_typet:public typet
61-
{
62-
public:
63-
integer_typet():typet(ID_integer)
64-
{
65-
}
66-
};
67-
68-
/// Natural numbers including zero (mathematical integers, not bitvectors)
69-
class natural_typet:public typet
70-
{
71-
public:
72-
natural_typet():typet(ID_natural)
73-
{
74-
}
75-
};
76-
77-
/// Unbounded, signed rational numbers
78-
class rational_typet:public typet
79-
{
80-
public:
81-
rational_typet():typet(ID_rational)
82-
{
83-
}
84-
};
85-
86-
/// Unbounded, signed real numbers
87-
class real_typet:public typet
88-
{
89-
public:
90-
real_typet():typet(ID_real)
91-
{
92-
}
93-
};
94-
9559
/// A reference into the symbol table
9660
class symbol_typet:public typet
9761
{
@@ -1778,157 +1742,6 @@ inline vector_typet &to_vector_type(typet &type)
17781742
return static_cast<vector_typet &>(type);
17791743
}
17801744

1781-
/// Complex numbers made of pair of given subtype
1782-
class complex_typet:public type_with_subtypet
1783-
{
1784-
public:
1785-
complex_typet():type_with_subtypet(ID_complex)
1786-
{
1787-
}
1788-
1789-
explicit complex_typet(const typet &_subtype):
1790-
type_with_subtypet(ID_complex, _subtype)
1791-
{
1792-
}
1793-
};
1794-
1795-
/// Check whether a reference to a typet is a \ref complex_typet.
1796-
/// \param type Source type.
1797-
/// \return True if \param type is a \ref complex_typet.
1798-
template <>
1799-
inline bool can_cast_type<complex_typet>(const typet &type)
1800-
{
1801-
return type.id() == ID_complex;
1802-
}
1803-
1804-
/// \brief Cast a typet to a \ref complex_typet
1805-
///
1806-
/// This is an unchecked conversion. \a type must be known to be \ref
1807-
/// complex_typet. Will fail with a precondition violation if type
1808-
/// doesn't match.
1809-
///
1810-
/// \param type Source type.
1811-
/// \return Object of type \ref complex_typet.
1812-
inline const complex_typet &to_complex_type(const typet &type)
1813-
{
1814-
PRECONDITION(can_cast_type<complex_typet>(type));
1815-
return static_cast<const complex_typet &>(type);
1816-
}
1817-
1818-
/// \copydoc to_complex_type(const typet &)
1819-
inline complex_typet &to_complex_type(typet &type)
1820-
{
1821-
PRECONDITION(can_cast_type<complex_typet>(type));
1822-
return static_cast<complex_typet &>(type);
1823-
}
1824-
1825-
/// A type for mathematical functions (do not confuse with functions/methods
1826-
/// in code)
1827-
class mathematical_function_typet:public typet
1828-
{
1829-
public:
1830-
// the domain of the function is composed of zero, one, or
1831-
// many variables
1832-
class variablet:public irept
1833-
{
1834-
public:
1835-
// the identifier is optional
1836-
irep_idt get_identifier() const
1837-
{
1838-
return get(ID_identifier);
1839-
}
1840-
1841-
void set_identifier(const irep_idt &identifier)
1842-
{
1843-
return set(ID_identifier, identifier);
1844-
}
1845-
1846-
typet &type()
1847-
{
1848-
return static_cast<typet &>(add(ID_type));
1849-
}
1850-
1851-
const typet &type() const
1852-
{
1853-
return static_cast<const typet &>(find(ID_type));
1854-
}
1855-
};
1856-
1857-
using domaint=std::vector<variablet>;
1858-
1859-
mathematical_function_typet(const domaint &_domain, const typet &_codomain)
1860-
: typet(ID_mathematical_function)
1861-
{
1862-
subtypes().resize(2);
1863-
domain() = _domain;
1864-
codomain() = _codomain;
1865-
}
1866-
1867-
domaint &domain()
1868-
{
1869-
return (domaint &)subtypes()[0].subtypes();
1870-
}
1871-
1872-
const domaint &domain() const
1873-
{
1874-
return (const domaint &)subtypes()[0].subtypes();
1875-
}
1876-
1877-
variablet &add_variable()
1878-
{
1879-
auto &d=domain();
1880-
d.push_back(variablet());
1881-
return d.back();
1882-
}
1883-
1884-
/// Return the codomain, i.e., the set of values that the function maps to
1885-
/// (the "target").
1886-
typet &codomain()
1887-
{
1888-
return subtypes()[1];
1889-
}
1890-
1891-
/// \copydoc codomain()
1892-
const typet &codomain() const
1893-
{
1894-
return subtypes()[1];
1895-
}
1896-
};
1897-
1898-
/// Check whether a reference to a typet is a \ref mathematical_function_typet.
1899-
/// \param type Source type.
1900-
/// \return True if \param type is a \ref mathematical_function_typet.
1901-
template <>
1902-
inline bool can_cast_type<mathematical_function_typet>(const typet &type)
1903-
{
1904-
return type.id() == ID_mathematical_function;
1905-
}
1906-
1907-
/// \brief Cast a typet to a \ref mathematical_function_typet
1908-
///
1909-
/// This is an unchecked conversion. \a type must be known to be \ref
1910-
/// mathematical_function_typet. Will fail with a precondition violation if type
1911-
/// doesn't match.
1912-
///
1913-
/// \param type Source type.
1914-
/// \return Object of type \ref mathematical_function_typet.
1915-
inline const mathematical_function_typet &
1916-
to_mathematical_function_type(const typet &type)
1917-
{
1918-
PRECONDITION(can_cast_type<mathematical_function_typet>(type));
1919-
return static_cast<const mathematical_function_typet &>(type);
1920-
}
1921-
1922-
/// \copydoc to_mathematical_function_type(const typet &)
1923-
inline mathematical_function_typet &
1924-
to_mathematical_function_type(typet &type)
1925-
{
1926-
PRECONDITION(can_cast_type<mathematical_function_typet>(type));
1927-
return static_cast<mathematical_function_typet &>(type);
1928-
}
1929-
1930-
bool is_number(const typet &type);
1931-
19321745
bool is_constant_or_has_constant_components(
19331746
const typet &type,
19341747
const namespacet &ns);

src/util/type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Author: Daniel Kroening, [email protected]
2222
/// modeled with two subs named “subtype” (a single type) and “subtypes”
2323
/// (a vector of types). The class typet only adds specialized methods
2424
/// for accessing the subtype information to the interface of irept.
25-
/// For pre-defined types see `std_types.h`.
25+
/// For pre-defined types see `std_types.h` and `mathematical_types.h`.
2626
class typet:public irept
2727
{
2828
public:

0 commit comments

Comments
 (0)