retdec
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
retdec::ctypes::Function Class Reference

A representation of a C function. More...

#include <function.h>

Collaboration diagram for retdec::ctypes::Function:
Collaboration graph
[legend]

Public Types

using Parameters = std::vector< Parameter >
 
using VarArgness = FunctionType::VarArgness
 
using parameter_iterator = Parameters::iterator
 
using const_parameter_iterator = Parameters::const_iterator
 

Public Member Functions

const std::string & getName () const
 
std::shared_ptr< FunctionTypegetType () const
 Returns function's function type - return type and parameters' types. More...
 
std::shared_ptr< TypegetReturnType () const
 Returns function's return type. More...
 
Function parameters.
parameter_iterator parameter_begin ()
 Returns an iterator to the parameter. More...
 
const_parameter_iterator parameter_begin () const
 Returns a constant iterator to the parameter. More...
 
parameter_iterator parameter_end ()
 Returns an iterator past the last parameter. More...
 
const_parameter_iterator parameter_end () const
 Returns a constant iterator past the last parameter. More...
 
Parameters::size_type getParameterCount () const
 Returns the number of parameters. More...
 
const ParametergetParameter (Parameters::size_type n) const
 Returns the n-th parameter. More...
 
const std::string & getParameterName (Parameters::size_type n) const
 Returns the n-th parameter's name. More...
 
std::shared_ptr< TypegetParameterType (Parameters::size_type n) const
 Returns the n-th parameter's type. More...
 
bool isVarArg () const
 Returns true if function takes variable number of arguments, false otherwise. More...
 
Function call convention.
void setCallConvention (const CallConvention &callConvention)
 Sets function's call convention. More...
 
const CallConventiongetCallConvention () const
 Returns function's call convention. More...
 
Function declaration.
void setDeclaration (const FunctionDeclaration &declaration)
 Sets function declaration. More...
 
FunctionDeclaration getDeclaration () const
 Returns function declaration. More...
 
Function header file.
void setHeaderFile (const HeaderFile &headerFile)
 Sets header file of function. More...
 
HeaderFile getHeaderFile () const
 Returns header file of function. More...
 

Static Public Member Functions

static std::shared_ptr< Functioncreate (const std::shared_ptr< Context > &context, const std::string &name, const std::shared_ptr< Type > &returnType, const Parameters &parameters, const CallConvention &callConvention=CallConvention(), VarArgness varArgness=VarArgness::IsNotVarArg)
 Creates function. More...
 

Private Member Functions

 Function (const std::string &name, const std::shared_ptr< FunctionType > &functionType, const Parameters &parameters)
 Constructs a new function. More...
 

Static Private Member Functions

static std::shared_ptr< FunctionTypecreateFunctionType (const std::shared_ptr< Context > &context, const std::shared_ptr< Type > &returnType, const Parameters &parameters, const CallConvention &callConvention, VarArgness varArgness)
 Creates function type. More...
 

Private Attributes

std::string name
 
std::shared_ptr< FunctionTypefunctionType
 
Parameters parameters
 
FunctionDeclaration declaration
 
HeaderFile headerFile
 

Detailed Description

A representation of a C function.

Member Typedef Documentation

◆ const_parameter_iterator

using retdec::ctypes::Function::const_parameter_iterator = Parameters::const_iterator

◆ parameter_iterator

using retdec::ctypes::Function::parameter_iterator = Parameters::iterator

◆ Parameters

◆ VarArgness

Constructor & Destructor Documentation

◆ Function()

retdec::ctypes::Function::Function ( const std::string &  name,
const std::shared_ptr< FunctionType > &  functionType,
const Parameters parameters 
)
private

Constructs a new function.

Member Function Documentation

◆ create()

std::shared_ptr< Function > retdec::ctypes::Function::create ( const std::shared_ptr< Context > &  context,
const std::string &  name,
const std::shared_ptr< Type > &  returnType,
const Parameters parameters,
const CallConvention callConvention = CallConvention(),
VarArgness  varArgness = VarArgness::IsNotVarArg 
)
static

Creates function.

Parameters
contextStorage for already created functions, types.
nameName of new function.
returnTypeFunction return type.
parametersFunction parameters.
callConventionFunction call convention.
varArgnessInfo that function takes variable number of arguments or not.
Preconditions
  • context is not null
  • returnType is not null

Does not create new function, if one has already been created and stored in context.

◆ createFunctionType()

std::shared_ptr< FunctionType > retdec::ctypes::Function::createFunctionType ( const std::shared_ptr< Context > &  context,
const std::shared_ptr< Type > &  returnType,
const Parameters parameters,
const CallConvention callConvention,
VarArgness  varArgness 
)
staticprivate

Creates function type.

Parameters
contextStorage for already created functions, types.
returnTypeFunction return type.
parametersFunction parameters.
callConventionFunction call convention.
varArgnessInfo that function takes variable number of arguments or not.
Preconditions
  • context is not null
  • returnType is not null

◆ getCallConvention()

const CallConvention & retdec::ctypes::Function::getCallConvention ( ) const

Returns function's call convention.

◆ getDeclaration()

FunctionDeclaration retdec::ctypes::Function::getDeclaration ( ) const

Returns function declaration.

◆ getHeaderFile()

HeaderFile retdec::ctypes::Function::getHeaderFile ( ) const

Returns header file of function.

◆ getName()

const std::string & retdec::ctypes::Function::getName ( ) const

◆ getParameter()

const Parameter & retdec::ctypes::Function::getParameter ( Parameters::size_type  n) const

Returns the n-th parameter.

Preconditions
  • 0 < n <= ParameterCount

The parameters are numbered starting with 1.

◆ getParameterCount()

Function::Parameters::size_type retdec::ctypes::Function::getParameterCount ( ) const

Returns the number of parameters.

Does not matter if function takes variable number of parameters or not.

◆ getParameterName()

const std::string & retdec::ctypes::Function::getParameterName ( Parameters::size_type  n) const

Returns the n-th parameter's name.

Preconditions
  • 0 < n <= ParameterCount

The parameters are numbered starting with 1.

◆ getParameterType()

std::shared_ptr< Type > retdec::ctypes::Function::getParameterType ( Parameters::size_type  n) const

Returns the n-th parameter's type.

Preconditions
  • 0 < n <= ParameterCount

The parameters are numbered starting with 1.

◆ getReturnType()

std::shared_ptr< Type > retdec::ctypes::Function::getReturnType ( ) const

Returns function's return type.

◆ getType()

std::shared_ptr< FunctionType > retdec::ctypes::Function::getType ( ) const

Returns function's function type - return type and parameters' types.

◆ isVarArg()

bool retdec::ctypes::Function::isVarArg ( ) const

Returns true if function takes variable number of arguments, false otherwise.

◆ parameter_begin() [1/2]

Function::parameter_iterator retdec::ctypes::Function::parameter_begin ( )

Returns an iterator to the parameter.

◆ parameter_begin() [2/2]

Function::const_parameter_iterator retdec::ctypes::Function::parameter_begin ( ) const

Returns a constant iterator to the parameter.

◆ parameter_end() [1/2]

Function::parameter_iterator retdec::ctypes::Function::parameter_end ( )

Returns an iterator past the last parameter.

◆ parameter_end() [2/2]

Function::const_parameter_iterator retdec::ctypes::Function::parameter_end ( ) const

Returns a constant iterator past the last parameter.

◆ setCallConvention()

void retdec::ctypes::Function::setCallConvention ( const CallConvention callConvention)

Sets function's call convention.

◆ setDeclaration()

void retdec::ctypes::Function::setDeclaration ( const FunctionDeclaration declaration)

Sets function declaration.

◆ setHeaderFile()

void retdec::ctypes::Function::setHeaderFile ( const HeaderFile headerFile)

Sets header file of function.

Member Data Documentation

◆ declaration

FunctionDeclaration retdec::ctypes::Function::declaration
private

◆ functionType

std::shared_ptr<FunctionType> retdec::ctypes::Function::functionType
private

◆ headerFile

HeaderFile retdec::ctypes::Function::headerFile
private

◆ name

std::string retdec::ctypes::Function::name
private

◆ parameters

Parameters retdec::ctypes::Function::parameters
private

The documentation for this class was generated from the following files: