retdec
assign_stmt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_ASSIGN_STMT_H
8 #define RETDEC_LLVMIR2HLL_IR_ASSIGN_STMT_H
9 
12 
13 namespace retdec {
14 namespace llvmir2hll {
15 
16 class Expression;
17 class Variable;
18 class Visitor;
19 
26 class AssignStmt final: public Statement {
27 public:
30 
31  virtual ShPtr<Value> clone() override;
32  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
33  virtual bool isCompound() override { return false; }
34  virtual void replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) override;
35  virtual ShPtr<Expression> asExpression() const override;
36 
37  ShPtr<Expression> getLhs() const;
38  ShPtr<Expression> getRhs() const;
39 
40  void setLhs(ShPtr<Expression> left);
41  void setRhs(ShPtr<Expression> right);
42 
45  virtual void update(ShPtr<Value> subject, ShPtr<Value> arg = nullptr) override;
47 
50  virtual void accept(Visitor *v) override;
52 
53 private:
54  // Since instances are created by calling the static function create(), the
55  // constructor can be private.
58 
59 private:
62 
65 };
66 
67 } // namespace llvmir2hll
68 } // namespace retdec
69 
70 #endif
Definition: address.h:21
static const uint64_t Undefined
Definition: address.h:47
An assignment statement.
Definition: assign_stmt.h:26
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: assign_stmt.cpp:33
virtual ShPtr< Expression > asExpression() const override
Returns the statement as an expression.
Definition: assign_stmt.cpp:56
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current statement.
Definition: assign_stmt.cpp:42
virtual bool isCompound() override
Returns true if the statement is a compound statement, false otherwise.
Definition: assign_stmt.h:33
ShPtr< Expression > lhs
Left-hand side of the assignment.
Definition: assign_stmt.h:61
void setLhs(ShPtr< Expression > left)
Set the left-hand side of the assignment.
Definition: assign_stmt.cpp:80
void setRhs(ShPtr< Expression > right)
Set the right-hand side of the assignment.
Definition: assign_stmt.cpp:94
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: assign_stmt.cpp:164
ShPtr< Expression > getRhs() const
Returns the left-hand side of the assignment.
Definition: assign_stmt.cpp:70
static ShPtr< AssignStmt > create(ShPtr< Expression > lhs, ShPtr< Expression > rhs, ShPtr< Statement > succ=nullptr, Address a=Address::Undefined)
Creates a new assignment statement.
Definition: assign_stmt.cpp:113
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: assign_stmt.cpp:148
ShPtr< Expression > rhs
Right-hand side of the assignment.
Definition: assign_stmt.h:64
AssignStmt(ShPtr< Expression > lhs, ShPtr< Expression > rhs, Address a=Address::Undefined)
Constructs a new assignment statement.
Definition: assign_stmt.cpp:22
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: assign_stmt.cpp:25
ShPtr< Expression > getLhs() const
Returns the left-hand side of the assignment.
Definition: assign_stmt.cpp:63
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.