Changeset 4d741e9 for libcfa/src/containers/list.hfa
- Timestamp:
- May 4, 2020, 8:45:20 PM (3 years ago)
- Branches:
- ADT, arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d3ab183
- Parents:
- 3f7d0b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/list.hfa
r3f7d0b4 r4d741e9 71 71 // will collapse to single pointer with tag bit 72 72 }; 73 inline void ?{}( $mgd_link(tE) &this, tE* elem ) {73 static inline void ?{}( $mgd_link(tE) &this, tE* elem ) { 74 74 (this.elem){ elem }; 75 75 (this.terminator){ 0p }; 76 76 (this.is_terminator){ 0 }; 77 77 } 78 inline void ?{}( $mgd_link(tE) &this, void * terminator ) {78 static inline void ?{}( $mgd_link(tE) &this, void * terminator ) { 79 79 (this.elem){ 0p }; 80 80 (this.terminator){ terminator }; … … 82 82 } 83 83 forall ( otype tInit | { void ?{}( $mgd_link(tE) &, tInit); } ) 84 void ?=?( $mgd_link(tE) &this, tInit i ) {84 static inline void ?=?( $mgd_link(tE) &this, tInit i ) { 85 85 ^?{}( this ); 86 86 ?{}( this, i ); … … 93 93 $mgd_link(tE) prev; 94 94 }; 95 inline void ?{}( $dlinks(tE) &this ) {95 static inline void ?{}( $dlinks(tE) &this ) { 96 96 (this.next){ (tE *)0p }; 97 97 (this.prev){ (tE *)0p }; … … 132 132 // an empty dlist 133 133 // links refer to self, making a tight circle 134 void ?{}( dlist(Tnode, Telem) & this ) {134 static inline void ?{}( dlist(Tnode, Telem) & this ) { 135 135 $mgd_link(Telem) selfRef = (void *) &this; 136 136 ( this.$links ) { selfRef, selfRef }; 137 137 } 138 138 139 Telem & ?`first( dlist(Tnode, Telem) &l ) {139 static inline Telem & ?`first( dlist(Tnode, Telem) &l ) { 140 140 return * l.$links.next.elem; 141 141 } 142 142 143 Telem & ?`last( dlist(Tnode, Telem) &l ) {143 static inline Telem & ?`last( dlist(Tnode, Telem) &l ) { 144 144 return * l.$links.prev.elem; 145 145 } 146 147 #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) 148 static bool $validate_fwd( dlist(Tnode, Telem) & this ) { 149 Tnode * it = & $tempcv_e2n( this`first ); 150 if (!it) return (& this`last == 0p); 151 152 while( $next_link(*it).elem ) { 153 it = & $tempcv_e2n( * $next_link(*it).elem ); 154 } 155 156 return ( it == & $tempcv_e2n( this`last ) ) && 157 ( $next_link(*it).is_terminator ) && 158 ( ((dlist(Tnode, Telem)*)$next_link(*it).terminator) == &this ); 159 } 160 static bool $validate_rev( dlist(Tnode, Telem) & this ) { 161 Tnode * it = & $tempcv_e2n( this`last ); 162 if (!it) return (& this`first == 0p); 163 164 while( $prev_link(*it).elem ) { 165 it = & $tempcv_e2n( * $prev_link(*it).elem ); 166 } 167 168 return ( it == & $tempcv_e2n( this`first ) ) && 169 ( $prev_link(*it).is_terminator ) && 170 ( ((dlist(Tnode, Telem)*)$prev_link(*it).terminator) == &this ); 171 } 172 static bool validate( dlist(Tnode, Telem) & this ) { 173 return $validate_fwd(this) && $validate_rev(this); 174 } 175 #endif 146 176 147 177 static inline void insert_after(Tnode &list_pos, Telem &to_insert) { … … 152 182 assert($next_link(singleton_to_insert).elem == 0p); 153 183 $prev_link(singleton_to_insert) = & $tempcv_n2e(list_pos); 154 $next_link(singleton_to_insert) = $next_link(list_pos) .elem;184 $next_link(singleton_to_insert) = $next_link(list_pos); 155 185 if ($next_link(list_pos).is_terminator) { 156 186 dlist(Tnode, Telem) *list = $next_link(list_pos).terminator; … … 175 205 assert($next_link(singleton_to_insert).elem == 0p); 176 206 $next_link(singleton_to_insert) = & $tempcv_n2e(list_pos); 177 $prev_link(singleton_to_insert) = $prev_link(list_pos) .elem;207 $prev_link(singleton_to_insert) = $prev_link(list_pos); 178 208 if ($prev_link(list_pos).is_terminator) { 179 209 dlist(Tnode, Telem) *list = $prev_link(list_pos).terminator;
Note: See TracChangeset
for help on using the changeset viewer.