PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::CTemplateInstance Class Reference

#include <Puma/CTemplateInstance.h>

Description

Semantic information about a template instance.

Contains the point of instantiation, the instantiated template, the instantiation arguments, and the deduced template arguments.

The point of instantiation (POI) is the corresponding template-id.

X<int> x; // X<int> is the POI

The instantiation arguments are the arguments of the template-id at the POI.

Y<int,1> y; // 'int' and '1' are the instantiation arguments

The deduced template arguments are calculated from the instantiation arguments and the template default arguments.

template<class T1, class T2 = float>
struct Foo {
template<class T3, class T4>
T1 foo(T2,T3,T4*);
};
void bar(bool b, char* s) {
Foo<int> f; // deduced arguments: T1=int, T2=float
f.foo(1,b,s); // deduced arguments: T3=bool, T4=char
}

If a template instance is not yet created (maybe because real template instantiation is disabled or due to late template instantiation), then this template instance is called a pseudo instance.

Public Member Functions

 CTemplateInstance ()
 Constructor.
 
 ~CTemplateInstance ()
 Destructor.
 
bool instantiate (CStructure *scope)
 If this is a pseudo instance, instantiate the template.
 
CTemplateInfoTemplate () const
 Get the semantic information about the instantiated template.
 
CObjectInfoObject () const
 Get the semantic information about the class or function.
 
void Template (CTemplateInfo *info)
 Set the semantic information about the instantiated template.
 
void Object (CObjectInfo *info)
 Set the semantic information about the instance.
 
CTreePointOfInstantiation () const
 Get the point of instantiation (e.g.
 
CScopeInfoPointOfInstantiationScope () const
 Get the scope in which the template was instantiated.
 
void PointOfInstantiation (CTree *poi, CScopeInfo *scope)
 Set the point of instantiation (e.g.
 
void canInstantiate (bool can)
 Set that the pseudo instance can be instantiated.
 
bool canInstantiate ()
 Return true if the pseudo instance can be instantiated.
 
void isPseudoInstance (bool v)
 Set whether this is a pseudo template instance.
 
bool isPseudoInstance () const
 Check if this is a pseudo template instance.
 
void isInstantiated (bool is)
 Set whether this template instance really is instantiated.
 
bool isInstantiated () const
 Check if this template instance really is instantiated.
 
void hasDelayedParseProblem (bool has)
 Indicate a delayed parse problem during instantiation.
 
bool hasDelayedParseProblem () const
 Check whether this instance had a delayed parse problem.
 
unsigned InstantiationArgs () const
 Get the number of instantiation arguments.
 
DeducedArgumentInstantiationArg (unsigned n) const
 Get the n-th instantiation argument.
 
void addInstantiationArg (DeducedArgument *arg)
 Add an instantiation argument.
 
unsigned DeducedArgs () const
 Get the number of deduced arguments.
 
DeducedArgumentDeducedArg (unsigned n) const
 Get the n-th deduced template argument.
 
void addDeducedArg (DeducedArgument *arg)
 Add a deduced template argument.
 
void clearDeducedArgs ()
 Discard the deduced template arguments.
 

Protected Attributes

CTemplateInfo_TemplateInfo
 The semantic information about the template.
 
CObjectInfo_ObjectInfo
 The semantic information about the instance.
 
CTree_PointOfInstantiation
 The point of instantiation.
 
CScopeInfo_PointOfInstantiationScope
 The scope in which the template was instantiated.
 
Array< DeducedArgument * > _DeducedArgs
 The list of deduced template arguments.
 
Array< DeducedArgument * > _InstantiationArgs
 The list of instantiation arguments.
 
bool _Pseudo
 True if this is not a real template instance.
 
bool _CanInstantiate
 True if this pseudo instance can be instantiated.
 
bool _IsInstantiated
 True if instantiated.
 
bool _IsSpecialization
 True if this is the instance of a template specialization.
 
bool _HasDelayedParseProblem
 True if this node had a delayed parse problem.
 

Constructor & Destructor Documentation

◆ CTemplateInstance()

Puma::CTemplateInstance::CTemplateInstance ( )
inline

Constructor.

◆ ~CTemplateInstance()

Puma::CTemplateInstance::~CTemplateInstance ( )

Destructor.

Destroys the instantiation and deduced arguments. Optionally destroys the translation unit of the instance code.

Member Function Documentation

◆ addDeducedArg()

void Puma::CTemplateInstance::addDeducedArg ( DeducedArgument * arg)
inline

Add a deduced template argument.

Parameters
argThe deduced template argument.

◆ addInstantiationArg()

void Puma::CTemplateInstance::addInstantiationArg ( DeducedArgument * arg)
inline

Add an instantiation argument.

Parameters
argThe instantiation argument.

◆ canInstantiate() [1/2]

bool Puma::CTemplateInstance::canInstantiate ( )
inline

Return true if the pseudo instance can be instantiated.

◆ canInstantiate() [2/2]

void Puma::CTemplateInstance::canInstantiate ( bool can)
inline

Set that the pseudo instance can be instantiated.

◆ clearDeducedArgs()

void Puma::CTemplateInstance::clearDeducedArgs ( )
inline

Discard the deduced template arguments.

◆ DeducedArg()

DeducedArgument * Puma::CTemplateInstance::DeducedArg ( unsigned n) const
inline

Get the n-th deduced template argument.

Parameters
nThe index of the template argument.

◆ DeducedArgs()

unsigned Puma::CTemplateInstance::DeducedArgs ( ) const
inline

Get the number of deduced arguments.

◆ hasDelayedParseProblem() [1/2]

bool Puma::CTemplateInstance::hasDelayedParseProblem ( ) const
inline

Check whether this instance had a delayed parse problem.

◆ hasDelayedParseProblem() [2/2]

void Puma::CTemplateInstance::hasDelayedParseProblem ( bool has)
inline

Indicate a delayed parse problem during instantiation.

Parameters
hasTrue for yes, false for no.

◆ instantiate()

bool Puma::CTemplateInstance::instantiate ( CStructure * scope)

If this is a pseudo instance, instantiate the template.

Parameters
scopeThe scope in which to instantiate the template.
Returns
true if instantiation succeeded.

◆ InstantiationArg()

DeducedArgument * Puma::CTemplateInstance::InstantiationArg ( unsigned n) const
inline

Get the n-th instantiation argument.

Parameters
nThe index of the instantiation argument.

◆ InstantiationArgs()

unsigned Puma::CTemplateInstance::InstantiationArgs ( ) const
inline

Get the number of instantiation arguments.

◆ isInstantiated() [1/2]

bool Puma::CTemplateInstance::isInstantiated ( ) const
inline

Check if this template instance really is instantiated.

◆ isInstantiated() [2/2]

void Puma::CTemplateInstance::isInstantiated ( bool is)
inline

Set whether this template instance really is instantiated.

Parameters
isTrue for yes, false for no.

◆ isPseudoInstance() [1/2]

bool Puma::CTemplateInstance::isPseudoInstance ( ) const
inline

Check if this is a pseudo template instance.

◆ isPseudoInstance() [2/2]

void Puma::CTemplateInstance::isPseudoInstance ( bool v)
inline

Set whether this is a pseudo template instance.

Parameters
vTrue for yes, false for no.

◆ Object() [1/2]

CObjectInfo * Puma::CTemplateInstance::Object ( ) const
inline

Get the semantic information about the class or function.

◆ Object() [2/2]

void Puma::CTemplateInstance::Object ( CObjectInfo * info)
inline

Set the semantic information about the instance.

Parameters
infoThe instance object.

◆ PointOfInstantiation() [1/2]

CTree * Puma::CTemplateInstance::PointOfInstantiation ( ) const
inline

Get the point of instantiation (e.g.

the template-id).

◆ PointOfInstantiation() [2/2]

void Puma::CTemplateInstance::PointOfInstantiation ( CTree * poi,
CScopeInfo * scope )
inline

Set the point of instantiation (e.g.

the template-id).

Parameters
poiThe template-id used to instantiate the template.
scopeThe scope in which the template was instantiated.

◆ PointOfInstantiationScope()

CScopeInfo * Puma::CTemplateInstance::PointOfInstantiationScope ( ) const
inline

Get the scope in which the template was instantiated.

◆ Template() [1/2]

CTemplateInfo * Puma::CTemplateInstance::Template ( ) const
inline

Get the semantic information about the instantiated template.

◆ Template() [2/2]

void Puma::CTemplateInstance::Template ( CTemplateInfo * info)
inline

Set the semantic information about the instantiated template.

Parameters
infoThe template that was instantiated.

Member Data Documentation

◆ _CanInstantiate

bool Puma::CTemplateInstance::_CanInstantiate
protected

True if this pseudo instance can be instantiated.

◆ _DeducedArgs

Array<DeducedArgument*> Puma::CTemplateInstance::_DeducedArgs
protected

The list of deduced template arguments.

◆ _HasDelayedParseProblem

bool Puma::CTemplateInstance::_HasDelayedParseProblem
protected

True if this node had a delayed parse problem.

◆ _InstantiationArgs

Array<DeducedArgument*> Puma::CTemplateInstance::_InstantiationArgs
protected

The list of instantiation arguments.

◆ _IsInstantiated

bool Puma::CTemplateInstance::_IsInstantiated
protected

True if instantiated.

◆ _IsSpecialization

bool Puma::CTemplateInstance::_IsSpecialization
protected

True if this is the instance of a template specialization.

◆ _ObjectInfo

CObjectInfo* Puma::CTemplateInstance::_ObjectInfo
protected

The semantic information about the instance.

◆ _PointOfInstantiation

CTree* Puma::CTemplateInstance::_PointOfInstantiation
protected

The point of instantiation.

◆ _PointOfInstantiationScope

CScopeInfo* Puma::CTemplateInstance::_PointOfInstantiationScope
protected

The scope in which the template was instantiated.

◆ _Pseudo

bool Puma::CTemplateInstance::_Pseudo
protected

True if this is not a real template instance.

◆ _TemplateInfo

CTemplateInfo* Puma::CTemplateInstance::_TemplateInfo
protected

The semantic information about the template.