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

Represents a c-style array type. More...

#include <sdfg/types/array.h>

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

Public Member Functions

 Array (const IType &element_type, const symbolic::Expression num_elements)
 Constructs an Array with the specified element type and size.
 Array (StorageType storage_type, size_t alignment, const std::string &initializer, const IType &element_type, const symbolic::Expression num_elements)
 Constructs an Array with explicit storage, alignment, initializer, element type, and size.
virtual PrimitiveType primitive_type () const override
 Returns the primitive type of the array's elements.
virtual TypeID type_id () const override
 Returns TypeID::Array.
virtual bool is_symbol () const override
 Arrays are not symbolic types.
bool is_pointer_like () const override
 Checks if this is a pointer or a structure behaves like a pointer.
const IType & element_type () const
 Gets the type of elements in this array.
const symbolic::Expression num_elements () const
 Gets the number of elements in this array.
virtual bool operator== (const IType &other) const override
 Compares this array with another type for equality.
virtual std::unique_ptr< IType > clone () const override
 Creates a deep copy of this array type.
virtual std::string print () const override
 Returns a string representation of this array 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 c-style array type.

The Array class represents a fixed-size sequence of elements of the same type. This corresponds to C-style arrays like int[10] or float[N] where N is a symbolic expression.

Arrays can be nested to create multi-dimensional arrays. The number of elements can be specified as either a concrete integer or a symbolic expression that may depend on parameters or variables.

Note
This represents c-style arrays, not C++ std::array or std::vector.
Arrays are stored contiguously in memory according to the storage type.

Constructor & Destructor Documentation

◆ Array() [1/2]

sdfg::types::Array::Array ( const IType & element_type,
const symbolic::Expression num_elements )

Constructs an Array with the specified element type and size.

Parameters
element_typeThe type of elements in the array
num_elementsThe number of elements (can be a symbolic expression)

◆ Array() [2/2]

sdfg::types::Array::Array ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
const IType & element_type,
const symbolic::Expression num_elements )

Constructs an Array with explicit storage, alignment, initializer, element type, and size.

Parameters
storage_typeThe storage location and management
alignmentMemory alignment in bytes
initializerOptional initializer expression
element_typeThe type of elements in the array
num_elementsThe number of elements (can be a symbolic expression)

Member Function Documentation

◆ clone()

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

Creates a deep copy of this array type.

Implements sdfg::types::IType.

◆ element_type()

const IType & sdfg::types::Array::element_type ( ) const

Gets the type of elements in this array.

Returns
A const reference to the element type

◆ is_pointer_like()

bool sdfg::types::Array::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::Array::is_symbol ( ) const
overridevirtual

Arrays are not symbolic types.

Returns
Always returns false

Implements sdfg::types::IType.

◆ num_elements()

const symbolic::Expression sdfg::types::Array::num_elements ( ) const

Gets the number of elements in this array.

Returns
The number of elements as a symbolic expression

◆ operator==()

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

Compares this array with another type for equality.

Implements sdfg::types::IType.

◆ primitive_type()

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

Returns the primitive type of the array's elements.

For nested arrays, this returns the primitive type of the innermost element.

Returns
The primitive type of the elements

Implements sdfg::types::IType.

◆ print()

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

Returns a string representation of this array type.

Implements sdfg::types::IType.

◆ replace_symbols() [1/2]

virtual void sdfg::types::Array::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::Array::replace_symbols ( const symbolic::ExpressionMapping & replacements)
overridevirtual

Implements sdfg::types::IType.

◆ type_id()

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

Returns TypeID::Array.

Implements sdfg::types::IType.


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