Changeset 218096f
- Timestamp:
- Sep 28, 2021, 2:45:42 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 0f781fb8
- Parents:
- 056cbdb
- Location:
- libcfa/src/containers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string_res.cfa
r056cbdb r218096f 17 17 #include <stdlib.hfa> // e.g. malloc 18 18 #include <string.h> // e.g. strlen 19 #include <assert.h> 19 20 20 21 //######################### VbyteHeap "header" ######################### … … 102 103 // creator. 103 104 104 void ?{}( HandleNode & this ) with(this) {105 static inline void ?{}( HandleNode & this ) with(this) { 105 106 #ifdef VbyteDebug 106 107 serr | "enter:HandleNode::HandleNode, this:" | &this; … … 117 118 // collection. 118 119 119 void ?{}( HandleNode & this, VbyteHeap & vh ) with(this) {120 static inline void ?{}( HandleNode & this, VbyteHeap & vh ) with(this) { 120 121 #ifdef VbyteDebug 121 122 serr | "enter:HandleNode::HandleNode, this:" | &this; … … 133 134 // is the responsibility of the creator to destroy it. 134 135 135 void ^?{}( HandleNode & this ) with(this) {136 static inline void ^?{}( HandleNode & this ) with(this) { 136 137 #ifdef VbyteDebug 137 138 serr | "enter:HandleNode::~HandleNode, this:" | & this; … … 223 224 void ?{}(string_res &s, const string_res & s2, StrResInitMode mode, size_t start, size_t end ) { 224 225 225 (s.Handle){ HeapArea }; 226 verify( start <= end && end <= s2.Handle.lnth ); 227 228 (s.Handle){}; 226 229 s.Handle.s = s2.Handle.s + start; 227 230 s.Handle.lnth = end - start; 228 MoveThisAfter(s.Handle, s2.Handle ); // insert this handle after rhs handle231 AddThisAfter(s.Handle, s2.Handle ); // insert this handle after rhs handle 229 232 // ^ bug? skip others at early point in string 230 233 … … 234 237 s.shareEditSet_next = &s; 235 238 } else { 236 assert( mode == SHARE_EDITS );239 verify( mode == SHARE_EDITS ); 237 240 238 241 // s2 is logically const but not implementation const … … 297 300 char *limit = pasting.Handle.s + pasting.Handle.lnth; 298 301 for (string_res * p = this.shareEditSet_next; p != &this; p = p->shareEditSet_next) { 299 assert(p->Handle.s >= beforeBegin);302 verify (p->Handle.s >= beforeBegin); 300 303 if ( p->Handle.s >= afterBegin ) { 301 assert( p->Handle.s <= afterBegin + afterLen );302 assert( p->Handle.s + p->Handle.lnth <= afterBegin + afterLen );304 verify ( p->Handle.s <= afterBegin + afterLen ); 305 verify ( p->Handle.s + p->Handle.lnth <= afterBegin + afterLen ); 303 306 // p starts after the edit 304 307 // take start and end as end-anchored … … 318 321 } else { 319 322 // p ends after the edit 320 assert( p->Handle.s + p->Handle.lnth <= afterBegin + afterLen );323 verify ( p->Handle.s + p->Handle.lnth <= afterBegin + afterLen ); 321 324 // take end as end-anchored 322 325 // stretch-shrink p according to the edit … … 328 331 p->Handle.s = pasting.Handle.s + startOffsetFromStart; 329 332 } else { 330 assert( p->Handle.s < afterBegin );333 verify ( p->Handle.s < afterBegin ); 331 334 // p starts during the edit 332 assert( p->Handle.s + p->Handle.lnth >= beforeBegin + beforeLen );335 verify( p->Handle.s + p->Handle.lnth >= beforeBegin + beforeLen ); 333 336 if ( p->Handle.s + p->Handle.lnth < afterBegin ) { 334 337 // p ends during the edit; p does not include the last character replaced … … 374 377 s.shareEditSet_prev->shareEditSet_next = s.shareEditSet_next; 375 378 s.shareEditSet_next->shareEditSet_prev = s.shareEditSet_prev; 376 s.shareEditSet_next = &s;377 s.shareEditSet_prev = &s;379 // s.shareEditSet_next = &s; 380 // s.shareEditSet_prev = &s; 378 381 } 379 382 … … 385 388 //TODO: Check if index is valid (no exceptions yet) 386 389 return Handle.s[index]; 390 } 391 392 void assignAt(const string_res &s, size_t index, char val) { 393 string_res editZone = { s, SHARE_EDITS, index, index+1 }; 394 assign(editZone, &val, 1); 387 395 } 388 396 … … 653 661 NoBytes = ( uintptr_t )EndVbyte + size; // try again 654 662 if ( NoBytes > ( uintptr_t )ExtVbyte ) { // enough room for new byte-string ? 663 // unimplemented feature - assert, not verify 655 664 assert( 0 && "need to implement actual growth" ); 656 665 // extend( size ); // extend the byte-string area … … 677 686 // | ( h->s ) | " and keep handles in ascending order"; 678 687 // exit(-1 ); 679 assert( 0 && "VbyteSM: Error - Cannot move byte strings as requested and keep handles in ascending order");688 verify( 0 && "VbyteSM: Error - Cannot move byte strings as requested and keep handles in ascending order"); 680 689 } // if 681 690 … … 839 848 if ( AmountFree < ( int )( CurrSize * 0.1 )) { // free space less than 10% ? 840 849 850 // unimplemented feature - assert, not verify 841 851 assert( 0 && "need to implement actual growth" ); 842 852 // extend( CurrSize ); // extend the heap -
libcfa/src/containers/string_res.hfa
r056cbdb r218096f 31 31 unsigned int lnth; // length of byte string 32 32 }; // HandleNode 33 34 void ?{}( HandleNode & ); // constructor for header node35 36 void ?{}( HandleNode &, VbyteHeap & ); // constructor for nodes in the handle list37 void ^?{}( HandleNode & ); // destructor for handle nodes38 33 39 34 extern VbyteHeap * DEBUG_string_heap; … … 105 100 106 101 // Character access 102 void assignAt(const string_res &s, size_t index, char val); 107 103 char ?[?](const string_res &s, size_t index); // Mike changed to ret by val from Sunjay's ref, to match Peter's 108 104 //char codePointAt(const string_res &s, size_t index); // revisit under Unicode
Note: See TracChangeset
for help on using the changeset viewer.