8 #include <hilti/ast/node-ref.h> 16 E operator*()
const {
return node; }
17 typename std::remove_reference<E>::type* operator->()
const {
return &node; }
21 Location(E node =
nullptr,
int child = 0) : node(node), child(child) {}
30 using Erased =
typename std::decay<E>::type;
39 const std::vector<Location<E>>&
path;
54 E
parent(
unsigned int parent_nr = 1)
const {
55 if ( path.size() < 1 + parent_nr )
56 throw std::out_of_range(
"node does not have requested parent");
58 return (**(path.end() - 1 - parent_nr));
63 std::optional<std::reference_wrapper<const T>>
findParent()
const {
64 for (
auto i = path.rbegin() + 1; i != path.rend(); i++ ) {
65 if ( (**i).template isA<T>() )
66 return {(**i).template as<T>()};
75 for (
auto i = path.rbegin() + 1; i != path.rend(); i++ ) {
76 if ( (**i).template isA<T>() )
Definition: operator.h:22
auto pathLength() const
Definition: visitor-types.h:46
Definition: visitor-types.h:28
E node
Definition: visitor-types.h:33
NodeRef findParentRef() const
Definition: visitor-types.h:74
const std::vector< Location< E > > & path
Definition: visitor-types.h:39
Definition: node-ref.h:45
std::optional< std::reference_wrapper< const T > > findParent() const
Definition: visitor-types.h:63
Definition: visitor-types.h:14
E parent(unsigned int parent_nr=1) const
Definition: visitor-types.h:54