46 template <
typename ChildNodeT>
47 static constexpr bool is_match = std::is_same<ParentNodeT, ChildNodeT>::value;
49 template <
typename F,
typename N>
50 static constexpr bool do_nothing = !is_match<N> || !F::traverse;
52 template <
typename F,
typename N>
53 using enable_nop = std::enable_if_t<do_nothing<F, N>>;
55 template <
typename F,
typename N>
56 using enable_call = std::enable_if_t<!do_nothing<F, N> && !F::iterable>;
58 template <
typename F,
typename N>
59 using enable_iterate = std::enable_if_t<!do_nothing<F, N> && F::iterable>;
61 template <
typename FieldT,
typename ChildNodeT, enable_nop<FieldT, ChildNodeT> * =
nullptr>
62 inline void operator() (ChildNodeT * node, PreFuncT & pre, PostFuncT & post)
const { }
64 template <
typename FieldT,
typename ChildNodeT, enable_call<FieldT, ChildNodeT> * =
nullptr>
65 inline void operator() (ChildNodeT * node, PreFuncT & pre, PostFuncT & post)
const {
66 using node_type = std::remove_pointer_t<typename FieldT::type>;
68 if (node->*(FieldT::mbr_ptr)) {
69 FieldDispatcher::dispatch(node->*(FieldT::mbr_ptr), pre, post, FieldT{FieldT::position});
73 template <
typename FieldT,
typename ChildNodeT, enable_iterate<FieldT, ChildNodeT> * =
nullptr>
74 inline void operator() (ChildNodeT * node, PreFuncT & pre, PostFuncT & post)
const {
75 using node_type = std::remove_pointer_t<typename FieldT::type>;
79 for (
auto ptr: node->*(FieldT::mbr_ptr)) {
81 FieldDispatcher::dispatch(ptr, pre, post, FieldT{i});
108 using subclasses = list_concrete_subclasses<OrigNodeT>;
110 static void dispatch(OrigNodeT * node, PreFuncT & pre, PostFuncT & post, FieldT field) {
112 auto const v = node->variantT();
113 subclasses::apply([&]<
typename ConcreteNodeT>() {
115 using fields =
typename get_inherited_traversable_list_t<ConcreteNodeT>::list;
117 ConcreteNodeT * cnode = (ConcreteNodeT*)node;
120 pre.PreFuncT::template operator()(cnode, field);
121 fields::apply(ftt, cnode, pre, post);
122 post.PostFuncT::template operator()(cnode, field);
131void traverse( NodeT * node_, PreFuncT & pre = traversal_details::nop_noargs_f, PostFuncT & post = traversal_details::nop_noargs_f) {
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.