1 #ifndef ROSE_AstAttributeMechanism_H
2 #define ROSE_AstAttributeMechanism_H
5 #include "rose_override.h"
6 #include <Sawyer/Attribute.h>
37 class ROSE_DLL_API AstAttribute {
105 class ROSE_DLL_API AttributeEdgeInfo {
112 AttributeEdgeInfo(
SgNode* fromNode,
SgNode* toNode, std::string label, std::string options)
113 : fromNode(fromNode), toNode(toNode), label(label), options(options) {}
115 ~AttributeEdgeInfo() {
122 class ROSE_DLL_API AttributeNodeInfo {
128 AttributeNodeInfo(
SgNode* nodePtr, std::string label, std::string options)
129 : nodePtr(nodePtr), label(label), options(options) {}
131 ~AttributeNodeInfo() {};
136 virtual ~AstAttribute() {}
147 virtual AstAttribute* constructor()
const {
148 return new AstAttribute;
163 virtual AstAttribute*
copy()
const {
171 virtual AstAttribute*
copy() {
172 return const_cast<const AstAttribute*
>(
this)->
copy();
183 virtual std::string attribute_class_name()
const {
184 return "AstAttribute";
197 virtual int packed_size();
198 virtual char* packed_data();
199 virtual void unpacked_data(
int size,
char* data );
205 virtual std::string additionalNodeOptions();
206 virtual std::vector<AttributeEdgeInfo> additionalEdgeInfo();
207 virtual std::vector<AttributeNodeInfo> additionalNodeInfo();
213 virtual bool commentOutNodeInGraph();
250 class ROSE_DLL_API AstAttributeMechanism {
258 AstAttributeMechanism() {}
268 AstAttributeMechanism(
const AstAttributeMechanism &other) {
283 AstAttributeMechanism& operator=(
const AstAttributeMechanism &other);
293 ~AstAttributeMechanism();
302 bool exists(
const std::string &name)
const;
320 void set(
const std::string &name, AstAttribute *value);
332 bool add(
const std::string &name, AstAttribute *value);
344 bool replace(
const std::string &name, AstAttribute *value);
359 AstAttribute* operator[](
const std::string &name)
const;
370 void remove(
const std::string &name);
373 typedef std::set<std::string> AttributeIdentifiers;
388 AttributeIdentifiers getAttributeIdentifiers()
const;
401 void assignFrom(
const AstAttributeMechanism &other);
412 class ROSE_DLL_API MetricAttribute:
public AstAttribute {
419 : is_derived_(false), value_(0) {}
421 MetricAttribute(
double value,
bool is_derived=
false)
422 : is_derived_(is_derived), value_(value) {}
424 virtual AstAttribute*
copy() const ROSE_OVERRIDE;
425 virtual
std::
string attribute_class_name() const ROSE_OVERRIDE;
427 virtual
bool isDerived()
const {
return is_derived_; }
428 virtual double getValue()
const {
return value_; }
429 virtual void setValue(
double newVal) { value_ = newVal; }
431 virtual std::string
toString() ROSE_OVERRIDE;
433 virtual
int packed_size() ROSE_OVERRIDE;
434 virtual
char* packed_data() ROSE_OVERRIDE;
435 virtual
void unpacked_data(
int size,
char* data) ROSE_OVERRIDE;
437 MetricAttribute& operator+=(const MetricAttribute &other);
438 MetricAttribute& operator-=(const MetricAttribute &other);
439 MetricAttribute& operator*=(const MetricAttribute &other);
440 MetricAttribute& operator/=(const MetricAttribute &other);
451 class ROSE_DLL_API AstValueAttribute: public AstAttribute {
459 AstValueAttribute() {}
462 explicit AstValueAttribute(
const T &value): value_(value) {}
465 AstValueAttribute(
const AstValueAttribute &other): value_(other.value_) {}
467 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
return new AstValueAttribute(*
this); }
468 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
return "AstValueAttribute"; }
473 const T&
get()
const {
return value_; }
474 T&
get() {
return value_; }
478 void set(
const T& value) { value_ = value; }
485 class ROSE_DLL_API AstRegExAttribute:
public AstAttribute {
487 std::string expression;
489 AstRegExAttribute() {}
491 explicit AstRegExAttribute(
const std::string & s)
494 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
495 return new AstRegExAttribute(*
this);
498 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
499 return "AstRegExAttribute";
508 class ROSE_DLL_API AstSgNodeAttribute:
public AstValueAttribute<SgNode*> {
510 typedef AstValueAttribute<SgNode*> Super;
511 AstSgNodeAttribute(): Super(NULL) {}
512 explicit AstSgNodeAttribute(
SgNode *value): Super(value) {}
513 AstSgNodeAttribute(
const AstSgNodeAttribute &other): Super(other) {}
514 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
return new AstSgNodeAttribute(*
this); }
515 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
return "AstSgNodeAttribute"; }
516 SgNode* getNode() {
return get(); }
517 void setNode(
SgNode *node) {
set(node); }
520 class ROSE_DLL_API AstSgNodeListAttribute:
public AstValueAttribute<std::vector<SgNode*> > {
522 typedef AstValueAttribute<std::vector<SgNode*> > Super;
523 AstSgNodeListAttribute() {}
524 explicit AstSgNodeListAttribute(std::vector<SgNode *> &value): Super(value) {}
525 AstSgNodeListAttribute(
const AstSgNodeListAttribute &other): Super(other) {}
526 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
return new AstSgNodeListAttribute(*
this); }
527 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
return "AstSgNodeListAttribute"; }
528 std::vector<SgNode*> &getNodeList() {
return get(); }
529 void addNode(
SgNode *n) {
get().push_back(n); }
530 void setNode(
SgNode*,
int);
532 int size() {
return get().size(); }
535 class ROSE_DLL_API AstIntAttribute :
public AstValueAttribute<int> {
537 typedef AstValueAttribute<int> Super;
538 AstIntAttribute(): Super(0) {}
539 explicit AstIntAttribute(
int value): Super(value) {}
540 AstIntAttribute(
const AstIntAttribute &other): Super(other) {}
541 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
return new AstIntAttribute(*
this); }
542 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
return "AstIntAttribute"; }
543 int getValue() {
return get(); }
546 class ROSE_DLL_API AstParameterizedTypeAttribute:
public AstAttribute {
548 std::list<SgJavaParameterizedType *> parameterizedTypes;
551 AstParameterizedTypeAttribute()
552 : genericType(NULL) {}
554 explicit AstParameterizedTypeAttribute(
SgNamedType *genericType);
556 AstParameterizedTypeAttribute(
const AstParameterizedTypeAttribute &other)
557 : genericType(other.genericType), parameterizedTypes(other.parameterizedTypes) {}
559 virtual AstAttribute*
copy() const ROSE_OVERRIDE {
560 return new AstParameterizedTypeAttribute(*
this);
563 virtual std::string attribute_class_name() const ROSE_OVERRIDE {
564 return "AstParameterizedTypeAttribute";
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.
ROSE_DLL_API std::string toString(const Attributes &)
Convert attributes to GraphViz language string.
void setValue(Word *words, const BitRange &where, bool value)
Set or clear some bits.
const char * OwnershipPolicy(int64_t)
Convert AstAttribute::OwnershipPolicy enum constant to a string.
This class represents the base class for all IR nodes within Sage III.
void set(Word *words, const BitRange &where)
Set some bits.