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

A representation of a function type. More...

#include <function_type.h>

Inheritance diagram for retdec::ctypes::FunctionType:
Inheritance graph
[legend]
Collaboration diagram for retdec::ctypes::FunctionType:
Collaboration graph
[legend]

Public Types

enum class  VarArgness { IsVarArg , IsNotVarArg }
 
using Parameters = std::vector< std::shared_ptr< Type > >
 
using parameter_iterator = Parameters::iterator
 
using const_parameter_iterator = Parameters::const_iterator
 

Public Member Functions

std::shared_ptr< TypegetReturnType () const
 Returns function's return type. More...
 
virtual bool isFunction () const override
 
Function type 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 ParametersgetParameters () const
 Returns function type parameters. More...
 
std::shared_ptr< TypegetParameter (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 type call convention.
void setCallConvention (const CallConvention &callConvention)
 Sets function type's call convention. More...
 
const CallConventiongetCallConvention () const
 Returns function type's call convention. More...
 
Visitor interface.
virtual void accept (Visitor *v) override
 Visitor pattern implementation. More...
 
- Public Member Functions inherited from retdec::ctypes::Type
virtual ~Type ()=default
 
const std::string & getName () const
 
unsigned getBitWidth () const
 
virtual bool isArray () const
 
virtual bool isEnum () const
 
virtual bool isFloatingPoint () const
 
virtual bool isIntegral () const
 
virtual bool isNamed () const
 
virtual bool isPointer () const
 
virtual bool isReference () const
 
virtual bool isStruct () const
 
virtual bool isTypedef () const
 
virtual bool isUnion () const
 
virtual bool isUnknown () const
 
virtual bool isVoid () const
 

Static Public Member Functions

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

Private Member Functions

 FunctionType (const std::shared_ptr< Type > &returnType, const Parameters &parameters, const CallConvention &callConvention, VarArgness varArgness)
 Constructs a new function type. More...
 

Private Attributes

std::shared_ptr< TypereturnType
 
Parameters parameters
 
CallConvention callConvention
 
VarArgness varArgness
 

Additional Inherited Members

- Protected Member Functions inherited from retdec::ctypes::Type
 Type ()=default
 
 Type (const std::string &name, unsigned bitWidth)
 Constructs a new type. More...
 
- Protected Member Functions inherited from retdec::ctypes::Visitable
 Visitable ()=default
 
 ~Visitable ()=default
 
- Protected Attributes inherited from retdec::ctypes::Type
std::string name
 
unsigned bitWidth
 

Detailed Description

A representation of a function type.

Member Typedef Documentation

◆ const_parameter_iterator

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

◆ parameter_iterator

◆ Parameters

using retdec::ctypes::FunctionType::Parameters = std::vector<std::shared_ptr<Type> >

Member Enumeration Documentation

◆ VarArgness

Enumerator
IsVarArg 
IsNotVarArg 

Constructor & Destructor Documentation

◆ FunctionType()

retdec::ctypes::FunctionType::FunctionType ( const std::shared_ptr< Type > &  returnType,
const Parameters parameters,
const CallConvention callConvention,
VarArgness  varArgness 
)
private

Constructs a new function type.

Member Function Documentation

◆ accept()

void retdec::ctypes::FunctionType::accept ( Visitor v)
overridevirtual

Visitor pattern implementation.

Subclasses should implement this method as:

v->visit(std::static_pointer_cast<T>(std::shared_from_this()));

where T is the name of the subclass.

Implements retdec::ctypes::Visitable.

◆ create()

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

Creates function type.

Parameters
contextStorage for already created functions, types.
returnTypeFunction type return type.
parametersFunction type parameters types.
callConventionFunction type 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 type, if one has already been created and stored in context.

◆ getCallConvention()

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

Returns function type's call convention.

◆ getParameter()

std::shared_ptr< Type > retdec::ctypes::FunctionType::getParameter ( Parameters::size_type  n) const

Returns the n-th parameter's type.

Preconditions
  • 0 < n <= ParameterCount

The parameters are numbered starting with 1.

◆ getParameterCount()

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

Returns the number of parameters.

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

◆ getParameters()

const FunctionType::Parameters & retdec::ctypes::FunctionType::getParameters ( ) const

Returns function type parameters.

◆ getReturnType()

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

Returns function's return type.

◆ isFunction()

bool retdec::ctypes::FunctionType::isFunction ( ) const
overridevirtual

Returns true when Type is function type, false otherwise.

Reimplemented from retdec::ctypes::Type.

◆ isVarArg()

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

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

◆ parameter_begin() [1/2]

FunctionType::parameter_iterator retdec::ctypes::FunctionType::parameter_begin ( )

Returns an iterator to the parameter.

◆ parameter_begin() [2/2]

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

Returns a constant iterator to the parameter.

◆ parameter_end() [1/2]

FunctionType::parameter_iterator retdec::ctypes::FunctionType::parameter_end ( )

Returns an iterator past the last parameter.

◆ parameter_end() [2/2]

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

Returns a constant iterator past the last parameter.

◆ setCallConvention()

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

Sets function type's call convention.

Member Data Documentation

◆ callConvention

CallConvention retdec::ctypes::FunctionType::callConvention
private

◆ parameters

Parameters retdec::ctypes::FunctionType::parameters
private

◆ returnType

std::shared_ptr<Type> retdec::ctypes::FunctionType::returnType
private

◆ varArgness

VarArgness retdec::ctypes::FunctionType::varArgness
private

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