docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
function.h
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "sdfg/types/type.h"
12
13namespace sdfg {
14
15namespace types {
16
31class Function : public IType {
32private:
33 std::vector<std::unique_ptr<IType>> params_;
34 std::unique_ptr<IType> return_type_;
35 bool is_var_arg_;
36
37public:
43 Function(const IType& return_type, bool is_var_arg = false);
44
55 size_t alignment,
56 const std::string& initializer,
57 const IType& return_type,
58 bool is_var_arg = false
59 );
60
65 virtual PrimitiveType primitive_type() const override;
66
68 virtual TypeID type_id() const override;
69
74 virtual bool is_symbol() const override;
75
76 bool is_pointer_like() const override {
77 return true;
78 }
79
84 size_t num_params() const;
85
91 const IType& param_type(symbolic::Integer index) const;
92
101 void add_param(const IType& param);
102
107 const IType& return_type() const;
108
113 bool is_var_arg() const;
114
116 virtual bool operator==(const IType& other) const override;
117
119 virtual std::unique_ptr<IType> clone() const override;
120
122 virtual std::string print() const override;
123
131 virtual void
132 replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
133 virtual void replace_symbols(const symbolic::ExpressionMapping& replacements) override;
134};
135
136} // namespace types
137} // namespace sdfg
virtual void replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace symbolic expressions on this type.
const IType & return_type() const
Gets the return type of the function.
virtual bool is_symbol() const override
Functions are not symbolic types.
bool is_var_arg() const
Checks if the function accepts variadic arguments.
size_t num_params() const
Gets the number of parameters.
virtual void replace_symbols(const symbolic::ExpressionMapping &replacements) override
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.
virtual TypeID type_id() const override
Returns TypeID::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.
virtual std::string print() const override
Returns a string representation of this function type.
virtual PrimitiveType primitive_type() const override
Returns the primitive type of the return type.
bool is_pointer_like() const override
Checks if this is a pointer or a structure behaves like a pointer.
Definition function.h:76
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.
Function(const IType &return_type, bool is_var_arg=false)
Constructs a Function with the specified return type.
IType(StorageType storage_type=StorageType::CPU_Stack(), size_t alignment=0, const std::string &initializer="")
Constructs an IType with optional storage, alignment, and initializer.
Definition type.h:638
StorageType storage_type() const
Gets the storage type (const version).
Definition type.h:651
std::string initializer() const
Gets the initializer expression.
Definition type.h:683
size_t alignment() const
Gets the alignment requirement in bytes.
Definition type.h:673
Represents the storage location and management characteristics of data.
Definition type.h:64
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::RCP< const SymEngine::Integer > Integer
Reference-counted pointer to a SymEngine Integer constant.
Definition symbolic.h:77
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition symbolic.h:57
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
TypeID
Enumeration of high-level type categories.
Definition type.h:607
Definition analysis.h:7
Core type system definitions for sdfglib.