Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Node.cpp

    r98e8b3b r4864a73  
    99// Author           : Thierry Delisle
    1010// Created On       : Thu May 16 14:16:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jun  5 10:21:00 2020
    13 // Update Count     : 1
     11// Last Modified By :
     12// Last Modified On :
     13// Update Count     :
    1414//
    1515
     
    1717#include "Fwd.hpp"
    1818
    19 #include <csignal>  // MEMORY DEBUG -- for raise
    2019#include <iostream>
    2120
     
    3029#include "Print.hpp"
    3130
    32 /// MEMORY DEBUG -- allows breaking on ref-count changes of dynamically chosen object.
    33 /// Process to use in GDB:
    34 ///   break ast::Node::_trap()
    35 ///   run
    36 ///   set variable MEM_TRAP_OBJ = <target>
    37 ///   disable <first breakpoint>
    38 ///   continue
    39 void * MEM_TRAP_OBJ = nullptr;
    40 
    41 void _trap( const void * node ) {
    42         if ( node == MEM_TRAP_OBJ ) std::raise(SIGTRAP);
    43 }
    44 
    45 [[noreturn]] static inline void strict_fail(const ast::Node * node) {
    46         assertf(node, "strict_as had nullptr input.");
    47         const ast::ParseNode * parse = dynamic_cast<const ast::ParseNode *>( node );
    48         if ( nullptr == parse ) {
    49                 assertf(nullptr, "%s (no location)", toString(node).c_str());
    50         } else if ( parse->location.isUnset() ) {
    51                 assertf(nullptr, "%s (unset location)", toString(node).c_str());
    52         } else {
    53                 assertf(nullptr, "%s (at %s:%d)", toString(node).c_str(),
    54                         parse->location.filename.c_str(), parse->location.first_line);
    55         }
    56 }
    57 
    58 template< typename node_t, enum ast::Node::ref_type ref_t >
    59 void ast::ptr_base<node_t, ref_t>::_strict_fail() const {
    60         strict_fail(node);
    61 }
    62 
    63 template< typename node_t, enum ast::Node::ref_type ref_t >
    64 void ast::ptr_base<node_t, ref_t>::_inc( const node_t * node ) {
    65         node->increment(ref_t);
    66         _trap( node );
    67 }
    68 
    69 template< typename node_t, enum ast::Node::ref_type ref_t >
    70 void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node, bool do_delete ) {
    71         _trap( node );
    72         node->decrement( ref_t, do_delete );
    73 }
    74 
    75 template< typename node_t, enum ast::Node::ref_type ref_t >
    76 void ast::ptr_base<node_t, ref_t>::_check() const {
    77         // if(node) assert(node->was_ever_strong == false || node->strong_count > 0);
    78 }
     31template< typename node_t, enum ast::Node::ref_type ref_t >
     32void ast::ptr_base<node_t, ref_t>::_inc( const node_t * node ) { node->increment(ref_t); }
     33
     34template< typename node_t, enum ast::Node::ref_type ref_t >
     35void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); }
     36
     37template< typename node_t, enum ast::Node::ref_type ref_t >
     38void ast::ptr_base<node_t, ref_t>::_check() const { if(node) assert(node->was_ever_strong == false || node->strong_count > 0); }
    7939
    8040template< typename node_t, enum ast::Node::ref_type ref_t >
     
    266226template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::weak >;
    267227template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::strong >;
    268 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::weak >;
    269 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::strong >;
     228template class ast::ptr_base< ast::ReferenceToType, ast::Node::ref_type::weak >;
     229template class ast::ptr_base< ast::ReferenceToType, ast::Node::ref_type::strong >;
    270230template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::weak >;
    271231template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::strong >;
Note: See TracChangeset for help on using the changeset viewer.