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

Represents a pointer type. More...

#include <sdfg/types/pointer.h>

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

Public Member Functions

 Pointer ()
 Constructs an opaque pointer (void* equivalent).
 Pointer (const IType &pointee_type)
 Constructs a typed pointer to the specified type.
 Pointer (StorageType storage_type, size_t alignment, const std::string &initializer)
 Constructs an opaque pointer with explicit storage and alignment.
 Pointer (StorageType storage_type, size_t alignment, const std::string &initializer, const IType &pointee_type)
 Constructs a typed pointer with explicit storage, alignment, and pointee type.
virtual std::unique_ptr< IType > clone () const override
 Creates a deep copy of this pointer type.
virtual TypeID type_id () const override
 Returns TypeID::Pointer.
virtual PrimitiveType primitive_type () const override
 Returns the primitive type of the pointee.
virtual bool is_symbol () const override
 Pointers are symbolic types.
bool is_pointer_like () const override
 Checks if this is a pointer or a structure behaves like a pointer.
bool has_pointee_type () const
 Checks if this pointer has a known pointee type.
const IType & pointee_type () const
 Gets the type of the object pointed to.
virtual bool operator== (const IType &other) const override
 Compares this pointer with another type for equality.
virtual std::string print () const override
 Returns a string representation of this pointer 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 pointer type.

The Pointer class represents a pointer to another type. Pointers can be:

  • Typed: pointing to a specific type (e.g., int*, float*)
  • Opaque: pointing to an unknown or void type (e.g., void*)

Pointers are fundamental for representing memory addresses, dynamic data structures, and references to data in different memory spaces (CPU heap, GPU memory, etc.).

Note
The pointee type is optional to support void pointers and opaque pointers.

Constructor & Destructor Documentation

◆ Pointer() [1/4]

sdfg::types::Pointer::Pointer ( )

Constructs an opaque pointer (void* equivalent).

Creates a pointer without a specific pointee type, similar to void* in C/C++.

◆ Pointer() [2/4]

sdfg::types::Pointer::Pointer ( const IType & pointee_type)

Constructs a typed pointer to the specified type.

WARNING: This constructor is less specific than the COPY-constructor, which still EXISTS and behaves differently!

Parameters
pointee_typeThe type of the object pointed to by this pointer

◆ Pointer() [3/4]

sdfg::types::Pointer::Pointer ( StorageType storage_type,
size_t alignment,
const std::string & initializer )

Constructs an opaque pointer with explicit storage and alignment.

Parameters
storage_typeThe storage location and management
alignmentMemory alignment in bytes
initializerOptional initializer expression

◆ Pointer() [4/4]

sdfg::types::Pointer::Pointer ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
const IType & pointee_type )

Constructs a typed pointer with explicit storage, alignment, and pointee type.

Parameters
storage_typeThe storage location and management
alignmentMemory alignment in bytes
initializerOptional initializer expression
pointee_typeThe type of the object pointed to by this pointer

Member Function Documentation

◆ clone()

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

Creates a deep copy of this pointer type.

Implements sdfg::types::IType.

◆ has_pointee_type()

bool sdfg::types::Pointer::has_pointee_type ( ) const

Checks if this pointer has a known pointee type.

Returns
true if the pointee type is specified, false for opaque pointers

◆ is_pointer_like()

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

Pointers are symbolic types.

Returns
Always returns true

Implements sdfg::types::IType.

◆ operator==()

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

Compares this pointer with another type for equality.

Implements sdfg::types::IType.

◆ pointee_type()

const IType & sdfg::types::Pointer::pointee_type ( ) const

Gets the type of the object pointed to.

Returns
A const reference to the pointee type
Precondition
has_pointee_type() must return true

◆ primitive_type()

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

Returns the primitive type of the pointee.

For typed pointers, returns the primitive type of the pointed-to object. For opaque pointers, the behavior depends on the implementation.

Returns
The primitive type of the pointee

Implements sdfg::types::IType.

◆ print()

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

Returns a string representation of this pointer type.

Implements sdfg::types::IType.

◆ replace_symbols() [1/2]

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

Implements sdfg::types::IType.

◆ type_id()

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

Returns TypeID::Pointer.

Implements sdfg::types::IType.


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