retdec
array_type.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_CTYPES_ARRAY_TYPE_H
8 #define RETDEC_CTYPES_ARRAY_TYPE_H
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "retdec/ctypes/type.h"
14 
15 namespace retdec {
16 namespace ctypes {
17 
18 class Context;
19 
23 class ArrayType: public Type
24 {
25  public:
26  using DimensionType = std::size_t;
27  using Dimensions = std::vector<DimensionType>;
28 
29  public:
32 
33  public:
34  static std::shared_ptr<ArrayType> create(const std::shared_ptr<Context> &context,
35  const std::shared_ptr<Type> &elementType, const Dimensions &dimensions);
36 
37  std::shared_ptr<Type> getElementType() const;
38  const Dimensions &getDimensions() const;
39  Dimensions::size_type getDimensionCount() const;
40 
41  virtual bool isArray() const override;
42 
45  virtual void accept(Visitor *v) override;
47  private:
48  ArrayType(const std::shared_ptr<Type> &elementType, const Dimensions &dimensions);
49 
50  private:
51  std::shared_ptr<Type> elementType;
53 };
54 
55 } // namespace ctypes
56 } // namespace retdec
57 
58 #endif
A representation of array types.
Definition: array_type.h:24
std::vector< DimensionType > Dimensions
Definition: array_type.h:27
std::size_t DimensionType
Definition: array_type.h:26
Dimensions::size_type getDimensionCount() const
Returns array's dimensions count.
Definition: array_type.cpp:76
Dimensions dimensions
Definition: array_type.h:52
std::shared_ptr< Type > getElementType() const
Returns element type.
Definition: array_type.cpp:60
ArrayType(const std::shared_ptr< Type > &elementType, const Dimensions &dimensions)
Constructs a new array type.
Definition: array_type.cpp:22
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: array_type.cpp:89
static std::shared_ptr< ArrayType > create(const std::shared_ptr< Context > &context, const std::shared_ptr< Type > &elementType, const Dimensions &dimensions)
Creates array type.
Definition: array_type.cpp:40
std::shared_ptr< Type > elementType
Definition: array_type.h:51
static const DimensionType UNKNOWN_DIMENSION
Value used for unknown dimension.
Definition: array_type.h:31
const Dimensions & getDimensions() const
Returns array's dimensions.
Definition: array_type.cpp:68
virtual bool isArray() const override
Returns true when Type is array, false otherwise.
Definition: array_type.cpp:84
A base class of all C types.
Definition: type.h:22
A base class of all C-types' visitors.
Definition: visitor.h:33
A base class of all C types.
Definition: archive_wrapper.h:19