retdec
const_struct.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_CONST_STRUCT_H
8 #define RETDEC_LLVMIR2HLL_IR_CONST_STRUCT_H
9 
10 #include <utility>
11 #include <vector>
12 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
19 class ConstInt;
20 class Expression;
21 class Visitor;
22 class StructType;
23 
30 class ConstStruct final: public Constant {
31 public:
33  using Item = std::pair<ShPtr<ConstInt>, ShPtr<Expression>>;
34 
36  using Type = std::vector<Item>;
37 
38 public:
40 
41  virtual ShPtr<Value> clone() override;
42 
43  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
44  virtual ShPtr<retdec::llvmir2hll::Type> getType() const override;
45  virtual void replace(ShPtr<Expression> oldExpr,
46  ShPtr<Expression> newExpr) override;
47 
48  Type getValue() const;
49 
52  virtual void update(ShPtr<Value> subject,
53  ShPtr<Value> arg = nullptr) override;
55 
58  virtual void accept(Visitor *v) override;
60 
61 private:
64 
67 
68 private:
69  // Since instances are created by calling the static function create(),
70  // constructors can be private.
72 };
73 
74 } // namespace llvmir2hll
75 } // namespace retdec
76 
77 #endif
A struct constant.
Definition: const_struct.h:30
Type value
Value of the constant.
Definition: const_struct.h:63
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: const_struct.cpp:38
static ShPtr< ConstStruct > create(Type value, ShPtr< StructType > type)
Creates a struct constant initialized to the given value.
Definition: const_struct.cpp:88
virtual void update(ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
Updates the structure according to the changes of subject.
Definition: const_struct.cpp:121
virtual ShPtr< retdec::llvmir2hll::Type > getType() const override
Returns the type of the expression.
Definition: const_struct.cpp:49
ShPtr< StructType > type
Type of the value.
Definition: const_struct.h:66
std::pair< ShPtr< ConstInt >, ShPtr< Expression > > Item
A single struct item (field name, value)
Definition: const_struct.h:33
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: const_struct.cpp:24
ConstStruct(Type value, ShPtr< StructType > type)
Constructs a struct constant initialized to the given value.
Definition: const_struct.cpp:21
Type getValue() const
Returns the constant's value.
Definition: const_struct.cpp:75
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: const_struct.cpp:137
std::vector< Item > Type
Underlying type for a struct constant.
Definition: const_struct.h:36
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current expression.
Definition: const_struct.cpp:53
A base class for all constants.
Definition: constant.h:20
A base class of all visitors.
Definition: visitor.h:95
A base class for all constants.
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.