asmjit::FuncSignature Struct Reference

Function signature.

Contains information about a function return type, count of arguments, and their TypeIds. Function signature is a low level structure which doesn't contain platform specific or calling convention specific information. It's typically used to describe function arguments in a C-API like form, which is then used to calculate a FuncDetail instance, which then maps function signature into a platform and calling convention specific format.

Function signature can be built either dynamically by using addArg() and addArgT() functionality, or dynamically by using a template-based FuncSignature::build() function, which maps template types into a function signature.

Public Members

Members

Static Public Attributes

Constants

Member Functions

Overloaded Operators
Initialization & Reset
Equality & Comparison
Accessors

Construction & Destruction

Constructor & Destructor Documentation

FuncSignature::FuncSignature()constexprconstexprdefault[1/4]◆ 

Default constructed function signature, initialized to CallConvId::kCDecl, having no return value and no arguments.

FuncSignature::FuncSignature(const FuncSignature& other)constexprconstexprdefault[2/4]◆ 

Copy constructor, which is initialized to the same function signature as other.

FuncSignature::FuncSignature(CallConvId ccId, uint32_t vaIndex = kNoVarArgs)constexprconstexprnoexcept[3/4]◆ 

Initializes the function signature with calling convention id ccId and variable argument's index vaIndex.

template<typename... Args>
FuncSignature::FuncSignature(CallConvId ccId, uint32_t vaIndex, TypeId ret, Args&&... args)constexprconstexprnoexcept[4/4]◆ 

Initializes the function signature with calling convention id ccId, vaIndex, return value, and function arguments.

Member Function Documentation

template<typename... RetValueAndArgs>
FuncSignature FuncSignature::build(CallConvId ccId = CallConvId::kCDecl, uint32_t vaIndex = kNoVarArgs)constexprstaticconstexprnoexcept◆ 

Builds a function signature based on RetValueAndArgs.

The first template argument is a function return type, and function arguments follow.

Note
This function returns a new function signature, which can be passed to functions where it's required. It's a convenience function that allows to build function signature statically based on types known at compile time, which is common in JIT code generation.

FuncSignature& FuncSignature::operator=(const FuncSignature& other)defaultnoexcept◆ 

Copy assignment - function signature can be copied by value.

bool FuncSignature::operator==(const FuncSignature& other) constnoexcept◆ 

Compares this function signature with other for equality..

bool FuncSignature::operator!=(const FuncSignature& other) constnoexcept◆ 

Compares this function signature with other for inequality..

void FuncSignature::reset()noexcept◆ 

Resets this function signature to a default constructed state.

bool FuncSignature::equals(const FuncSignature& other) constnoexcept◆ 

Compares this function signature with other for equality..

CallConvId FuncSignature::callConvId() constnoexcept◆ 

Returns the calling convention.

void FuncSignature::setCallConvId(CallConvId ccId)noexcept◆ 

Sets the calling convention to ccId;.

bool FuncSignature::hasRet() constnoexcept◆ 

Tests whether the function signature has a return value.

TypeId FuncSignature::ret() constnoexcept◆ 

Returns the type of the return value.

void FuncSignature::setRet(TypeId retType)noexcept◆ 

Sets the return type to retType.

template<typename T>
void FuncSignature::setRetT()noexcept◆ 

Sets the return type based on T.

const TypeId* FuncSignature::args() constnoexcept◆ 

Returns the array of function arguments' types.

uint32_t FuncSignature::argCount() constnoexcept◆ 

Returns the number of function arguments.

TypeId FuncSignature::arg(uint32_t i) constnoexcept◆ 

Returns the type of the argument at index i.

void FuncSignature::setArg(uint32_t index, TypeId argType)noexcept◆ 

Sets the argument at index index to argType.

template<typename T>
void FuncSignature::setArgT(uint32_t index)noexcept◆ 

Sets the argument at index i to the type based on T.

bool FuncSignature::canAddArg() constnoexcept◆ 

Tests whether an argument can be added to the signature, use before calling addArg() and addArgT().

Note
If you know that you are not adding more arguments than Globals::kMaxFuncArgs then it's not necessary to use this function. However, if you are adding arguments based on user input, for example, then either check the number of arguments before using function signature or use canAddArg() before actually adding them to the function signature.

void FuncSignature::addArg(TypeId type)noexcept◆ 

Appends an argument of type to the function prototype.

template<typename T>
void FuncSignature::addArgT()noexcept◆ 

Appends an argument of type based on T to the function prototype.

bool FuncSignature::hasVarArgs() constnoexcept◆ 

Tests whether the function has variable number of arguments (...).

uint32_t FuncSignature::vaIndex() constnoexcept◆ 

Returns the variable arguments (...) index, kNoVarArgs if none.

void FuncSignature::setVaIndex(uint32_t index)noexcept◆ 

Sets the variable arguments (...) index to index.

void FuncSignature::resetVaIndex()noexcept◆ 

Resets the variable arguments index (making it a non-va function).

Member Data Documentation

uint8_t FuncSignature::kNoVarArgs = 0xFFuconstexprstaticconstexpr◆ 

Doesn't have variable number of arguments (...).

CallConvId FuncSignature::_ccId = CallConvId::kCDecl◆ 

Calling convention id.

uint8_t FuncSignature::_argCount = 0◆ 

Count of arguments.

uint8_t FuncSignature::_vaIndex = kNoVarArgs◆ 

Index of a first VA or kNoVarArgs.

TypeId FuncSignature::_ret = TypeId::kVoid◆ 

Return value TypeId.

uint8_t FuncSignature::_reserved[4] {}◆ 

Reserved for future use.

TypeId FuncSignature::_args[Globals::kMaxFuncArgs] {}◆ 

Function argument TypeIds.