CBMC
generic_parameter_specialization_mapt Class Reference

Author: Diffblue Ltd. More...

#include <generic_parameter_specialization_map.h>

+ Collaboration diagram for generic_parameter_specialization_mapt:

Classes

struct  container_paramt
 The index of the container and the type parameter inside that container. More...
 
struct  printert
 A wrapper for a generic_parameter_specialization_mapt and a namespacet that can be output to a stream. More...
 

Public Member Functions

std::size_t insert (const std::vector< java_generic_parametert > &parameters, std::vector< reference_typet > types)
 Insert a specialization for each type parameters of a container. More...
 
void pop (std::size_t container_index)
 Pop the top of the specialization stack for a given container. More...
 
std::optional< reference_typetpop (const irep_idt &parameter_name)
 Pop the top of the specialization stack for the container associated with a given type parameter. More...
 

Private Attributes

std::unordered_map< irep_idt, container_paramtparam_to_container
 A map from parameter names to container_paramt instances. More...
 
std::vector< std::stack< std::vector< reference_typet > > > container_to_specializations
 The list of containers and, for each one, the stack of lists of specializations. More...
 

Friends

template<typename ostreamt >
ostreamt & operator<< (ostreamt &stm, const printert &map)
 Output a generic_parameter_specialization_mapt wrapped in a generic_parameter_specialization_mapt::printert to a stream. More...
 

Detailed Description

Author: Diffblue Ltd.

A map from generic type parameters to their specializations (type arguments) We need to map from the names of parameters to the container (class or method) that contains them as well as the particular specialization of that parameter. However we do not need the name of the container, merely the full set of specializations for the parameters of that container. We store a stack of specializations for each container for a particular context. Finding the value for a type parameter is a matter of following the specialization for that parameter, unwinding the stack of its container as you do so and repeating until one reaches a non-generic type.

Definition at line 23 of file generic_parameter_specialization_map.h.

Member Function Documentation

◆ insert()

std::size_t generic_parameter_specialization_mapt::insert ( const std::vector< java_generic_parametert > &  parameters,
std::vector< reference_typet types 
)

Insert a specialization for each type parameters of a container.

Author: Diffblue Ltd.

Parameters
parametersThe type parameters
typesThe type arguments
Returns
: The index of the added container

Definition at line 5 of file generic_parameter_specialization_map.cpp.

◆ pop() [1/2]

std::optional< reference_typet > generic_parameter_specialization_mapt::pop ( const irep_idt parameter_name)

Pop the top of the specialization stack for the container associated with a given type parameter.

Parameters
parameter_nameThe name of the type parameter
Returns
: The specialization for the given type parameter, if there was one before the pop, or an empty std::optional if the stack was empty

Definition at line 55 of file generic_parameter_specialization_map.cpp.

◆ pop() [2/2]

void generic_parameter_specialization_mapt::pop ( std::size_t  container_index)

Pop the top of the specialization stack for a given container.

Parameters
container_indexThe index of the container to pop

Definition at line 49 of file generic_parameter_specialization_map.cpp.

Friends And Related Function Documentation

◆ operator<<

template<typename ostreamt >
ostreamt& operator<< ( ostreamt &  stm,
const printert map 
)
friend

Output a generic_parameter_specialization_mapt wrapped in a generic_parameter_specialization_mapt::printert to a stream.

Template Parameters
ostreamtThe type of stream to output to (not restricted to be derived from std::ostream)
Parameters
stmThe stream to output to
mapThe generic_parameter_specialization_mapt printer to output
Returns
: A reference to the stream passed in

Definition at line 86 of file generic_parameter_specialization_map.h.

Member Data Documentation

◆ container_to_specializations

std::vector<std::stack<std::vector<reference_typet> > > generic_parameter_specialization_mapt::container_to_specializations
private

The list of containers and, for each one, the stack of lists of specializations.

Definition at line 37 of file generic_parameter_specialization_map.h.

◆ param_to_container

std::unordered_map<irep_idt, container_paramt> generic_parameter_specialization_mapt::param_to_container
private

A map from parameter names to container_paramt instances.

Definition at line 33 of file generic_parameter_specialization_map.h.


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