Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.proto.hpp

    rdff6452 rb0abc8a0  
    107107                bool     * m_prev;
    108108                bool_ref * m_ref;
    109         };
    110 
    111         template<typename pass_t, typename node_t>
    112         struct is_valid_previsit {
    113                 using ret_t = decltype( ((pass_t*)nullptr)->previsit( (const node_t *)nullptr ) );
    114 
    115                 static constexpr bool value = std::is_void< ret_t >::value ||
    116                         std::is_base_of<const node_t, typename std::remove_pointer<ret_t>::type >::value;
    117109        };
    118110
     
    135127        static inline auto previsit( pass_t & pass, const node_t * & node, int ) -> decltype( pass.previsit( node ), void() ) {
    136128                static_assert(
    137                         is_valid_previsit<pass_t, node_t>::value,
    138                         "Previsit may not change the type of the node. It must return its paremeter or void."
     129                        std::is_base_of<const node_t, typename std::remove_pointer<decltype( pass.previsit( node ) )>::type >::value,
     130                        "Previsit may not change the type of the node. Use postvisit instead."
    139131                );
    140                 if(std::is_void< decltype( pass.previsit(node) ) >::value) {
    141                         pass.previsit( node );
    142                 } else {
    143                         node = pass.previsit( node );
    144                         assert(node);
    145                 }
     132                node = pass.previsit( node );
     133                assert(node);
    146134        }
    147135
     
    151139        // PostVisit : never mutates the passed pointer but may return a different node
    152140        template<typename pass_t, typename node_t>
    153         static inline auto postvisit( pass_t & pass, const node_t * node, int ) ->
    154                 decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) )
    155         {
     141        static inline auto postvisit( pass_t & pass, const node_t * node, int ) -> decltype( pass.postvisit( node ), (const node_t *)nullptr ) {
    156142                return pass.postvisit( node );
    157143        }
Note: See TracChangeset for help on using the changeset viewer.