docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::types::Function Class Reference

Represents a function type. More...

#include <sdfg/types/function.h>

Inheritance diagram for sdfg::types::Function:
[legend]

Public Member Functions

 Function (const IType &return_type, bool is_var_arg=false)
 Constructs a Function with the specified return type.
 Function (StorageType storage_type, size_t alignment, const std::string &initializer, const IType &return_type, bool is_var_arg=false)
 Constructs a Function with explicit storage, alignment, initializer, and return type.
virtual PrimitiveType primitive_type () const override
 Returns the primitive type of the return type.
virtual TypeID type_id () const override
 Returns TypeID::Function.
virtual bool is_symbol () const override
 Functions are not symbolic types.
bool is_pointer_like () const override
 Checks if this is a pointer or a structure behaves like a pointer.
size_t num_params () const
 Gets the number of parameters.
const IType & param_type (symbolic::Integer index) const
 Gets the type of a parameter at the specified index.
void add_param (const IType &param)
 Adds a parameter to the function signature.
const IType & return_type () const
 Gets the return type of the function.
bool is_var_arg () const
 Checks if the function accepts variadic arguments.
virtual bool operator== (const IType &other) const override
 Compares this function type with another type for equality.
virtual std::unique_ptr< IType > clone () const override
 Creates a deep copy of this function type.
virtual std::string print () const override
 Returns a string representation of this function type.
virtual void replace_symbols (const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
 Replace symbolic expressions on this type.
virtual void replace_symbols (const symbolic::ExpressionMapping &replacements) override
Public Member Functions inherited from sdfg::types::IType
 IType (StorageType storage_type=StorageType::CPU_Stack(), size_t alignment=0, const std::string &initializer="")
 Constructs an IType with optional storage, alignment, and initializer.
virtual ~IType ()=default
 Virtual destructor for proper cleanup of derived classes.
StorageType storage_type () const
 Gets the storage type (const version).
StorageType & storage_type ()
 Gets the storage type (mutable reference).
void storage_type (const StorageType &storage_type)
 Sets the storage type.
size_t alignment () const
 Gets the alignment requirement in bytes.
void alignment (size_t alignment)
 Sets the alignment requirement in bytes.
std::string initializer () const
 Gets the initializer expression.
void initializer (const std::string &initializer)
 Sets the initializer expression.

Additional Inherited Members

Protected Attributes inherited from sdfg::types::IType
StorageType storage_type_
 Where and how the data is stored.
size_t alignment_
 Memory alignment requirement in bytes.
std::string initializer_
 Optional initializer expression.

Detailed Description

Represents a function type.

The Function class represents a function signature, including:

  • Parameter types (in order)
  • Return type
  • Whether the function accepts variadic arguments (like C's ...)

Function types are used to represent function pointers, function declarations, and callable objects in the SDFG type system.

Note
This represents the type of a function, not a function definition or call.

Constructor & Destructor Documentation

◆ Function() [1/2]

sdfg::types::Function::Function ( const IType & return_type,
bool is_var_arg = false )

Constructs a Function with the specified return type.

Parameters
return_typeThe return type of the function
is_var_argWhether the function accepts variadic arguments (default: false)

◆ Function() [2/2]

sdfg::types::Function::Function ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
const IType & return_type,
bool is_var_arg = false )

Constructs a Function with explicit storage, alignment, initializer, and return type.

Parameters
storage_typeThe storage location and management
alignmentMemory alignment in bytes
initializerOptional initializer expression
return_typeThe return type of the function
is_var_argWhether the function accepts variadic arguments (default: false)

Member Function Documentation

◆ add_param()

void sdfg::types::Function::add_param ( const IType & param)

Adds a parameter to the function signature.

Parameters are added in order. This method should be called for each parameter in the function signature.

Parameters
paramThe type of the parameter to add

◆ clone()

virtual std::unique_ptr< IType > sdfg::types::Function::clone ( ) const
overridevirtual

Creates a deep copy of this function type.

Implements sdfg::types::IType.

◆ is_pointer_like()

bool sdfg::types::Function::is_pointer_like ( ) const
inlineoverridevirtual

Checks if this is a pointer or a structure behaves like a pointer.

Some structures may have pointer-like semantics in certain contexts.

Implements sdfg::types::IType.

◆ is_symbol()

virtual bool sdfg::types::Function::is_symbol ( ) const
overridevirtual

Functions are not symbolic types.

Returns
Always returns false

Implements sdfg::types::IType.

◆ is_var_arg()

bool sdfg::types::Function::is_var_arg ( ) const

Checks if the function accepts variadic arguments.

Returns
true if the function is variadic (like C's ...), false otherwise

◆ num_params()

size_t sdfg::types::Function::num_params ( ) const

Gets the number of parameters.

Returns
The number of parameters in the function signature

◆ operator==()

virtual bool sdfg::types::Function::operator== ( const IType & other) const
overridevirtual

Compares this function type with another type for equality.

Implements sdfg::types::IType.

◆ param_type()

const IType & sdfg::types::Function::param_type ( symbolic::Integer index) const

Gets the type of a parameter at the specified index.

Parameters
indexThe zero-based index of the parameter
Returns
A const reference to the parameter's type

◆ primitive_type()

virtual PrimitiveType sdfg::types::Function::primitive_type ( ) const
overridevirtual

Returns the primitive type of the return type.

Returns
The primitive type of the function's return type

Implements sdfg::types::IType.

◆ print()

virtual std::string sdfg::types::Function::print ( ) const
overridevirtual

Returns a string representation of this function type.

Implements sdfg::types::IType.

◆ replace_symbols() [1/2]

virtual void sdfg::types::Function::replace_symbols ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )
overridevirtual

Replace symbolic expressions on this type.

Parameters
old_expressionExpression to replace
new_expressionReplacement expression

Replaces occurrences of symbolic expressions on the type.

Implements sdfg::types::IType.

◆ replace_symbols() [2/2]

virtual void sdfg::types::Function::replace_symbols ( const symbolic::ExpressionMapping & replacements)
overridevirtual

Implements sdfg::types::IType.

◆ return_type()

const IType & sdfg::types::Function::return_type ( ) const

Gets the return type of the function.

Returns
A const reference to the return type

◆ type_id()

virtual TypeID sdfg::types::Function::type_id ( ) const
overridevirtual

Returns TypeID::Function.

Implements sdfg::types::IType.


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