Changeset 2377ca2 for src


Ignore:
Timestamp:
Mar 28, 2022, 1:48:13 PM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
18f7858
Parents:
8e819a9
Message:

Updated some names on mutate functions to me more consistent with some 'better' names we came up with more recently.

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Node.hpp

    r8e819a9 r2377ca2  
    103103
    104104/// Mutate a node field (only clones if not equal to existing value)
    105 template<typename node_t, typename parent_t, typename field_t, typename assn_t>
    106 const node_t * mutate_field( const node_t * node, field_t parent_t::* field, assn_t && val ) {
     105template<typename node_t, typename super_t, typename field_t, typename assn_t>
     106const node_t * mutate_field( const node_t * node, field_t super_t::* field, assn_t && val ) {
    107107        // skip mutate if equivalent
    108108        if ( node->*field == val ) return node;
     
    115115
    116116/// Mutate a single index of a node field (only clones if not equal to existing value)
    117 template<typename node_t, typename parent_t, typename coll_t, typename ind_t, typename field_t>
     117template<typename node_t, typename super_t, typename coll_t, typename ind_t, typename field_t>
    118118const node_t * mutate_field_index(
    119         const node_t * node, coll_t parent_t::* field, ind_t i, field_t && val
     119        const node_t * node, coll_t super_t::* field, ind_t i, field_t && val
    120120) {
    121121        // skip mutate if equivalent
     
    129129
    130130/// Mutate an entire indexed collection by cloning to accepted value
    131 template<typename node_t, typename parent_t, typename coll_t>
    132 const node_t * mutate_each( const node_t * node, coll_t parent_t::* field, Visitor & v ) {
     131template<typename node_t, typename super_t, typename coll_t>
     132const node_t * mutate_each( const node_t * node, coll_t super_t::* field, Visitor & v ) {
    133133        for ( unsigned i = 0; i < (node->*field).size(); ++i ) {
    134134                node = mutate_field_index( node, field, i, (node->*field)[i]->accept( v ) );
  • src/AST/Pass.impl.hpp

    r8e819a9 r2377ca2  
    399399
    400400        template< typename core_t >
    401         template<typename node_t, typename parent_t, typename child_t>
     401        template<typename node_t, typename super_t, typename field_t>
    402402        void ast::Pass< core_t >::maybe_accept(
    403403                const node_t * & parent,
    404                 child_t parent_t::*child
     404                field_t super_t::*field
    405405        ) {
    406                 static_assert( std::is_base_of<parent_t, node_t>::value, "Error deducing member object" );
    407 
    408                 if(__pass::skip(parent->*child)) return;
    409                 const auto & old_val = __pass::get(parent->*child, 0);
     406                static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" );
     407
     408                if(__pass::skip(parent->*field)) return;
     409                const auto & old_val = __pass::get(parent->*field, 0);
    410410
    411411                static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR");
     
    417417                if( new_val.differs ) {
    418418                        auto new_parent = __pass::mutate<core_t>(parent);
    419                         new_val.apply(new_parent, child);
     419                        new_val.apply(new_parent, field);
    420420                        parent = new_parent;
    421421                }
     
    423423
    424424        template< typename core_t >
    425         template<typename node_t, typename parent_t, typename child_t>
     425        template<typename node_t, typename super_t, typename field_t>
    426426        void ast::Pass< core_t >::maybe_accept_as_compound(
    427427                const node_t * & parent,
    428                 child_t parent_t::*child
     428                field_t super_t::*child
    429429        ) {
    430                 static_assert( std::is_base_of<parent_t, node_t>::value, "Error deducing member object" );
     430                static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" );
    431431
    432432                if(__pass::skip(parent->*child)) return;
Note: See TracChangeset for help on using the changeset viewer.