retdec
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
retdec::llvmir2hll::UnaryOpExpr Class Reference

A base class for all unary operators. More...

#include <unary_op_expr.h>

Inheritance diagram for retdec::llvmir2hll::UnaryOpExpr:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::UnaryOpExpr:
Collaboration graph
[legend]

Public Member Functions

virtual ShPtr< TypegetType () const override
 Returns the type of the expression. More...
 
virtual void replace (ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr) override
 Replaces all occurrences of oldExpr with newExpr in the current expression. More...
 
ShPtr< ExpressiongetOperand () const
 Returns the operand. More...
 
void setOperand (ShPtr< Expression > newOp)
 Sets a new operand. More...
 
Observer Interface
virtual void update (ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
 Updates the operator according to the changes of subject. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Value
virtual ~Value ()=default
 
virtual ShPtr< ValuegetSelf () override
 Returns a shared pointer of self. More...
 
virtual ShPtr< Valueclone ()=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...
 
- Public Member Functions inherited from retdec::llvmir2hll::Visitable
virtual void accept (Visitor *v)=0
 Visitor pattern implementation. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Metadatable< std::string >
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...
 
- Public Member Functions inherited from retdec::llvmir2hll::Observer< Value >
 Observer ()=default
 Creates a new observer. More...
 
virtual ~Observer ()=default
 Destructs the observer. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Subject< Value >
 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...
 

Protected Member Functions

 UnaryOpExpr (ShPtr< Expression > op)
 Constructs a unary operator. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::Expression
 Expression ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Value
 Value ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Visitable
 Visitable ()=default
 
 ~Visitable ()=default
 
- Protected Member Functions inherited from retdec::llvmir2hll::Metadatable< std::string >
 Metadatable ()
 Constructs a new metadatable object. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::Subject< Value >
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...
 

Protected Attributes

ShPtr< Expressionop
 Operand. More...
 

Additional Inherited Members

- Public Types inherited from retdec::llvmir2hll::Subject< Value >
using ConcreteObserver = Observer< Value, Value >
 A concrete observer. More...
 
using ObserverPtr = WkPtr< ConcreteObserver >
 A pointer to an observer. More...
 
- Static Public Member Functions inherited from retdec::llvmir2hll::Expression
static void replaceExpression (ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr)
 Replaces oldExpr with newExpr. More...
 
- Protected Types inherited from retdec::llvmir2hll::Subject< Value >
using ObserverContainer = std::vector< ObserverPtr >
 A container to store observers. More...
 
using observer_iterator = typename ObserverContainer::const_iterator
 

Detailed Description

A base class for all unary operators.

Instances of this class have reference object semantics.

Constructor & Destructor Documentation

◆ UnaryOpExpr()

retdec::llvmir2hll::UnaryOpExpr::UnaryOpExpr ( ShPtr< Expression op)
explicitprotected

Constructs a unary operator.

Parameters
[in]opOperand.
Preconditions
  • op is non-null

Member Function Documentation

◆ getOperand()

ShPtr< Expression > retdec::llvmir2hll::UnaryOpExpr::getOperand ( ) const

Returns the operand.

◆ getType()

ShPtr< Type > retdec::llvmir2hll::UnaryOpExpr::getType ( ) const
overridevirtual

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.

Implements retdec::llvmir2hll::Expression.

Reimplemented in retdec::llvmir2hll::NotOpExpr.

◆ replace()

void retdec::llvmir2hll::UnaryOpExpr::replace ( ShPtr< Expression oldExpr,
ShPtr< Expression newExpr 
)
overridevirtual

Replaces all occurrences of oldExpr with newExpr in the current expression.

Parameters
[in]oldExprOld expression to be replaced.
[in]newExprReplacement.

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.

Preconditions
  • oldExpr is non-null

Implements retdec::llvmir2hll::Expression.

◆ setOperand()

void retdec::llvmir2hll::UnaryOpExpr::setOperand ( ShPtr< Expression newOp)

Sets a new operand.

Preconditions
  • operand is non-null

◆ update()

void retdec::llvmir2hll::UnaryOpExpr::update ( ShPtr< Value subject,
ShPtr< Value arg = nullptr 
)
overridevirtual

Updates the operator according to the changes of subject.

Parameters
[in]subjectObservable object.
[in]argOptional argument.

Replaces subject with

  • . For example, if subject is the operand of the operator, this function replaces it with arg.

This function does nothing when:

  • subject does not correspond to the operand
  • arg is not an expression
Preconditions
  • both operands are non-null
See also
Subject::update()

Reimplemented from retdec::llvmir2hll::Observer< Value >.

Member Data Documentation

◆ op

ShPtr<Expression> retdec::llvmir2hll::UnaryOpExpr::op
protected

Operand.


The documentation for this class was generated from the following files: