ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
type2t Class Reference

Base class for all types. More...

#include <irep2.h>

Inheritance diagram for type2t:
[legend]

Classes

class  symbolic_type_excp
 Symbolic type exception class. More...

Public Types

enum  type_ids { end_type_id }
 Enumeration identifying each sort of type. More...
typedef esbmct::function_ref< void(const type2tc &)> const_subtype_delegate
typedef esbmct::function_ref< void(type2tc &)> subtype_delegate
typedef type2tc container_type
typedef type2t base_type

Public Member Functions

virtual ~type2t ()=default
unsigned int get_width () const
 Fetch bit width of this type.
bool operator== (const type2t &ref) const
bool operator!= (const type2t &ref) const
bool operator< (const type2t &ref) const
std::string pretty (unsigned int indent=0) const
 Produce a human-readable string representation of type.
DUMP_METHOD void dump () const
 Dump object string representation to stdout.
size_t crc () const
 Produce a checksum/hash of the current object.
bool cmp (const type2t &ref) const
 Structural comparison.
int lt (const type2t &ref) const
 Trinary structural ordering.
list_of_memberst tostring (unsigned int indent) const
 Extract a list of members from type as strings.
type2tc clone () const
 Clone method.
template<typename T>
void foreach_subtype (T &&t) const
template<typename T>
void Foreach_subtype (T &&t)
Public Member Functions inherited from irep2t
 irep2t () noexcept
 irep2t (const irep2t &) noexcept
irep2t & operator= (const irep2t &)=delete
virtual ~irep2t ()=default
void mark_writer () const noexcept
void clear_writer () const noexcept

Public Attributes

const type_ids type_id
 Instance of type_ids recording this types type.
std::atomic< size_t > crc_val
Public Attributes inherited from irep2t
std::atomic< unsigned int > refcount
std::atomic< std::uintptr_t > writer_thread

Protected Member Functions

 type2t (type_ids id)
 Primary constructor.
 type2t (const type2t &ref)
 Copy constructor.
void foreach_subtype_impl_const (const_subtype_delegate &t) const
void foreach_subtype_impl (subtype_delegate &t)

Additional Inherited Members

Static Public Member Functions inherited from irep2t
static std::uintptr_t current_thread_tag () noexcept

Detailed Description

Base class for all types.

Contains only a type identifier enumeration - for some types (such as bool, or empty,) there's no need for any significant amount of data to be stored.

Member Typedef Documentation

◆ base_type

◆ const_subtype_delegate

◆ container_type

◆ subtype_delegate

Member Enumeration Documentation

◆ type_ids

Enumeration identifying each sort of type.

Driven by type_kinds.inc; see that file's header for the IREP2_TYPE(kind, pretty_name) contract.

Enumerator
end_type_id 

Constructor & Destructor Documentation

◆ type2t() [1/2]

type2t::type2t ( type_ids id)
protected

Primary constructor.

Parameters
idType ID of type being constructed

◆ type2t() [2/2]

type2t::type2t ( const type2t & ref)
protected

Copy constructor.

◆ ~type2t()

virtual type2t::~type2t ( )
virtualdefault

Member Function Documentation

◆ clone()

type2tc type2t::clone ( ) const

Clone method.

Self explanatory.

Returns
New container, containing a duplicate of this object.

◆ cmp()

bool type2t::cmp ( const type2t & ref) const

Structural comparison.

Switch-dispatches on type_id and walks the kind's K::fields; returns false immediately when the type_ids differ.

Parameters
refReference to type to compare against
Returns
True if types match, false otherwise

◆ crc()

size_t type2t::crc ( ) const

Produce a checksum/hash of the current object.

Takes current object and produces a lossy digest of it. Originally used crc32, now uses a more hacky but faster hash function. For use in hash objects.

See also
do_crc
Returns
Digest of the current type.

◆ dump()

void type2t::dump ( ) const

Dump object string representation to stdout.

This take the output of the pretty method, and dumps it to stdout. To be used for debugging and when single stepping in gdb.

See also
pretty

◆ Foreach_subtype()

template<typename T>
void type2t::Foreach_subtype ( T && t)
inline

◆ foreach_subtype()

template<typename T>
void type2t::foreach_subtype ( T && t) const
inline

◆ foreach_subtype_impl()

void type2t::foreach_subtype_impl ( subtype_delegate & t)
protected

◆ foreach_subtype_impl_const()

void type2t::foreach_subtype_impl_const ( const_subtype_delegate & t) const
protected

◆ get_width()

unsigned int type2t::get_width ( ) const

Fetch bit width of this type.

For a particular type, calculate its size in a bit representation of itself. May throw various exceptions depending on whether this operation is viable - for example, for symbol types, infinite sized or dynamically sized arrays.

Note that the bit width is not the same as the ansi-c byte model representation of this type.

Exceptions
symbolic_type_excp
array_type2t::inf_sized_array_excp
array_type2t::dyn_sized_array_excp
Returns
Size of types byte representation, in bits

◆ lt()

int type2t::lt ( const type2t & ref) const

Trinary structural ordering.

Mirrors cmp but returns -1/0/+1; mismatched type_ids are ordered by the id itself.

Parameters
refReference to type to measure against
Returns
0 if types are the same, 1 if this > ref, -1 if ref > this.

◆ operator!=()

bool type2t::operator!= ( const type2t & ref) const

◆ operator<()

bool type2t::operator< ( const type2t & ref) const

◆ operator==()

bool type2t::operator== ( const type2t & ref) const

◆ pretty()

std::string type2t::pretty ( unsigned int indent = 0) const

Produce a human-readable string representation of type.

Parameters
indentNumber of spaces to indent lines by in the output
Returns
String obj containing representation of this object

◆ tostring()

list_of_memberst type2t::tostring ( unsigned int indent) const

Extract a list of members from type as strings.

Produces a list of pairs, mapping a member name to a string value. Used in the body of the pretty method.

See also
pretty
Parameters
indentNumber of spaces to indent output strings with, if multiline
Returns
list of name:value pairs.

Member Data Documentation

◆ crc_val

std::atomic<size_t> type2t::crc_val
mutable

◆ type_id

const type_ids type2t::type_id

Instance of type_ids recording this types type.


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