Changeset c2794b2
- Timestamp:
- May 17, 2021, 9:32:35 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d286e94d
- Parents:
- 02a43ff
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/list.hfa
r02a43ff rc2794b2 125 125 verify(linkToInsert.prev == 0p); 126 126 verify(linkToInsert.next == 0p); 127 tE & list_pos_raw = list_pos; 128 tE & list_pos_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & list_pos_raw ); 127 tE & list_pos_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & list_pos ); 129 128 dlink(tE) & list_pos_links = list_pos_elem`inner; 130 129 asm( "" : : : "memory" ); 131 130 tE & after_raw = * list_pos_links.next; 132 131 tE & after_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & after_raw ); 133 linkToInsert.prev = & list_pos _raw;132 linkToInsert.prev = & list_pos; 134 133 linkToInsert.next = & after_raw; 135 134 dlink(tE) & afterLinks = after_elem`inner; … … 145 144 verify(linkToInsert.next == 0p); 146 145 verify(linkToInsert.prev == 0p); 147 tE & list_pos_raw = list_pos; 148 tE & list_pos_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & list_pos_raw ); 146 tE & list_pos_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & list_pos ); 149 147 dlink(tE) & list_pos_links = list_pos_elem`inner; 150 148 asm( "" : : : "memory" ); 151 149 tE & before_raw = * (list_pos_links).prev; 152 150 tE & before_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & before_raw ); 153 linkToInsert.next = & list_pos _raw;151 linkToInsert.next = & list_pos; 154 152 linkToInsert.prev = & before_raw; 155 153 dlink(tE) & beforeLinks = before_elem`inner; … … 161 159 static inline tE & remove(tE & list_pos) { 162 160 verify (&list_pos != 0p); 163 tE & list_pos_elem = list_pos; 164 verify( ! ORIGIN_TAG_QUERY((size_t) & list_pos_elem) ); 165 dlink(tE) & list_pos_links = list_pos_elem`inner; 161 verify( ! ORIGIN_TAG_QUERY((size_t) & list_pos) ); 162 dlink(tE) & list_pos_links = list_pos`inner; 166 163 tE & before_raw = * list_pos_links.prev; 167 164 tE & before_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & before_raw ); … … 176 173 list_pos_links.next = 0p; 177 174 asm( "" : : : "memory" ); 178 return list_pos _elem;175 return list_pos; 179 176 } 180 177 … … 194 191 if (ORIGIN_TAG_QUERY((size_t)firstPtr)) firstPtr = 0p; 195 192 return firstPtr == 0p; 193 } 194 195 static inline bool ?`isListed( tE & e ) { 196 verify (&e != 0p); 197 dlink(tE) & e_links = e`inner; 198 return (e_links.prev != 0p) || (e_links.next != 0p); 196 199 } 197 200 -
tests/list/.expect/dlist-insert-remove.txt
r02a43ff rc2794b2 1109 1109 try_pop cases done 1110 1110 origin_mutation cases done 1111 isListed cases done -
tests/list/dlist-insert-remove.cfa
r02a43ff rc2794b2 1607 1607 } 1608 1608 1609 void test__isListed_cases__mary() { 1610 1611 mary m1 = {1.7}; assert(! m1`isListed); 1612 mary m2 = {2.7}; assert(! m2`isListed); 1613 mary m3 = {3.7}; assert(! m3`isListed); 1614 1615 dlist(mary) ml; 1616 1617 insert_last(ml, m1); assert( m1`isListed); assert(! m2`isListed); 1618 insert_last(ml, m2); assert( m2`isListed); assert(! m3`isListed); 1619 insert_last(ml, m3); assert( m3`isListed); 1620 1621 remove( m1 ); assert(! m1`isListed); assert( m2`isListed); 1622 remove( m2 ); assert(! m2`isListed); assert( m3`isListed); 1623 remove( m3 ); assert(! m3`isListed); 1624 1625 printf("isListed cases done\n"); 1626 } 1627 1609 1628 //////////////////////////////////////////////////////////// 1610 1629 // … … 1904 1923 test__try_pop__mary(); 1905 1924 test__origin_mutation__mary(); 1925 test__isListed_cases__mary(); 1906 1926 1907 1927 return 0;
Note: See TracChangeset
for help on using the changeset viewer.