retdec
|
A base class of all expressions. More...
#include <expression.h>
Public Member Functions | |
virtual ShPtr< Type > | getType () const =0 |
Returns the type of the expression. More... | |
virtual void | replace (ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr)=0 |
Replaces all occurrences of oldExpr with newExpr in the current expression. More... | |
![]() | |
virtual | ~Value ()=default |
virtual ShPtr< Value > | getSelf () override |
Returns a shared pointer of self. More... | |
virtual ShPtr< Value > | clone ()=0 |
Returns a clone of the value. More... | |
virtual bool | isEqualTo (ShPtr< Value > otherValue) const =0 |
Returns true if this value is equal to otherValue, false otherwise. More... | |
std::string | getTextRepr () |
Returns a textual representation of the value. More... | |
![]() | |
virtual void | accept (Visitor *v)=0 |
Visitor pattern implementation. More... | |
![]() | |
void | setMetadata (std::string data) |
Attaches new metadata. More... | |
std::string | getMetadata () const |
Returns the attached metadata. More... | |
bool | hasMetadata () const |
Are there any non-empty metadata? More... | |
![]() | |
Observer ()=default | |
Creates a new observer. More... | |
virtual | ~Observer ()=default |
Destructs the observer. More... | |
virtual void | update (ShPtr< Value > subject, ShPtr< Value > arg=nullptr) |
Subject has changed its state. More... | |
![]() | |
Subject () | |
Creates a new subject. More... | |
virtual | ~Subject ()=default |
Destructs the subject. More... | |
void | addObserver (ObserverPtr observer) |
Adds a new observer to the list of observers. More... | |
void | removeObserver (ObserverPtr observer) |
Removes the selected observer from the list of observers. More... | |
void | removeObservers () |
Removes all observers. More... | |
void | notifyObservers (ShPtr< Value > arg=nullptr) |
Notifies all observers by calling Observer::update() on them. More... | |
Static Public Member Functions | |
static void | replaceExpression (ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) |
Replaces oldExpr with newExpr. More... | |
Protected Member Functions | |
Expression ()=default | |
![]() | |
Value ()=default | |
![]() | |
Visitable ()=default | |
~Visitable ()=default | |
![]() | |
Metadatable () | |
Constructs a new metadatable object. More... | |
![]() | |
observer_iterator | observer_begin () const |
Returns a constant iterator to the first observer. More... | |
observer_iterator | observer_end () const |
Returns a constant iterator past the last observer. More... | |
Additional Inherited Members | |
![]() | |
using | ConcreteObserver = Observer< Value, Value > |
A concrete observer. More... | |
using | ObserverPtr = WkPtr< ConcreteObserver > |
A pointer to an observer. More... | |
![]() | |
using | ObserverContainer = std::vector< ObserverPtr > |
A container to store observers. More... | |
using | observer_iterator = typename ObserverContainer::const_iterator |
A base class of all expressions.
Instances of this class have reference object semantics.
|
protecteddefault |
Returns the type of the expression.
If an appropriate type cannot be detected, UnknownType
is returned. This may happen, for example, when a binary operator have its operands of incompatible type.
Implemented in retdec::llvmir2hll::Variable, retdec::llvmir2hll::UnaryOpExpr, retdec::llvmir2hll::TernaryOpExpr, retdec::llvmir2hll::StructIndexOpExpr, retdec::llvmir2hll::OrOpExpr, retdec::llvmir2hll::NotOpExpr, retdec::llvmir2hll::NeqOpExpr, retdec::llvmir2hll::LtOpExpr, retdec::llvmir2hll::LtEqOpExpr, retdec::llvmir2hll::GtOpExpr, retdec::llvmir2hll::GtEqOpExpr, retdec::llvmir2hll::EqOpExpr, retdec::llvmir2hll::ConstSymbol, retdec::llvmir2hll::ConstStruct, retdec::llvmir2hll::ConstString, retdec::llvmir2hll::ConstNullPointer, retdec::llvmir2hll::ConstInt, retdec::llvmir2hll::ConstFloat, retdec::llvmir2hll::ConstBool, retdec::llvmir2hll::ConstArray, retdec::llvmir2hll::CastExpr, retdec::llvmir2hll::CallExpr, retdec::llvmir2hll::BinaryOpExpr, retdec::llvmir2hll::ArrayIndexOpExpr, and retdec::llvmir2hll::AndOpExpr.
|
pure virtual |
Replaces all occurrences of oldExpr with newExpr in the current expression.
[in] | oldExpr | Old expression to be replaced. |
[in] | newExpr | Replacement. |
Note that if oldExpr is the current expression on which this function is called, nothing gets replaced, i.e. the replacements are done only in the members of the current expression on which this function is called.
Implemented in retdec::llvmir2hll::Variable, retdec::llvmir2hll::UnaryOpExpr, retdec::llvmir2hll::TernaryOpExpr, retdec::llvmir2hll::ConstSymbol, retdec::llvmir2hll::ConstStruct, retdec::llvmir2hll::ConstString, retdec::llvmir2hll::ConstNullPointer, retdec::llvmir2hll::ConstInt, retdec::llvmir2hll::ConstFloat, retdec::llvmir2hll::ConstBool, retdec::llvmir2hll::ConstArray, retdec::llvmir2hll::CastExpr, retdec::llvmir2hll::CallExpr, and retdec::llvmir2hll::BinaryOpExpr.
|
static |
Replaces oldExpr with newExpr.
[in] | oldExpr | Old expression to be replaced. |
[in] | newExpr | Replacement. |
If you want to replace oldExpr with newExpr only in a single expression (where
), then use where->replace(oldExpr, newExpr)
. However, if where
is identical to oldExpr, then it has to be replaced manually. For example, if where
is the return value of a return statement stmt
, the following code can be used: