retdec
call_expr.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_CALL_EXPR_H
8 #define RETDEC_LLVMIR2HLL_IR_CALL_EXPR_H
9 
10 #include <cstddef>
11 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
19 class Visitor;
20 
27 class CallExpr final: public Expression {
28 public:
31 
32  virtual ShPtr<Value> clone() override;
33  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
34  virtual ShPtr<Type> getType() const override;
35  virtual void replace(ShPtr<Expression> oldExpr,
36  ShPtr<Expression> newExpr) override;
37 
39  bool hasArg(std::size_t n) const;
40  ShPtr<Expression> getArg(std::size_t n) const;
41  const ExprVector &getArgs() const;
42  std::size_t getNumOfArgs() const;
43 
44  void setCalledExpr(ShPtr<Expression> newCalledExpr);
45  void setArgs(ExprVector newArgs);
46  void setArg(std::size_t position, ShPtr<Expression> newArg);
47  void replaceArg(ShPtr<Expression> oldArg, ShPtr<Expression> newArg);
48 
51  virtual void update(ShPtr<Value> subject,
52  ShPtr<Value> arg = nullptr) override;
54 
57  virtual void accept(Visitor *v) override;
59 
60 private:
61  // Since instances are created by calling the static function create(), the
62  // constructor can be private.
64 
65 private:
68 
71 };
72 
73 } // namespace llvmir2hll
74 } // namespace retdec
75 
76 #endif
A call expression.
Definition: call_expr.h:27
void setArgs(ExprVector newArgs)
Sets a new argument list.
Definition: call_expr.cpp:167
virtual ShPtr< Type > getType() const override
Returns the type of the expression.
Definition: call_expr.cpp:71
ShPtr< Expression > getCalledExpr() const
Returns the expression called by this call.
Definition: call_expr.cpp:100
ShPtr< Expression > getArg(std::size_t n) const
Returns the n-th argument.
Definition: call_expr.cpp:142
bool hasArg(std::size_t n) const
Returns true if the call has an n-th argument, false otherwise.
Definition: call_expr.cpp:126
std::size_t getNumOfArgs() const
Returns the number of arguments in the call.
Definition: call_expr.cpp:114
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: call_expr.cpp:39
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current expression.
Definition: call_expr.cpp:75
ShPtr< Expression > calledExpr
Expression that is called by this call.
Definition: call_expr.h:67
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: call_expr.cpp:265
void setArg(std::size_t position, ShPtr< Expression > newArg)
Sets a new argument to the given position.
Definition: call_expr.cpp:187
const ExprVector & getArgs() const
Returns the argument list.
Definition: call_expr.cpp:107
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: call_expr.cpp:284
CallExpr(ShPtr< Expression > calledExpr, ExprVector args)
Constructs a new call expression.
Definition: call_expr.cpp:23
ExprVector args
Arguments.
Definition: call_expr.h:70
void setCalledExpr(ShPtr< Expression > newCalledExpr)
Sets a new called expression.
Definition: call_expr.cpp:156
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: call_expr.cpp:26
void replaceArg(ShPtr< Expression > oldArg, ShPtr< Expression > newArg)
Replaces oldArg with newArg.
Definition: call_expr.cpp:212
static ShPtr< CallExpr > create(ShPtr< Expression > calledExpr, ExprVector args=ExprVector())
Creates a new call expression.
Definition: call_expr.cpp:232
A base class of all expressions.
Definition: expression.h:23
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
std::vector< ShPtr< Expression > > ExprVector
Vector of expressions.
Definition: types.h:99
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.
Aliases for several useful types.