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

Represents a scalar primitive type. More...

#include <sdfg/types/scalar.h>

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

Public Member Functions

 Scalar (PrimitiveType primitive_type)
 Constructs a Scalar with the specified primitive type.
 Scalar (StorageType storage_type, size_t alignment, const std::string &initializer, PrimitiveType primitive_type)
 Constructs a Scalar with explicit storage, alignment, initializer, and primitive type.
virtual TypeID type_id () const override
 Returns TypeID::Scalar.
virtual PrimitiveType primitive_type () const override
 Returns the primitive type of this scalar.
virtual bool is_symbol () const override
 Checks if this scalar type can be used as a symbol.
bool is_pointer_like () const override
 Checks if this is a pointer or a structure behaves like a pointer.
Scalar as_signed () const
 Creates a copy of this scalar with signed integer type.
Scalar as_unsigned () const
 Creates a copy of this scalar with unsigned integer type.
virtual bool operator== (const IType &other) const override
 Compares this scalar with another type for equality.
virtual std::unique_ptr< IType > clone () const override
 Creates a deep copy of this scalar.
virtual std::string print () const override
 Returns a string representation of this scalar 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 scalar primitive type.

The Scalar class wraps a PrimitiveType and provides operations for working with scalar types, including type conversions between signed and unsigned variants.

Scalar types are the most basic types in the type system and include integers, floating-point numbers, and booleans.

Constructor & Destructor Documentation

◆ Scalar() [1/2]

sdfg::types::Scalar::Scalar ( PrimitiveType primitive_type)

Constructs a Scalar with the specified primitive type.

Parameters
primitive_typeThe primitive type (e.g., Int32, Float, Bool)

◆ Scalar() [2/2]

sdfg::types::Scalar::Scalar ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
PrimitiveType primitive_type )

Constructs a Scalar with explicit storage, alignment, initializer, and primitive type.

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

Member Function Documentation

◆ as_signed()

Scalar sdfg::types::Scalar::as_signed ( ) const

Creates a copy of this scalar with signed integer type.

If this scalar is an unsigned integer type, returns a new Scalar with the corresponding signed type. Otherwise, returns a copy with the same type.

Returns
A new Scalar with signed type

◆ as_unsigned()

Scalar sdfg::types::Scalar::as_unsigned ( ) const

Creates a copy of this scalar with unsigned integer type.

If this scalar is a signed integer type, returns a new Scalar with the corresponding unsigned type. Otherwise, returns a copy with the same type.

Returns
A new Scalar with unsigned type

◆ clone()

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

Creates a deep copy of this scalar.

Implements sdfg::types::IType.

◆ is_pointer_like()

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

Checks if this scalar type can be used as a symbol.

Integer types (signed and unsigned) are considered symbolic and can be used in symbolic expressions. Floating-point types are not symbolic.

Returns
true if this is an integer type, false otherwise

Implements sdfg::types::IType.

◆ operator==()

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

Compares this scalar with another type for equality.

Implements sdfg::types::IType.

◆ primitive_type()

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

Returns the primitive type of this scalar.

Implements sdfg::types::IType.

◆ print()

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

Returns a string representation of this scalar type.

Implements sdfg::types::IType.

◆ replace_symbols() [1/2]

virtual void sdfg::types::Scalar::replace_symbols ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )
inlineoverridevirtual

Replace symbolic expressions on this type.

Parameters
old_expressionExpression to replace
new_expressionReplacement expression

Nothing to do.

Implements sdfg::types::IType.

◆ replace_symbols() [2/2]

virtual void sdfg::types::Scalar::replace_symbols ( const symbolic::ExpressionMapping & replacements)
inlineoverridevirtual

Implements sdfg::types::IType.

◆ type_id()

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

Returns TypeID::Scalar.

Implements sdfg::types::IType.


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