Changeset d908563 for src/AST/Node.hpp
- Timestamp:
- May 27, 2019, 11:08:54 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f88a252
- Parents:
- 933f32f (diff), 21a44ca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.hpp
r933f32f rd908563 10 10 // Created On : Wed May 8 10:27:04 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 15 16:02:00 201913 // Update Count : 312 // Last Modified On : Thu May 23 16:00:00 2019 13 // Update Count : 4 14 14 // 15 15 … … 94 94 std::ostream& operator<< ( std::ostream& out, const Node * node ); 95 95 96 /// Call a visitor on a possibly-null node 97 template<typename node_t> 98 auto maybe_accept( const node_t * n, Visitor & v ) -> decltype( n->accept(v) ) { 99 return n ? n->accept( v ) : nullptr; 100 } 101 96 102 /// Base class for the smart pointer types 97 103 /// should never really be used. … … 103 109 ~ptr_base() { if( node ) _dec(node); } 104 110 111 ptr_base( const ptr_base & o ) : node(o.node) { 112 if( node ) _inc(node); 113 } 114 115 ptr_base( ptr_base && o ) : node(o.node) { 116 if( node ) _inc(node); 117 } 118 105 119 template< enum Node::ref_type o_ref_t > 106 120 ptr_base( const ptr_base<node_t, o_ref_t> & o ) : node(o.node) { … … 115 129 template<typename o_node_t> 116 130 ptr_base & operator=( const o_node_t * node ) { 117 assign(strict_dynamic_cast<const node_t *>(node)); 131 assign( node ? strict_dynamic_cast<const node_t *>(node) : nullptr ); 132 return *this; 133 } 134 135 ptr_base & operator=( const ptr_base & o ) { 136 assign(o.node); 137 return *this; 138 } 139 140 ptr_base & operator=( ptr_base && o ) { 141 assign(o.node); 118 142 return *this; 119 143 } … … 141 165 const o_node_t * as() const { return dynamic_cast<const o_node_t *>(node); } 142 166 167 /// Returns a mutable version of the pointer in this node. 168 node_t * get_and_mutate(); 169 143 170 /// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere. 144 171 /// Returns a mutable version of the pointer in this node.
Note: See TracChangeset
for help on using the changeset viewer.