retdec
const_bool.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_CONST_BOOL_H
8 #define RETDEC_LLVMIR2HLL_IR_CONST_BOOL_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class IntType;
18 class Visitor;
19 
26 class ConstBool final: public Constant {
27 public:
29  using Type = bool;
30 
31 public:
33 
34  virtual ShPtr<Value> clone() override;
35 
36  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
37  virtual ShPtr<retdec::llvmir2hll::Type> getType() const override;
38  virtual void replace(ShPtr<Expression> oldExpr,
39  ShPtr<Expression> newExpr) override;
40 
41  Type getValue() const;
42  bool isTrue() const;
43  bool isFalse() const;
44 
47  virtual void accept(Visitor *v) override;
49 
50 private:
53 
56 
57 private:
58  // Since instances are created by calling the static function create(), the
59  // constructor can be private.
60  explicit ConstBool(Type value = Type());
61 };
62 
63 } // namespace llvmir2hll
64 } // namespace retdec
65 
66 #endif
A bool constant.
Definition: const_bool.h:26
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current expression.
Definition: const_bool.cpp:41
Type getValue() const
Returns the constant's value.
Definition: const_bool.cpp:50
ShPtr< IntType > type
Type of the constant.
Definition: const_bool.h:55
Type value
Value of the constant.
Definition: const_bool.h:52
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: const_bool.cpp:84
bool Type
Underlying bool type.
Definition: const_bool.h:29
static ShPtr< ConstBool > create(Type value=Type())
Constructs a bool constant initialized to the given value.
Definition: const_bool.cpp:80
virtual ShPtr< retdec::llvmir2hll::Type > getType() const override
Returns the type of the expression.
Definition: const_bool.cpp:37
bool isFalse() const
Determines if the value of the constant is false.
Definition: const_bool.cpp:68
ConstBool(Type value=Type())
Constructs a bool constant initialized to the given value.
Definition: const_bool.cpp:20
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: const_bool.cpp:23
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: const_bool.cpp:29
bool isTrue() const
Determines if the value of the constant is true.
Definition: const_bool.cpp:59
A base class for all constants.
Definition: constant.h:20
A base class of all visitors.
Definition: visitor.h:95
A base class for all constants.
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.