ROSE 0.11.145.192
Public Types | Public Member Functions | List of all members
AstValueAttribute< T > Class Template Reference

Description

template<class T>
class AstValueAttribute< T >

IR node attribute that stores a copyable value.

Since IR node attributes must all inherit from AstAttribute we need to write wrappers around POD types and 3rd party types when we want to store them as IR attributes. We've ended up with a proliferation of such attributes that all do almost the same thing but have different names to access their data members. Hopefully by providing one class template we can avoid further proliferation.

Definition at line 450 of file AstAttributeMechanism.h.

#include <midend/astProcessing/AstAttributeMechanism.h>

Inheritance diagram for AstValueAttribute< T >:
Inheritance graph
[legend]
Collaboration diagram for AstValueAttribute< T >:
Collaboration graph
[legend]

Public Types

typedef T Value
 Type of value this wrapper holds.
 
- Public Types inherited from AstAttribute
enum  OwnershipPolicy {
  CONTAINER_OWNERSHIP ,
  NO_OWNERSHIP ,
  CUSTOM_OWNERSHIP ,
  UNKNOWN_OWNERSHIP
}
 Who owns this attribute. More...
 

Public Member Functions

 AstValueAttribute ()
 Default constructor.
 
 AstValueAttribute (const T &value)
 Constructs an attribute containing a specified value.
 
 AstValueAttribute (const AstValueAttribute &other)
 Copy constructor.
 
virtual AstAttributecopy () const override
 Virtual copy constructor.
 
virtual std::string attribute_class_name () const override
 Attribute class name.
 
void set (const T &value)
 Assign a new value.
 
const T & get () const
 Return the stored value by reference.
 
T & get ()
 Return the stored value by reference.
 
- Public Member Functions inherited from AstAttribute
virtual OwnershipPolicy getOwnershipPolicy () const
 Who owns this attribute.
 
virtual AstAttributeconstructor () const
 Virtual default constructor.
 
virtual AstAttributecopy ()
 
virtual std::string toString ()
 Convert an attribute to a string.
 
virtual bool commentOutNodeInGraph ()
 Eliminate IR nodes in DOT graphs.
 
virtual int packed_size ()
 Packing support.
 
virtual char * packed_data ()
 Packing support.
 
virtual void unpacked_data (int size, char *data)
 Packing support.
 
virtual std::string additionalNodeOptions ()
 DOT support.
 
virtual std::vector< AttributeEdgeInfoadditionalEdgeInfo ()
 DOT support.
 
virtual std::vector< AttributeNodeInfoadditionalNodeInfo ()
 DOT support.
 

Member Typedef Documentation

◆ Value

template<class T >
typedef T AstValueAttribute< T >::Value

Type of value this wrapper holds.

Definition at line 453 of file AstAttributeMechanism.h.

Constructor & Destructor Documentation

◆ AstValueAttribute() [1/3]

template<class T >
AstValueAttribute< T >::AstValueAttribute ( )
inline

Default constructor.

Constructs an attribute wrapper having a default-constructed value.

Definition at line 458 of file AstAttributeMechanism.h.

◆ AstValueAttribute() [2/3]

template<class T >
AstValueAttribute< T >::AstValueAttribute ( const T &  value)
inlineexplicit

Constructs an attribute containing a specified value.

Definition at line 461 of file AstAttributeMechanism.h.

◆ AstValueAttribute() [3/3]

template<class T >
AstValueAttribute< T >::AstValueAttribute ( const AstValueAttribute< T > &  other)
inline

Copy constructor.

Invokes the copy-constructor of the contained value.

Definition at line 464 of file AstAttributeMechanism.h.

Member Function Documentation

◆ copy()

template<class T >
virtual AstAttribute * AstValueAttribute< T >::copy ( ) const
inlineoverridevirtual

Virtual copy constructor.

Copy-constructs a new object on the heap and returns its pointer. All subclasses must implement this in order to instantiate the correct dynamic type, although many don't. If this copy method returns a null pointer (like the base implementation) then the attribute is not copied as part of copying its container. E.g., an attribute stored in an AST will not be copied when the AST is copied if that attribute is directly derived from AstAttribute and fails to implement copy. If a subclass fails to implement copy and inherits from a class that does implement a copy that returns non-null, then the copied attribute will have an incorrect dynamic type.

It would be nice if we could make this pure virtual, but unfortunately ROSETTA-generated code fails to compile because it generates an instantiation of this interface (whether or not that code is ever executed is unkown). [Robb Matzke 2015-11-10]

Reimplemented from AstAttribute.

Reimplemented in AstSgNodeAttribute, AstSgNodeListAttribute, and AstIntAttribute.

Definition at line 466 of file AstAttributeMechanism.h.

◆ attribute_class_name()

template<class T >
virtual std::string AstValueAttribute< T >::attribute_class_name ( ) const
inlineoverridevirtual

Attribute class name.

Returns the name of the dynamic type. All subclasses must implement this in order to return the correct type name, although many don't. If a subclass fails to implement this then it will return an incorrect class name.

It would be nice if this could be pure virtual, but unfortunately ROSETTA-generated code fails to compile because it generates an instantiation of this interface (whether or not that code is ever executed is unknown). [Robb Matzke 2015-11-10]

Reimplemented from AstAttribute.

Reimplemented in AstSgNodeAttribute, AstSgNodeListAttribute, and AstIntAttribute.

Definition at line 467 of file AstAttributeMechanism.h.

◆ get() [1/2]

template<class T >
const T & AstValueAttribute< T >::get ( ) const
inline

Return the stored value by reference.

Definition at line 472 of file AstAttributeMechanism.h.

◆ get() [2/2]

template<class T >
T & AstValueAttribute< T >::get ( )
inline

Return the stored value by reference.

Definition at line 473 of file AstAttributeMechanism.h.

◆ set()

template<class T >
void AstValueAttribute< T >::set ( const T &  value)
inline

Assign a new value.

Definition at line 477 of file AstAttributeMechanism.h.


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