Changeset c2794b2 for libcfa


Ignore:
Timestamp:
May 17, 2021, 9:32:35 PM (3 years ago)
Author:
Michael Brooks <mlbrooks@…>
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
Message:

Adding isListed accessor function to new linked list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/list.hfa

    r02a43ff rc2794b2  
    125125                verify(linkToInsert.prev == 0p);
    126126                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 );
    129128        dlink(tE) & list_pos_links = list_pos_elem`inner;
    130129        asm( "" : : : "memory" );
    131130        tE & after_raw = * list_pos_links.next;
    132131        tE & after_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & after_raw );
    133                 linkToInsert.prev = & list_pos_raw;
     132                linkToInsert.prev = & list_pos;
    134133                linkToInsert.next = & after_raw;
    135134        dlink(tE) & afterLinks = after_elem`inner;
     
    145144                verify(linkToInsert.next == 0p);
    146145                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 );
    149147        dlink(tE) & list_pos_links = list_pos_elem`inner;
    150148        asm( "" : : : "memory" );
    151149        tE & before_raw = * (list_pos_links).prev;
    152150        tE & before_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & before_raw );
    153                 linkToInsert.next = & list_pos_raw;
     151                linkToInsert.next = & list_pos;
    154152                linkToInsert.prev = & before_raw;
    155153        dlink(tE) & beforeLinks = before_elem`inner;
     
    161159        static inline tE & remove(tE & list_pos) {
    162160                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;
    166163        tE & before_raw = * list_pos_links.prev;
    167164        tE & before_elem = * (tE *) ORIGIN_TAG_CLEAR( (size_t) & before_raw );
     
    176173                list_pos_links.next = 0p;
    177174        asm( "" : : : "memory" );
    178         return list_pos_elem;
     175        return list_pos;
    179176        }
    180177
     
    194191        if (ORIGIN_TAG_QUERY((size_t)firstPtr)) firstPtr = 0p;
    195192        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);
    196199    }
    197200
Note: See TracChangeset for help on using the changeset viewer.