retdec
ufor_loop_stmt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_UFOR_LOOP_STMT_H
8 #define RETDEC_LLVMIR2HLL_IR_UFOR_LOOP_STMT_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class Value;
18 
30 class UForLoopStmt final: public Statement {
31 public:
37  ShPtr<Statement> succ = nullptr,
39  );
40 
41  virtual ShPtr<Value> clone() override;
42  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
43  virtual bool isCompound() override { return true; }
44  virtual void replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) override;
45  virtual ShPtr<Expression> asExpression() const override;
46 
47  ShPtr<Expression> getInit() const;
48  ShPtr<Expression> getCond() const;
49  ShPtr<Expression> getStep() const;
50  ShPtr<Statement> getBody() const;
51 
52  void setInit(ShPtr<Expression> newInit);
53  void setCond(ShPtr<Expression> newCond);
54  void setStep(ShPtr<Expression> newStep);
55  void setBody(ShPtr<Statement> newBody);
56 
57  bool isInitDefinition() const;
58  void markInitAsDefinition();
59 
62  virtual void update(ShPtr<Value> subject, ShPtr<Value> arg = nullptr) override;
64 
67  virtual void accept(Visitor *v) override;
69 
70 private:
71  // Since instances are created by calling the static function create(), the
72  // constructor can be private.
79  );
80 
83 
86 
89 
92 
95 };
96 
97 } // namespace llvmir2hll
98 } // namespace retdec
99 
100 #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 universal for loop statement.
Definition: ufor_loop_stmt.h:30
ShPtr< Expression > getStep() const
Returns the step part.
Definition: ufor_loop_stmt.cpp:95
ShPtr< Expression > cond
Conditional part.
Definition: ufor_loop_stmt.h:88
virtual ShPtr< Expression > asExpression() const override
Returns the statement as an expression.
Definition: ufor_loop_stmt.cpp:73
ShPtr< Expression > getInit() const
Returns the initialization part.
Definition: ufor_loop_stmt.cpp:81
void setStep(ShPtr< Expression > newStep)
Sets a new step part.
Definition: ufor_loop_stmt.cpp:140
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: ufor_loop_stmt.cpp:259
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: ufor_loop_stmt.cpp:42
bool initIsDefinition
Is the initialization part a definition?
Definition: ufor_loop_stmt.h:85
void markInitAsDefinition()
Marks the initialization part of the statement as a definition of the variable assigned in the part.
Definition: ufor_loop_stmt.cpp:173
ShPtr< Statement > body
Body.
Definition: ufor_loop_stmt.h:94
static ShPtr< UForLoopStmt > create(ShPtr< Expression > init, ShPtr< Expression > cond, ShPtr< Expression > step, ShPtr< Statement > body, ShPtr< Statement > succ=nullptr, Address a=Address::Undefined)
Constructs a new universal for loop statement.
Definition: ufor_loop_stmt.cpp:190
ShPtr< Statement > getBody() const
Returns the body.
Definition: ufor_loop_stmt.cpp:102
void setInit(ShPtr< Expression > newInit)
Sets a new initialization part.
Definition: ufor_loop_stmt.cpp:112
ShPtr< Expression > getCond() const
Returns the conditional part.
Definition: ufor_loop_stmt.cpp:88
virtual bool isCompound() override
Returns true if the statement is a compound statement, false otherwise.
Definition: ufor_loop_stmt.h:43
void setCond(ShPtr< Expression > newCond)
Sets a new conditional part.
Definition: ufor_loop_stmt.cpp:126
ShPtr< Expression > step
Step part.
Definition: ufor_loop_stmt.h:91
void setBody(ShPtr< Statement > newBody)
Sets a new body.
Definition: ufor_loop_stmt.cpp:154
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current statement.
Definition: ufor_loop_stmt.cpp:53
bool isInitDefinition() const
Is the initialization part a definition of a variable?
Definition: ufor_loop_stmt.cpp:165
ShPtr< Expression > init
Initialization part.
Definition: ufor_loop_stmt.h:82
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: ufor_loop_stmt.cpp:236
UForLoopStmt(ShPtr< Expression > init, ShPtr< Expression > cond, ShPtr< Expression > step, ShPtr< Statement > body, Address a=Address::Undefined)
Constructs a new universal for loop statement.
Definition: ufor_loop_stmt.cpp:20
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: ufor_loop_stmt.cpp:29
A base class of all visitors.
Definition: visitor.h:95
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.