Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Constant.cpp
Go to the documentation of this file.
4
5namespace storm {
6namespace prism {
7Constant::Constant(storm::expressions::Variable const& variable, storm::expressions::Expression const& expression, std::string const& filename,
8 uint_fast64_t lineNumber)
9 : LocatedInformation(filename, lineNumber), variable(variable), expression(expression) {
10 // Intentionally left empty.
11}
12
13Constant::Constant(storm::expressions::Variable const& variable, std::string const& filename, uint_fast64_t lineNumber)
14 : LocatedInformation(filename, lineNumber), variable(variable), expression() {
15 // Intentionally left empty.
16}
17
18std::string const& Constant::getName() const {
19 return this->variable.getName();
20}
21
25
27 return this->variable;
28}
29
30bool Constant::isDefined() const {
31 return this->expression.isInitialized();
32}
33
35 return this->expression;
36}
37
38Constant Constant::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) const {
39 if (!this->isDefined()) {
40 return *this;
41 } else {
42 return Constant(variable, this->getExpression().substitute(substitution), this->getFilename(), this->getLineNumber());
43 }
44}
45
46std::ostream& operator<<(std::ostream& stream, Constant const& constant) {
47 stream << "const ";
48 if (constant.getType().isRationalType()) {
49 stream << "double" << " ";
50 } else {
51 stream << constant.getType() << " ";
52 }
53 stream << constant.getName();
54 if (constant.isDefined()) {
55 stream << " = " << constant.getExpression();
56 }
57 stream << ";";
58 return stream;
59}
60
61bool operator==(Constant const& lhs, Constant const& rhs) {
63}
64} // namespace prism
65} // namespace storm
bool isSyntacticallyEqual(storm::expressions::Expression const &other) const
Checks whether the two expressions are syntatically the same.
bool isInitialized() const
Checks whether the object encapsulates a base-expression.
bool isRationalType() const
Checks whether this type is a rational type.
Definition Type.cpp:214
Type const & getType() const
Retrieves the type of the variable.
Definition Variable.cpp:50
std::string const & getName() const
Retrieves the name of the variable.
Definition Variable.cpp:46
bool isDefined() const
Retrieves whether the constant is defined, i.e., whether there is an expression defining its value.
Definition Constant.cpp:30
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the expression variable associated with this constant.
Definition Constant.cpp:26
std::string const & getName() const
Retrieves the name of the constant.
Definition Constant.cpp:18
Constant substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution) const
Substitutes all identifiers in the constant according to the given map.
Definition Constant.cpp:38
storm::expressions::Type const & getType() const
Retrieves the type of the constant.
Definition Constant.cpp:22
storm::expressions::Expression const & getExpression() const
Retrieves the expression that defines the constant.
Definition Constant.cpp:34
uint_fast64_t getLineNumber() const
Retrieves the line number in which the information was found.
std::string const & getFilename() const
Retrieves the name of the file in which the information was found.
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)
bool operator==(Constant const &lhs, Constant const &rhs)
Definition Constant.cpp:61
LabParser.cpp.
Definition cli.cpp:18