Changeset 3f91792
- Timestamp:
- Dec 8, 2020, 1:01:05 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:
- 8e58264
- Parents:
- 33a129a (diff), c9e0991 (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. - Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/collection.hfa
r33a129a r3f91792 7 7 8 8 inline { 9 // PUBLIC 10 9 11 void ?{}( Colable & co ) with( co ) { 10 12 next = 0p; … … 16 18 } 17 19 18 Colable *getNext( Colable & co ) with( co ) {19 return next;20 Colable & getNext( Colable & co ) with( co ) { 21 return *next; 20 22 } 23 24 // PRIVATE 21 25 22 26 Colable *& Next( Colable * cp ) { … … 24 28 } 25 29 30 // wrappers to make Collection have T 26 31 forall( dtype T ) { 27 32 T *& Next( T * n ) { -
libcfa/src/bits/multi_list.cfa
r33a129a r3f91792 57 57 58 58 SeqIter(TaskDL) sqiter; 59 TaskDL & dl; 59 TaskDL & dl; // iterator index 60 60 TaskSL & sl; 61 61 -
libcfa/src/bits/queue.hfa
r33a129a r3f91792 28 28 29 29 T * succ( Queue(T) & q, T * n ) with( q ) { // pre: *n in *q 30 #ifdef __CFA_DEBUG__30 #ifdef __CFA_DEBUG__ 31 31 if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n ); 32 #endif // __CFA_DEBUG__32 #endif // __CFA_DEBUG__ 33 33 return (Next( n ) == n) ? 0p : Next( n ); 34 34 } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q 35 35 36 36 void addHead( Queue(T) & q, T & n ) with( q ) { 37 #ifdef __CFA_DEBUG__37 #ifdef __CFA_DEBUG__ 38 38 if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n ); 39 #endif // __CFA_DEBUG__39 #endif // __CFA_DEBUG__ 40 40 if ( last ) { 41 41 Next( &n ) = &head( q ); … … 43 43 } else { 44 44 root = last = &n; 45 Next( &n ) = &n; 45 Next( &n ) = &n; // last node points to itself 46 46 } 47 47 } 48 48 49 49 void addTail( Queue(T) & q, T & n ) with( q ) { 50 #ifdef __CFA_DEBUG__50 #ifdef __CFA_DEBUG__ 51 51 if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n ); 52 #endif // __CFA_DEBUG__52 #endif // __CFA_DEBUG__ 53 53 if ( last ) Next( last ) = &n; 54 54 else root = &n; 55 55 last = &n; 56 Next( &n ) = &n; 56 Next( &n ) = &n; // last node points to itself 57 57 } 58 58 … … 78 78 79 79 void remove( Queue(T) & q, T & n ) with( q ) { // O(n) 80 #ifdef __CFA_DEBUG__80 #ifdef __CFA_DEBUG__ 81 81 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n ); 82 #endif // __CFA_DEBUG__82 #endif // __CFA_DEBUG__ 83 83 T * prev = 0p; 84 84 T * curr = (T *)root; … … 96 96 break; 97 97 } 98 #ifdef __CFA_DEBUG__99 98 // not found => error 100 if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n ); 101 #endif // __CFA_DEBUG__ 99 #ifdef __CFA_DEBUG__ 100 if ( curr == last ) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n ); 101 #endif // __CFA_DEBUG__ 102 102 prev = curr; 103 103 curr = Next( curr ); … … 125 125 // Node "n" must be in the "from" list. 126 126 void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) { 127 #ifdef __CFA_DEBUG__127 #ifdef __CFA_DEBUG__ 128 128 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n ); 129 #endif // __CFA_DEBUG__129 #endif // __CFA_DEBUG__ 130 130 Queue(T) to; 131 131 to.root = from.root; // start of "to" list … … 177 177 } // distribution 178 178 } // distribution 179 180 // Local Variables: //181 // compile-command: "cfa queue.cfa" //182 // End: // -
libcfa/src/bits/queue_example.cfa
r33a129a r3f91792 107 107 } 108 108 } 109 110 // Local Variables: //111 // compile-command: "cfa queue_example.cfa" //112 // End: // -
libcfa/src/bits/sequence.hfa
r33a129a r3f91792 9 9 10 10 inline { 11 // PUBLIC 12 11 13 void ?{}( Seqable & sq ) with( sq ) { 12 ((Colable &) 14 ((Colable &)sq){}; 13 15 back = 0p; 14 16 } // post: ! listed() … … 18 20 } 19 21 22 // PRIVATE 23 20 24 Seqable *& Back( Seqable * sq ) { 21 25 return sq->back; 22 26 } 27 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 23 34 } // distribution 24 35 … … 34 45 } // post: empty() & head() == 0 | !empty() & head() in *s 35 46 36 T *& Back( T * n ) {37 return (T *)Back( (Seqable *)n );38 }39 40 47 void ?{}( Sequence(T) &, const Sequence(T) & ) = void; // no copy 41 48 Sequence(T) & ?=?( const Sequence(T) & ) = void; // no assignment 42 49 43 50 void ?{}( Sequence(T) & s ) with( s ) { 44 ((Collection &) 51 ((Collection &)s){}; 45 52 } // post: isEmpty(). 46 53 … … 50 57 } // post: empty() & tail() == 0 | !empty() & tail() in *s 51 58 52 // Return a pointer to the element after *n, or 0p if there isn't one.59 // Return a pointer to the element after *n, or 0p if list empty. 53 60 T * succ( Sequence(T) & s, T * n ) with( s ) { // pre: *n in *s 54 #ifdef __CFA_DEBUG__61 #ifdef __CFA_DEBUG__ 55 62 if ( ! listed( n ) ) abort( "(Sequence &)%p.succ( %p ) : Node is not on a list.", &s, n ); 56 #endif // __CFA_DEBUG__63 #endif // __CFA_DEBUG__ 57 64 return Next( n ) == &head( s ) ? 0p : Next( n ); 58 65 } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s … … 60 67 // Return a pointer to the element before *n, or 0p if there isn't one. 61 68 T * pred( Sequence(T) & s, T * n ) with( s ) { // pre: *n in *s 62 #ifdef __CFA_DEBUG__69 #ifdef __CFA_DEBUG__ 63 70 if ( ! listed( n ) ) abort( "(Sequence &)%p.pred( %p ) : Node is not on a list.", &s, n ); 64 #endif // __CFA_DEBUG__71 #endif // __CFA_DEBUG__ 65 72 return n == &head( s ) ? 0p : Back( n ); 66 73 } // post: n == head() & head(n) == 0 | n != head() & *pred(n) in *s … … 69 76 // Insert *n into the sequence before *bef, or at the end if bef == 0. 70 77 void insertBef( Sequence(T) & s, T & n, T & bef ) with( s ) { // pre: !n->listed() & *bef in *s 71 #ifdef __CFA_DEBUG__78 #ifdef __CFA_DEBUG__ 72 79 if ( listed( &n ) ) abort( "(Sequence &)%p.insertBef( %p, %p ) : Node is already on another list.", &s, n, &bef ); 73 #endif // __CFA_DEBUG__80 #endif // __CFA_DEBUG__ 74 81 if ( &bef == &head( s ) ) { // must change root 75 82 if ( root ) { … … 101 108 // Insert *n into the sequence after *aft, or at the beginning if aft == 0. 102 109 void insertAft( Sequence(T) & s, T & aft, T & n ) with( s ) { // pre: !n->listed() & *aft in *s 103 #ifdef __CFA_DEBUG__110 #ifdef __CFA_DEBUG__ 104 111 if ( listed( &n ) ) abort( "(Sequence &)%p.insertAft( %p, %p ) : Node is already on another list.", &s, &aft, &n ); 105 #endif // __CFA_DEBUG__112 #endif // __CFA_DEBUG__ 106 113 if ( ! &aft ) { // must change root 107 114 if ( root ) { … … 130 137 // pre: n->listed() & *n in *s 131 138 void remove( Sequence(T) & s, T & n ) with( s ) { // O(1) 132 #ifdef __CFA_DEBUG__139 #ifdef __CFA_DEBUG__ 133 140 if ( ! listed( &n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, &n ); 134 #endif // __CFA_DEBUG__141 #endif // __CFA_DEBUG__ 135 142 if ( &n == &head( s ) ) { 136 143 if ( Next( &head( s ) ) == &head( s ) ) root = 0p; … … 188 195 // Node "n" must be in the "from" list. 189 196 void split( Sequence(T) & s, Sequence(T) & from, T & n ) with( s ) { 190 #ifdef __CFA_DEBUG__197 #ifdef __CFA_DEBUG__ 191 198 if ( ! listed( &n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, &n ); 192 #endif // __CFA_DEBUG__199 #endif // __CFA_DEBUG__ 193 200 Sequence(T) to; 194 201 to.root = from.root; // start of "to" list … … 199 206 Back( &head( from ) ) = Back( &head( to ) ); // fix "from" list 200 207 Next( Back( &head( to ) ) ) = &head( from ); 201 Next( &n ) = &head( to ); 208 Next( &n ) = &head( to ); // fix "to" list 202 209 Back( &head( to ) ) = &n; 203 210 } // if … … 214 221 // passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence 215 222 // to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular. 216 Sequence(T) * seq; 223 Sequence(T) * seq; // FIX ME: cannot be reference 217 224 }; 218 225 … … 224 231 225 232 void ?{}( SeqIter(T) & si, Sequence(T) & s ) with( si ) { 226 ((ColIter &) 233 ((ColIter &)si){}; 227 234 seq = &s; 228 235 curr = &head( s ); … … 230 237 231 238 void ?{}( SeqIter(T) & si, Sequence(T) & s, T & start ) with( si ) { 232 ((ColIter &) 239 ((ColIter &)si){}; 233 240 seq = &s; 234 241 curr = &start; … … 255 262 inline ColIter; 256 263 // See above for explanation. 257 Sequence(T) * seq; 264 Sequence(T) * seq; // FIX ME: cannot be reference 258 265 }; 259 266 260 267 inline { 261 268 void ?{}( SeqIterRev(T) & si ) with( si ) { 262 ((ColIter &) 269 ((ColIter &)si){}; 263 270 seq = 0p; 264 271 } // post: elts = null. 265 272 266 273 void ?{}( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) { 267 ((ColIter &) 274 ((ColIter &)si){}; 268 275 seq = &s; 269 276 curr = &tail( s ); … … 271 278 272 279 void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) { 273 ((ColIter &) 280 ((ColIter &)si){}; 274 281 seq = &s; 275 282 curr = &start; … … 291 298 } // distribution 292 299 } // distribution 293 294 // Local Variables: //295 // compile-command: "cfa sequence.hfa" //296 // End: // -
libcfa/src/bits/sequence_example.cfa
r33a129a r3f91792 137 137 } 138 138 } 139 140 // Local Variables: //141 // compile-command: "cfa sequence_example.cfa" //142 // End: // -
libcfa/src/bits/stack.hfa
r33a129a r3f91792 26 26 27 27 void addHead( Stack(T) & s, T & n ) with( s ) { 28 #ifdef __CFA_DEBUG__28 #ifdef __CFA_DEBUG__ 29 29 if ( listed( (Colable &)(n) ) ) abort( "(Stack &)%p.addHead( %p ) : Node is already on another list.", &s, n ); 30 #endif // __CFA_DEBUG__30 #endif // __CFA_DEBUG__ 31 31 Next( &n ) = &head( s ) ? &head( s ) : &n; 32 32 root = &n; … … 44 44 T & t = head( s ); 45 45 if ( root ) { 46 root = ( T *)Next( root);46 root = ( T *)Next( root ); 47 47 if ( &head( s ) == &t ) root = 0p; // only one element ? 48 48 Next( &t ) = 0p; … … 92 92 } // distribution 93 93 } // distribution 94 95 // Local Variables: //96 // compile-command: "make install" //97 // End: // -
libcfa/src/bits/stack_example.cfa
r33a129a r3f91792 107 107 } 108 108 } 109 110 // Local Variables: //111 // compile-command: "cfa stack_example.cfa" //112 // End: // -
src/Common/module.mk
r33a129a r3f91792 18 18 Common/Assert.cc \ 19 19 Common/CodeLocation.h \ 20 Common/CodeLocationTools.hpp \ 21 Common/CodeLocationTools.cpp \ 20 22 Common/CompilerError.h \ 21 23 Common/Debug.h \ -
src/main.cc
r33a129a r3f91792 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Dec 1 14:52:00 202013 // Update Count : 63 812 // Last Modified On : Mon Dec 7 15:29:00 2020 13 // Update Count : 639 14 14 // 15 15 … … 40 40 #include "CodeTools/ResolvProtoDump.h" // for dumpAsResolvProto 41 41 #include "CodeTools/TrackLoc.h" // for fillLocations 42 #include "Common/CodeLocationTools.hpp" // for forceFillCodeLocations 42 43 #include "Common/CompilerError.h" // for CompilerError 43 44 #include "Common/Stats.h" … … 353 354 } // if 354 355 355 // TODO: This is a quick fix to get the build working. 356 // Get rid of fillLocations or at least make a new-ast version. 357 translationUnit = convert( move( transUnit ) ); 358 CodeTools::fillLocations( translationUnit ); 359 transUnit = convert( move( translationUnit ) ); 356 forceFillCodeLocations( transUnit ); 360 357 361 358 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
Note: See TracChangeset
for help on using the changeset viewer.