retdec
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
retdec::llvmir2hll::IntType Class Referencefinal

A representation of an integer type. More...

#include <int_type.h>

Inheritance diagram for retdec::llvmir2hll::IntType:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::IntType:
Collaboration graph
[legend]

Public Member Functions

virtual ShPtr< Valueclone () override
 Returns a clone of the value. More...
 
virtual bool isEqualTo (ShPtr< Value > otherValue) const override
 Returns true if this value is equal to otherValue, false otherwise. More...
 
unsigned getSize () const
 Returns the number of bits. More...
 
bool isSigned () const
 Returns true if the integer is signed, false otherwise. More...
 
bool isUnsigned () const
 Returns true if the integer is unsigned, false otherwise. More...
 
bool isBool () const
 Returns true if the type is bool, false otherwise. More...
 
Visitor Interface
virtual void accept (Visitor *v) override
 Visitor pattern implementation. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Type
virtual ~Type ()=default
 
- Public Member Functions inherited from retdec::llvmir2hll::Value
virtual ~Value ()=default
 
virtual ShPtr< ValuegetSelf () override
 Returns a shared pointer of self. More...
 
std::string getTextRepr ()
 Returns a textual representation of the value. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Metadatable< std::string >
void setMetadata (std::string data)
 Attaches new metadata. More...
 
std::string getMetadata () const
 Returns the attached metadata. More...
 
bool hasMetadata () const
 Are there any non-empty metadata? More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Observer< Value >
 Observer ()=default
 Creates a new observer. More...
 
virtual ~Observer ()=default
 Destructs the observer. More...
 
virtual void update (ShPtr< Value > subject, ShPtr< Value > arg=nullptr)
 Subject has changed its state. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Subject< Value >
 Subject ()
 Creates a new subject. More...
 
virtual ~Subject ()=default
 Destructs the subject. More...
 
void addObserver (ObserverPtr observer)
 Adds a new observer to the list of observers. More...
 
void removeObserver (ObserverPtr observer)
 Removes the selected observer from the list of observers. More...
 
void removeObservers ()
 Removes all observers. More...
 
void notifyObservers (ShPtr< Value > arg=nullptr)
 Notifies all observers by calling Observer::update() on them. More...
 

Static Public Member Functions

static ShPtr< IntTypecreate (unsigned size, bool isSigned=true)
 Creates a new integer type. More...
 

Private Types

using SizeToIntTypeMap = std::map< unsigned, ShPtr< IntType > >
 Mapping of integer sizes into IntType instances. More...
 

Private Member Functions

 IntType (unsigned size, bool isSigned=false)
 Constructs a new integer type. More...
 

Private Attributes

unsigned size
 Number of bits (size of the integer). More...
 
bool signedInt
 Is the integer signed? More...
 

Static Private Attributes

static SizeToIntTypeMap createdSignedTypes
 Set of already created signed integer types of the given size. More...
 
static SizeToIntTypeMap createdUnsignedTypes
 Set of already created unsigned integer types of the given size. More...
 

Additional Inherited Members

- Public Types inherited from retdec::llvmir2hll::Subject< Value >
using ConcreteObserver = Observer< Value, Value >
 A concrete observer. More...
 
using ObserverPtr = WkPtr< ConcreteObserver >
 A pointer to an observer. More...
 
- Protected Types inherited from retdec::llvmir2hll::Subject< Value >
using ObserverContainer = std::vector< ObserverPtr >
 A container to store observers. More...
 
using observer_iterator = typename ObserverContainer::const_iterator
 
- Protected Member Functions inherited from retdec::llvmir2hll::Type
 Type ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Value
 Value ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Visitable
 Visitable ()=default
 
 ~Visitable ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Metadatable< std::string >
 Metadatable ()
 Constructs a new metadatable object. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::Subject< Value >
observer_iterator observer_begin () const
 Returns a constant iterator to the first observer. More...
 
observer_iterator observer_end () const
 Returns a constant iterator past the last observer. More...
 

Detailed Description

A representation of an integer type.

Use create() to create instances. Instances of this class have reference object semantics. This class is not meant to be subclassed.

Member Typedef Documentation

◆ SizeToIntTypeMap

using retdec::llvmir2hll::IntType::SizeToIntTypeMap = std::map<unsigned, ShPtr<IntType> >
private

Mapping of integer sizes into IntType instances.

Constructor & Destructor Documentation

◆ IntType()

retdec::llvmir2hll::IntType::IntType ( unsigned  size,
bool  isSigned = false 
)
private

Constructs a new integer type.

See create() for more information.

Member Function Documentation

◆ accept()

void retdec::llvmir2hll::IntType::accept ( Visitor v)
overridevirtual

Visitor pattern implementation.

Subclasses should implement this method as:

v->visit(ucast<T>(shared_from_this()));

where T is the name of the subclass, and shared_from_this() and ucast<> are from Decompiler/Support/SmartPtr.h.

Implements retdec::llvmir2hll::Visitable.

◆ clone()

ShPtr< Value > retdec::llvmir2hll::IntType::clone ( )
overridevirtual

Returns a clone of the value.

A clone is (in most cases) an exact copy of the value. This member function provides the copy mechanism for reference objects.

The following parts of values are not cloned:

  • predecessors and successors of statements

The following subclasses of Value are not cloned, i.e. they are returned without any copying:

Statements in compound statements (i.e. statements where isCompound() returns true) are cloned without their successors; therefore, e.g., just the first statement of every if's clause is cloned.

Implements retdec::llvmir2hll::Value.

◆ create()

ShPtr< IntType > retdec::llvmir2hll::IntType::create ( unsigned  size,
bool  isSigned = true 
)
static

Creates a new integer type.

Parameters
[in]sizeNumber of bits.
[in]isSignedIf true, the integer will be signed; otherwise, it will be unsigned.
Preconditions
  • size > 0

◆ getSize()

unsigned retdec::llvmir2hll::IntType::getSize ( ) const

Returns the number of bits.

◆ isBool()

bool retdec::llvmir2hll::IntType::isBool ( ) const

Returns true if the type is bool, false otherwise.

An integer type is bool if its size is 1.

◆ isEqualTo()

bool retdec::llvmir2hll::IntType::isEqualTo ( ShPtr< Value otherValue) const
overridevirtual

Returns true if this value is equal to otherValue, false otherwise.

This member function brings the support of value object semantics into reference objects, namely equality based not only on identity.

This function doesn't consider observers, metadata, etc.

Implements retdec::llvmir2hll::Value.

◆ isSigned()

bool retdec::llvmir2hll::IntType::isSigned ( ) const

Returns true if the integer is signed, false otherwise.

An integer can be either signed or unsigned.

◆ isUnsigned()

bool retdec::llvmir2hll::IntType::isUnsigned ( ) const

Returns true if the integer is unsigned, false otherwise.

An integer can be either signed or unsigned.

Member Data Documentation

◆ createdSignedTypes

std::map< unsigned, ShPtr< IntType > > retdec::llvmir2hll::IntType::createdSignedTypes
staticprivate

Set of already created signed integer types of the given size.

◆ createdUnsignedTypes

std::map< unsigned, ShPtr< IntType > > retdec::llvmir2hll::IntType::createdUnsignedTypes
staticprivate

Set of already created unsigned integer types of the given size.

◆ signedInt

bool retdec::llvmir2hll::IntType::signedInt
private

Is the integer signed?

◆ size

unsigned retdec::llvmir2hll::IntType::size
private

Number of bits (size of the integer).


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