retdec
struct_type.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_STRUCT_TYPE_H
8 #define RETDEC_LLVMIR2HLL_IR_STRUCT_TYPE_H
9 
10 #include <map>
11 #include <vector>
12 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
19 class ConstInt;
20 class Visitor;
21 
28 class StructType final: public Type {
29 public:
31  using ElementTypes = std::vector<ShPtr<Type>>;
32 
33 public:
35  const std::string &name = "");
36 
37  virtual ShPtr<Value> clone() override;
38  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
39 
40  const ElementTypes &getElementTypes() const;
41  const ShPtr<Type> getTypeOfElement(ShPtr<ConstInt> index) const;
42  bool hasName() const;
43  const std::string &getName() const;
44 
47  virtual void accept(Visitor *v) override;
49 
50 private:
51  // Since instances are created by calling the static function create(), the
52  // constructor can be private.
53  StructType(ElementTypes elementTypes, const std::string &name);
54 
55 private:
58 
60  std::string name;
61 };
62 
63 } // namespace llvmir2hll
64 } // namespace retdec
65 
66 #endif
A representation of a structured type.
Definition: struct_type.h:28
StructType(ElementTypes elementTypes, const std::string &name)
Constructs a new structured type.
Definition: struct_type.cpp:23
std::string name
Name of the structure.
Definition: struct_type.h:60
std::vector< ShPtr< Type > > ElementTypes
Vector of types of elements in the structure.
Definition: struct_type.h:31
const ShPtr< Type > getTypeOfElement(ShPtr< ConstInt > index) const
Returns the type of the given element.
Definition: struct_type.cpp:69
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: struct_type.cpp:30
ElementTypes elementTypes
Types of elements in the structure.
Definition: struct_type.h:57
const std::string & getName() const
Returns the name of the structure.
Definition: struct_type.cpp:52
const ElementTypes & getElementTypes() const
Returns the vector of elements in the structure.
Definition: struct_type.cpp:59
bool hasName() const
Returns true if the structure has a name, false otherwise.
Definition: struct_type.cpp:43
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: struct_type.cpp:87
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: struct_type.cpp:26
static ShPtr< StructType > create(ElementTypes elementTypes, const std::string &name="")
Creates a new structured type.
Definition: struct_type.cpp:82
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.