CIRCT 24.0.0git
Loading...
Searching...
No Matches
esi::Type Class Reference

Root class of the ESI type system. More...

#include <Types.h>

Inheritance diagram for esi::Type:
Collaboration diagram for esi::Type:

Public Types

using ID = std::string

Public Member Functions

 Type (const ID &id)
virtual ~Type ()=default
ID getID () const
virtual std::ptrdiff_t getBitWidth () const
void setHWBitwidth (std::ptrdiff_t bw)
 Set from manifest JSON hwBitwidth.
virtual MutableBitVector serialize (const std::any &obj) const
 Serialize an object to a MutableBitVector (LSB-first stream).
virtual std::any deserialize (BitVector &data) const
 Deserialize from a BitVector stream (LSB-first).
std::any deserialize (const MessageData &data) const
virtual void ensureValid (const std::any &obj) const
 Ensure that a std::any object is valid for this type.
std::optional< std::string > isValid (const std::any &obj) const
void dump (std::ostream &os, bool oneLine=false) const
std::string toString (bool oneLine=false) const

Protected Attributes

ID id
std::ptrdiff_t hwBitwidth = -1

Detailed Description

Root class of the ESI type system.

Definition at line 36 of file Types.h.

Member Typedef Documentation

◆ ID

using esi::Type::ID = std::string

Definition at line 38 of file Types.h.

Constructor & Destructor Documentation

◆ Type()

◆ ~Type()

virtual esi::Type::~Type ( )
virtualdefault

Member Function Documentation

◆ deserialize() [1/2]

virtual std::any esi::Type::deserialize ( BitVector & data) const
inlinevirtual

Deserialize from a BitVector stream (LSB-first).

Implementations consume bits from 'data' in-place (via logical right shifts) and return the reconstructed value. Remaining bits stay in 'data'.

Reimplemented in esi::ArrayType, esi::BitsType, esi::ChannelType, esi::SIntType, esi::StructType, esi::TypeAliasType, esi::UIntType, esi::UnionType, and esi::VoidType.

Definition at line 60 of file Types.h.

Referenced by esi::StructType::deserialize(), and deserialize().

◆ deserialize() [2/2]

std::any esi::Type::deserialize ( const MessageData & data) const
inline

Definition at line 67 of file Types.h.

References deserialize().

◆ dump()

void esi::Type::dump ( std::ostream & os,
bool oneLine = false ) const

Definition at line 115 of file Types.cpp.

References esi::dumpType().

Referenced by toString().

◆ ensureValid()

virtual void esi::Type::ensureValid ( const std::any & obj) const
inlinevirtual

Ensure that a std::any object is valid for this type.

Throws std::runtime_error if the object is not valid.

Reimplemented in esi::ArrayType, esi::BitsType, esi::ChannelType, esi::SIntType, esi::StructType, esi::TypeAliasType, esi::UIntType, esi::UnionType, and esi::VoidType.

Definition at line 74 of file Types.h.

Referenced by isValid().

◆ getBitWidth()

virtual std::ptrdiff_t esi::Type::getBitWidth ( ) const
inlinevirtual

◆ getID()

ID esi::Type::getID ( ) const
inline

Definition at line 42 of file Types.h.

References id.

Referenced by esi::dumpType(), NB_MODULE(), esi::Context::registerType(), and esi::verifyTypeCompatibility().

◆ isValid()

std::optional< std::string > esi::Type::isValid ( const std::any & obj) const
inline

Definition at line 80 of file Types.h.

References ensureValid().

◆ serialize()

virtual MutableBitVector esi::Type::serialize ( const std::any & obj) const
inlinevirtual

Serialize an object to a MutableBitVector (LSB-first stream).

The object should be passed via std::any. Implementations append fields in the order they are iterated (the first serialized field occupies the least-significant bits of the result).

Reimplemented in esi::ArrayType, esi::BitsType, esi::ChannelType, esi::SIntType, esi::StructType, esi::TypeAliasType, esi::UIntType, esi::UnionType, and esi::VoidType.

Definition at line 53 of file Types.h.

Referenced by esi::StructType::serialize(), and esi::UnionType::serialize().

◆ setHWBitwidth()

void esi::Type::setHWBitwidth ( std::ptrdiff_t bw)
inline

Set from manifest JSON hwBitwidth.

Allows types without specialized parsers (e.g. union types) to still report their width.

Definition at line 47 of file Types.h.

References hwBitwidth.

◆ toString()

Member Data Documentation

◆ hwBitwidth

std::ptrdiff_t esi::Type::hwBitwidth = -1
protected

Definition at line 97 of file Types.h.

Referenced by getBitWidth(), and setHWBitwidth().

◆ id


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