retdec
for_loop_stmt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_FOR_LOOP_STMT_H
8 #define RETDEC_LLVMIR2HLL_IR_FOR_LOOP_STMT_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class Variable;
18 class Visitor;
19 
26 class ForLoopStmt final: public Statement {
27 public:
32 
33  virtual ShPtr<Value> clone() override;
34  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
35  virtual bool isCompound() override { return true; }
36  virtual void replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) override;
37  virtual ShPtr<Expression> asExpression() const override;
38 
39  ShPtr<Variable> getIndVar() const;
42  ShPtr<Expression> getStep() const;
43  ShPtr<Statement> getBody() const;
44 
45  void setIndVar(ShPtr<Variable> newIndVar);
46  void setStartValue(ShPtr<Expression> newStartValue);
47  void setEndCond(ShPtr<Expression> newEndCond);
48  void setStep(ShPtr<Expression> newStep);
49  void setBody(ShPtr<Statement> newBody);
50 
53  virtual void update(ShPtr<Value> subject, ShPtr<Value> arg = nullptr) override;
55 
58  virtual void accept(Visitor *v) override;
60 
61 private:
62  // Since instances are created by calling the static function create(), the
63  // constructor can be private.
67 
68 private:
71 
74 
77 
80 
83 };
84 
85 } // namespace llvmir2hll
86 } // namespace retdec
87 
88 #endif
Definition: address.h:21
static const uint64_t Undefined
Definition: address.h:47
A for loop statement.
Definition: for_loop_stmt.h:26
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: for_loop_stmt.cpp:284
ShPtr< Expression > step
Step.
Definition: for_loop_stmt.h:79
ShPtr< Expression > getStep() const
Returns the step.
Definition: for_loop_stmt.cpp:111
ShPtr< Variable > getIndVar() const
Returns the induction variable.
Definition: for_loop_stmt.cpp:90
ShPtr< Statement > getBody() const
Returns the body.
Definition: for_loop_stmt.cpp:118
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current statement.
Definition: for_loop_stmt.cpp:53
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: for_loop_stmt.cpp:255
virtual ShPtr< Expression > asExpression() const override
Returns the statement as an expression.
Definition: for_loop_stmt.cpp:82
void setStep(ShPtr< Expression > newStep)
Sets a new step.
Definition: for_loop_stmt.cpp:170
ShPtr< Expression > endCond
End condition.
Definition: for_loop_stmt.h:76
virtual bool isCompound() override
Returns true if the statement is a compound statement, false otherwise.
Definition: for_loop_stmt.h:35
void setBody(ShPtr< Statement > newBody)
Sets a new body.
Definition: for_loop_stmt.cpp:184
ForLoopStmt(ShPtr< Variable > indVar, ShPtr< Expression > startValue, ShPtr< Expression > endCond, ShPtr< Expression > step, ShPtr< Statement > body, Address a)
Constructs a new for loop statement.
Definition: for_loop_stmt.cpp:21
static ShPtr< ForLoopStmt > create(ShPtr< Variable > indVar, ShPtr< Expression > startValue, ShPtr< Expression > endCond, ShPtr< Expression > step, ShPtr< Statement > body, ShPtr< Statement > succ=nullptr, Address a=Address::Undefined)
Constructs a new for loop statement.
Definition: for_loop_stmt.cpp:212
ShPtr< Variable > indVar
Induction variable.
Definition: for_loop_stmt.h:70
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: for_loop_stmt.cpp:40
void setStartValue(ShPtr< Expression > newStartValue)
Sets a new start value.
Definition: for_loop_stmt.cpp:142
ShPtr< Expression > getEndCond() const
Returns the end condition.
Definition: for_loop_stmt.cpp:104
void setIndVar(ShPtr< Variable > newIndVar)
Sets a new induction variable.
Definition: for_loop_stmt.cpp:128
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: for_loop_stmt.cpp:27
ShPtr< Expression > startValue
Starting value.
Definition: for_loop_stmt.h:73
ShPtr< Expression > getStartValue() const
Returns the starting value.
Definition: for_loop_stmt.cpp:97
ShPtr< Statement > body
Body.
Definition: for_loop_stmt.h:82
void setEndCond(ShPtr< Expression > newEndCond)
Sets a new end condition.
Definition: for_loop_stmt.cpp:156
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 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.