retdec
int_type.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_INT_TYPE_H
8 #define RETDEC_LLVMIR2HLL_IR_INT_TYPE_H
9 
10 #include <map>
11 
14 
15 namespace retdec {
16 namespace llvmir2hll {
17 
18 class Visitor;
19 
26 class IntType final: public Type {
27 public:
28  static ShPtr<IntType> create(unsigned size, bool isSigned = true);
29 
30  virtual ShPtr<Value> clone() override;
31  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
32 
33  unsigned getSize() const;
34  bool isSigned() const;
35  bool isUnsigned() const;
36  bool isBool() const;
37 
40  virtual void accept(Visitor *v) override;
42 
43 private:
45  using SizeToIntTypeMap = std::map<unsigned, ShPtr<IntType>>;
46 
47 private:
49  unsigned size;
50 
52  bool signedInt;
53 
56 
59 
60 private:
61  // Since instances are created by calling the static function create(), the
62  // constructor can be private.
63  IntType(unsigned size, bool isSigned = false);
64 };
65 
66 } // namespace llvmir2hll
67 } // namespace retdec
68 
69 #endif
A representation of an integer type.
Definition: int_type.h:26
unsigned size
Number of bits (size of the integer).
Definition: int_type.h:49
bool isBool() const
Returns true if the type is bool, false otherwise.
Definition: int_type.cpp:64
static SizeToIntTypeMap createdUnsignedTypes
Set of already created unsigned integer types of the given size.
Definition: int_type.h:58
bool signedInt
Is the integer signed?
Definition: int_type.h:52
unsigned getSize() const
Returns the number of bits.
Definition: int_type.cpp:37
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: int_type.cpp:104
bool isSigned() const
Returns true if the integer is signed, false otherwise.
Definition: int_type.cpp:46
bool isUnsigned() const
Returns true if the integer is unsigned, false otherwise.
Definition: int_type.cpp:55
static ShPtr< IntType > create(unsigned size, bool isSigned=true)
Creates a new integer type.
Definition: int_type.cpp:78
IntType(unsigned size, bool isSigned=false)
Constructs a new integer type.
Definition: int_type.cpp:19
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: int_type.cpp:26
static SizeToIntTypeMap createdSignedTypes
Set of already created signed integer types of the given size.
Definition: int_type.h:55
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: int_type.cpp:22
std::map< unsigned, ShPtr< IntType > > SizeToIntTypeMap
Mapping of integer sizes into IntType instances.
Definition: int_type.h:45
A base class of all types.
Definition: type.h:20
A base class of all visitors.
Definition: visitor.h:95
A base class of all types.
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.