Template Class AstValueAttribute#
Defined in File AstAttributeMechanism.h
Inheritance Relationships#
Base Type#
public AstAttribute(Class AstAttribute)
Class Documentation#
-
template<class T>
class AstValueAttribute : public AstAttribute# 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.
Public Functions
-
inline AstValueAttribute()#
Default constructor.
Constructs an attribute wrapper having a default-constructed value.
-
inline explicit AstValueAttribute(const T &value)#
Constructs an attribute containing a specified value.
-
inline AstValueAttribute(const AstValueAttribute &other)#
Copy constructor.
Invokes the copy-constructor of the contained value.
-
inline virtual AstAttribute *copy() const override#
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]
-
inline virtual std::string attribute_class_name() const override#
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]
-
inline AstValueAttribute()#