retdec
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::CallExpr Class Referencefinal

A call expression. More...

#include <call_expr.h>

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

Public Member Functions

virtual ShPtr< Valueclone () override
 Returns a clone of the value. More...
 
virtual bool isEqualTo (ShPtr< Value > otherValue) const override
 Returns true if this value is equal to otherValue, false otherwise. More...
 
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< ExpressiongetCalledExpr () const
 Returns the expression called by this call. More...
 
bool hasArg (std::size_t n) const
 Returns true if the call has an n-th argument, false otherwise. More...
 
ShPtr< ExpressiongetArg (std::size_t n) const
 Returns the n-th argument. More...
 
const ExprVectorgetArgs () const
 Returns the argument list. More...
 
std::size_t getNumOfArgs () const
 Returns the number of arguments in the call. More...
 
void setCalledExpr (ShPtr< Expression > newCalledExpr)
 Sets a new called expression. More...
 
void setArgs (ExprVector newArgs)
 Sets a new argument list. More...
 
void setArg (std::size_t position, ShPtr< Expression > newArg)
 Sets a new argument to the given position. More...
 
void replaceArg (ShPtr< Expression > oldArg, ShPtr< Expression > newArg)
 Replaces oldArg with newArg. More...
 
Observer Interface
virtual void update (ShPtr< Value > subject, ShPtr< Value > arg=nullptr) override
 Updates the statement according to the changes of subject. More...
 
Visitor Interface
virtual void accept (Visitor *v) override
 Visitor pattern implementation. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::Value
virtual ~Value ()=default
 
virtual ShPtr< ValuegetSelf () override
 Returns a shared pointer of self. More...
 
std::string getTextRepr ()
 Returns a textual representation of the value. 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...
 

Static Public Member Functions

static ShPtr< CallExprcreate (ShPtr< Expression > calledExpr, ExprVector args=ExprVector())
 Creates a new call expression. More...
 
- Static Public Member Functions inherited from retdec::llvmir2hll::Expression
static void replaceExpression (ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr)
 Replaces oldExpr with newExpr. More...
 

Private Member Functions

 CallExpr (ShPtr< Expression > calledExpr, ExprVector args)
 Constructs a new call expression. More...
 

Private Attributes

ShPtr< ExpressioncalledExpr
 Expression that is called by this call. More...
 
ExprVector args
 Arguments. 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...
 
- 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
 
- 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...
 

Detailed Description

A call expression.

Use create() to create instances. Instances of this class have reference object semantics. This class is not meant to be subclassed.

Constructor & Destructor Documentation

◆ CallExpr()

retdec::llvmir2hll::CallExpr::CallExpr ( ShPtr< Expression calledExpr,
ExprVector  args 
)
private

Constructs a new call expression.

See create() for more information.

Member Function Documentation

◆ accept()

void retdec::llvmir2hll::CallExpr::accept ( Visitor v)
overridevirtual

Visitor pattern implementation.

Subclasses should implement this method as:

v->visit(ucast<T>(shared_from_this()));

where T is the name of the subclass, and shared_from_this() and ucast<> are from Decompiler/Support/SmartPtr.h.

Implements retdec::llvmir2hll::Visitable.

◆ clone()

ShPtr< Value > retdec::llvmir2hll::CallExpr::clone ( )
overridevirtual

Returns a clone of the value.

A clone is (in most cases) an exact copy of the value. This member function provides the copy mechanism for reference objects.

The following parts of values are not cloned:

  • predecessors and successors of statements

The following subclasses of Value are not cloned, i.e. they are returned without any copying:

Statements in compound statements (i.e. statements where isCompound() returns true) are cloned without their successors; therefore, e.g., just the first statement of every if's clause is cloned.

Implements retdec::llvmir2hll::Value.

◆ create()

ShPtr< CallExpr > retdec::llvmir2hll::CallExpr::create ( ShPtr< Expression calledExpr,
ExprVector  args = ExprVector() 
)
static

Creates a new call expression.

Parameters
[in]calledExprExpression that is called by this call.
[in]argsArgument list.
Preconditions
  • calledExpr is non-null

◆ getArg()

ShPtr< Expression > retdec::llvmir2hll::CallExpr::getArg ( std::size_t  n) const

Returns the n-th argument.

The arguments are numbered in the following way:

func(1, 2, 3, 4, ...)
Preconditions
  • 0 < n <= NUM_OF_ARGS, where NUM_OF_ARGS is the number of arguments that the call has

◆ getArgs()

const ExprVector & retdec::llvmir2hll::CallExpr::getArgs ( ) const

Returns the argument list.

◆ getCalledExpr()

ShPtr< Expression > retdec::llvmir2hll::CallExpr::getCalledExpr ( ) const

Returns the expression called by this call.

◆ getNumOfArgs()

std::size_t retdec::llvmir2hll::CallExpr::getNumOfArgs ( ) const

Returns the number of arguments in the call.

◆ getType()

ShPtr< Type > retdec::llvmir2hll::CallExpr::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.

◆ hasArg()

bool retdec::llvmir2hll::CallExpr::hasArg ( std::size_t  n) const

Returns true if the call has an n-th argument, false otherwise.

The arguments are numbered in the following way:

func(1, 2, 3, 4, ...)

◆ isEqualTo()

bool retdec::llvmir2hll::CallExpr::isEqualTo ( ShPtr< Value otherValue) const
overridevirtual

Returns true if this value is equal to otherValue, false otherwise.

This member function brings the support of value object semantics into reference objects, namely equality based not only on identity.

This function doesn't consider observers, metadata, etc.

Implements retdec::llvmir2hll::Value.

◆ replace()

void retdec::llvmir2hll::CallExpr::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.

◆ replaceArg()

void retdec::llvmir2hll::CallExpr::replaceArg ( ShPtr< Expression oldArg,
ShPtr< Expression newArg 
)

Replaces oldArg with newArg.

If oldArg does not correspond to any argument, this function does nothing.

Preconditions
  • both arguments are non-null

◆ setArg()

void retdec::llvmir2hll::CallExpr::setArg ( std::size_t  position,
ShPtr< Expression newArg 
)

Sets a new argument to the given position.

Parameters
[in]positionPosition on which the new argument is placed.
[in]newArgNew argument.
Preconditions
  • position is not out of range
  • newArg is non-null

◆ setArgs()

void retdec::llvmir2hll::CallExpr::setArgs ( ExprVector  newArgs)

Sets a new argument list.

◆ setCalledExpr()

void retdec::llvmir2hll::CallExpr::setCalledExpr ( ShPtr< Expression newCalledExpr)

Sets a new called expression.

Preconditions
  • newCalledExpr is non-null

◆ update()

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

Updates the statement according to the changes of subject.

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

Replaces subject with arg. For example, if subject is one of the arguments of this call, this function replaces it with arg.

This function does nothing when:

  • subject does not correspond to any part of this call
  • arg is not an expression
Preconditions
  • both arguments are non-null
See also
Subject::update()

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

Member Data Documentation

◆ args

ExprVector retdec::llvmir2hll::CallExpr::args
private

Arguments.

◆ calledExpr

ShPtr<Expression> retdec::llvmir2hll::CallExpr::calledExpr
private

Expression that is called by this call.


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