Changes in / [154672d:79b05224]
- Files:
-
- 2 deleted
- 10 edited
-
libcfa/src/collections/string.cfa (modified) (1 diff)
-
libcfa/src/collections/string.hfa (modified) (1 diff)
-
libcfa/src/collections/string_res.cfa (modified) (1 diff)
-
libcfa/src/collections/string_res.hfa (modified) (1 diff)
-
libcfa/src/concurrency/io.cfa (modified) (5 diffs)
-
libcfa/src/concurrency/io/types.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/pthread.cfa (modified) (8 diffs)
-
src/ControlStruct/MultiLevelExit.cpp (modified) (6 diffs)
-
src/ResolvExpr/ResolveTypeof.cc (modified) (4 diffs)
-
src/ResolvExpr/Resolver.cc (modified) (2 diffs)
-
tests/collections/.expect/string-compare.txt (deleted)
-
tests/collections/string-compare.cfa (deleted)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.cfa
r154672d r79b05224 157 157 // Comparison 158 158 159 int cmp (const string &s1, const string &s2) { return cmp(*s1.inner , *s2.inner); } 160 bool ?==?(const string &s1, const string &s2) { return *s1.inner == *s2.inner ; } 161 bool ?!=?(const string &s1, const string &s2) { return *s1.inner != *s2.inner ; } 162 bool ?>? (const string &s1, const string &s2) { return *s1.inner > *s2.inner ; } 163 bool ?>=?(const string &s1, const string &s2) { return *s1.inner >= *s2.inner ; } 164 bool ?<=?(const string &s1, const string &s2) { return *s1.inner <= *s2.inner ; } 165 bool ?<? (const string &s1, const string &s2) { return *s1.inner < *s2.inner ; } 166 167 int cmp (const string &s1, const char* s2) { return cmp(*s1.inner , s2 ); } 168 bool ?==?(const string &s1, const char* s2) { return *s1.inner == s2 ; } 169 bool ?!=?(const string &s1, const char* s2) { return *s1.inner != s2 ; } 170 bool ?>? (const string &s1, const char* s2) { return *s1.inner > s2 ; } 171 bool ?>=?(const string &s1, const char* s2) { return *s1.inner >= s2 ; } 172 bool ?<=?(const string &s1, const char* s2) { return *s1.inner <= s2 ; } 173 bool ?<? (const string &s1, const char* s2) { return *s1.inner < s2 ; } 174 175 int cmp (const char* s1, const string &s2) { return cmp( s1 , *s2.inner); } 176 bool ?==?(const char* s1, const string &s2) { return s1 == *s2.inner ; } 177 bool ?!=?(const char* s1, const string &s2) { return s1 != *s2.inner ; } 178 bool ?>? (const char* s1, const string &s2) { return s1 > *s2.inner ; } 179 bool ?>=?(const char* s1, const string &s2) { return s1 >= *s2.inner ; } 180 bool ?<=?(const char* s1, const string &s2) { return s1 <= *s2.inner ; } 181 bool ?<? (const char* s1, const string &s2) { return s1 < *s2.inner ; } 182 159 bool ?==?(const string & s, const string & other) { 160 return *s.inner == *other.inner; 161 } 162 163 bool ?!=?(const string & s, const string & other) { 164 return *s.inner != *other.inner; 165 } 166 167 bool ?==?(const string & s, const char * other) { 168 return *s.inner == other; 169 } 170 171 bool ?!=?(const string & s, const char * other) { 172 return *s.inner != other; 173 } 183 174 184 175 //////////////////////////////////////////////////////// -
libcfa/src/collections/string.hfa
r154672d r79b05224 116 116 117 117 // Comparisons 118 int cmp (const string &, const string &); 119 bool ?==?(const string &, const string &); 120 bool ?!=?(const string &, const string &); 121 bool ?>? (const string &, const string &); 122 bool ?>=?(const string &, const string &); 123 bool ?<=?(const string &, const string &); 124 bool ?<? (const string &, const string &); 125 126 int cmp (const string &, const char*); 127 bool ?==?(const string &, const char*); 128 bool ?!=?(const string &, const char*); 129 bool ?>? (const string &, const char*); 130 bool ?>=?(const string &, const char*); 131 bool ?<=?(const string &, const char*); 132 bool ?<? (const string &, const char*); 133 134 int cmp (const char*, const string &); 135 bool ?==?(const char*, const string &); 136 bool ?!=?(const char*, const string &); 137 bool ?>? (const char*, const string &); 138 bool ?>=?(const char*, const string &); 139 bool ?<=?(const char*, const string &); 140 bool ?<? (const char*, const string &); 141 118 bool ?==?(const string & s, const string & other); 119 bool ?!=?(const string & s, const string & other); 120 bool ?==?(const string & s, const char * other); 121 bool ?!=?(const string & s, const char * other); 142 122 143 123 // Slicing -
libcfa/src/collections/string_res.cfa
r154672d r79b05224 637 637 // Comparisons 638 638 639 int cmp(const string_res &s1, const string_res &s2) { 640 // return 0; 641 int ans1 = memcmp(s1.Handle.s, s2.Handle.s, min(s1.Handle.lnth, s2.Handle.lnth)); 642 if (ans1 != 0) return ans1; 643 return s1.Handle.lnth - s2.Handle.lnth; 644 } 645 646 bool ?==?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) == 0; } 647 bool ?!=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) != 0; } 648 bool ?>? (const string_res &s1, const string_res &s2) { return cmp(s1, s2) > 0; } 649 bool ?>=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) >= 0; } 650 bool ?<=?(const string_res &s1, const string_res &s2) { return cmp(s1, s2) <= 0; } 651 bool ?<? (const string_res &s1, const string_res &s2) { return cmp(s1, s2) < 0; } 652 653 int cmp (const string_res &s1, const char* s2) { 654 string_res s2x = s2; 655 return cmp(s1, s2x); 656 } 657 658 bool ?==?(const string_res &s1, const char* s2) { return cmp(s1, s2) == 0; } 659 bool ?!=?(const string_res &s1, const char* s2) { return cmp(s1, s2) != 0; } 660 bool ?>? (const string_res &s1, const char* s2) { return cmp(s1, s2) > 0; } 661 bool ?>=?(const string_res &s1, const char* s2) { return cmp(s1, s2) >= 0; } 662 bool ?<=?(const string_res &s1, const char* s2) { return cmp(s1, s2) <= 0; } 663 bool ?<? (const string_res &s1, const char* s2) { return cmp(s1, s2) < 0; } 664 665 int cmp (const char* s1, const string_res & s2) { 666 string_res s1x = s1; 667 return cmp(s1x, s2); 668 } 669 670 bool ?==?(const char* s1, const string_res &s2) { return cmp(s1, s2) == 0; } 671 bool ?!=?(const char* s1, const string_res &s2) { return cmp(s1, s2) != 0; } 672 bool ?>? (const char* s1, const string_res &s2) { return cmp(s1, s2) > 0; } 673 bool ?>=?(const char* s1, const string_res &s2) { return cmp(s1, s2) >= 0; } 674 bool ?<=?(const char* s1, const string_res &s2) { return cmp(s1, s2) <= 0; } 675 bool ?<? (const char* s1, const string_res &s2) { return cmp(s1, s2) < 0; } 676 639 640 bool ?==?(const string_res &s1, const string_res &s2) { 641 return ByteCmp( s1.Handle.s, 0, s1.Handle.lnth, s2.Handle.s, 0, s2.Handle.lnth) == 0; 642 } 643 644 bool ?!=?(const string_res &s1, const string_res &s2) { 645 return !(s1 == s2); 646 } 647 bool ?==?(const string_res &s, const char* other) { 648 string_res sother = other; 649 return s == sother; 650 } 651 bool ?!=?(const string_res &s, const char* other) { 652 return !(s == other); 653 } 677 654 678 655 -
libcfa/src/collections/string_res.hfa
r154672d r79b05224 142 142 143 143 // Comparisons 144 int cmp (const string_res &, const string_res &); 145 bool ?==?(const string_res &, const string_res &); 146 bool ?!=?(const string_res &, const string_res &); 147 bool ?>? (const string_res &, const string_res &); 148 bool ?>=?(const string_res &, const string_res &); 149 bool ?<=?(const string_res &, const string_res &); 150 bool ?<? (const string_res &, const string_res &); 151 152 int cmp (const string_res &, const char*); 153 bool ?==?(const string_res &, const char*); 154 bool ?!=?(const string_res &, const char*); 155 bool ?>? (const string_res &, const char*); 156 bool ?>=?(const string_res &, const char*); 157 bool ?<=?(const string_res &, const char*); 158 bool ?<? (const string_res &, const char*); 159 160 int cmp (const char*, const string_res &); 161 bool ?==?(const char*, const string_res &); 162 bool ?!=?(const char*, const string_res &); 163 bool ?>? (const char*, const string_res &); 164 bool ?>=?(const char*, const string_res &); 165 bool ?<=?(const char*, const string_res &); 166 bool ?<? (const char*, const string_res &); 144 bool ?==?(const string_res &s, const string_res &other); 145 bool ?!=?(const string_res &s, const string_res &other); 146 bool ?==?(const string_res &s, const char* other); 147 bool ?!=?(const string_res &s, const char* other); 167 148 168 149 // String search -
libcfa/src/concurrency/io.cfa
r154672d r79b05224 594 594 lock( queue.lock __cfaabi_dbg_ctx2 ); 595 595 { 596 was_empty = queue.queue`isEmpty;596 was_empty = empty(queue.queue); 597 597 598 598 // Add our request to the list 599 insert_last( queue.queue, item );599 add( queue.queue, item ); 600 600 601 601 // Mark as pending … … 632 632 // notify the arbiter that new allocations are available 633 633 static void __ioarbiter_notify( io_arbiter$ & this, io_context$ * ctx ) { 634 /* paranoid */ verify( ! this.pending.queue`isEmpty);634 /* paranoid */ verify( !empty(this.pending.queue) ); 635 635 /* paranoid */ verify( __preemption_enabled() ); 636 636 … … 642 642 // as long as there are pending allocations try to satisfy them 643 643 // for simplicity do it in FIFO order 644 while( ! this.pending.queue`isEmpty) {644 while( !empty(this.pending.queue) ) { 645 645 // get first pending allocs 646 646 __u32 have = ctx->sq.free_ring.tail - ctx->sq.free_ring.head; 647 __pending_alloc & pa = (__pending_alloc&) (this.pending.queue`first);647 __pending_alloc & pa = (__pending_alloc&)head( this.pending.queue ); 648 648 649 649 // check if we have enough to satisfy the request … … 651 651 652 652 // if there are enough allocations it means we can drop the request 653 try_pop_front( this.pending.queue );653 drop( this.pending.queue ); 654 654 655 655 /* paranoid */__attribute__((unused)) bool ret = … … 727 727 // pop each operation one at a time. 728 728 // There is no wait morphing because of the io sq ring 729 while( ! ctx.ext_sq.queue`isEmpty) {729 while( !empty(ctx.ext_sq.queue) ) { 730 730 // drop the element from the queue 731 __external_io & ei = (__external_io&) try_pop_front( ctx.ext_sq.queue );731 __external_io & ei = (__external_io&)drop( ctx.ext_sq.queue ); 732 732 733 733 // submit it -
libcfa/src/concurrency/io/types.hfa
r154672d r79b05224 24 24 25 25 #include "bits/locks.hfa" 26 #include "bits/queue.hfa" 26 27 #include "iofwd.hfa" 27 28 #include "kernel/fwd.hfa" 28 29 29 30 #if defined(CFA_HAVE_LINUX_IO_URING_H) 31 #include "bits/sequence.hfa" 30 32 #include "monitor.hfa" 31 33 … … 118 120 struct __outstanding_io { 119 121 // intrusive link fields 120 inline dlink(__outstanding_io);122 inline Colable; 121 123 122 124 // primitive on which to block until the io is processed 123 125 oneshot waitctx; 124 126 }; 125 P9_EMBEDDED( __outstanding_io, dlink(__outstanding_io) ) 127 static inline __outstanding_io *& Next( __outstanding_io * n ) { return (__outstanding_io *)Next( (Colable *)n ); } 126 128 127 129 // queue of operations that are outstanding … … 132 134 133 135 // the actual queue 134 dlist(__outstanding_io) queue;136 Queue(__outstanding_io) queue; 135 137 136 138 // volatile used to avoid the need for taking the lock if it's empty -
libcfa/src/concurrency/pthread.cfa
r154672d r79b05224 20 20 #include <errno.h> 21 21 #include "locks.hfa" 22 #include "bits/stack.hfa" 23 #include "bits/sequence.hfa" 24 22 25 23 26 #define check_nonnull(x) asm("": "+rm"(x)); if( x == 0p ) return EINVAL; … … 31 34 32 35 struct pthread_values{ 33 inline dlink(pthread_values);36 inline Seqable; 34 37 void * value; 35 38 bool in_use; 36 39 }; 37 P9_EMBEDDED( pthread_values, dlink(pthread_values) ) 40 41 static inline { 42 pthread_values *& Back( pthread_values * n ) { 43 return (pthread_values *)Back( (Seqable *)n ); 44 } 45 46 pthread_values *& Next( pthread_values * n ) { 47 return (pthread_values *)Next( (Colable *)n ); 48 } 49 } 38 50 39 51 struct pthread_keys { 40 52 bool in_use; 41 53 void (* destructor)( void * ); 42 dlist( pthread_values) threads;54 Sequence(pthread_values) threads; 43 55 }; 44 56 … … 66 78 67 79 struct Pthread_kernel_threads{ 68 inline dlink(Pthread_kernel_threads);80 inline Colable; 69 81 processor p; 70 82 }; 71 P9_EMBEDDED( Pthread_kernel_threads, dlink(Pthread_kernel_threads) ) 72 73 static dlist(Pthread_kernel_threads) cfa_pthreads_kernel_threads; 83 84 Pthread_kernel_threads *& Next( Pthread_kernel_threads * n ) { 85 return (Pthread_kernel_threads *)Next( (Colable *)n ); 86 } 87 88 static Stack(Pthread_kernel_threads) cfa_pthreads_kernel_threads; 74 89 static bool cfa_pthreads_kernel_threads_zero = false; // set to zero ? 75 90 static int cfa_pthreads_no_kernel_threads = 1; // number of kernel threads … … 216 231 key = &cfa_pthread_keys[i]; 217 232 value->in_use = false; 218 remove(*value); 219 233 remove(key->threads, *value); 220 234 // if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, 221 235 // the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. … … 537 551 538 552 // Remove key from all threads with a value. 539 540 // Sequence(pthread_values)& head = cfa_pthread_keys[key].threads; 541 // for ( SeqIter(pthread_values) iter = { head }; iter | p; ) { 542 // remove(head, p); 543 // p.in_use = false; 544 // } 545 pthread_values * p = &try_pop_front( cfa_pthread_keys[key].threads ); 546 for ( ; p; ) { 547 p->in_use = false; 548 p = &try_pop_front( cfa_pthread_keys[key].threads ); 549 } 553 pthread_values& p; 554 Sequence(pthread_values)& head = cfa_pthread_keys[key].threads; 555 for ( SeqIter(pthread_values) iter = { head }; iter | p; ) { 556 remove(head, p); 557 p.in_use = false; 558 } 550 559 unlock(key_lock); 551 560 return 0; … … 576 585 if ( ! entry.in_use ) { 577 586 entry.in_use = true; 578 insert_last(cfa_pthread_keys[key].threads, entry);587 add(cfa_pthread_keys[key].threads, entry); 579 588 } // if 580 589 entry.value = (void *)value; … … 603 612 //######################### Parallelism ######################### 604 613 void pthread_delete_kernel_threads_() __THROW { // see uMain::~uMain 605 Pthread_kernel_threads * p = &try_pop_front(cfa_pthreads_kernel_threads); 606 for ( ; p; ) { 607 delete(p); 608 p = &try_pop_front(cfa_pthreads_kernel_threads); 614 Pthread_kernel_threads& p; 615 for ( StackIter(Pthread_kernel_threads) iter = {cfa_pthreads_kernel_threads}; iter | p; ) { 616 delete(&p); 609 617 } // for 610 618 } // pthread_delete_kernel_threads_ … … 623 631 lock( concurrency_lock ); 624 632 for ( ; new_level > cfa_pthreads_no_kernel_threads; cfa_pthreads_no_kernel_threads += 1 ) { // add processors ? 625 insert_last(cfa_pthreads_kernel_threads, *new() );633 push(cfa_pthreads_kernel_threads, *new() ); 626 634 } // for 627 635 for ( ; new_level < cfa_pthreads_no_kernel_threads; cfa_pthreads_no_kernel_threads -= 1 ) { // remove processors ? 628 delete(& try_pop_front(cfa_pthreads_kernel_threads));636 delete(&pop(cfa_pthreads_kernel_threads)); 629 637 } // for 630 638 unlock( concurrency_lock ); -
src/ControlStruct/MultiLevelExit.cpp
r154672d r79b05224 10 10 // Created On : Mon Nov 1 13:48:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Sep 6 12:00:00 202313 // Update Count : 3 512 // Last Modified On : Mon Mar 28 9:42:00 2022 13 // Update Count : 34 14 14 // 15 15 … … 18 18 #include "AST/Pass.hpp" 19 19 #include "AST/Stmt.hpp" 20 #include "Common/CodeLocationTools.hpp" 20 21 #include "LabelGeneratorNew.hpp" 21 22 … … 25 26 26 27 namespace ControlStruct { 27 28 namespace {29 30 28 class Entry { 31 29 public: … … 37 35 bool used = false; 38 36 Target( const Label & label ) : label( label ) {} 39 Target() : label( CodeLocation() , "") {}37 Target() : label( CodeLocation() ) {} 40 38 }; 41 39 Target firstTarget; … … 526 524 // if continue is used insert a continue label into the back of the body of the loop 527 525 if ( entry.isContUsed() ) { 526 CompoundStmt * new_body = new CompoundStmt( body->location ); 527 // {} 528 new_body->kids.push_back( body ); 528 529 // { 529 530 // body 530 // ContinueLabel: ;531 531 // } 532 return new CompoundStmt( body->location, { 533 body, 534 labelledNullStmt( body->location, entry.useContExit() ), 535 } ); 532 new_body->kids.push_back( 533 labelledNullStmt( body->location, entry.useContExit() ) ); 534 // { 535 // body 536 // ContinueLabel: {} 537 // } 538 return new_body; 536 539 } 537 540 … … 617 620 } 618 621 619 } // namespace620 621 622 const CompoundStmt * multiLevelExitUpdate( 622 const CompoundStmt * stmt, const LabelToStmt & labelTable ) { 623 const CompoundStmt * stmt, 624 const LabelToStmt & labelTable ) { 623 625 // Must start in the body, so FunctionDecls can be a stopping point. 624 626 Pass<MultiLevelExitCore> visitor( labelTable ); 625 return stmt->accept( visitor ); 626 } 627 627 const CompoundStmt * ret = stmt->accept( visitor ); 628 // There are some unset code locations slipping in, possibly by Labels. 629 const Node * node = localFillCodeLocations( ret->location, ret ); 630 return strict_dynamic_cast<const CompoundStmt *>( node ); 631 } 628 632 } // namespace ControlStruct 629 633 -
src/ResolvExpr/ResolveTypeof.cc
r154672d r79b05224 237 237 // The designator I want to replace 238 238 const ast::Expr * designator = des->designators.at(0); 239 // Stupid flag variable for development, to be removed 240 bool mutated = false; 239 241 240 if ( const ast::NameExpr * designatorName = dynamic_cast<const ast::NameExpr *>(designator) ) { 242 241 auto candidates = context.symtab.lookupId(designatorName->name); … … 245 244 if ( candidates.size() != 1 ) return mutDecl; 246 245 auto candidate = candidates.at(0); 247 if ( const ast::EnumInstType * enumInst = dynamic_cast<const ast::EnumInstType *>(candidate.id->get_type()) ) {246 if ( const ast::EnumInstType * enumInst = dynamic_cast<const ast::EnumInstType *>(candidate.id->get_type()) ) { 248 247 // determine that is an enumInst, swap it with its const value 249 248 assert( candidates.size() == 1 ); … … 251 250 // Need to iterate over all enum value to find the initializer to swap 252 251 for ( size_t m = 0; m < baseEnum->members.size(); ++m ) { 253 const ast::ObjectDecl * mem = baseEnum->members.at(m).as<const ast::ObjectDecl>();254 252 if ( baseEnum->members.at(m)->name == designatorName->name ) { 253 const ast::ObjectDecl * mem = baseEnum->members.at(m).as<const ast::ObjectDecl>(); 255 254 assert(mem); 256 if ( mem->init ) { 257 const ast::SingleInit * memInit = mem->init.as<const ast::SingleInit>(); 258 ast::Expr * initValue = shallowCopy( memInit->value.get() ); 259 newDesination->designators.push_back( initValue ); 260 mutated = true; 261 } 262 break; 255 const ast::ConstantExpr * enumAsInit = ast::ConstantExpr::from_int(newDesination->location, m); 256 newDesination->designators.push_back( enumAsInit ); 263 257 } 258 } 259 if ( newDesination->designators.size() == 0 ) { 260 SemanticError(des->location, "Resolution Error: Resolving array designation as Enum Instance value, but cannot find a desgination value"); 264 261 } 265 262 } else { … … 269 266 newDesination->designators.push_back( des->designators.at(0) ); 270 267 } 271 if ( mutated ) { 272 mutListInit = ast::mutate_field_index(mutListInit, &ast::ListInit::designations, k, newDesination); 273 } 268 mutListInit = ast::mutate_field_index(mutListInit, &ast::ListInit::designations, k, newDesination); 274 269 } 275 270 } -
src/ResolvExpr/Resolver.cc
r154672d r79b05224 988 988 } 989 989 }; 990 991 struct ResolveDesignators_new final : public ast::WithShortCircuiting {992 ResolveContext& context;993 bool result = false;994 995 ResolveDesignators_new( ResolveContext& _context ): context{_context} {};996 997 void previsit( const ast::Node * ) {998 // short circuit if we already know there are designations999 if ( result ) visit_children = false;1000 }1001 1002 void previsit( const ast::Designation * des ) {1003 if ( result ) visit_children = false;1004 else if ( ! des->designators.empty() ) {1005 if ( (des->designators.size() == 1) ) {1006 const ast::Expr * designator = des->designators.at(0);1007 if ( const ast::NameExpr * designatorName = dynamic_cast<const ast::NameExpr *>(designator) ) {1008 auto candidates = context.symtab.lookupId(designatorName->name);1009 for ( auto candidate : candidates ) {1010 if ( dynamic_cast<const ast::EnumInstType *>(candidate.id->get_type()) ) {1011 result = true;1012 break;1013 }1014 }1015 }1016 }1017 visit_children = false;1018 }1019 }1020 };1021 990 } // anonymous namespace 1022 991 /// Check if this expression is or includes a deleted expression … … 1538 1507 if ( InitTweak::tryConstruct( mutDecl ) && ( managedTypes.isManaged( mutDecl ) || ((! isInFunction() || mutDecl->storage.is_static ) && ! InitTweak::isConstExpr( mutDecl->init ) ) ) ) { 1539 1508 // constructed objects cannot be designated 1509 // if ( InitTweak::isDesignated( mutDecl->init ) ) SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" ); 1540 1510 if ( InitTweak::isDesignated( mutDecl->init ) ) { 1541 ast::Pass<ResolveDesignators_new> res( context ); 1542 maybe_accept( mutDecl->init.get(), res ); 1543 if ( !res.core.result ) { 1544 SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" ); 1545 } 1511 SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" ); 1546 1512 } 1547 1513 // constructed objects should not have initializers nested too deeply
Note:
See TracChangeset
for help on using the changeset viewer.