Changes in / [8d96dee:89bef959]
- Files:
-
- 1 added
- 4 deleted
- 11 edited
-
libcfa/src/containers/string.cfa (modified) (2 diffs)
-
libcfa/src/containers/string.hfa (modified) (1 diff)
-
libcfa/src/containers/string_res.cfa (modified) (18 diffs)
-
libcfa/src/containers/string_res.hfa (modified) (3 diffs)
-
src/ControlStruct/ExceptDeclNew.cpp (modified) (4 diffs)
-
src/Parser/StatementNode.cc (modified) (2 diffs)
-
src/Parser/StatementNode.h (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (2 diffs)
-
tests/collections/.expect/string-istream.txt (deleted)
-
tests/collections/.in/string-istream.txt (deleted)
-
tests/collections/string-istream.cfa (deleted)
-
tests/io/.expect/manipulatorsOutput2.arm64.txt (modified) (1 diff)
-
tests/io/.expect/manipulatorsOutput2.x86.txt (modified) (1 diff)
-
tests/io/.expect/manipulatorsOutput3.arm64.txt (modified) (1 diff)
-
tests/io/.expect/manipulatorsOutput3.txt (added)
-
tests/io/.expect/manipulatorsOutput3.x64.txt (deleted)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string.cfa
r8d96dee r89bef959 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 12 15:24:18202313 // Update Count : 612 // Last Modified On : Mon Aug 7 10:07:26 2023 13 // Update Count : 2 14 14 // 15 15 … … 100 100 101 101 //////////////////////////////////////////////////////// 102 // Input-Output 103 104 ofstream & ?|?( ofstream & out, const string & this ) { 105 return out | (*this.inner); // print internal string_res 106 } 107 108 void ?|?( ofstream & out, const string & this ) { 109 (ofstream &)(out | (*this.inner)); ends( out ); 110 } 111 112 ifstream & ?|?(ifstream &in, string &this) { 113 return in | (*this.inner); // read to internal string_res 114 } 115 102 // Output 103 104 ofstream & ?|?( ofstream & fs, const string & this ) { 105 return fs | (*this.inner); 106 } 107 108 void ?|?( ofstream & fs, const string & this ) { 109 fs | (*this.inner); 110 } 116 111 117 112 //////////////////////////////////////////////////////// -
libcfa/src/containers/string.hfa
r8d96dee r89bef959 55 55 ofstream & ?|?(ofstream &out, const string &s); 56 56 void ?|?(ofstream &out, const string &s); 57 ifstream & ?|?(ifstream &in, string &s);58 57 59 58 // Concatenation -
libcfa/src/containers/string_res.cfa
r8d96dee r89bef959 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 12 15:37:47202313 // Update Count : 1012 // Last Modified On : Thu Jun 29 09:29:06 2023 13 // Update Count : 2 14 14 // 15 15 … … 17 17 #include "string_sharectx.hfa" 18 18 #include "stdlib.hfa" 19 #include <ctype.h>20 19 21 20 // Workaround for observed performance penalty from calling CFA's alloc. … … 135 134 serr | nlOff; 136 135 serr | " lnth:" | lnth | " s:" | (void *)s | ",\""; 137 for ( i ; lnth) {136 for ( int i = 0; i < lnth; i += 1 ) { 138 137 serr | s[i]; 139 138 } // for … … 199 198 // Output operator 200 199 ofstream & ?|?(ofstream &out, const string_res &s) { 201 // CFA string is NOT null terminated, so print exactly lnth characters in a minimum width of 0. 202 out | wd( 0, s.Handle.lnth, s.Handle.s ) | nonl; 200 // Store auto-newline state so it can be restored 201 bool anl = getANL$(out); 202 nlOff(out); 203 for (size_t i = 0; i < s.Handle.lnth; i++) { 204 out | s[i]; 205 } 206 out | sepVal; 207 // Re-apply newlines after done, for chaining version 208 if (anl) nlOn(out); 203 209 return out; 204 210 } 205 211 206 212 void ?|?(ofstream &out, const string_res &s) { 207 (ofstream &)(out | s); ends( out ); 208 } 209 210 // Input operator 211 ifstream & ?|?(ifstream &in, string_res &s) { 212 213 // Reading into a temp before assigning to s is near zero overhead in typical cases because of sharing. 214 // If s is a substring of something larger, simple assignment takes care of that case correctly. 215 // But directly reading a variable amount of text into the middle of a larger context is not practical. 216 string_res temp; 217 218 // Read in chunks. Often, one chunk is enough. Keep the string that accumulates chunks last in the heap, 219 // so available room is rest of heap. When a chunk fills the heap, force growth then take the next chunk. 220 for (;;) { 221 // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops) 222 // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator 223 temp += "--"; 224 assert( temp.Handle.ulink->EndVbyte == temp.Handle.s + temp.Handle.lnth ); // last in heap 225 226 // reset, to overwrite the appended "--" 227 temp.Handle.lnth -= 2; 228 temp.Handle.ulink->EndVbyte -= 2; 229 230 // rest of heap, less 1 byte for null terminator, is available to read into 231 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte - 1; 232 assert (lenReadable >= 1); 233 234 // get bytes 235 in | wdi( lenReadable, temp.Handle.ulink->EndVbyte ); 236 int lenWasRead = strlen(temp.Handle.ulink->EndVbyte); 237 238 // update metadata 239 temp.Handle.lnth += lenWasRead; 240 temp.Handle.ulink->EndVbyte += lenWasRead; 241 242 if (lenWasRead < lenReadable) break; 243 } 244 245 s = temp; 246 return in; 247 } 248 213 // Store auto-newline state so it can be restored 214 bool anl = getANL$(out); 215 if( s.Handle.lnth == 0 ) { 216 sout | ""; 217 } else { 218 nlOff(out); 219 for (size_t i = 0; i < s.Handle.lnth; i++) { 220 // Need to re-apply on the last output operator, for whole-statement version 221 if (anl && i == s.Handle.lnth-1) nlOn(out); 222 out | s[i]; 223 } 224 } 225 } 249 226 250 227 // Empty constructor … … 361 338 // adjust all substring string and handle locations, and check if any substring strings are outside the new base string 362 339 char *limit = resultSesStart + resultSesLnth; 363 for ( string_res * p = this.shareEditSet_next; p != &this; p = p->shareEditSet_next) {340 for (string_res * p = this.shareEditSet_next; p != &this; p = p->shareEditSet_next) { 364 341 verify (p->Handle.s >= beforeBegin); 365 342 if ( p->Handle.s >= afterBegin ) { … … 414 391 } 415 392 416 // traverse the share-edit set (SES) to recover the range of a base string to which `this` belongs 417 static void locateInShareEditSet( string_res &this, string_res *&shareEditSetStartPeer, string_res *&shareEditSetEndPeer ) { 418 shareEditSetStartPeer = & this; 419 shareEditSetEndPeer = & this; 393 static string_res & assign_(string_res &this, const char* buffer, size_t bsize, const string_res & valSrc) { 394 395 // traverse the incumbent share-edit set (SES) to recover the range of a base string to which `this` belongs 396 string_res * shareEditSetStartPeer = & this; 397 string_res * shareEditSetEndPeer = & this; 420 398 for (string_res * editPeer = this.shareEditSet_next; editPeer != &this; editPeer = editPeer->shareEditSet_next) { 421 399 if ( editPeer->Handle.s < shareEditSetStartPeer->Handle.s ) { … … 426 404 } 427 405 } 428 }429 430 static string_res & assign_(string_res &this, const char* buffer, size_t bsize, const string_res & valSrc) {431 432 string_res * shareEditSetStartPeer;433 string_res * shareEditSetEndPeer;434 locateInShareEditSet( this, shareEditSetStartPeer, shareEditSetEndPeer );435 406 436 407 verify( shareEditSetEndPeer->Handle.s >= shareEditSetStartPeer->Handle.s ); … … 618 589 619 590 bool contains(const string_res &s, char ch) { 620 for ( i; size(s)) {591 for (i; size(s)) { 621 592 if (s[i] == ch) return true; 622 593 } … … 672 643 } 673 644 674 for ( i; fromPos ~ s.Handle.lnth) {645 for (size_t i = fromPos; i < s.Handle.lnth; i++) { 675 646 size_t remaining = s.Handle.lnth - i; 676 647 // Never going to find the search string if the remaining string is … … 681 652 682 653 bool matched = true; 683 for ( j; searchsize) {654 for (size_t j = 0; j < searchsize; j++) { 684 655 if (search[j] != s.Handle.s[i + j]) { 685 656 matched = false; … … 769 740 770 741 int exclude(const string_res &s, const charclass_res &mask) { 771 for ( i; size(s)) {742 for (int i = 0; i < size(s); i++) { 772 743 if ( test(mask, s[i]) ) return i; 773 744 } … … 776 747 777 748 int include(const string_res &s, const charclass_res &mask) { 778 for ( i; size(s)) {749 for (int i = 0; i < size(s); i++) { 779 750 if ( ! test(mask, s[i]) ) return i; 780 751 } … … 804 775 for ( HandleNode *ni = HeaderPtr->flink; ni != HeaderPtr; ni = ni->flink ) { 805 776 serr | "\tnode:" | ni | " lnth:" | ni->lnth | " s:" | (void *)ni->s | ",\""; 806 for ( i ; ni->lnth) {777 for ( int i = 0; i < ni->lnth; i += 1 ) { 807 778 serr | ni->s[i]; 808 779 } // for … … 910 881 for ( HandleNode *n = HeaderPtr->flink; n != HeaderPtr; n = n->flink ) { 911 882 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 912 for ( i ; n->lnth) {913 serr | n->s[i];883 for ( int i = 0; i < n->lnth; i += 1 ) { 884 serr | n->s[i]; 914 885 } // for 915 886 serr | "\" flink:" | n->flink | " blink:" | n->blink | nl; … … 989 960 EndVbyte = StartVbyte; 990 961 h = Header.flink; // ignore header node 991 for ( ) {962 for (;;) { 992 963 memmove( EndVbyte, h->s, h->lnth ); 993 964 obase = h->s; … … 1000 971 // check if any substrings are allocated within a string 1001 972 1002 for ( ) {973 for (;;) { 1003 974 if ( h == &Header ) break; // end of header list ? 1004 975 if ( h->s >= limit ) break; // outside of current string ? … … 1030 1001 serr | nlOff; 1031 1002 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 1032 for ( i ; n->lnth) {1003 for ( int i = 0; i < n->lnth; i += 1 ) { 1033 1004 serr | n->s[i]; 1034 1005 } // for … … 1065 1036 serr | nlOff; 1066 1037 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 1067 for ( i ; n->lnth) {1038 for ( int i = 0; i < n->lnth; i += 1 ) { 1068 1039 serr | n->s[i]; 1069 1040 } // for -
libcfa/src/containers/string_res.hfa
r8d96dee r89bef959 9 9 // Author : Michael L. Brooks 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Aug 12 15:45:47 202313 // Update Count : 211 // Last Modified By : Michael L. Brooks 12 // Last Modified On : Fri Sep 03 11:00:00 2021 13 // Update Count : 1 14 14 // 15 15 … … 30 30 VbyteHeap *ulink; // upward link 31 31 32 char *s; // pointer to byte string32 char *s; // pointer to byte string 33 33 unsigned int lnth; // length of byte string 34 34 }; // HandleNode … … 101 101 ofstream & ?|?(ofstream &out, const string_res &s); 102 102 void ?|?(ofstream &out, const string_res &s); 103 ifstream & ?|?(ifstream &in, string_res &s);104 103 105 104 // Concatenation -
src/ControlStruct/ExceptDeclNew.cpp
r8d96dee r89bef959 242 242 } 243 243 244 ast::ObjectDecl * createExternVTable(244 static ast::ObjectDecl * createExternVTable( 245 245 CodeLocation const & location, 246 246 std::string const & exceptionName, … … 453 453 std::string const & tableName = decl->name; 454 454 455 ast::ObjectDecl * retDecl;455 ast::ObjectDecl * retDecl; 456 456 if ( decl->storage.is_extern ) { 457 457 // Unique type-ids are only needed for polymorphic instances. … … 475 475 } 476 476 477 for ( ast::ptr<ast::Attribute> const & attr : decl->attributes ) {478 retDecl->attributes.push_back( attr );479 }480 481 return retDecl;477 for ( ast::ptr<ast::Attribute> const & attr : decl->attributes ) { 478 retDecl->attributes.push_back( attr ); 479 } 480 481 return retDecl; 482 482 } 483 483 … … 485 485 ast::StructInstType const * postvisit( ast::VTableType const * type ) { 486 486 auto inst = type->base.as<ast::BaseInstType>(); 487 487 488 488 std::string vtableName = Virtual::vtableTypeName( inst->name ); 489 489 -
src/Parser/StatementNode.cc
r8d96dee r89bef959 10 10 // Author : Rodolfo G. Esteves 11 11 // Created On : Sat May 16 14:59:41 2015 12 // Last Modified By : Peter A. Buhr13 // Last Modified On : Fri Aug 11 11:44:15202314 // Update Count : 42 912 // Last Modified By : Andrew Beach 13 // Last Modified On : Tue Apr 11 10:16:00 2023 14 // Update Count : 428 15 15 // 16 16 … … 374 374 } 375 375 376 ast::WaitUntilStmt::ClauseNode * build_waituntil_timeout( const CodeLocation & loc, ExpressionNode * when, ExpressionNode * timeout, StatementNode * stmt ) { 377 ast::WhenClause * clause = new ast::WhenClause( loc ); 378 clause->when_cond = notZeroExpr( maybeMoveBuild( when ) ); 379 clause->stmt = maybeMoveBuild( stmt ); 380 clause->target = maybeMoveBuild( timeout ); 381 return new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::TIMEOUT, clause ); 382 } 383 376 384 ast::WaitUntilStmt * build_waituntil_stmt( const CodeLocation & loc, ast::WaitUntilStmt::ClauseNode * root ) { 377 385 ast::WaitUntilStmt * retStmt = new ast::WaitUntilStmt( loc ); -
src/Parser/StatementNode.h
r8d96dee r89bef959 9 9 // Author : Andrew Beach 10 10 // Created On : Wed Apr 5 11:42:00 2023 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Aug 11 11:44:07202313 // Update Count : 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Apr 11 9:43:00 2023 13 // Update Count : 1 14 14 // 15 15 … … 102 102 ast::WaitUntilStmt::ClauseNode * build_waituntil_clause( const CodeLocation &, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt ); 103 103 ast::WaitUntilStmt::ClauseNode * build_waituntil_else( const CodeLocation &, ExpressionNode * when, StatementNode * stmt ); 104 ast::WaitUntilStmt::ClauseNode * build_waituntil_timeout( const CodeLocation &, ExpressionNode * when, ExpressionNode * timeout, StatementNode * stmt ); 104 105 ast::WaitUntilStmt * build_waituntil_stmt( const CodeLocation &, ast::WaitUntilStmt::ClauseNode * root ); 105 106 ast::Stmt * build_with( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt ); -
src/Parser/parser.yy
r8d96dee r89bef959 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 18 22:51:30202313 // Update Count : 63 9112 // Last Modified On : Wed Jul 12 23:06:44 2023 13 // Update Count : 6389 14 14 // 15 15 … … 1708 1708 | wor_waituntil_clause wor when_clause_opt ELSE statement 1709 1709 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_else( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); } 1710 | wor_waituntil_clause wor when_clause_opt timeout statement %prec THEN 1711 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ) ); } 1712 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1713 | wor_waituntil_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rule 1714 { SemanticError( yylloc, "syntax error, else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1715 | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement 1716 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, 1717 new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::OR, 1718 build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ), 1719 build_waituntil_else( yylloc, $7, maybe_build_compound( yylloc, $9 ) ) ) ); } 1710 1720 ; 1711 1721 1712 1722 waituntil_statement: 1713 1723 wor_waituntil_clause %prec THEN 1714 { $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); } 1724 // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement. 1725 { 1726 $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); 1727 // $$ = new StatementNode( build_compound( yylloc, nullptr ) ); 1728 } 1715 1729 ; 1716 1730 -
tests/io/.expect/manipulatorsOutput2.arm64.txt
r8d96dee r89bef959 4 4 0 033 033 033 033 5 5 0345 0177745 037777777745 01777777777777777777745 6 0 x00x1b 0x1b 0x1b 0x1b6 0 0x1b 0x1b 0x1b 0x1b 7 7 0xe5 0xffe5 0xffffffe5 0xffffffffffffffe5 8 0x0p+0 0x1.b8p+4 0x1.b8p+4 0x1.b8p+48 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0x1.b8p+4 9 9 -0x1.b8p+4 -0x1.b8p+4 -0x1.b8p+4 10 10 0.000000e+00 2.750000e+01 -2.750000e+01 -
tests/io/.expect/manipulatorsOutput2.x86.txt
r8d96dee r89bef959 4 4 0 033 033 033 033 5 5 0345 0177745 037777777745 037777777745 6 0 x00x1b 0x1b 0x1b 0x1b6 0 0x1b 0x1b 0x1b 0x1b 7 7 0xe5 0xffe5 0xffffffe5 0xffffffe5 8 0x0p+0 0x1.b8p+4 0x1.b8p+4 0xd.cp+18 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0xd.cp+1 9 9 -0x1.b8p+4 -0x1.b8p+4 -0xd.cp+1 10 10 0.000000e+00 2.750000e+01 -2.750000e+01 -
tests/io/.expect/manipulatorsOutput3.arm64.txt
r8d96dee r89bef959 246 246 -1 0xffffffffffffffffffffffffffffffff 03777777777777777777777777777777777777777777 247 247 0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 248 +0 0 x00248 +0 0 0 249 249 0b0 250 250 +1 0x1 01
Note:
See TracChangeset
for help on using the changeset viewer.