retdec
value.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_VALUE_H
8 #define RETDEC_LLVMIR2HLL_IR_VALUE_H
9 
10 #include <iosfwd>
11 #include <string>
12 
13 #include <llvm/Support/raw_ostream.h>
14 
21 
22 namespace retdec {
23 namespace llvmir2hll {
24 
30 class Value: public Visitable, public Metadatable<std::string>,
31  public SharableFromThis<Value>, public Observer<Value>,
32  public Subject<Value>, private retdec::utils::NonCopyable {
33 public:
34  virtual ~Value() = default;
35 
36  virtual ShPtr<Value> getSelf() override;
37 
56  virtual ShPtr<Value> clone() = 0;
57 
67  virtual bool isEqualTo(ShPtr<Value> otherValue) const = 0;
68 
69  std::string getTextRepr();
70 
71 protected:
72  Value() = default;
73 };
74 
77 
78 // These functions have to be declared in the same namespace that defines Value
79 // and its subclasses; C++ lookup rules rely on that.
80 llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const ShPtr<Value> &value);
81 // The following function is used to print values in tests (Google Tests
82 // framework). It must have this signature; ShPtr<Value> does not work.
83 std::ostream &operator<<(std::ostream &os, Value *value);
84 
86 
87 } // namespace llvmir2hll
88 } // namespace retdec
89 
90 #endif
A mixin providing metadata attached to objects.
Definition: metadatable.h:19
Implementation of a generic typed observer using shared pointers (observer part).
Definition: observer.h:41
Enables shared_from_this() in the inheriting class.
Definition: smart_ptr.h:44
Implementation of a generic typed observer using shared pointers (subject part).
Definition: subject.h:43
A base class of all objects a module can contain.
Definition: value.h:32
virtual ShPtr< Value > getSelf() override
Returns a shared pointer of self.
Definition: value.cpp:31
virtual ~Value()=default
virtual ShPtr< Value > clone()=0
Returns a clone of the value.
virtual bool isEqualTo(ShPtr< Value > otherValue) const =0
Returns true if this value is equal to otherValue, false otherwise.
std::string getTextRepr()
Returns a textual representation of the value.
Definition: value.cpp:41
Interface for classes whose instances are visitable by a Visitor.
Definition: visitable.h:20
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
Interface for classes whose instances are visitable by a Visitor.
A mixin providing metadata attached to objects.
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
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const ShPtr< Value > &value)
Emits value into os.
Definition: value.cpp:48
Definition: archive_wrapper.h:19
A mixin to make classes non-copyable.
Implementation of a generic typed observer (observer part).
Declarations, aliases, macros, etc. for the use of smart pointers.
Implementation of a generic typed observer (subject part).