Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Type.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_EXPRESSIONS_EXPRESSIONRETURNTYPE_H_
2#define STORM_STORAGE_EXPRESSIONS_EXPRESSIONRETURNTYPE_H_
3
4#include <cstdint>
5#include <iosfwd>
6#include <memory>
7
8namespace storm {
9namespace expressions {
10class ExpressionManager;
11class BaseType;
12
13class Type {
14 public:
15 friend bool operator<(storm::expressions::Type const& type1, storm::expressions::Type const& type2);
16
17 Type();
18
25 Type(std::shared_ptr<ExpressionManager const> const& manager, std::shared_ptr<BaseType> const& innerType);
26
33 bool operator==(Type const& other) const;
34
40 uint64_t getMask() const;
41
47 std::string getStringRepresentation() const;
48
54 bool isBooleanType() const;
55
61 bool isIntegerType() const;
62
68 bool isBitVectorType() const;
69
75 bool isRationalType() const;
76
82 bool isNumericalType() const;
83
89 bool isArrayType() const;
90
96 bool isTranscendentalNumberType() const;
97
103 std::size_t getWidth() const;
104
110 Type getElementType() const;
111
118
119 // Functions that, given the input types, produce the output type of the corresponding function application.
120 Type plusMinusTimes(Type const& other) const;
121 Type minus() const;
122 Type divide(Type const& other) const;
123 Type modulo(Type const& other) const;
124 Type logarithm(Type const& other) const;
125 Type power(Type const& other, bool allowIntegerType = false) const;
126 Type trigonometric() const;
127 Type logicalConnective(Type const& other) const;
128 Type logicalConnective() const;
129 Type numericalComparison(Type const& other) const;
130 Type ite(Type const& thenType, Type const& elseType) const;
131 Type floorCeil() const;
132 Type minimumMaximum(Type const& other) const;
133
134 private:
135 // The manager responsible for the type.
136 std::shared_ptr<ExpressionManager const> manager;
137
138 // The encapsulated type.
139 std::shared_ptr<BaseType> innerType;
140};
141
142std::ostream& operator<<(std::ostream& stream, Type const& type);
143
144bool operator<(storm::expressions::Type const& type1, storm::expressions::Type const& type2);
145
146class BaseType {
147 public:
148 BaseType();
149 virtual ~BaseType() = default;
150
156 virtual uint64_t getMask() const = 0;
157
164 virtual bool operator==(BaseType const& other) const;
165
171 virtual std::string getStringRepresentation() const = 0;
172
173 virtual bool isErrorType() const;
174 virtual bool isBooleanType() const;
175 virtual bool isIntegerType() const;
176 virtual bool isBitVectorType() const;
177 virtual bool isRationalType() const;
178 virtual bool isArrayType() const;
179 virtual bool isTranscendentalNumberType() const;
180};
181
182class BooleanType : public BaseType {
183 public:
184 virtual uint64_t getMask() const override;
185 virtual std::string getStringRepresentation() const override;
186 virtual bool isBooleanType() const override;
187
188 private:
189 static const uint64_t mask = (1ull << 56);
190};
191
192class IntegerType : public BaseType {
193 public:
194 virtual uint64_t getMask() const override;
195 virtual std::string getStringRepresentation() const override;
196 virtual bool isIntegerType() const override;
197
198 private:
199 static const uint64_t mask = (1ull << 58);
200};
201
202class BitVectorType : public BaseType {
203 public:
209 BitVectorType(std::size_t width);
210
216 std::size_t getWidth() const;
217
218 virtual bool operator==(BaseType const& other) const override;
219 virtual uint64_t getMask() const override;
220 virtual std::string getStringRepresentation() const override;
221 virtual bool isIntegerType() const override;
222 virtual bool isBitVectorType() const override;
223
224 private:
225 static const uint64_t mask = (1ull << 57);
226
227 // The bit width of the type.
228 std::size_t width;
229};
230
231class RationalType : public BaseType {
232 public:
233 virtual uint64_t getMask() const override;
234 virtual std::string getStringRepresentation() const override;
235 virtual bool isRationalType() const override;
236
237 private:
238 static const uint64_t mask = (1ull << 59);
239};
240
241class ArrayType : public BaseType {
242 public:
243 ArrayType(Type elementType);
244
245 Type getElementType() const;
246
247 virtual bool operator==(BaseType const& other) const override;
248 virtual uint64_t getMask() const override;
249 virtual std::string getStringRepresentation() const override;
250 virtual bool isArrayType() const override;
251
252 private:
253 static const uint64_t mask = (1ull << 55);
254
255 // The type of the array elements (can again be of type array).
256 Type elementType;
257};
258
260 public:
261 virtual uint64_t getMask() const override;
262 virtual std::string getStringRepresentation() const override;
263 virtual bool isTranscendentalNumberType() const override;
264
265 private:
266 static const uint64_t mask = (1ull << 60);
267};
268
269class ErrorType : public BaseType {
270 public:
271 virtual uint64_t getMask() const override;
272 virtual std::string getStringRepresentation() const override;
273 virtual bool isErrorType() const override;
274
275 private:
276 static const uint64_t mask = 0;
277};
278
279bool operator<(BaseType const& first, BaseType const& second);
280} // namespace expressions
281} // namespace storm
282
283namespace std {
284// Provide a hashing operator, so we can put types in unordered collections.
285template<>
286struct hash<storm::expressions::Type> {
287 std::size_t operator()(storm::expressions::Type const& type) const {
288 return std::hash<uint64_t>()(type.getMask());
289 }
290};
291} // namespace std
292
293#endif /* STORM_STORAGE_EXPRESSIONS_EXPRESSIONRETURNTYPE_H_ */
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:137
Type getElementType() const
Definition Type.cpp:125
virtual bool operator==(BaseType const &other) const override
Checks whether two types are actually the same.
Definition Type.cpp:129
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:133
virtual bool isArrayType() const override
Definition Type.cpp:65
virtual bool isBooleanType() const
Definition Type.cpp:25
virtual bool isIntegerType() const
Definition Type.cpp:33
virtual std::string getStringRepresentation() const =0
Returns a string representation of the type.
virtual bool isArrayType() const
Definition Type.cpp:61
virtual bool operator==(BaseType const &other) const
Checks whether two types are actually the same.
Definition Type.cpp:17
virtual bool isTranscendentalNumberType() const
Definition Type.cpp:69
virtual bool isRationalType() const
Definition Type.cpp:53
virtual bool isBitVectorType() const
Definition Type.cpp:45
virtual bool isErrorType() const
Definition Type.cpp:21
virtual ~BaseType()=default
virtual uint64_t getMask() const =0
Retrieves the mask that is associated with this type.
virtual bool operator==(BaseType const &other) const override
Checks whether two types are actually the same.
Definition Type.cpp:109
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:101
std::size_t getWidth() const
Retrieves the bit width of the bounded type.
Definition Type.cpp:105
virtual bool isIntegerType() const override
Definition Type.cpp:41
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:97
virtual bool isBitVectorType() const override
Definition Type.cpp:49
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:77
virtual bool isBooleanType() const override
Definition Type.cpp:29
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:81
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
virtual bool isErrorType() const override
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual bool isIntegerType() const override
Definition Type.cpp:37
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:89
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:85
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:117
virtual bool isRationalType() const override
Definition Type.cpp:57
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:113
virtual bool isTranscendentalNumberType() const override
Definition Type.cpp:73
virtual uint64_t getMask() const override
Retrieves the mask that is associated with this type.
Definition Type.cpp:141
virtual std::string getStringRepresentation() const override
Returns a string representation of the type.
Definition Type.cpp:145
Type minus() const
Definition Type.cpp:227
Type getElementType() const
Retrieves the element type of the type, provided that it is an Array type.
Definition Type.cpp:210
bool isBooleanType() const
Checks whether this type is a boolean type.
Definition Type.cpp:178
Type modulo(Type const &other) const
Definition Type.cpp:239
bool operator==(Type const &other) const
Checks whether two types are the same.
Definition Type.cpp:170
friend bool operator<(storm::expressions::Type const &type1, storm::expressions::Type const &type2)
Definition Type.cpp:301
Type logarithm(Type const &other) const
Definition Type.cpp:244
Type divide(Type const &other) const
Definition Type.cpp:232
Type power(Type const &other, bool allowIntegerType=false) const
Definition Type.cpp:249
storm::expressions::ExpressionManager const & getManager() const
Retrieves the manager of the type.
Definition Type.cpp:218
std::size_t getWidth() const
Retrieves the bit width of the type, provided that it is a bitvector type.
Definition Type.cpp:206
Type numericalComparison(Type const &other) const
Definition Type.cpp:274
Type plusMinusTimes(Type const &other) const
Definition Type.cpp:222
Type logicalConnective() const
Definition Type.cpp:269
bool isIntegerType() const
Checks whether this type is an integral type.
Definition Type.cpp:182
bool isNumericalType() const
Checks whether this type is a numerical type.
Definition Type.cpp:190
bool isArrayType() const
Checks whether this type is an array type.
Definition Type.cpp:194
std::string getStringRepresentation() const
Retrieves a string representation of the type.
Definition Type.cpp:202
Type ite(Type const &thenType, Type const &elseType) const
Definition Type.cpp:279
uint64_t getMask() const
Retrieves the bit mask of the type.
Definition Type.cpp:174
bool isRationalType() const
Checks whether this type is a rational type.
Definition Type.cpp:214
bool isTranscendentalNumberType() const
Checks whether this type is a transcendental number type.
Definition Type.cpp:198
Type trigonometric() const
Definition Type.cpp:259
bool isBitVectorType() const
Checks whether this type is a bitvector type.
Definition Type.cpp:186
Type minimumMaximum(Type const &other) const
Definition Type.cpp:296
Type floorCeil() const
Definition Type.cpp:291
Expression operator<(Expression const &first, Expression const &second)
std::ostream & operator<<(std::ostream &stream, BaseExpression const &expression)
LabParser.cpp.
Definition cli.cpp:18