Changes in src/AST/Node.hpp [18e683b:7d0881c]
- File:
-
- 1 edited
-
src/AST/Node.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.hpp
r18e683b r7d0881c 38 38 Node& operator= (const Node&) = delete; 39 39 Node& operator= (Node&&) = delete; 40 virtual ~Node() = default;40 virtual ~Node() {} 41 41 42 42 virtual const Node * accept( Visitor & v ) const = 0; … … 69 69 } 70 70 71 void decrement(ast::Node::ref_type ref ) const {71 void decrement(ast::Node::ref_type ref, bool do_delete = true) const { 72 72 switch (ref) { 73 73 case ref_type::strong: strong_count--; break; … … 75 75 } 76 76 77 if( !strong_count && !weak_count) {77 if( do_delete && !strong_count && !weak_count) { 78 78 delete this; 79 79 } … … 123 123 (ret->*field)[i] = std::forward< field_t >( val ); 124 124 return ret; 125 } 126 127 /// Mutate an entire indexed collection by cloning to accepted value 128 template<typename node_t, typename parent_t, typename coll_t> 129 const node_t * mutate_each( const node_t * node, coll_t parent_t::* field, Visitor & v ) { 130 for ( unsigned i = 0; i < (node->*field).size(); ++i ) { 131 node = mutate_field_index( node, field, i, (node->*field)[i]->accept( v ) ); 132 } 133 return node; 125 134 } 126 135 … … 219 228 operator const node_t * () const { _check(); return node; } 220 229 230 const node_t * release() { 231 const node_t * ret = node; 232 if ( node ) { 233 _dec(node, false); 234 node = nullptr; 235 } 236 return ret; 237 } 238 221 239 /// wrapper for convenient access to dynamic_cast 222 240 template<typename o_node_t> … … 244 262 245 263 void _inc( const node_t * other ); 246 void _dec( const node_t * other );264 void _dec( const node_t * other, bool do_delete = true ); 247 265 void _check() const; 248 266
Note:
See TracChangeset
for help on using the changeset viewer.