Changeset 7a70fb2 for libcfa/src/bits
- Timestamp:
- Dec 17, 2020, 10:34:27 AM (5 years ago)
- 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. - Location:
- libcfa/src/bits
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/collection.hfa
r72a3aff r7a70fb2 1 1 #pragma once 2 #include <stdio.h> // REMOVE THIS AFTER DEBUGGING 3 2 4 3 5 struct Colable { 4 Colable * next; // next node in the list6 struct Colable * next; // next node in the list 5 7 // invariant: (next != 0) <=> listed() 6 8 }; 7 8 inline {9 #ifdef __cforall 10 static inline { 9 11 // PUBLIC 10 12 … … 28 30 } 29 31 30 // wrappers to make Collection have T31 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 // } 35 37 36 bool listed( T * n ) {37 return Next( (Colable *)n ) != 0p;38 }39 } // distribution38 // bool listed( T * n ) { 39 // return Next( (Colable *)n ) != 0p; 40 // } 41 // } // distribution 40 42 } // distribution 41 43 … … 45 47 }; 46 48 47 inline {49 static inline { 48 50 // class invariant: root == 0 & empty() | *root in *this 49 51 void ?{}( Collection &, const Collection & ) = void; // no copy … … 68 70 }; 69 71 70 inline {72 static inline { 71 73 void ?{}( ColIter & colIter ) with( colIter ) { 72 74 curr = 0p; … … 79 81 } // distribution 80 82 } // distribution 83 #endif -
libcfa/src/bits/containers.hfa
r72a3aff r7a70fb2 36 36 #define __small_array_t(T) __small_array(T) 37 37 #else 38 #define __small_array_t(T) struct__small_array38 #define __small_array_t(T) __small_array 39 39 #endif 40 40 -
libcfa/src/bits/defs.hfa
r72a3aff r7a70fb2 29 29 #define __cfa_anonymous_object(x) inline struct x 30 30 #else 31 #define __cfa_anonymous_object(x) x __cfa_anonymous_object31 #define __cfa_anonymous_object(x) struct x __cfa_anonymous_object 32 32 #endif 33 33 -
libcfa/src/bits/queue.hfa
r72a3aff r7a70fb2 3 3 #include "bits/collection.hfa" 4 4 5 forall( dtype T ) {5 forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) { 6 6 struct Queue { 7 7 inline Collection; // Plan 9 inheritance … … 64 64 T & t = head( q ); 65 65 if ( root ) { 66 root = Next( root );66 root = Next( (T *)root ); 67 67 if ( &head( q ) == &t ) { 68 68 root = last = 0p; // only one element … … 142 142 } // distribution 143 143 144 forall( dtype T ) {144 forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) { 145 145 struct QueueIter { 146 146 inline ColIter; // Plan 9 inheritance -
libcfa/src/bits/sequence.hfa
r72a3aff r7a70fb2 2 2 3 3 #include "bits/collection.hfa" 4 #include "bits/defs.hfa" 4 5 5 6 struct Seqable { 6 inline Colable;7 Seqable * back; // pointer to previous node in the list7 __cfa_anonymous_object(Colable); 8 struct Seqable * back; // pointer to previous node in the list 8 9 }; 9 10 10 inline { 11 #ifdef __cforall 12 static inline { 11 13 // PUBLIC 12 14 … … 26 28 } 27 29 28 // wrappers to make Collection have T29 forall( dtype T ) {30 T *& Back( T * n ) {31 return (T *)Back( (Seqable *)n );32 }33 } // distribution30 // // wrappers to make Collection have T 31 // forall( dtype T ) { 32 // T *& Back( T * n ) { 33 // return (T *)Back( (Seqable *)n ); 34 // } 35 // } // distribution 34 36 } // distribution 35 37 36 forall( dtype T ) {38 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) { 37 39 struct Sequence { 38 40 inline Collection; // Plan 9 inheritance 39 41 }; 40 42 41 inline {43 static inline { 42 44 // wrappers to make Collection have T 43 45 T & head( Sequence(T) & s ) with( s ) { … … 184 186 T * toEnd = Back( &head( s ) ); 185 187 T * fromEnd = Back( &head( from ) ); 186 Back( root ) = fromEnd;188 Back( (T *)root ) = fromEnd; 187 189 Next( fromEnd ) = &head( s ); 188 Back( from.root ) = toEnd;190 Back( (T *)from.root ) = toEnd; 189 191 Next( toEnd ) = &head( from ); 190 192 } // if … … 214 216 } // distribution 215 217 216 forall( dtype T ) {218 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) { 217 219 // SeqIter(T) is used to iterate over a Sequence(T) in head-to-tail order. 218 220 struct SeqIter { … … 224 226 }; 225 227 226 inline {228 static inline { 227 229 void ?{}( SeqIter(T) & si ) with( si ) { 228 230 ((ColIter &)si){}; … … 265 267 }; 266 268 267 inline {269 static inline { 268 270 void ?{}( SeqIterRev(T) & si ) with( si ) { 269 271 ((ColIter &)si){}; … … 298 300 } // distribution 299 301 } // distribution 302 303 #endif -
libcfa/src/bits/stack.hfa
r72a3aff r7a70fb2 3 3 #include "bits/collection.hfa" 4 4 5 forall( dtype T ) {5 forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) { 6 6 struct Stack { 7 7 inline Collection; // Plan 9 inheritance … … 44 44 T & t = head( s ); 45 45 if ( root ) { 46 root = ( T *)Next( root );46 root = ( T *)Next( (T *)root ); 47 47 if ( &head( s ) == &t ) root = 0p; // only one element ? 48 48 Next( &t ) = 0p; … … 58 58 59 59 60 forall( dtype T ) {60 forall( dtype T | { T *& Next ( T * ); bool listed ( T * ); } ) { 61 61 struct StackIter { 62 62 inline ColIter; // Plan 9 inheritance
Note:
See TracChangeset
for help on using the changeset viewer.