retdec
string_type.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_STRING_TYPE_H
8 #define RETDEC_LLVMIR2HLL_IR_STRING_TYPE_H
9 
10 #include <cstdint>
11 #include <map>
12 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
19 class Visitor;
20 
27 class StringType final: public Type {
28 public:
29  static ShPtr<StringType> create(std::size_t charSize);
30 
31  virtual ShPtr<Value> clone() override;
32 
33  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
34 
35  std::size_t getCharSize() const;
36 
39  virtual void accept(Visitor *v) override;
41 
42 private:
44  using SizeToStringTypeMap = std::map<std::size_t, ShPtr<StringType>>;
45 
46 private:
48  std::size_t charSize;
49 
52 
53 private:
54  // Since instances are created by calling the static function create(), the
55  // constructor can be private.
56  explicit StringType(std::size_t charSize);
57 };
58 
59 } // namespace llvmir2hll
60 } // namespace retdec
61 
62 #endif
A representation of a string type.
Definition: string_type.h:27
std::size_t charSize
How large are characters in the string (in bits)?
Definition: string_type.h:48
virtual void accept(Visitor *v) override
Visitor pattern implementation.
std::map< std::size_t, ShPtr< StringType > > SizeToStringTypeMap
Mapping of sizes into StringType instances.
Definition: string_type.h:44
static ShPtr< StringType > create(std::size_t charSize)
virtual ShPtr< Value > clone() override
Returns a clone of the value.
std::size_t getCharSize() const
static SizeToStringTypeMap createdTypes
Set of already created string types with characters of the given size.
Definition: string_type.h:51
StringType(std::size_t charSize)
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
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.