retdec
Private Types | Private Attributes | List of all members
retdec::ctypes::Context Class Reference

Container for all C functions and types. More...

#include <context.h>

Collaboration diagram for retdec::ctypes::Context:
Collaboration graph
[legend]

Public Member Functions

Access to functions.
bool hasFunctionWithName (const std::string &name) const
 Checks if context contains function. More...
 
std::shared_ptr< FunctiongetFunctionWithName (const std::string &name) const
 Returns function from context. More...
 
void addFunction (const std::shared_ptr< Function > &function)
 Inserts new function to context. More...
 
Access to function types.
bool hasFunctionType (const std::shared_ptr< Type > &returnType, const FunctionType::Parameters &parameters, const CallConvention &callConvention, FunctionType::VarArgness varArgness) const
 Checks if context contains function type. More...
 
std::shared_ptr< FunctionTypegetFunctionType (const std::shared_ptr< Type > &returnType, const FunctionType::Parameters &parameters, const CallConvention &callConvention, FunctionType::VarArgness varArgness) const
 Returns function type from context. More...
 
void addFunctionType (const std::shared_ptr< FunctionType > &functionType)
 Inserts new function type to context. More...
 
Access to named types.
bool hasNamedType (const std::string &name) const
 Checks if context contains type with specific name. More...
 
std::shared_ptr< TypegetNamedType (const std::string &name) const
 Returns type with specific name from context. More...
 
void addNamedType (const std::shared_ptr< Type > &type)
 Inserts new type with specific name to context. More...
 
Access to pointer types.
bool hasPointerType (const std::shared_ptr< Type > &pointedType) const
 Checks if context contains pointer type. More...
 
std::shared_ptr< PointerTypegetPointerType (const std::shared_ptr< Type > &pointedType) const
 Returns pointerType from context. More...
 
void addPointerType (const std::shared_ptr< PointerType > &pointerType)
 Inserts new pointerType with specific name to context. More...
 
Access to reference types.
bool hasReferenceType (const std::shared_ptr< Type > &referencedType) const
 Checks if context contains reference type. More...
 
std::shared_ptr< ReferenceTypegetReferenceType (const std::shared_ptr< Type > &referencedType) const
 Returns referenceType from context. More...
 
void addReferenceType (const std::shared_ptr< ReferenceType > &referenceType)
 Inserts new referenceType with specific name to context. More...
 
Access to array types.
bool hasArrayType (const std::shared_ptr< Type > &elementType, const ArrayType::Dimensions &dimensions) const
 Checks if context contains array type. More...
 
std::shared_ptr< ArrayTypegetArrayType (const std::shared_ptr< Type > &elementType, const ArrayType::Dimensions &dimensions) const
 Returns array type from context. More...
 
void addArrayType (const std::shared_ptr< ArrayType > &arrayType)
 Adds array type to context. More...
 
Access to annotations.
bool hasAnnotation (const std::string &name) const
 Checks if context contains annotation. More...
 
std::shared_ptr< AnnotationgetAnnotation (const std::string &name) const
 Returns annotation from context. More...
 
void addAnnotation (const std::shared_ptr< Annotation > &annot)
 Adds annotation to context. More...
 

Private Types

using Functions = std::unordered_map< std::string, std::shared_ptr< Function > >
 
using FunctionTypes = std::map< std::tuple< std::shared_ptr< Type >, FunctionType::Parameters, std::string, bool >, std::shared_ptr< FunctionType > >
 
using NamedTypes = std::unordered_map< std::string, std::shared_ptr< Type > >
 
using PointerTypes = std::unordered_map< std::shared_ptr< Type >, std::shared_ptr< PointerType > >
 
using ReferenceTypes = std::unordered_map< std::shared_ptr< Type >, std::shared_ptr< ReferenceType > >
 
using ArrayTypes = std::map< std::pair< std::shared_ptr< Type >, ArrayType::Dimensions >, std::shared_ptr< ArrayType > >
 
using Annotations = std::unordered_map< std::string, std::shared_ptr< Annotation > >
 

Private Attributes

Functions functions
 Stored functions. More...
 
FunctionTypes functionTypes
 Stored function types, key is return type and parameters' types. More...
 
NamedTypes namedTypes
 Stored types that can be identified by name. More...
 
PointerTypes pointerTypes
 Stored pointer types, key is type that they point to. More...
 
ReferenceTypes referenceTypes
 Stored reference types, key is type that they reference. More...
 
ArrayTypes arrayTypes
 Stored array types, key is element type and dimensions. More...
 
Annotations annotations
 Stored annotations. More...
 

Detailed Description

Container for all C functions and types.

Member Typedef Documentation

◆ Annotations

using retdec::ctypes::Context::Annotations = std::unordered_map<std::string, std::shared_ptr<Annotation> >
private

◆ ArrayTypes

using retdec::ctypes::Context::ArrayTypes = std::map< std::pair<std::shared_ptr<Type>, ArrayType::Dimensions>, std::shared_ptr<ArrayType> >
private

◆ Functions

using retdec::ctypes::Context::Functions = std::unordered_map<std::string, std::shared_ptr<Function> >
private

◆ FunctionTypes

using retdec::ctypes::Context::FunctionTypes = std::map< std::tuple<std::shared_ptr<Type>, FunctionType::Parameters, std::string, bool>, std::shared_ptr<FunctionType> >
private

◆ NamedTypes

using retdec::ctypes::Context::NamedTypes = std::unordered_map<std::string, std::shared_ptr<Type> >
private

◆ PointerTypes

using retdec::ctypes::Context::PointerTypes = std::unordered_map<std::shared_ptr<Type>, std::shared_ptr<PointerType> >
private

◆ ReferenceTypes

using retdec::ctypes::Context::ReferenceTypes = std::unordered_map<std::shared_ptr<Type>, std::shared_ptr<ReferenceType> >
private

Member Function Documentation

◆ addAnnotation()

void retdec::ctypes::Context::addAnnotation ( const std::shared_ptr< Annotation > &  annot)

Adds annotation to context.

◆ addArrayType()

void retdec::ctypes::Context::addArrayType ( const std::shared_ptr< ArrayType > &  arrayType)

Adds array type to context.

Preconditions
  • arrayType is not null

◆ addFunction()

void retdec::ctypes::Context::addFunction ( const std::shared_ptr< Function > &  function)

Inserts new function to context.

Preconditions
  • function is not null

Function with same name will be overwritten.

◆ addFunctionType()

void retdec::ctypes::Context::addFunctionType ( const std::shared_ptr< FunctionType > &  functionType)

Inserts new function type to context.

Preconditions
  • functionType is not null

◆ addNamedType()

void retdec::ctypes::Context::addNamedType ( const std::shared_ptr< Type > &  type)

Inserts new type with specific name to context.

Preconditions
  • type is not null

◆ addPointerType()

void retdec::ctypes::Context::addPointerType ( const std::shared_ptr< PointerType > &  pointerType)

Inserts new pointerType with specific name to context.

Preconditions
  • pointerType is not null

◆ addReferenceType()

void retdec::ctypes::Context::addReferenceType ( const std::shared_ptr< ReferenceType > &  referenceType)

Inserts new referenceType with specific name to context.

Preconditions
  • referenceType is not null

◆ getAnnotation()

std::shared_ptr< Annotation > retdec::ctypes::Context::getAnnotation ( const std::string &  name) const

Returns annotation from context.

Returns
Requested annotation. If it is not in context return nullptr.

◆ getArrayType()

std::shared_ptr< ArrayType > retdec::ctypes::Context::getArrayType ( const std::shared_ptr< Type > &  elementType,
const ArrayType::Dimensions dimensions 
) const

Returns array type from context.

Returns
Requested pointerType. If it is not in context return nullptr.
Preconditions
  • elementType is not null

◆ getFunctionType()

std::shared_ptr< FunctionType > retdec::ctypes::Context::getFunctionType ( const std::shared_ptr< Type > &  returnType,
const FunctionType::Parameters parameters,
const CallConvention callConvention,
FunctionType::VarArgness  varArgness 
) const

Returns function type from context.

Returns
Requested type. If it is not in context return nullptr.
Preconditions
  • returnType is not null

◆ getFunctionWithName()

std::shared_ptr< Function > retdec::ctypes::Context::getFunctionWithName ( const std::string &  name) const

Returns function from context.

Returns
Requested function. If it is not in context return nullptr.

◆ getNamedType()

std::shared_ptr< Type > retdec::ctypes::Context::getNamedType ( const std::string &  name) const

Returns type with specific name from context.

Returns
Requested type. If it is not in context return nullptr.

◆ getPointerType()

std::shared_ptr< PointerType > retdec::ctypes::Context::getPointerType ( const std::shared_ptr< Type > &  pointedType) const

Returns pointerType from context.

Returns
Requested pointerType. If it is not in context return nullptr.
Preconditions
  • pointedType is not null

◆ getReferenceType()

std::shared_ptr< ReferenceType > retdec::ctypes::Context::getReferenceType ( const std::shared_ptr< Type > &  referencedType) const

Returns referenceType from context.

Returns
Requested referenceType. If it is not in context return nullptr.
Preconditions
  • referencedType is not null

◆ hasAnnotation()

bool retdec::ctypes::Context::hasAnnotation ( const std::string &  name) const

Checks if context contains annotation.

Returns
True if context has annotation, false otherwise.

◆ hasArrayType()

bool retdec::ctypes::Context::hasArrayType ( const std::shared_ptr< Type > &  elementType,
const ArrayType::Dimensions dimensions 
) const

Checks if context contains array type.

Returns
True if context has array type, false otherwise.
Preconditions
  • elementType is not null

◆ hasFunctionType()

bool retdec::ctypes::Context::hasFunctionType ( const std::shared_ptr< Type > &  returnType,
const FunctionType::Parameters parameters,
const CallConvention callConvention,
FunctionType::VarArgness  varArgness 
) const

Checks if context contains function type.

Returns
True if context has function type, false otherwise.
Preconditions
  • returnType is not null

◆ hasFunctionWithName()

bool retdec::ctypes::Context::hasFunctionWithName ( const std::string &  name) const

Checks if context contains function.

Returns
True if context has function, false otherwise.

◆ hasNamedType()

bool retdec::ctypes::Context::hasNamedType ( const std::string &  name) const

Checks if context contains type with specific name.

Returns
True if context has type, false otherwise.

◆ hasPointerType()

bool retdec::ctypes::Context::hasPointerType ( const std::shared_ptr< Type > &  pointedType) const

Checks if context contains pointer type.

Returns
True if context has pointer type, false otherwise.
Preconditions
  • pointedType is not null

◆ hasReferenceType()

bool retdec::ctypes::Context::hasReferenceType ( const std::shared_ptr< Type > &  referencedType) const

Checks if context contains reference type.

Returns
True if context has reference type, false otherwise.
Preconditions
  • referencedType is not null

Member Data Documentation

◆ annotations

Annotations retdec::ctypes::Context::annotations
private

Stored annotations.

◆ arrayTypes

ArrayTypes retdec::ctypes::Context::arrayTypes
private

Stored array types, key is element type and dimensions.

◆ functions

Functions retdec::ctypes::Context::functions
private

Stored functions.

◆ functionTypes

FunctionTypes retdec::ctypes::Context::functionTypes
private

Stored function types, key is return type and parameters' types.

◆ namedTypes

NamedTypes retdec::ctypes::Context::namedTypes
private

Stored types that can be identified by name.

◆ pointerTypes

PointerTypes retdec::ctypes::Context::pointerTypes
private

Stored pointer types, key is type that they point to.

◆ referenceTypes

ReferenceTypes retdec::ctypes::Context::referenceTypes
private

Stored reference types, key is type that they reference.


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