Changes in / [25cdca5:84b4d607]
- Files:
-
- 21 deleted
- 25 edited
-
doc/theses/lynn_tran_SE499/Bibliography.bib (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/CFA.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/Conclusion.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/Demangler.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/Extensions.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/GDB.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/Introduction.tex (deleted)
-
doc/theses/lynn_tran_SE499/Chapters/uCPP.tex (deleted)
-
doc/theses/lynn_tran_SE499/LICENSE (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master.zip (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/.gdbinit (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/README.md (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/test.cc (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/utils-gdb.gdb (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/utils-gdb.py (deleted)
-
doc/theses/lynn_tran_SE499/SE499-master/utils.cpp (deleted)
-
doc/theses/lynn_tran_SE499/Thesis.cls (deleted)
-
doc/theses/lynn_tran_SE499/lstpatch.sty (deleted)
-
doc/theses/lynn_tran_SE499/se499-report.tex (deleted)
-
doc/theses/lynn_tran_SE499/uContext_stack.png (deleted)
-
doc/theses/lynn_tran_SE499/vector.sty (deleted)
-
libcfa/src/fstream.cfa (modified) (4 diffs)
-
libcfa/src/fstream.hfa (modified) (5 diffs)
-
libcfa/src/iostream.cfa (modified) (24 diffs)
-
libcfa/src/iostream.hfa (modified) (8 diffs)
-
libcfa/src/rational.cfa (modified) (2 diffs)
-
libcfa/src/stdlib.hfa (modified) (2 diffs)
-
libcfa/src/time.cfa (modified) (5 diffs)
-
tests/concurrent/examples/quickSort.cfa (modified) (2 diffs)
-
tests/coroutine/fmtLines.cfa (modified) (2 diffs)
-
tests/fallthrough.cfa (modified) (5 diffs)
-
tests/fstream_test.cfa (modified) (2 diffs)
-
tests/genericUnion.cfa (modified) (3 diffs)
-
tests/gmp.cfa (modified) (3 diffs)
-
tests/io1.cfa (modified) (2 diffs)
-
tests/io2.cfa (modified) (3 diffs)
-
tests/loopctrl.cfa (modified) (3 diffs)
-
tests/polymorphism.cfa (modified) (3 diffs)
-
tests/pybin/tools.py (modified) (1 diff)
-
tests/raii/dtor-early-exit.cfa (modified) (2 diffs)
-
tests/references.cfa (modified) (3 diffs)
-
tests/searchsort.cfa (modified) (7 diffs)
-
tests/sum.cfa (modified) (2 diffs)
-
tests/swap.cfa (modified) (2 diffs)
-
tests/time.cfa (modified) (4 diffs)
-
tests/withStatement.cfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 18:33:38 201813 // Update Count : 30412 // Last Modified On : Wed Dec 12 08:34:28 2018 13 // Update Count : 298 14 14 // 15 15 … … 26 26 #define IO_MSG "I/O error: " 27 27 28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool prt, const char * separator, const char * tupleSeparator ) {28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool nonlManip, const char * separator, const char * tupleSeparator ) { 29 29 os.file = file; 30 30 os.sepDefault = sepDefault; 31 31 os.sepOnOff = sepOnOff; 32 32 os.nlOnOff = nlOnOff; 33 os. prt = prt;33 os.nonlManip = nonlManip; 34 34 sepSet( os, separator ); 35 35 sepSetCur( os, sepGet( os ) ); … … 46 46 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 47 47 bool getANL( ofstream & os ) { return os.nlOnOff; } 48 bool get Prt( ofstream & os ) { return os.prt; }49 void set Prt( ofstream & os, bool state ) { os.prt= state; }48 bool getNonl( ofstream & os ) { return os.nonlManip; } 49 void setNonl( ofstream & os, bool state ) { os.nonlManip = state; } 50 50 51 51 // public … … 150 150 va_end( args ); 151 151 152 setPrt( os, true ); // called in output cascade153 152 sepReset( os ); // reset separator 154 153 return len; -
libcfa/src/fstream.hfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 18:33:41 201813 // Update Count : 14 912 // Last Modified On : Wed Dec 12 07:52:41 2018 13 // Update Count : 143 14 14 // 15 15 … … 24 24 bool sepOnOff; 25 25 bool nlOnOff; 26 bool prt; // print text26 bool nonlManip; 27 27 bool sawNL; 28 28 const char * sepCur; … … 40 40 void setNL( ofstream &, bool ); 41 41 bool getANL( ofstream & ); 42 bool get Prt( ofstream & );43 void set Prt( ofstream &, bool );42 bool getNonl( ofstream & ); 43 void setNonl( ofstream &, bool ); 44 44 45 45 // public … … 62 62 void close( ofstream & ); 63 63 ofstream & write( ofstream &, const char * data, size_t size ); 64 int fmt( ofstream &, const char f ormat[], ... );64 int fmt( ofstream &, const char fmt[], ... ); 65 65 66 66 void ?{}( ofstream & os ); … … 83 83 ifstream & read( ifstream & is, char * data, size_t size ); 84 84 ifstream & ungetc( ifstream & is, char c ); 85 int fmt( ifstream &, const char f ormat[], ... );85 int fmt( ifstream &, const char fmt[], ... ); 86 86 87 87 void ?{}( ifstream & is ); -
libcfa/src/iostream.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 18:33:40201813 // Update Count : 5 8912 // Last Modified On : Thu Dec 13 14:13:22 2018 13 // Update Count : 548 14 14 // 15 15 … … 33 33 } // ?|? 34 34 void ?|?( ostype & os, bool b ) { 35 (ostype &)(os | b);nl( os );35 (ostype)(os | b); if ( getANL( os ) ) nl( os ); 36 36 } // ?|? 37 37 … … 42 42 } // ?|? 43 43 void ?|?( ostype & os, char c ) { 44 (ostype &)(os | c);nl( os );44 (ostype)(os | c); if ( getANL( os ) ) nl( os ); 45 45 } // ?|? 46 46 … … 51 51 } // ?|? 52 52 void ?|?( ostype & os, signed char sc ) { 53 (ostype &)(os | sc);nl( os );53 (ostype)(os | sc); if ( getANL( os ) ) nl( os ); 54 54 } // ?|? 55 55 … … 60 60 } // ?|? 61 61 void ?|?( ostype & os, unsigned char usc ) { 62 (ostype &)(os | usc);nl( os );62 (ostype)(os | usc); if ( getANL( os ) ) nl( os ); 63 63 } // ?|? 64 64 … … 69 69 } // ?|? 70 70 void & ?|?( ostype & os, short int si ) { 71 (ostype &)(os | si);nl( os );71 (ostype)(os | si); if ( getANL( os ) ) nl( os ); 72 72 } // ?|? 73 73 … … 78 78 } // ?|? 79 79 void & ?|?( ostype & os, unsigned short int usi ) { 80 (ostype &)(os | usi);nl( os );80 (ostype)(os | usi); if ( getANL( os ) ) nl( os ); 81 81 } // ?|? 82 82 … … 87 87 } // ?|? 88 88 void & ?|?( ostype & os, int i ) { 89 (ostype &)(os | i);nl( os );89 (ostype)(os | i); if ( getANL( os ) ) nl( os ); 90 90 } // ?|? 91 91 … … 96 96 } // ?|? 97 97 void & ?|?( ostype & os, unsigned int ui ) { 98 (ostype &)(os | ui);nl( os );98 (ostype)(os | ui); if ( getANL( os ) ) nl( os ); 99 99 } // ?|? 100 100 … … 105 105 } // ?|? 106 106 void & ?|?( ostype & os, long int li ) { 107 (ostype &)(os | li);nl( os );107 (ostype)(os | li); if ( getANL( os ) ) nl( os ); 108 108 } // ?|? 109 109 … … 114 114 } // ?|? 115 115 void & ?|?( ostype & os, unsigned long int uli ) { 116 (ostype &)(os | uli);nl( os );116 (ostype)(os | uli); if ( getANL( os ) ) nl( os ); 117 117 } // ?|? 118 118 … … 123 123 } // ?|? 124 124 void & ?|?( ostype & os, long long int lli ) { 125 (ostype &)(os | lli);nl( os );125 (ostype)(os | lli); if ( getANL( os ) ) nl( os ); 126 126 } // ?|? 127 127 … … 132 132 } // ?|? 133 133 void & ?|?( ostype & os, unsigned long long int ulli ) { 134 (ostype &)(os | ulli);nl( os );134 (ostype)(os | ulli); if ( getANL( os ) ) nl( os ); 135 135 } // ?|? 136 136 … … 141 141 } // ?|? 142 142 void & ?|?( ostype & os, float f ) { 143 (ostype &)(os | f);nl( os );143 (ostype)(os | f); if ( getANL( os ) ) nl( os ); 144 144 } // ?|? 145 145 … … 150 150 } // ?|? 151 151 void & ?|?( ostype & os, double d ) { 152 (ostype &)(os | d);nl( os );152 (ostype)(os | d); if ( getANL( os ) ) nl( os ); 153 153 } // ?|? 154 154 … … 159 159 } // ?|? 160 160 void & ?|?( ostype & os, long double ld ) { 161 (ostype &)(os | ld);nl( os );161 (ostype)(os | ld); if ( getANL( os ) ) nl( os ); 162 162 } // ?|? 163 163 … … 168 168 } // ?|? 169 169 void & ?|?( ostype & os, float _Complex fc ) { 170 (ostype &)(os | fc);nl( os );170 (ostype)(os | fc); if ( getANL( os ) ) nl( os ); 171 171 } // ?|? 172 172 … … 177 177 } // ?|? 178 178 void & ?|?( ostype & os, double _Complex dc ) { 179 (ostype &)(os | dc);nl( os );179 (ostype)(os | dc); if ( getANL( os ) ) nl( os ); 180 180 } // ?|? 181 181 … … 186 186 } // ?|? 187 187 void & ?|?( ostype & os, long double _Complex ldc ) { 188 (ostype &)(os | ldc);nl( os );188 (ostype)(os | ldc); if ( getANL( os ) ) nl( os ); 189 189 } // ?|? 190 190 … … 228 228 } // ?|? 229 229 void ?|?( ostype & os, const char * str ) { 230 (ostype &)(os | str);nl( os );230 (ostype)(os | str); if ( getANL( os ) ) nl( os ); 231 231 } // ?|? 232 232 … … 257 257 } // ?|? 258 258 void ?|?( ostype & os, const void * p ) { 259 (ostype &)(os | p);nl( os );259 (ostype)(os | p); if ( getANL( os ) ) nl( os ); 260 260 } // ?|? 261 261 262 262 // manipulators 263 263 ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 264 (ostype &)(manip( os )); 264 (ostype)(manip( os )); 265 setNonl( os, false ); // ignore nonl in middle 265 266 return os; 266 267 } // ?|? 267 268 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 268 (ostype &)(manip( os ));269 if ( get Prt( os ) ) nl( os ); // something printed ?270 set Prt( os, false ); // turn off269 (ostype)(manip( os )); 270 if ( getANL( os ) && ! getNonl( os ) ) nl( os ); // ignore nl if nonl at end 271 setNonl( os, false ); 271 272 } // ?|? 272 273 273 274 ostype & sep( ostype & os ) { 274 return (ostype &)(os | sepGet( os ));275 return (ostype)(os | sepGet( os )); 275 276 } // sep 276 277 … … 280 281 281 282 ostype & nl( ostype & os ) { 282 (ostype &)(os | '\n'); 283 setPrt( os, false ); // turn off 283 (ostype)(os | '\n'); 284 284 setNL( os, true ); 285 285 flush( os ); … … 287 287 } // nl 288 288 289 void nl( ostype & os ) {290 if ( getANL( os ) ) (ostype &)(nl( os )); // implementation only291 else setPrt( os, false ); // turn off292 } // nl293 294 289 ostype & nonl( ostype & os ) { 295 set Prt( os, false ); // turn off290 setNonl( os, true ); // indicate nonl manipulator 296 291 return os; 297 292 } // nonl … … 331 326 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 332 327 ostype & ?|?( ostype & os, T arg, Params rest ) { 333 (ostype &)(os | arg);// print first argument328 (ostype)(os | arg); // print first argument 334 329 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 335 (ostype &)(os | rest); // print remaining arguments330 (ostype)(os | rest); // print remaining arguments 336 331 sepSetCur( os, sepGet( os ) ); // switch to regular separator 337 332 return os; 338 333 } // ?|? 339 334 void ?|?( ostype & os, T arg, Params rest ) { 340 // (ostype &)(?|?( os, arg, rest ));nl( os );341 (ostype &)(os | arg);// print first argument335 // (ostype)(?|?( os, arg, rest )); if ( getANL( os ) ) nl( os ); 336 (ostype)(os | arg); // print first argument 342 337 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 343 (ostype &)(os | rest); // print remaining arguments338 (ostype)(os | rest); // print remaining arguments 344 339 sepSetCur( os, sepGet( os ) ); // switch to regular separator 345 nl( os );340 if ( getANL( os ) ) nl( os ); 346 341 } // ?|? 347 342 } // distribution -
libcfa/src/iostream.hfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 18:33:40201813 // Update Count : 2 2012 // Last Modified On : Tue Dec 11 22:01:31 2018 13 // Update Count : 213 14 14 // 15 15 … … 20 20 trait ostream( dtype ostype ) { 21 21 // private 22 bool sepPrt( ostype & ); // getseparator state (on/off)22 bool sepPrt( ostype & ); // return separator state (on/off) 23 23 void sepReset( ostype & ); // set separator state to default state 24 24 void sepReset( ostype &, bool ); // set separator and default state … … 27 27 bool getNL( ostype & ); // check newline 28 28 void setNL( ostype &, bool ); // saw newline 29 bool getANL( ostype & ); // get auto newline (on/off)30 bool get Prt( ostype & ); // get fmt called in output cascade31 void set Prt( ostype &, bool ); // set fmt called in output cascade29 bool getANL( ostype & ); // check auto newline 30 bool getNonl( ostype & ); // check nonnl manipulator 31 void setNonl( ostype &, bool ); // set nonnl manipulator 32 32 // public 33 33 void sepOn( ostype & ); // turn separator state on … … 48 48 void close( ostype & os ); 49 49 ostype & write( ostype &, const char *, size_t ); 50 int fmt( ostype &, const char f ormat[], ... );50 int fmt( ostype &, const char fmt[], ... ); 51 51 }; // ostream 52 52 … … 63 63 forall( dtype ostype | ostream( ostype ) ) { 64 64 ostype & ?|?( ostype &, bool ); 65 void ?|?( ostype &, bool );65 void & ?|?( ostype &, bool ); 66 66 67 67 ostype & ?|?( ostype &, char ); 68 void ?|?( ostype &, char );68 void & ?|?( ostype &, char ); 69 69 ostype & ?|?( ostype &, signed char ); 70 void ?|?( ostype &, signed char );70 void & ?|?( ostype &, signed char ); 71 71 ostype & ?|?( ostype &, unsigned char ); 72 void ?|?( ostype &, unsigned char );72 void & ?|?( ostype &, unsigned char ); 73 73 74 74 ostype & ?|?( ostype &, short int ); 75 void ?|?( ostype &, short int );75 void & ?|?( ostype &, short int ); 76 76 ostype & ?|?( ostype &, unsigned short int ); 77 void ?|?( ostype &, unsigned short int );77 void & ?|?( ostype &, unsigned short int ); 78 78 ostype & ?|?( ostype &, int ); 79 void ?|?( ostype &, int );79 void & ?|?( ostype &, int ); 80 80 ostype & ?|?( ostype &, unsigned int ); 81 void ?|?( ostype &, unsigned int );81 void & ?|?( ostype &, unsigned int ); 82 82 ostype & ?|?( ostype &, long int ); 83 void ?|?( ostype &, long int );83 void & ?|?( ostype &, long int ); 84 84 ostype & ?|?( ostype &, long long int ); 85 void ?|?( ostype &, long long int );85 void & ?|?( ostype &, long long int ); 86 86 ostype & ?|?( ostype &, unsigned long int ); 87 void ?|?( ostype &, unsigned long int );87 void & ?|?( ostype &, unsigned long int ); 88 88 ostype & ?|?( ostype &, unsigned long long int ); 89 void ?|?( ostype &, unsigned long long int );89 void & ?|?( ostype &, unsigned long long int ); 90 90 91 91 ostype & ?|?( ostype &, float ); // FIX ME: should not be required 92 void ?|?( ostype &, float ); // FIX ME: should not be required92 void & ?|?( ostype &, float ); // FIX ME: should not be required 93 93 ostype & ?|?( ostype &, double ); 94 void ?|?( ostype &, double );94 void & ?|?( ostype &, double ); 95 95 ostype & ?|?( ostype &, long double ); 96 void ?|?( ostype &, long double );96 void & ?|?( ostype &, long double ); 97 97 98 98 ostype & ?|?( ostype &, float _Complex ); 99 void ?|?( ostype &, float _Complex );99 void & ?|?( ostype &, float _Complex ); 100 100 ostype & ?|?( ostype &, double _Complex ); 101 void ?|?( ostype &, double _Complex );101 void & ?|?( ostype &, double _Complex ); 102 102 ostype & ?|?( ostype &, long double _Complex ); 103 void ?|?( ostype &, long double _Complex );103 void & ?|?( ostype &, long double _Complex ); 104 104 105 105 ostype & ?|?( ostype &, const char * ); 106 void ?|?( ostype &, const char * );106 void & ?|?( ostype &, const char * ); 107 107 // ostype & ?|?( ostype &, const char16_t * ); 108 108 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 111 111 // ostype & ?|?( ostype &, const wchar_t * ); 112 112 ostype & ?|?( ostype &, const void * ); 113 void ?|?( ostype &, const void * );113 void & ?|?( ostype &, const void * ); 114 114 115 115 // manipulators … … 117 117 void ?|?( ostype &, ostype & (*)( ostype & ) ); 118 118 ostype & nl( ostype & ); 119 void nl( ostype & );120 119 ostype & nonl( ostype & ); 121 120 ostype & sep( ostype & ); … … 150 149 istype & read( istype &, char *, size_t ); 151 150 istype & ungetc( istype &, char ); 152 int fmt( istype &, const char f ormat[], ... );151 int fmt( istype &, const char fmt[], ... ); 153 152 }; // istream 154 153 -
libcfa/src/rational.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 23 22:56:49 201813 // Update Count : 1 7012 // Last Modified On : Tue Dec 11 22:02:29 2018 13 // Update Count : 168 14 14 // 15 15 … … 181 181 182 182 void ?|?( ostype & os, Rational(RationalImpl) r ) { 183 (ostype &)(os | r);nl( os );183 (ostype)(os | r); if ( getANL( os ) ) nl( os ); 184 184 } // ?|? 185 185 } // distribution -
libcfa/src/stdlib.hfa
r25cdca5 r84b4d607 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 17 15:37:45201813 // Update Count : 34 612 // Last Modified On : Fri Jul 27 07:21:36 2018 13 // Update Count : 345 14 14 // 15 15 … … 178 178 179 179 static inline { 180 int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }180 int ato( const char * sptr ) {return (int)strtol( sptr, 0, 10 ); } 181 181 unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); } 182 182 long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); } -
libcfa/src/time.cfa
r25cdca5 r84b4d607 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 23 22:57:48201813 // Update Count : 5 712 // Last Modified On : Tue Dec 11 21:32:15 2018 13 // Update Count : 53 14 14 // 15 15 … … 33 33 forall( dtype ostype | ostream( ostype ) ) { 34 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 (ostype &)(os | tv / TIMEGRAN); // print seconds35 (ostype)(os | tv / TIMEGRAN); // print seconds 36 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 37 if ( ns != 0 ) { // some ? 38 38 char buf[16]; 39 (ostype &)(os | nanomsd( ns, buf )); // print nanoseconds39 (ostype)(os | nanomsd( ns, buf )); // print nanoseconds 40 40 } // if 41 41 return os; … … 43 43 44 44 void ?|?( ostype & os, Duration dur ) with( dur ) { 45 (ostype &)(os | dur);nl( os );45 (ostype)(os | dur); if ( getANL( os ) ) nl( os ); 46 46 } // ?|? 47 47 } // distribution … … 150 150 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 151 151 if ( ns == 0 ) { // none ? 152 (ostype &)(os | buf); // print date/time/year152 (ostype)(os | buf); // print date/time/year 153 153 } else { 154 154 buf[19] = '\0'; // truncate to "Wed Jun 30 21:49:08" 155 155 char buf2[16]; 156 156 nanomsd( ns, buf2 ); // compute nanoseconds 157 (ostype &)(os | buf | buf2 | ' ' | &buf[20]); // print date/time, nanoseconds and year157 (ostype)(os | buf | buf2 | ' ' | &buf[20]); // print date/time, nanoseconds and year 158 158 } // if 159 159 return os; … … 161 161 162 162 void ?|?( ostype & os, Time time ) with( time ) { 163 (ostype &)(os | time);nl( os );163 (ostype)(os | time); if ( getANL( os ) ) nl( os ); 164 164 } // ?|? 165 165 } // distribution -
tests/concurrent/examples/quickSort.cfa
r25cdca5 r84b4d607 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Sat Dec 22 08:44:27 201812 // Update Count : 16 811 // Last Modified On : Tue Dec 4 18:00:27 2018 12 // Update Count : 167 13 13 // 14 14 … … 151 151 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 152 152 } // for 153 sortedfile | nl | nl;153 sortedfile | nl; 154 154 155 155 delete( values ); -
tests/coroutine/fmtLines.cfa
r25cdca5 r84b4d607 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 22 18:27:00201813 // Update Count : 5712 // Last Modified On : Wed Dec 12 22:45:36 2018 13 // Update Count : 48 14 14 // 15 15 … … 24 24 void main( Format & fmt ) with( fmt ) { 25 25 for () { // for as many characters 26 for ( g = 0; g < 5; g += 1 ) {// groups of 5 blocks27 for ( b = 0; b < 4; b += 1 ) {// blocks of 4 characters26 for ( g; 5 ) { // groups of 5 blocks 27 for ( b; 4 ) { // blocks of 4 characters 28 28 for () { // for newline characters 29 29 suspend(); 30 if ( ch != '\n' ) break;// ignore newline30 if ( ch != '\n' ) break; // ignore newline 31 31 } // for 32 32 sout | ch; // print character -
tests/fallthrough.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Mar 14 10:06:25 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 11:24:35201813 // Update Count : 2212 // Last Modified On : Tue Dec 4 21:36:14 2018 13 // Update Count : 17 14 14 // 15 15 … … 18 18 void test(int choice) { 19 19 choose ( choice ) { 20 case 1:21 sout | "case 1";22 fallthru;23 case 2:24 sout | "case 2";25 fallthru;26 sout | "did not fallthru";27 if ( 7 ) fallthru common2;28 fallthru common1;29 case 3:30 sout | "case 3";31 fallthru default;32 fallthru common1;33 common1:34 sout | "common1";20 case 1: 21 sout | "case 1"; 22 fallthru; 23 case 2: 24 sout | "case 2"; 25 fallthru; 26 sout | "did not fallthru"; 27 if ( 7 ) fallthru common2; 28 fallthru common1; 29 case 3: 30 sout | "case 3"; 31 fallthru default; 32 fallthru common1; 33 common1: 34 sout | "common1"; 35 35 // break 36 case 4:37 sout | "case 4";38 fallthru common2;39 case 5:40 sout | "case 5";41 fallthru common2;42 fallthru default;43 case 6:44 sout | "case 6";45 fallthru common2;46 common2:47 sout | "common2";36 case 4: 37 sout | "case 4"; 38 fallthru common2; 39 case 5: 40 sout | "case 5"; 41 fallthru common2; 42 fallthru default; 43 case 6: 44 sout | "case 6"; 45 fallthru common2; 46 common2: 47 sout | "common2"; 48 48 // break 49 default:50 sout | "default";51 fallthru;52 } // choose49 default: 50 sout | "default"; 51 fallthru; 52 } 53 53 54 54 sout | nl; … … 61 61 sout | "case 1"; 62 62 for ( int i = 0; i < 4; i += 1 ) { 63 sout | i;63 printf("%d\n", i); 64 64 if ( i == 2 ) fallthru common; 65 65 } // for … … 77 77 } // if 78 78 common: 79 sout | "common";79 printf( "common\n" ); 80 80 fallthru; 81 81 break; 82 82 default: 83 sout | "default";83 printf( "default\n" ); 84 84 fallthru; 85 85 } // switch … … 93 93 fallthru default; 94 94 choose ( 3 ) { 95 case 2: 96 for () { 97 choose ( 2 ) { 98 case 1: 99 // ERROR: default is later, but in a different switch 100 fallthru default; 101 // ERROR: common3 is later, but not at the same level as a case clause 102 fallthru common3; 95 case 2: 96 for () { 97 choose ( 2 ) { 98 case 1: 99 // ERROR: default is later, but in a different switch 100 fallthru default; 101 // ERROR: common3 is later, but not at the same level as a case clause 102 fallthru common3; 103 } 104 common3: ; 103 105 } 104 common3: ; 105 } // for 106 default: 107 case 1: 108 common4: 109 // ERROR: attempt to jump up with fallthrough 110 if ( 7 ) fallthru common4; 111 // ERROR: attempt to jump up with fallthrough 112 fallthru default; 113 } // choose 106 default: 107 case 1: 108 common4: 109 // ERROR: attempt to jump up with fallthrough 110 if ( 7 ) fallthru common4; 111 // ERROR: attempt to jump up with fallthrough 112 fallthru default; 113 } 114 114 #endif 115 115 } -
tests/fstream_test.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 22 09:47:44 201813 // Update Count : 6 812 // Last Modified On : Tue Dec 4 21:36:34 2018 13 // Update Count : 67 14 14 // 15 15 … … 24 24 | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif"); 25 25 26 sout | "Entrez trois nombres, s'il vous plaît: ";26 sout | "Entrez trois nombres, s'il vous plaît: "; 27 27 int i, j, k; 28 28 sin | i | j | k; -
tests/genericUnion.cfa
r25cdca5 r84b4d607 1 //2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // genericUnion.cfa --8 //9 // Author : Peter A. Buhr10 // Created On : Tue Dec 25 14:42:46 201811 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Dec 25 14:46:33 201813 // Update Count : 214 //15 16 1 #include <limits.hfa> 17 2 … … 19 4 union ByteView { 20 5 T val; 21 char bytes[(sizeof(int))]; // want to change to sizeof(T)6 char bytes[(sizeof(int))]; // want to change to sizeof(T) 22 7 }; 23 8 24 9 forall(otype T) 25 10 void print(ByteView(T) x) { 26 for (int i = 0; i < sizeof(int); i++) { // want to change to sizeof(T)11 for (int i = 0; i < sizeof(int); i++) { // want to change to sizeof(T) 27 12 printf("%02x", x.bytes[i] & 0xff); 28 13 } … … 44 29 f(i, -1); 45 30 } 46 47 // Local Variables: //48 // tab-width: 4 //49 // compile-command: "cfa genericUnion.cfa" //50 // End: // -
tests/gmp.cfa
r25cdca5 r84b4d607 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 20 22:41:47201813 // Update Count : 55 912 // Last Modified On : Tue Dec 4 21:37:29 2018 13 // Update Count : 558 14 14 // 15 15 … … 76 76 sout | "x:" | x | "y:" | y; 77 77 78 sout | nl;78 sout; 79 79 80 80 sin | x | y | z; 81 81 sout | x | y | z; 82 82 83 sout | nl;83 sout; 84 84 85 85 sout | "Fibonacci Numbers"; … … 94 94 } // for 95 95 96 sout | nl;96 sout; 97 97 98 98 sout | "Factorial Numbers"; -
tests/io1.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 21 16:02:55201813 // Update Count : 11 412 // Last Modified On : Wed Dec 12 18:23:44 2018 13 // Update Count : 110 14 14 // 15 15 … … 22 22 sout | '1' | '2' | '3'; 23 23 sout | 1 | "" | 2 | "" | 3; 24 sout | nl;24 sout; 25 25 26 sout | nlOff; 27 sout | "opening delimiters" | nl; 28 sout | "x (" | 1; 29 sout | "x [" | 2; 30 sout | "x {" | 3; 31 sout | "x =" | 4; 32 sout | "x $" | 5; 33 sout | "x £" | 6; 34 sout | "x ¥" | 7; 35 sout | "x ¡" | 8; 36 sout | "x ¿" | 9; 26 sout | "opening delimiters"; 27 sout | "x (" | 1 | nonl; 28 sout | "x [" | 2 | nonl; 29 sout | "x {" | 3 | nonl; 30 sout | "x =" | 4 | nonl; 31 sout | "x $" | 5 | nonl; 32 sout | "x £" | 6 | nonl; 33 sout | "x ¥" | 7 | nonl; 34 sout | "x ¡" | 8 | nonl; 35 sout | "x ¿" | 9 | nonl; 37 36 sout | "x «" | 10; 38 sout | nl | nl;39 37 40 sout | "closing delimiters" | nl;41 sout | 1 | ", x" ;42 sout | 2 | ". x" ;43 sout | 3 | "; x" ;44 sout | 4 | "! x" ;45 sout | 5 | "? x" ;46 sout | 6 | "% x" ;47 sout | 7 | "¢ x" ;48 sout | 8 | "» x" ;49 sout | 9 | ") x" ;50 sout | 10 | "] x" ;38 sout | "closing delimiters"; 39 sout | 1 | ", x" | nonl; 40 sout | 2 | ". x" | nonl; 41 sout | 3 | "; x" | nonl; 42 sout | 4 | "! x" | nonl; 43 sout | 5 | "? x" | nonl; 44 sout | 6 | "% x" | nonl; 45 sout | 7 | "¢ x" | nonl; 46 sout | 8 | "» x" | nonl; 47 sout | 9 | ") x" | nonl; 48 sout | 10 | "] x" | nonl; 51 49 sout | 11 | "} x"; 52 sout | nl | nl;53 50 54 sout | "opening/closing delimiters" | nl;55 sout | "x`" | 1 | "`x'" | 2 ;56 sout | "'x\"" | 3 | "\"x:" | 4 ;57 sout | ":x " | 5 | " x\t" | 6 ;58 sout | "\tx\f" | 7 | "\fx\v" | 8 ;59 sout | "\vx\n" | 9 | "\nx\r" | 10 ;51 sout | "opening/closing delimiters"; 52 sout | "x`" | 1 | "`x'" | 2 | nonl; 53 sout | "'x\"" | 3 | "\"x:" | 4 | nonl; 54 sout | ":x " | 5 | " x\t" | 6 | nonl; 55 sout | "\tx\f" | 7 | "\fx\v" | 8 | nonl; 56 sout | "\vx\n" | 9 | "\nx\r" | 10 | nonl; 60 57 sout | "\rx"; 61 sout | nl | nl;62 58 63 sout | nlOn;64 59 sout | "override opening/closing delimiters"; 65 60 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4; 66 sout | nl;61 sout; 67 62 } 68 63 -
tests/io2.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 21 08:20:14201813 // Update Count : 11 212 // Last Modified On : Wed Dec 12 16:19:15 2018 13 // Update Count : 110 14 14 // 15 15 … … 96 96 sout | sepOn | 1 | 2 | 3 | sepOn; // no separator at start/end of line 97 97 sout | 1 | sepOff | 2 | 3; // locally turn off implicit separator 98 sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n' | nonl; // no separator at start/end of line99 sout | 1 | 2 | 3 | "\n\n" | sepOn | nonl; // no separator at start of next line98 sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line 99 sout | 1 | 2 | 3 | "\n\n" | sepOn; // no separator at start of next line 100 100 sout | 1 | 2 | 3; 101 101 sout | nl; … … 133 133 // Local Variables: // 134 134 // tab-width: 4 // 135 // compile-command: "cfa -DIN_DIR=".in/"io2.cfa" //135 // compile-command: "cfa io2.cfa" // 136 136 // End: // -
tests/loopctrl.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 23 23:00:29201813 // Update Count : 7 912 // Last Modified On : Wed Dec 12 08:14:44 2018 13 // Update Count : 76 14 14 // 15 15 … … 32 32 S ?-=?( S & t, one_t ) { t.i -= 1; t.j -= 1; return t; } 33 33 ofstream & ?|?( ofstream & os, S v ) { return os | '(' | v.i | v.j | ')'; } 34 void & ?|?( ofstream & os, S v ) { (ofstream &)(os | v);nl( os ); }34 void & ?|?( ofstream & os, S v ) { (ofstream)(os | v); if ( getANL( os ) ) nl( os ); } 35 35 36 36 int main() { … … 38 38 while () { sout | "empty"; break; } sout | nl; 39 39 do { sout | "empty"; break; } while (); sout | nl; 40 for () { sout | "empty"; break; } sout | nl | nl;40 for () { sout | "empty"; break; } sout | nl; 41 41 42 42 for ( 0 ) { sout | "A"; } sout | "zero" | nl; -
tests/polymorphism.cfa
r25cdca5 r84b4d607 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Oct 17 12:19:48 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Dec 25 14:40:24 201813 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Oct 17 12:21:07 2017 13 // Update Count : 1 14 14 // 15 15 16 16 #include <assert.h> 17 17 #include <inttypes.h> 18 #include <fstream.hfa>19 18 20 19 forall(otype T) … … 62 61 int y = 456; 63 62 int z = f(x, y); 64 sout | x | y | z;63 printf("%d %d %d\n", x, y, z); 65 64 } 65 66 66 { 67 67 // explicitly specialize function 68 68 int (*f)(int) = ident; 69 69 ((int(*)(int))ident); 70 sout | f(5) | ((int(*)(int))ident)(5);70 printf("%d %d\n", f(5), ((int(*)(int))ident)(5)); 71 71 } 72 72 73 { 73 74 // test aggregates with polymorphic members … … 99 100 100 101 void print(x_type x) { 101 sout | x;102 printf("%"PRIu32"\n", x); 102 103 } 103 104 104 105 void print(y_type y) { 105 sout | y;106 printf("%"PRIu64"\n", y); 106 107 } 107 108 -
tests/pybin/tools.py
r25cdca5 r84b4d607 79 79 def diff( lhs, rhs ): 80 80 # diff the output of the files 81 diff_cmd = ("diff --text " 82 # "--ignore-all-space " 83 # "--ignore-blank-lines " 81 diff_cmd = ("diff --ignore-all-space --text " 82 "--ignore-blank-lines " 84 83 "--old-group-format='\t\tmissing lines :\n" 85 84 "%%<' \\\n" -
tests/raii/dtor-early-exit.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed Aug 17 08:26:25 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 21 08:45:19201813 // Update Count : 1012 // Last Modified On : Tue Dec 11 22:05:24 2018 13 // Update Count : 9 14 14 // 15 15 … … 71 71 } 72 72 } 73 sout | nl;73 sout; 74 74 for (int i = 0; i < 10; i++) { 75 75 switch(10) { -
tests/references.cfa
r25cdca5 r84b4d607 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Aug 23 16:11:50 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Dec 25 14:31:48 201813 // Update Count : 1111 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 23 16:12:03 13 // Update Count : 2 14 14 // 15 15 16 #include <fstream.hfa>17 18 16 struct Y { int i; }; 19 void ?{}( Y & y ) { sout | "Default constructing a Y"; }20 void ?{}( Y & y, Y other ) { sout | "Copy constructing a Y"; }21 void ^?{}( Y & y ) { sout | "Destructing a Y"; }22 Y ?=?( Y & y, Y other ) { sout | "Assigning a Y"; return y; }23 void ?{}( Y & y, int i ) { sout | "Value constructing a Y" | i; y.i = i; }17 void ?{}(Y & y) { printf("Default constructing a Y\n"); } 18 void ?{}(Y & y, Y other) { printf("Copy constructing a Y\n"); } 19 void ^?{}(Y & y) { printf("Destructing a Y\n"); } 20 Y ?=?(Y & y, Y other) { printf("Assigning a Y\n"); return y; } 21 void ?{}(Y & y, int i) { printf("Value constructing a Y %d\n", i); y.i = i; } 24 22 25 23 struct X { Y & r; Y y; }; 26 void ?{}( X & x) {24 void ?{}(X & x) { 27 25 // ensure that r is not implicitly constructed 28 26 } 29 void ?{}( X & x, X other) {27 void ?{}(X & x, X other) { 30 28 // ensure that r is not implicitly constructed 31 29 } 32 void ^?{}( X & x) {30 void ^?{}(X & x) { 33 31 // ensure that r is not implicitly destructed 34 32 } 35 X ?=?( X & x, X other) { return x; }33 X ?=?(X & x, X other) { return x; } 36 34 37 35 // ensure that generated functions do not implicitly operate on references … … 50 48 int x = 123456, x2 = 789, *p1 = &x, **p2 = &p1, ***p3 = &p2, 51 49 &r1 = x, &&r2 = r1, &&&r3 = r2; 52 ***p3 = 3; // change x53 **p3 = &x; // change p154 *p3 = &p1; // change p255 int y = 0, z = 11, & ar[3] = { x, y, z }; // initialize array of references56 // &ar[1] = &z; // change reference array element57 // typeof( ar[1] ) p = 3; // is int, i.e., the type of referenced object58 // typeof( &ar[1] ) q = &x; // is int *, i.e., the type of pointer50 ***p3 = 3; // change x 51 **p3 = &x; // change p1 52 *p3 = &p1; // change p2 53 int y = 0, z = 11, & ar[3] = { x, y, z }; // initialize array of references 54 // &ar[1] = &z; // change reference array element 55 // typeof( ar[1] ) p = 3; // is int, i.e., the type of referenced object 56 // typeof( &ar[1] ) q = &x; // is int *, i.e., the type of pointer 59 57 // _Static_assert( sizeof( ar[1] ) == sizeof( int ), "Array type should be int." ); // is true, i.e., the size of referenced object 60 58 // _Static_assert( sizeof( &ar[1] ) == sizeof( int *), "Address of array should be int *." ); // is true, i.e., the size of a reference 61 59 62 ((int*&)&r3) = &x; // change r1, (&*)**r360 ((int*&)&r3) = &x; // change r1, (&*)**r3 63 61 x = 3; 64 62 // test that basic reference properties are true - r1 should be an alias for x 65 sout | x | r1 | &x == &r1;63 printf("%d %d %d\n", x, r1, &x == &r1); 66 64 r1 = 12; 67 sout | x | r1 | &x == &r1;65 printf("%d %d %d\n", x, r1, &x == &r1); 68 66 69 67 // test that functions using basic references work 70 sout | toref( &x ) | toref( p1 ) | toptr( r1 ) == toptr( x ) | toptr( r1 ) == &x;68 printf("%d %d %d %d\n", toref(&x), toref(p1), toptr(r1) == toptr(x), toptr(r1) == &x); 71 69 72 70 changeRef( x ); 73 71 changeRef( y ); 74 72 changeRef( z ); 75 sout | x | y | z;73 printf("%d %d %d\n", x, y, z); 76 74 changeRef( r1 ); 77 sout | r1 | x;75 printf("%d %d\n", r1, x); 78 76 79 r3 = 6; // change x, ***r380 sout | "x = " | x | " ; x2 = " | x2;// check that x was changed81 &r3 = &x2; // change r1 to refer to x2, (&*)**r382 r3 = 999; // modify x283 sout | "x = " | x | " ; x2 = " | x2;// check that x2 was changed84 ((int**&)&&r3) = p2; // change r2, (&(&*)*)*r3, ensure explicit cast to reference works85 r3 = 12345; // modify x86 sout | "x = " | x | " ; x2 = " | x2;// check that x was changed87 &&&r3 = p3; // change r3 to p3, (&(&(&*)*)*)r388 ((int&)r3) = 22222; // modify x, ensure explicit cast to reference works89 sout | "x = " | x | " ; x2 = " | x2;// check that x was changed77 r3 = 6; // change x, ***r3 78 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed 79 &r3 = &x2; // change r1 to refer to x2, (&*)**r3 80 r3 = 999; // modify x2 81 printf("x = %d ; x2 = %d\n", x, x2); // check that x2 was changed 82 ((int**&)&&r3) = p2; // change r2, (&(&*)*)*r3, ensure explicit cast to reference works 83 r3 = 12345; // modify x 84 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed 85 &&&r3 = p3; // change r3 to p3, (&(&(&*)*)*)r3 86 ((int&)r3) = 22222; // modify x, ensure explicit cast to reference works 87 printf("x = %d ; x2 = %d\n", x, x2); // check that x was changed 90 88 91 89 // test that reference members are not implicitly constructed/destructed/assigned … … 104 102 struct S { double x, y; }; 105 103 void f( int & i, int & j, S & s, int v[] ) { 106 sout | i | j | "{ " | s.[x, y] | " }," | "[" | v[0] | "," | v[1] | "," | v[2] | "]";104 printf("%d %d { %g, %g }, [%d, %d, %d]\n", i, j, s.[x, y], v[0], v[1], v[2]); 107 105 } 108 void g(int & i) { sout | i; }109 void h(int &&& i) { sout | i; }106 void g(int & i) { printf("%d\n", i); } 107 void h(int &&& i) { printf("%d\n", i); } 110 108 111 int &&& r = 3; // rvalue to reference109 int &&& r = 3; // rvalue to reference 112 110 int i = r; 113 sout | i | r;// both 3111 printf("%d %d\n", i, r); // both 3 114 112 115 g( 3 ); // rvalue to reference116 h( (int &&&)3 ); // rvalue to reference113 g( 3 ); // rvalue to reference 114 h( (int &&&)3 ); // rvalue to reference 117 115 118 116 int a = 5, b = 4; -
tests/searchsort.cfa
r25cdca5 r84b4d607 10 10 // Created On : Thu Feb 4 18:17:50 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 20 22:49:46201813 // Update Count : 10 812 // Last Modified On : Wed Dec 5 08:18:42 2018 13 // Update Count : 106 14 14 // 15 15 … … 21 21 22 22 int main( void ) { 23 const int size = 10;23 const unsigned int size = 10; 24 24 int iarr[size]; 25 25 26 26 sout | nlOff; // turn off auto newline 27 27 28 for ( i; 0 ~ size ) {28 for ( i; 0u ~ size ) { 29 29 iarr[i] = size - i; 30 30 sout | iarr[i] | ", "; 31 31 } // for 32 sout | nl | nl;32 sout | nl; 33 33 34 34 // ascending sort/search by changing < to > 35 35 qsort( iarr, size ); 36 for ( i; 0 ~ size ) {36 for ( i; 0u ~ size ) { 37 37 sout | iarr[i] | ", "; 38 38 } // for 39 39 sout | nl; 40 for ( i; 0 ~ size ) { // C version40 for ( i; 0u ~ size ) { // C version 41 41 int key = size - i; 42 42 int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp ); … … 45 45 sout | nl; 46 46 47 for ( i; 0 ~ size ) {47 for ( i; 0u ~ size ) { 48 48 int * v = bsearch( size - i, iarr, size ); 49 49 sout | size - i | ':' | *v | ", "; 50 50 } // for 51 51 sout | nl; 52 for ( i; 0 ~ size ) {52 for ( i; 0u ~ size ) { 53 53 unsigned int posn = bsearch( size - i, iarr, size ); 54 54 sout | size - i | ':' | iarr[posn] | ", "; 55 55 } // for 56 sout | nl | nl;56 sout | nl; 57 57 58 58 // descending sort/search by changing < to > … … 63 63 sout | nl; 64 64 { 65 // redefinition of ?<? can't overlap the loop controls: 66 { 67 int (*?<?)(int, int) = ?>?; 68 qsort( iarr, size ); 69 } 70 for ( i; 0 ~ size ) { 65 int ?<?( int x, int y ) { return x > y; } 66 qsort( iarr, size ); 67 for ( i; 0u ~ size ) { 71 68 sout | iarr[i] | ", "; 72 69 } // for 73 70 sout | nl; 74 for ( i; 0 ~ size ) { 75 int (*?<?)(int, int) = ?>?; 71 for ( i; 0u ~ size ) { 76 72 int * v = bsearch( size - i, iarr, size ); 77 73 sout | size - i | ':' | *v | ", "; 78 74 } // for 79 75 sout | nl; 80 for ( i; 0 ~ size ) { 81 int (*?<?)(int, int) = ?>?; 76 for ( i; 0u ~ size ) { 82 77 unsigned int posn = bsearch( size - i, iarr, size ); 83 78 sout | size - i | ':' | iarr[posn] | ", "; 84 79 } // for 85 80 } 86 sout | nl | nl;81 sout | nl; 87 82 88 83 double darr[size]; 89 for ( i; 0 ~ size ) {84 for ( i; 0u ~ size ) { 90 85 darr[i] = size - i + 0.5; 91 86 sout | darr[i] | ", "; … … 93 88 sout | nl; 94 89 qsort( darr, size ); 95 for ( i; 0 ~ size ) {90 for ( i; 0u ~ size ) { 96 91 sout | darr[i] | ", "; 97 92 } // for 98 93 sout | nl; 99 for ( i; 0 ~ size ) {94 for ( i; 0u ~ size ) { 100 95 double * v = bsearch( size - i + 0.5, darr, size ); 101 96 sout | size - i + 0.5 | ':' | *v | ", "; 102 97 } // for 103 98 sout | nl; 104 for ( i; 0 ~ size ) {99 for ( i; 0u ~ size ) { 105 100 unsigned int posn = bsearch( size - i + 0.5, darr, size ); 106 101 sout | size - i + 0.5 | ':' | darr[posn] | ", "; 107 102 } // for 108 sout | nl | nl;103 sout | nl; 109 104 110 105 struct S { int i, j; } sarr[size]; 111 106 int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; } 112 107 ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; } 113 for ( i; 0 ~ size ) {108 for ( i; 0u ~ size ) { 114 109 sarr[i].i = size - i; 115 110 sarr[i].j = size - i + 1; … … 118 113 sout | nl; 119 114 qsort( sarr, size ); 120 for ( i; 0 ~ size ) {115 for ( i; 0u ~ size ) { 121 116 sout | sarr[i] | ", "; 122 117 } // for 123 118 sout | nl; 124 for ( i; 0 ~ size ) {119 for ( i; 0u ~ size ) { 125 120 S temp = { size - i, size - i + 1 }; 126 121 S * v = bsearch( temp, sarr, size ); … … 128 123 } // for 129 124 sout | nl; 130 for ( i; 0 ~ size ) {125 for ( i; 0u ~ size ) { 131 126 S temp = { size - i, size - i + 1 }; 132 127 unsigned int posn = bsearch( temp, sarr, size ); 133 128 sout | temp | ':' | sarr[posn] | ", "; 134 129 } // for 135 sout | nl | nl;130 sout | nl; 136 131 { 137 int getKey( const S & s ) { return s.j; }138 for ( i; 0 ~ size ) {132 unsigned int getKey( const S & s ) { return s.j; } 133 for ( i; 0u ~ size ) { 139 134 sout | sarr[i] | ", "; 140 135 } // for 141 136 sout | nl; 142 for ( i; 0 ~ size ) {137 for ( i; 0u ~ size ) { 143 138 S * v = bsearch( size - i + 1, sarr, size ); 144 139 sout | size - i + 1 | ':' | *v | ", "; 145 140 } // for 146 141 sout | nl; 147 for ( i; 0 ~ size ) {142 for ( i; 0u ~ size ) { 148 143 unsigned int posn = bsearch( size - i + 1, sarr, size ); 149 144 sout | size - i + 1 | ':' | sarr[posn] | ", "; 150 145 } // for 151 sout | nl | nl;146 sout | nl; 152 147 } 153 148 } // main -
tests/sum.cfa
r25cdca5 r84b4d607 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Sun Dec 23 23:00:38201814 // Update Count : 28 713 // Last Modified On : Tue Dec 11 21:50:41 2018 14 // Update Count : 285 15 15 // 16 16 … … 93 93 S ?++( S & t ) { S temp = t; t += (S){1}; return temp; } 94 94 ofstream & ?|?( ofstream & os, S v ) { return os | v.i | v.j; } 95 void ?|?( ofstream & os, S v ) { (ofstream &)(os | v);nl( os ); }95 void ?|?( ofstream & os, S v ) { (ofstream)(os | v); if ( getANL( os ) ) nl( os ); } 96 96 97 97 S s = (S){0}, a[size], v = { low, low }; -
tests/swap.cfa
r25cdca5 r84b4d607 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 23 23:00:49201813 // Update Count : 7 712 // Last Modified On : Tue Dec 11 10:17:40 2018 13 // Update Count : 74 14 14 // 15 15 … … 85 85 struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 }; 86 86 ofstream & ?|?( ofstream & os, S s ) { return os | s.i | s.j; } 87 void ?|?( ofstream & os, S s ) { (ofstream &)(os | s.i | s.j); nl( os ); }88 87 sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap " | nonl; 89 88 swap( s1, s2 ); -
tests/time.cfa
r25cdca5 r84b4d607 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 20 23:09:21201813 // Update Count : 2 312 // Last Modified On : Tue Dec 11 21:44:03 2018 13 // Update Count : 22 14 14 // 15 15 … … 30 30 sout | d1 == 7`s | d1 == d2 | d1 == 0; 31 31 sout | div( 7`s, 2`s ); 32 sout | nl;33 32 34 33 Time t = { 1970, 1, 2, 0, 0, 0, 10_000_000 }; … … 47 46 Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 }; 48 47 sout | t2 | t2.tv | nl | t3 | t3.tv; 49 sout | nl;50 48 51 49 // Clock Newfoundland = { -3.5`h }, PST = { -8`h }; // distance from GMT (UTC) … … 55 53 // | "local nsec" | getTimeNsec() 56 54 // | "PST" | PST(); // getTime short form 57 // sout | nl;55 // sout; 58 56 59 57 // http://en.cppreference.com/w/cpp/chrono/duration/operator_arith4 -
tests/withStatement.cfa
r25cdca5 r84b4d607 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon Dec 04 17:41:45 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Dec 24 19:08:18 201813 // Update Count : 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Dec 04 17:45:07 2017 13 // Update Count : 2 14 14 // 15 15 16 #include <fstream.hfa>17 18 16 struct S { 19 int i;20 // dynamically allocated member ensures ctor/dtors are called correctly on temporaries21 int * ptr;17 int i; 18 // dynamically allocated member ensures ctor/dtors are called correctly on temporaries 19 int * ptr; 22 20 }; 23 21 24 22 // with clause on reference parameter 25 void ?{}( S & this, int n ) with( this) {26 i = n;27 ptr = (int *)malloc( sizeof(int));23 void ?{}(S & this, int n) with(this) { 24 i = n; 25 ptr = (int *)malloc(sizeof(int)); 28 26 } 29 27 30 void ?{}( S & this) {31 this{ 0 };28 void ?{}(S & this) { 29 this{ 0 }; 32 30 } 33 31 34 void ?{}( S & this, S other) {35 this{ other.i };32 void ?{}(S & this, S other) { 33 this{ other.i }; 36 34 } 37 35 38 S ?=?( S & this, S other ) with( this) {39 i = other.i;40 *ptr = *other.ptr;41 return this;36 S ?=?(S & this, S other) with(this) { 37 i = other.i; 38 *ptr = *other.ptr; 39 return this; 42 40 } 43 41 44 void ^?{}( S & this ) with( this) {45 free( ptr);42 void ^?{}(S & this) with(this) { 43 free(ptr); 46 44 } 47 45 48 46 struct S2 { 49 S s;47 S s; 50 48 }; 51 49 52 void ?{}( S2 & this, int n) {53 (this.s){ n };50 void ?{}(S2 & this, int n) { 51 (this.s){ n }; 54 52 } 55 53 56 forall( otype T)54 forall(otype T) 57 55 struct Box { 58 T x;56 T x; 59 57 }; 60 58 61 forall( otype T)62 void ?{}( Box(T) & this ) with( this) { // with clause in polymorphic function63 x{};59 forall(otype T) 60 void ?{}(Box(T) & this) with(this) { // with clause in polymorphic function 61 x{}; 64 62 } 65 63 66 void print( int i ) { sout | i; }64 void print(int i) { printf("%d", i); } 67 65 68 forall( otype T | { void print( T ); }) 69 void foo( T t ) { 70 Box( T ) b = { t }; 71 with( b ) { // with statement in polymorphic function 72 print( x ); 73 } 66 forall(otype T | { void print(T); }) 67 void foo(T t) { 68 Box(T) b = { t }; 69 with(b) { // with statement in polymorphic function 70 print(x); 71 printf("\n"); 72 } 74 73 } 75 74 76 75 // ensure with-statement temporary generation works correctly 77 76 S mk() { 78 sout | "called mk";79 return (S){ 444 };77 printf("called mk\n"); 78 return (S) { 444 }; 80 79 } 81 80 82 81 // ensure with-statement temporary generation with reference-returning functions works correctly 83 82 S & ref() { 84 static S var = { 123456789 };85 return var;83 static S var = { 123456789 }; 84 return var; 86 85 } 87 86 88 87 int main() { 89 S2 s2 = { 12345 };90 with (s2) {91 with( s) { // with s2.s92 sout | i | s.i | s2.s.i;93 foo( i); // s.i94 with(mk()) {95 sout | i | i | i;96 with(ref()) {97 sout | i | i | i;98 } // with ref()99 with(ref()) {100 sout | i | i | i;101 } // with ref()102 } // with mk()103 } // with s104 } // with s288 S2 s2 = { 12345 }; 89 with (s2) { 90 with(s) { // with s2.s 91 printf("%d %d %d\n", i, s.i, s2.s.i); 92 foo(i); // s.i 93 with(mk()) { 94 printf("%d %d %d\n", i, i, i); 95 with(ref()) { 96 printf("%d %d %d\n", i, i, i); 97 } // with ref() 98 with(ref()) { 99 printf("%d %d %d\n", i, i, i); 100 } // with ref() 101 } // with mk() 102 } // with s 103 } // with s2 105 104 } 106 105
Note:
See TracChangeset
for help on using the changeset viewer.