ROSE 0.11.145.237
|
This namespace contains template functions that operate on the ROSE AST.
Classes | |
struct | AncestorTypeFinder |
helper class for _ancestor More... | |
struct | ConditionalEnable |
struct | ConditionalEnable< false > |
struct | ConstLike |
projects the constness of T1 on T2 More... | |
struct | ConstLike< const T1, T2 > |
struct | DefaultHandler |
struct DefaultHandler More... | |
struct | DispatchHandler |
struct DispatchHandler More... | |
struct | DispatchHelper |
prevents the dispatch handler being called on nullptr. More... | |
struct | EnableConversion |
struct | NotNull |
experimental class for returning non-null pointers More... | |
struct | TypeRecovery |
struct | VisitDispatcher |
Functions | |
void | report_error (std::string desc, const char *file=nullptr, size_t ln=0) |
void | unexpected_node (const SgNode &n, const char *file=nullptr, size_t ln=0) |
template<class T > | |
T & | deref (T *ptr, const char *file=0, size_t ln=0) |
dereferences an object (= checked dereference in debug mode) | |
template<class T , class U , bool = EnableConversion<U*,T*>::value || EnableConversion<T*,U*>::value> | |
bool | operator< (NotNull< T > lhs, NotNull< U > rhs) |
template<class RoseVisitor > | |
std::remove_const< typenamestd::remove_reference< RoseVisitor >::type >::type | _dispatch (RoseVisitor &&rv, SgNode *n) |
template<class RoseVisitor > | |
std::remove_const< typenamestd::remove_reference< RoseVisitor >::type >::type | dispatch (RoseVisitor &&rv, SgNode *n) |
uncovers the type of SgNode and passes it to an function "handle" in RoseVisitor. | |
template<class RoseVisitor > | |
std::remove_const< typenamestd::remove_reference< RoseVisitor >::type >::type | dispatch (RoseVisitor &&rv, const SgNode *n) |
template<class AncestorNode , class QualSgNode > | |
AncestorNode * | _ancestor (QualSgNode &n) |
implements the ancestor search | |
template<class AncestorNode > | |
AncestorNode * | ancestor (SgNode *n) |
finds an ancestor node with a given type | |
template<class AncestorNode > | |
const AncestorNode * | ancestor (const SgNode *n) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class AncestorNode > | |
AncestorNode & | ancestor (SgNode &n) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class AncestorNode > | |
const AncestorNode & | ancestor (const SgNode &n) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<class SageNode , class... SageNodes> | |
auto | ancestorPath (const SgNode &n) -> typename SageGenericLastType< SageNode, SageNodes... >::type * |
returns the last parent in an ancestor path | |
template<class SageNode , class SageChild > | |
void | swap_child (SageNode &lhs, SageNode &rhs, SageChild *(SageNode::*getter)() const, void(SageNode::*setter)(SageChild *)) |
swaps children (of equal kind) between two ancestor nodes of the same type | |
template<class SageParent , class SageChild > | |
void | linkParentChild (SageParent &parent, SageChild &child, void(SageParent::*setter)(SageChild *)) |
Links parent node parent to child node child using the setter method setter . | |
template<class SageNode > | |
SageNode * | assert_sage_type (SgNode *n, const char *f=0, size_t ln=0) |
asserts that n has type SageNode | |
template<class SageNode > | |
const SageNode * | assert_sage_type (const SgNode *n, const char *f=0, size_t ln=0) |
asserts that n has type SageNode | |
template<class SageNode > | |
SageNode & | assert_sage_type (SgNode &n, const char *f=0, size_t ln=0) |
asserts that n has type SageNode | |
template<class SageNode > | |
const SageNode & | assert_sage_type (const SgNode &n, const char *f=0, size_t ln=0) |
asserts that n has type SageNode | |
template<class SageNode > | |
SageNode::base_node_type & | asBaseType (SageNode &n) |
returns the same node n upcasted to its base type | |
template<class SageNode > | |
const SageNode::base_node_type & | asBaseType (const SageNode &n) |
returns the same node n upcasted to its base type | |
template<class SageNode > | |
SageNode::base_node_type * | asBaseType (SageNode *n) |
returns the same node n upcasted to its base type | |
template<class SageNode > | |
const SageNode::base_node_type * | asBaseType (const SageNode *n) |
returns the same node n upcasted to its base type | |
T & sg::deref | ( | T * | ptr, |
const char * | file = 0 , |
||
size_t | ln = 0 |
||
) |
dereferences an object (= checked dereference in debug mode)
Definition at line 99 of file sageGeneric.h.
bool sg::operator< | ( | NotNull< T > | lhs, |
NotNull< U > | rhs | ||
) |
Definition at line 169 of file sageGeneric.h.
|
inline |
Definition at line 1281 of file sageGeneric.h.
|
inline |
uncovers the type of SgNode and passes it to an function "handle" in RoseVisitor.
which should be overloaded with every possible target node. After the traversal, RoseVisitor should contain the intended return data.
RoseVisitor. | The visitor that will be called back with the recovered type information. It must implement "handle." The handle function with the most suitable SgNode type will get invoked. |
rv | an instance of a rose visitor; ie any class with a "handle" function. Note: rv is essentially passed by value (similar to STL's for_each). |
n | The root of the tree to visit. SgNode |
The following code has two classes.
Definition at line 1371 of file sageGeneric.h.
Referenced by _ancestor(), assert_sage_type(), assert_sage_type(), assert_sage_type(), assert_sage_type(), and SageInterface::getDeclaredType().
|
inline |
Definition at line 1380 of file sageGeneric.h.
AncestorNode * sg::_ancestor | ( | QualSgNode & | n | ) |
implements the ancestor search
see comments for AncestorTypeFinder
Definition at line 1433 of file sageGeneric.h.
References dispatch().
AncestorNode * sg::ancestor | ( | SgNode * | n | ) |
finds an ancestor node with a given type
the function family comes in four variants:
Definition at line 1459 of file sageGeneric.h.
const AncestorNode * sg::ancestor | ( | const SgNode * | n | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1468 of file sageGeneric.h.
AncestorNode & sg::ancestor | ( | SgNode & | n | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1477 of file sageGeneric.h.
const AncestorNode & sg::ancestor | ( | const SgNode & | n | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1487 of file sageGeneric.h.
SageNode * sg::assert_sage_type | ( | SgNode * | n, |
const char * | f = 0 , |
||
size_t | ln = 0 |
||
) |
asserts that n has type SageNode
the ROSE assert in the following example holds b/c assert_sage_type aborts if the input node is not a SgStatement
Definition at line 1537 of file sageGeneric.h.
References dispatch().
const SageNode * sg::assert_sage_type | ( | const SgNode * | n, |
const char * | f = 0 , |
||
size_t | ln = 0 |
||
) |
asserts that n has type SageNode
the ROSE assert in the following example holds b/c assert_sage_type aborts if the input node is not a SgStatement
Definition at line 1543 of file sageGeneric.h.
References dispatch().
SageNode & sg::assert_sage_type | ( | SgNode & | n, |
const char * | f = 0 , |
||
size_t | ln = 0 |
||
) |
asserts that n has type SageNode
the ROSE assert in the following example holds b/c assert_sage_type aborts if the input node is not a SgStatement
Definition at line 1549 of file sageGeneric.h.
References dispatch().
const SageNode & sg::assert_sage_type | ( | const SgNode & | n, |
const char * | f = 0 , |
||
size_t | ln = 0 |
||
) |
asserts that n has type SageNode
the ROSE assert in the following example holds b/c assert_sage_type aborts if the input node is not a SgStatement
Definition at line 1555 of file sageGeneric.h.
References dispatch().
auto sg::ancestorPath | ( | const SgNode & | n | ) | -> typename SageGenericLastType<SageNode, SageNodes...>::type* |
returns the last parent in an ancestor path
Definition at line 1610 of file sageGeneric.h.
void sg::swap_child | ( | SageNode & | lhs, |
SageNode & | rhs, | ||
SageChild *(SageNode::*)() const | getter, | ||
void(SageNode::*)(SageChild *) | setter | ||
) |
swaps children (of equal kind) between two ancestor nodes of the same type
SageNode | the parent node type |
SageChild | the child node type |
lhs | one parent node |
rhs | another parent node |
getter | the getter function to extract the child from lhs (and rhs) |
setter | the setter function to store the child in lhs (and rhs) |
Definition at line 1645 of file sageGeneric.h.
void sg::linkParentChild | ( | SageParent & | parent, |
SageChild & | child, | ||
void(SageParent::*)(SageChild *) | setter | ||
) |
Links parent node parent
to child node child
using the setter method setter
.
Also sets the parent link from child
to parent
.
Definition at line 1724 of file sageGeneric.h.
SageNode::base_node_type & sg::asBaseType | ( | SageNode & | n | ) |
returns the same node n
upcasted to its base type
Definition at line 1735 of file sageGeneric.h.
const SageNode::base_node_type & sg::asBaseType | ( | const SageNode & | n | ) |
returns the same node n
upcasted to its base type
Definition at line 1739 of file sageGeneric.h.
SageNode::base_node_type * sg::asBaseType | ( | SageNode * | n | ) |
returns the same node n
upcasted to its base type
Definition at line 1743 of file sageGeneric.h.
const SageNode::base_node_type * sg::asBaseType | ( | const SageNode * | n | ) |
returns the same node n
upcasted to its base type
Definition at line 1747 of file sageGeneric.h.