retdec
const_symbol.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_IR_CONST_SYMBOL_H
8 #define RETDEC_LLVMIR2HLL_IR_CONST_SYMBOL_H
9 
10 #include <string>
11 
14 
15 namespace retdec {
16 namespace llvmir2hll {
17 
18 class Expression;
19 class Visitor;
20 
27 class ConstSymbol final: public Constant {
28 public:
29  static ShPtr<ConstSymbol> create(const std::string &name,
31 
32  virtual ShPtr<Value> clone() override;
33  virtual bool isEqualTo(ShPtr<Value> otherValue) const override;
34  virtual ShPtr<Type> getType() const override;
35  virtual void replace(ShPtr<Expression> oldExpr,
36  ShPtr<Expression> newExpr) override;
37 
38  const std::string &getName() const;
39  ShPtr<Constant> getValue() const;
40 
43  virtual void accept(Visitor *v) override;
45 
46 private:
48  std::string name;
49 
52 
53 private:
54  // Since instances are created by calling the static function create(), the
55  // constructor can be private.
56  ConstSymbol(const std::string &name, ShPtr<Constant> value);
57 
58  void setValue(ShPtr<Constant> newValue);
59 };
60 
61 } // namespace llvmir2hll
62 } // namespace retdec
63 
64 #endif
A symbolic constant.
Definition: const_symbol.h:27
std::string name
Name of the constant.
Definition: const_symbol.h:48
virtual void accept(Visitor *v) override
Visitor pattern implementation.
Definition: const_symbol.cpp:107
static ShPtr< ConstSymbol > create(const std::string &name, ShPtr< Constant > value)
Constructs a symbolic constant with the given name and value.
Definition: const_symbol.cpp:66
virtual ShPtr< Type > getType() const override
Returns the type of the expression.
Definition: const_symbol.cpp:37
virtual ShPtr< Value > clone() override
Returns a clone of the value.
Definition: const_symbol.cpp:22
void setValue(ShPtr< Constant > newValue)
Sets a new value of the constant.
Definition: const_symbol.cpp:99
ConstSymbol(const std::string &name, ShPtr< Constant > value)
Constructs a symbolic constant.
Definition: const_symbol.cpp:19
const std::string & getName() const
Returns the name of the symbolic constant.
Definition: const_symbol.cpp:82
ShPtr< Constant > getValue() const
Returns the value of the symbolic constant.
Definition: const_symbol.cpp:89
ShPtr< Constant > value
Value of the constant.
Definition: const_symbol.h:51
virtual void replace(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
Replaces all occurrences of oldExpr with newExpr in the current expression.
Definition: const_symbol.cpp:41
virtual bool isEqualTo(ShPtr< Value > otherValue) const override
Returns true if this value is equal to otherValue, false otherwise.
Definition: const_symbol.cpp:28
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.