Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Node.cpp

    r87701b6 r10a1225  
    1616#include "Node.hpp"
    1717#include "Fwd.hpp"
     18
     19#include "Attribute.hpp"
    1820#include "Decl.hpp"
    1921#include "Expr.hpp"
     22#include "Init.hpp"
    2023#include "Stmt.hpp"
    2124#include "Type.hpp"
     25#include "TypeSubstitution.hpp"
    2226
    2327template< typename node_t, enum ast::Node::ref_type ref_t >
     
    2630template< typename node_t, enum ast::Node::ref_type ref_t >
    2731void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); }
     32
     33/// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere.
     34/// Returns a mutable version of the pointer in this node.
     35template< typename node_t, enum ast::Node::ref_type ref_t >
     36node_t * ast::ptr_base<node_t, ref_t>::set_and_mutate( const node_t * n ) {
     37        // ensure ownership of `n` by this node to avoid spurious single-owner mutates
     38        assign( n );
     39        // get mutable version of `n`
     40        auto r = mutate( node );
     41        // re-assign mutable version in case `mutate()` produced a new pointer
     42        assign( r );
     43        return r;
     44}
    2845
    2946template class ast::ptr_base< ast::Node, ast::Node::ref_type::weak >;
     
    153170template class ast::ptr_base< ast::CompoundLiteralExpr, ast::Node::ref_type::weak >;
    154171template class ast::ptr_base< ast::CompoundLiteralExpr, ast::Node::ref_type::strong >;
    155 template class ast::ptr_base< ast::UntypedValofExpr, ast::Node::ref_type::weak >;
    156 template class ast::ptr_base< ast::UntypedValofExpr, ast::Node::ref_type::strong >;
    157172template class ast::ptr_base< ast::RangeExpr, ast::Node::ref_type::weak >;
    158173template class ast::ptr_base< ast::RangeExpr, ast::Node::ref_type::strong >;
     
    229244template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::weak >;
    230245template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::strong >;
    231 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::weak >;
    232 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::strong >;
    233246template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::weak >;
    234247template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::strong >;
Note: See TracChangeset for help on using the changeset viewer.