Changeset 7d0881c for src/AST/Node.hpp


Ignore:
Timestamp:
Jun 28, 2019, 11:59:00 AM (5 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
55b6476
Parents:
e0e9a0b
Message:

Aaron added decrement-without delete option to Node infrastructure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Node.hpp

    re0e9a0b r7d0881c  
    6969        }
    7070
    71         void decrement(ast::Node::ref_type ref) const {
     71        void decrement(ast::Node::ref_type ref, bool do_delete = true) const {
    7272                switch (ref) {
    7373                        case ref_type::strong: strong_count--; break;
     
    7575                }
    7676
    77                 if(!strong_count && !weak_count) {
     77                if( do_delete && !strong_count && !weak_count) {
    7878                        delete this;
    7979                }
     
    228228        operator const node_t * () const { _check(); return node; }
    229229
     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
    230239        /// wrapper for convenient access to dynamic_cast
    231240        template<typename o_node_t>
     
    253262
    254263        void _inc( const node_t * other );
    255         void _dec( const node_t * other );
     264        void _dec( const node_t * other, bool do_delete = true );
    256265        void _check() const;
    257266
Note: See TracChangeset for help on using the changeset viewer.