retdec
while_loop_stmt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_WHILE_LOOP_STMT_H
8 #define RETDEC_LLVMIR2HLL_IR_WHILE_LOOP_STMT_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class Visitor;
18 
25 class WhileLoopStmt final: public Statement {
26 public:
29 
30  virtual ShPtr<Value> clone() override;
31  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
32  virtual bool isCompound() override { return true; }
33  virtual void replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) override;
34  virtual ShPtr<Expression> asExpression() const override;
35 
37  ShPtr<Statement> getBody() const;
38 
39  void setCondition(ShPtr<Expression> newCond);
40  void setBody(ShPtr<Statement> newBody);
41 
44  virtual void update(ShPtr<Value> subject, ShPtr<Value> arg = nullptr) override;
46 
49  virtual void accept(Visitor *v) override;
51 
52 private:
53  // Since instances are created by calling the static function create(), the
54  // constructor can be private.
57 
58 private:
61 
64 };
65 
66 } // namespace llvmir2hll
67 } // namespace retdec
68 
69 #endif
Definition: address.h:21
static const uint64_t Undefined
Definition: address.h:47
A representation of a program statement.
Definition: statement.h:39
ShPtr< Statement > succ
Successor statement.
Definition: statement.h:141
A base class of all visitors.
Definition: visitor.h:95
A while loop statement.
Definition: while_loop_stmt.h:25
WhileLoopStmt(ShPtr< Expression > cond, ShPtr< Statement > body, Address a=Address::Undefined)
Constructs a new while loop statement.
Definition: while_loop_stmt.cpp:21
ShPtr< Expression > getCondition() const
Returns the loop condition.
Definition: while_loop_stmt.cpp:59
static ShPtr< WhileLoopStmt > create(ShPtr< Expression > cond, ShPtr< Statement > body, ShPtr< Statement > succ=nullptr, Address a=Address::Undefined)
Constructs a new while loop statement.
Definition: while_loop_stmt.cpp:112
void setBody(ShPtr< Statement > newBody)
Sets a new body.
Definition: while_loop_stmt.cpp:90
ShPtr< Statement > body
Loop body.
Definition: while_loop_stmt.h:63
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current statement.
Definition: while_loop_stmt.cpp:43
void setCondition(ShPtr< Expression > newCond)
Sets a condition.
Definition: while_loop_stmt.cpp:76
virtual ShPtr< Expression > asExpression() const override
Returns the statement as an expression.
Definition: while_loop_stmt.cpp:51
ShPtr< Expression > cond
Loop condition.
Definition: while_loop_stmt.h:60
ShPtr< Statement > getBody() const
Returns the loop body.
Definition: while_loop_stmt.cpp:66
virtual bool isCompound() override
Returns true if the statement is a compound statement, false otherwise.
Definition: while_loop_stmt.h:32
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: while_loop_stmt.cpp:162
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: while_loop_stmt.cpp:33
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: while_loop_stmt.cpp:147
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: while_loop_stmt.cpp:25
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.
A representation of a program statement.