retdec
ternary_op_expr.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_TERNARY_OP_EXPR_H
8 #define RETDEC_LLVMIR2HLL_IR_TERNARY_OP_EXPR_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
24 class TernaryOpExpr final: public Expression {
25 public:
28 
29  virtual ShPtr<Value> clone() override;
30 
31  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
32  virtual ShPtr<Type> getType() const override;
33  virtual void replace(ShPtr<Expression> oldExpr,
34  ShPtr<Expression> newExpr) override;
35 
39 
40  void setCondition(ShPtr<Expression> newCond);
41  void setTrueValue(ShPtr<Expression> newTrueValue);
42  void setFalseValue(ShPtr<Expression> newFalseValue);
43 
46  virtual void update(ShPtr<Value> subject,
47  ShPtr<Value> arg = nullptr) override;
49 
52  virtual void accept(Visitor *v) override;
54 
55 private:
56  // Since instances are created by calling the static function create(), the
57  // constructor can be private.
60 private:
63 
66 
69 };
70 
71 } // namespace llvmir2hll
72 } // namespace retdec
73 
74 #endif
A base class of all expressions.
Definition: expression.h:23
A ternary operator.
Definition: ternary_op_expr.h:24
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: ternary_op_expr.cpp:201
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current expression.
Definition: ternary_op_expr.cpp:51
void setFalseValue(ShPtr< Expression > newFalseValue)
Sets the false value.
Definition: ternary_op_expr.cpp:128
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: ternary_op_expr.cpp:33
ShPtr< Expression > falseValue
False value.
Definition: ternary_op_expr.h:68
ShPtr< Expression > cond
Condition.
Definition: ternary_op_expr.h:62
TernaryOpExpr(ShPtr< Expression > cond, ShPtr< Expression > trueValue, ShPtr< Expression > falseValue)
Constructs a ternary operator.
Definition: ternary_op_expr.cpp:20
void setTrueValue(ShPtr< Expression > newTrueValue)
Sets the true value.
Definition: ternary_op_expr.cpp:114
ShPtr< Expression > trueValue
True value.
Definition: ternary_op_expr.h:65
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the operator according to the changes of subject.
Definition: ternary_op_expr.cpp:183
static ShPtr< TernaryOpExpr > create(ShPtr< Expression > cond, ShPtr< Expression > trueValue, ShPtr< Expression > falseValue)
Creates a new ternary operator.
Definition: ternary_op_expr.cpp:148
void setCondition(ShPtr< Expression > newCond)
Sets the condition.
Definition: ternary_op_expr.cpp:100
ShPtr< Expression > getCondition() const
Returns the operator condition.
Definition: ternary_op_expr.cpp:76
ShPtr< Expression > getTrueValue() const
Returns the true value.
Definition: ternary_op_expr.cpp:83
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: ternary_op_expr.cpp:24
virtual ShPtr< Type > getType() const override
Returns the type of the expression.
Definition: ternary_op_expr.cpp:43
ShPtr< Expression > getFalseValue() const
Returns the false value.
Definition: ternary_op_expr.cpp:90
A base class of all visitors.
Definition: visitor.h:95
A base class of all expressions.
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.