Changeset 7a70fb2 for libcfa/src/bits


Ignore:
Timestamp:
Dec 17, 2020, 10:34:27 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
852ae0ea
Parents:
72a3aff (diff), 28e88d7 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src/bits
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/collection.hfa

    r72a3aff r7a70fb2  
    11#pragma once
     2#include <stdio.h> // REMOVE THIS AFTER DEBUGGING
     3
    24
    35struct Colable {
    4         Colable * next;                                                                         // next node in the list
     6        struct Colable * next;                                                                          // next node in the list
    57        // invariant: (next != 0) <=> listed()
    68};
    7 
    8 inline {
     9#ifdef __cforall
     10static inline {
    911        // PUBLIC
    1012
     
    2830        }
    2931
    30         // wrappers to make Collection have T
    31         forall( dtype T ) {
    32                 T *& Next( T * n ) {
    33                         return (T *)Next( (Colable *)n );
    34                 }
     32        // // wrappers to make Collection have T
     33        // forall( dtype T ) {
     34        //      T *& Next( T * n ) {
     35        //              return (T *)Next( (Colable *)n );
     36        //      }
    3537
    36                 bool listed( T * n ) {
    37                         return Next( (Colable *)n ) != 0p;
    38                 }
    39         } // distribution
     38        //      bool listed( T * n ) {
     39        //              return Next( (Colable *)n ) != 0p;
     40        //      }
     41        // } // distribution
    4042} // distribution
    4143
     
    4547};
    4648
    47 inline {
     49static inline {
    4850        // class invariant: root == 0 & empty() | *root in *this
    4951        void ?{}( Collection &, const Collection & ) = void; // no copy
     
    6870};
    6971
    70 inline {
     72static inline {
    7173        void ?{}( ColIter & colIter ) with( colIter ) {
    7274                curr = 0p;
     
    7981        } // distribution
    8082} // distribution
     83#endif
  • libcfa/src/bits/containers.hfa

    r72a3aff r7a70fb2  
    3636        #define __small_array_t(T) __small_array(T)
    3737#else
    38         #define __small_array_t(T) struct __small_array
     38        #define __small_array_t(T) __small_array
    3939#endif
    4040
  • libcfa/src/bits/defs.hfa

    r72a3aff r7a70fb2  
    2929#define __cfa_anonymous_object(x) inline struct x
    3030#else
    31 #define __cfa_anonymous_object(x) x __cfa_anonymous_object
     31#define __cfa_anonymous_object(x) struct x __cfa_anonymous_object
    3232#endif
    3333
  • libcfa/src/bits/queue.hfa

    r72a3aff r7a70fb2  
    33#include "bits/collection.hfa"
    44
    5 forall( dtype T ) {
     5forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) {
    66        struct Queue {
    77                inline Collection;                                                              // Plan 9 inheritance
     
    6464                        T & t = head( q );
    6565                        if ( root ) {
    66                                 root = Next( root );
     66                                root = Next( (T *)root );
    6767                                if ( &head( q ) == &t ) {
    6868                                        root = last = 0p;                                       // only one element
     
    142142} // distribution
    143143
    144 forall( dtype T ) {
     144forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) {
    145145        struct QueueIter {
    146146                inline ColIter;                                                                 // Plan 9 inheritance
  • libcfa/src/bits/sequence.hfa

    r72a3aff r7a70fb2  
    22
    33#include "bits/collection.hfa"
     4#include "bits/defs.hfa"
    45
    56struct Seqable {
    6         inline Colable;
    7         Seqable * back;                                                                         // pointer to previous node in the list
     7        __cfa_anonymous_object(Colable);
     8        struct Seqable * back;                                                                          // pointer to previous node in the list
    89};
    910
    10 inline {
     11#ifdef __cforall
     12static inline {
    1113        // PUBLIC
    1214
     
    2628        }
    2729
    28         // wrappers to make Collection have T
    29         forall( dtype T ) {
    30                 T *& Back( T * n ) {
    31                         return (T *)Back( (Seqable *)n );
    32                 }
    33         } // distribution
     30        // // wrappers to make Collection have T
     31        // forall( dtype T ) {
     32        //      T *& Back( T * n ) {
     33        //              return (T *)Back( (Seqable *)n );
     34        //      }
     35        // } // distribution
    3436} // distribution
    3537
    36 forall( dtype T ) {
     38forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) {
    3739        struct Sequence {
    3840                inline Collection;                                                              // Plan 9 inheritance
    3941        };
    4042
    41         inline {
     43        static inline {
    4244                // wrappers to make Collection have T
    4345                T & head( Sequence(T) & s ) with( s ) {
     
    184186                                T * toEnd = Back( &head( s ) );
    185187                                T * fromEnd = Back( &head( from ) );
    186                                 Back( root ) = fromEnd;
     188                                Back( (T *)root ) = fromEnd;
    187189                                Next( fromEnd ) = &head( s );
    188                                 Back( from.root ) = toEnd;
     190                                Back( (T *)from.root ) = toEnd;
    189191                                Next( toEnd ) = &head( from );
    190192                        } // if
     
    214216} // distribution
    215217
    216 forall( dtype T ) {
     218forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) {
    217219        // SeqIter(T) is used to iterate over a Sequence(T) in head-to-tail order.
    218220        struct SeqIter {
     
    224226        };
    225227
    226         inline {
     228        static inline {
    227229                void ?{}( SeqIter(T) & si ) with( si ) {
    228230                        ((ColIter &)si){};
     
    265267        };
    266268
    267         inline {
     269        static inline {
    268270                void ?{}( SeqIterRev(T) & si ) with( si ) {     
    269271                        ((ColIter &)si){};
     
    298300        } // distribution
    299301} // distribution
     302
     303#endif
  • libcfa/src/bits/stack.hfa

    r72a3aff r7a70fb2  
    33#include "bits/collection.hfa"
    44
    5 forall( dtype T ) {
     5forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) {
    66        struct Stack {
    77                inline Collection;                                                              // Plan 9 inheritance
     
    4444                        T & t = head( s );
    4545                        if ( root ) {
    46                                 root = ( T *)Next( root );
     46                                root = ( T *)Next( (T *)root );
    4747                                if ( &head( s ) == &t ) root = 0p;              // only one element ?
    4848                                Next( &t ) = 0p;
     
    5858
    5959
    60 forall( dtype T ) {
     60forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) {
    6161        struct StackIter {
    6262                inline ColIter;                                                                 // Plan 9 inheritance
Note: See TracChangeset for help on using the changeset viewer.