7 #ifndef RETDEC_LLVMIR2HLL_IR_FUNCTION_H
8 #define RETDEC_LLVMIR2HLL_IR_FUNCTION_H
45 const std::string &
getName()
const;
68 void setName(
const std::string &newName);
A representation of a function.
Definition: function.h:33
void replaceLocalVar(ShPtr< Variable > oldVar, ShPtr< Variable > newVar)
Replaces oldVar with newVar.
Definition: function.cpp:398
VarSet localVars
Local variables, including parameters.
Definition: function.h:102
void removeParam(ShPtr< Variable > param)
Removes the given parameter.
Definition: function.cpp:438
Address getStartAddress() const
Definition: function.cpp:245
ShPtr< Variable > funcVar
Definition: function.h:109
void convertToDeclaration()
Makes the function to be a declaration.
Definition: function.cpp:485
WkPtr< Module > module
The module to which the function belongs.
Definition: function.h:93
void addParam(ShPtr< Variable > var)
Adds a new parameter to the function.
Definition: function.cpp:342
void removeLocalVar(ShPtr< Variable > var)
Removes the given variable from the set of local variables.
Definition: function.cpp:422
const VarVector & getParams() const
Returns function parameters.
Definition: function.cpp:116
void addLocalVar(ShPtr< Variable > var)
Adds a new local variable to the function.
Definition: function.cpp:364
Address getEndAddress() const
Definition: function.cpp:249
void setBody(ShPtr< Statement > newBody)
Sets a new body.
Definition: function.cpp:452
void updateUnderlyingVarType()
Updates the type of the underlying variable.
Definition: function.cpp:618
bool isDeclaration() const
Returns true if the function is just a declaration, false otherwise.
Definition: function.cpp:265
void setLocalVars(VarSet newLocalVars)
Sets a new set of local variables.
Definition: function.cpp:332
void setRetType(ShPtr< Type > newRetType)
Sets a new return type;.
Definition: function.cpp:300
ShPtr< Statement > body
Function body.
Definition: function.h:105
ShPtr< Type > getRetType() const
Returns function type.
Definition: function.cpp:93
void setParams(VarVector newParams)
Sets a new parameter list.
Definition: function.cpp:316
ShPtr< Module > getModule() const
Definition: function.cpp:234
ShPtr< Variable > getAsVar() const
Returns a variable corresponding the function.
Definition: function.cpp:220
void setVarArg(bool isVarArg=true)
Sets the function's status concerning the number of arguments it takes.
Definition: function.cpp:469
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the statement according to the changes of subject.
Definition: function.cpp:553
bool hasParam(ShPtr< Variable > var) const
Returns true if var is a parameter of the function, false otherwise.
Definition: function.cpp:280
std::size_t getNumOfLocalVars(bool includeParams=false) const
Returns the number of local variables.
Definition: function.cpp:186
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: function.cpp:494
std::size_t getNumOfParams() const
Returns the number of parameters.
Definition: function.cpp:162
bool hasLocalVar(ShPtr< Variable > var, bool includeParams=false) const
Returns true if var is a local variable of the function, false otherwise.
Definition: function.cpp:201
bool isVarArg() const
Returns true if the function takes a variable number of arguments, false otherwise.
Definition: function.cpp:257
const std::string & getInitialName() const
Returns the initial name of the function.
Definition: function.cpp:102
ShPtr< Type > getType() const
Returns the type of the function.
Definition: function.cpp:230
ShPtr< Statement > getBody() const
Returns function body.
Definition: function.cpp:211
Function(ShPtr< Module > module, ShPtr< Type >, std::string name, VarVector params, VarSet localVars=VarSet(), ShPtr< Statement > body=nullptr, bool isVarArg=false)
Constructs a new function.
Definition: function.cpp:31
const std::string & getName() const
Returns function name.
Definition: function.cpp:109
void includeParamsIntoLocalVars()
Includes all parameters into the set of local variables.
Definition: function.cpp:627
VarSet getLocalVars(bool includeParams=false) const
Returns local variables of the function.
Definition: function.cpp:171
void setName(const std::string &newName)
Sets a new name.
Definition: function.cpp:309
std::size_t getParamPos(ShPtr< Variable > param) const
Returns the position of the given parameter.
Definition: function.cpp:148
VarVector params
Parameters.
Definition: function.h:99
AddressRange getAddressRange() const
Definition: function.cpp:238
static ShPtr< Function > create(ShPtr< Module > module, ShPtr< Type > retType, std::string name, VarVector params, VarSet localVars=VarSet(), ShPtr< Statement > body=nullptr, bool isVarArg=false)
Constructs a new function.
Definition: function.cpp:516
ShPtr< Type > retType
Return type.
Definition: function.h:96
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: function.cpp:608
ShPtr< Variable > getParam(std::size_t n) const
Returns the n-th parameter.
Definition: function.cpp:132
bool varArg
Definition: function.h:112
void replaceParam(ShPtr< Variable > oldParam, ShPtr< Variable > newParam)
Replaces oldParam with newParam.
Definition: function.cpp:376
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: function.cpp:43
bool isDefinition() const
Returns true if the function is a definition, false otherwise.
Definition: function.cpp:272
A base class of all objects a module can contain.
Definition: value.h:32
A base class of all visitors.
Definition: visitor.h:95
A library providing API for working with back-end IR.
std::weak_ptr< T > WkPtr
An alias for a weak pointer.
Definition: smart_ptr.h:22
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
std::set< ShPtr< Variable > > VarSet
Set of variables.
Definition: types.h:57
std::vector< ShPtr< Variable > > VarVector
Vector of variables.
Definition: types.h:93
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.
Aliases for several useful types.
A base class of all objects a module can contain.