Changes in / [29207bf:5ebb1368]
- Files:
-
- 87 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.in
r29207bf r5ebb1368 714 714 715 715 compile-attributes$(EXEEXT): 716 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.c 716 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 717 717 718 718 compile-empty$(EXEEXT): -
benchmark/Monitor.c
r29207bf r5ebb1368 29 29 EndTime = Time(); 30 30 31 sout | ( EndTime - StartTime ) / N | endl;31 sout | ( EndTime - StartTime ) / N; 32 32 } -
doc/papers/concurrency/Paper.tex
r29207bf r5ebb1368 686 686 Fib f1, f2; 687 687 for ( int i = 1; i <= 10; i += 1 ) { 688 sout | next( f1 ) | next( f2 ) | endl;688 sout | next( f1 ) | next( f2 ); 689 689 } 690 690 } … … 772 772 sout | " "; // separator 773 773 } 774 sout | endl;774 sout | nl; 775 775 } 776 776 } 777 777 void ?{}( Format & fmt ) { `resume( fmt );` } 778 778 void ^?{}( Format & fmt ) with( fmt ) { 779 if ( g != 0 || b != 0 ) sout | endl;779 if ( g != 0 || b != 0 ) sout | nl; 780 780 } 781 781 void format( Format & fmt ) { … … 855 855 for ( int i = 0; i < N; i += 1 ) { 856 856 int p1 = random( 100 ), p2 = random( 100 ); 857 sout | p1 | " " | p2 | endl;857 sout | p1 | " " | p2; 858 858 int status = delivery( c, p1, p2 ); 859 sout | " $" | money | endl | status | endl;859 sout | " $" | money | nl | status; 860 860 receipt += 1; 861 861 } 862 862 stop( c ); 863 sout | "prod stops" | endl;863 sout | "prod stops"; 864 864 } 865 865 int payment( Prod & prod, int money ) { … … 895 895 int money = 1, receipt; 896 896 for ( ; ! done; ) { 897 sout | p1 | " " | p2 | endl | " $" | money | endl;897 sout | p1 | " " | p2 | nl | " $" | money; 898 898 status += 1; 899 899 receipt = payment( p, money ); 900 sout | " #" | receipt | endl;900 sout | " #" | receipt; 901 901 money += 1; 902 902 } 903 sout | "cons stops" | endl;903 sout | "cons stops"; 904 904 } 905 905 int delivery( Cons & cons, int p1, int p2 ) { … … 1099 1099 1100 1100 void main(foo & this) { 1101 sout | "Hello World!" | endl;1101 sout | "Hello World!"; 1102 1102 } 1103 1103 \end{cfa} … … 1124 1124 1125 1125 void hello(/*unused*/ int) { 1126 sout | "Hello World!" | endl;1126 sout | "Hello World!"; 1127 1127 } 1128 1128 … … 1141 1141 thread World {}; 1142 1142 void main( World & this ) { 1143 sout | "World!" | endl;1143 sout | "World!"; 1144 1144 } 1145 1145 int main() { 1146 1146 World w`[10]`; $\C{// implicit forks after creation}$ 1147 sout | "Hello " | endl; $\C{// "Hello " and 10 "World!" printed concurrently}$1147 sout | "Hello "; $\C{// "Hello " and 10 "World!" printed concurrently}$ 1148 1148 } $\C{// implicit joins before destruction}$ 1149 1149 \end{cfa} … … 1193 1193 total += subtotals[r]; $\C{// total subtotal}$ 1194 1194 } 1195 sout | total | endl;1195 sout | total; 1196 1196 } 1197 1197 \end{cfa} … … 2192 2192 BENCH( 2193 2193 for ( size_t i = 0; i < N; i += 1 ) { @resume( c );@ } ) 2194 sout | result`ns | endl;2194 sout | result`ns; 2195 2195 } 2196 2196 \end{cfa} … … 2205 2205 BENCH( 2206 2206 for ( size_t i = 0; i < N; i += 1 ) { @yield();@ } ) 2207 sout | result`ns | endl;2207 sout | result`ns; 2208 2208 } 2209 2209 \end{cfa} … … 2244 2244 int main() { 2245 2245 BENCH( for( size_t i = 0; i < N; i += 1 ) { @do_call( m1/*, m2, m3, m4*/ );@ } ) 2246 sout | result`ns | endl;2246 sout | result`ns; 2247 2247 } 2248 2248 \end{cfa} … … 2305 2305 BENCH( for ( size_t i = 0; i < N; i += 1 ) { @wait( c );@ } ); 2306 2306 go = 0; // stop other thread 2307 sout | result`ns | endl;2307 sout | result`ns; 2308 2308 } 2309 2309 int main() { … … 2356 2356 BENCH( for ( size_t i = 0; i < N; i += 1 ) { @waitfor( do_call, m );@ } ) 2357 2357 go = 0; // stop other thread 2358 sout | result`ns | endl;2358 sout | result`ns; 2359 2359 } 2360 2360 int main() { … … 2391 2391 int main() { 2392 2392 BENCH( for ( size_t i = 0; i < N; i += 1 ) { @MyThread m;@ } ) 2393 sout | result`ns | endl;2393 sout | result`ns; 2394 2394 } 2395 2395 \end{cfa} -
doc/proposals/flags.md
r29207bf r5ebb1368 60 60 ``` 61 61 FunFlags f = some_val(); 62 if ( f ) { sout | "f has some flag(s) set" | endl; }63 if ( f & FOO ) { sout | "f has FOO set" | endl; }62 if ( f ) { sout | "f has some flag(s) set"; } 63 if ( f & FOO ) { sout | "f has FOO set"; } 64 64 f |= FOO; // set FOO 65 65 f -= FOO; // unset FOO … … 88 88 ``` 89 89 FunFlags f = some_val(); 90 if ( f.FOO ) { sout | "f has FOO set" | endl; }90 if ( f.FOO ) { sout | "f has FOO set"; } 91 91 f.FOO = true; // set FOO 92 92 f.FOO = false; // unset FOO -
doc/user/user.tex
r29207bf r5ebb1368 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Nov 7 17:00:49201814 %% Update Count : 3 39913 %% Last Modified On : Tue Dec 11 23:19:26 2018 14 %% Update Count : 3400 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 178 178 int main( void ) { 179 179 int x = 0, y = 1, z = 2; 180 ®sout | x | y | z | endl;®§\indexc{sout}§180 ®sout | x | y | z;®§\indexc{sout}§ 181 181 } 182 182 \end{cfa} … … 513 513 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the base cannot be negative. 514 514 \begin{cfa} 515 sout | 2 ®\® 8u | 4 ®\® 3u | -4 ®\® 3u | 4 ®\® -3 | -4 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi) | endl;515 sout | 2 ®\® 8u | 4 ®\® 3u | -4 ®\® 3u | 4 ®\® -3 | -4 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 516 516 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i 517 517 \end{cfa} … … 591 591 & 592 592 \begin{cfa} 593 sout | endl;594 sout | endl;595 sout | endl;596 sout | "zero" | endl;597 sout | endl;598 sout | endl;599 sout | endl;600 sout | endl;601 sout | endl;602 sout | endl;603 sout | endl;604 sout | endl;605 sout | endl;606 sout | endl;607 sout | endl;608 sout | endl;609 sout | endl | endl;610 611 sout | endl;612 sout | endl;613 sout | endl | endl;614 615 sout | endl;593 sout | nl; 594 sout | nl; 595 sout | nl; 596 sout | "zero" | nl; 597 sout | nl; 598 sout | nl; 599 sout | nl; 600 sout | nl; 601 sout | nl; 602 sout | nl; 603 sout | nl; 604 sout | nl; 605 sout | nl; 606 sout | nl; 607 sout | nl; 608 sout | nl; 609 sout | nl | nl; 610 611 sout | nl; 612 sout | nl; 613 sout | nl | nl; 614 615 sout | nl; 616 616 \end{cfa} 617 617 & … … 2459 2459 int bar( int p ) { 2460 2460 ®i® += 1; §\C{// dependent on local variable}§ 2461 sout | ®i® | endl;2461 sout | ®i®; 2462 2462 } 2463 2463 return bar; §\C{// undefined because of local dependence}§ … … 2465 2465 int main() { 2466 2466 * [int]( int ) fp = foo(); §\C{// int (* fp)( int )}§ 2467 sout | fp( 3 ) | endl;2467 sout | fp( 3 ); 2468 2468 } 2469 2469 \end{cfa} … … 3231 3231 \begin{cfa} 3232 3232 int x = 1, y = 2, z = 3; 3233 sout | x ®|® y ®|® z | endl;3233 sout | x ®|® y ®|® z; 3234 3234 \end{cfa} 3235 3235 & … … 3252 3252 \begin{cfa} 3253 3253 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 3254 sout | t1 | t2 | endl;§\C{// print tuples}§3254 sout | t1 | t2; §\C{// print tuples}§ 3255 3255 \end{cfa} 3256 3256 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3264 3264 & 3265 3265 \begin{cfa} 3266 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;3266 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2); 3267 3267 \end{cfa} 3268 3268 \\ … … 3290 3290 A separator does not appear at the start or end of a line. 3291 3291 \begin{cfa}[belowskip=0pt] 3292 sout | 1 | 2 | 3 | endl;3292 sout | 1 | 2 | 3; 3293 3293 \end{cfa} 3294 3294 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3299 3299 A separator does not appear before or after a character literal or variable. 3300 3300 \begin{cfa} 3301 sout | '1' | '2' | '3' | endl;3301 sout | '1' | '2' | '3'; 3302 3302 123 3303 3303 \end{cfa} … … 3306 3306 A separator does not appear before or after a null (empty) C string. 3307 3307 \begin{cfa} 3308 sout | 1 | "" | 2 | "" | 3 | endl;3308 sout | 1 | "" | 2 | "" | 3; 3309 3309 123 3310 3310 \end{cfa} … … 3316 3316 \begin{cfa}[mathescape=off] 3317 3317 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" 3318 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;3318 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10; 3319 3319 \end{cfa} 3320 3320 %$ … … 3330 3330 \begin{cfa}[belowskip=0pt] 3331 3331 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" 3332 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;3332 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x"; 3333 3333 \end{cfa} 3334 3334 \begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3340 3340 A seperator does not appear before or after a C string begining/ending with the \Index*{ASCII} quote or whitespace characters: \lstinline[basicstyle=\tt,showspaces=true]@`'": \t\v\f\r\n@ 3341 3341 \begin{cfa}[belowskip=0pt] 3342 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;3342 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx"; 3343 3343 \end{cfa} 3344 3344 \begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] … … 3349 3349 If a space is desired before or after one of the special string start/end characters, simply insert a space. 3350 3350 \begin{cfa}[belowskip=0pt] 3351 sout | "x (§\color{red}\texttt{\textvisiblespace}§" | 1 | "§\color{red}\texttt{\textvisiblespace}§) x" | 2 | "§\color{red}\texttt{\textvisiblespace}§, x" | 3 | "§\color{red}\texttt{\textvisiblespace}§:x:§\color{red}\texttt{\textvisiblespace}§" | 4 | endl;3351 sout | "x (§\color{red}\texttt{\textvisiblespace}§" | 1 | "§\color{red}\texttt{\textvisiblespace}§) x" | 2 | "§\color{red}\texttt{\textvisiblespace}§, x" | 3 | "§\color{red}\texttt{\textvisiblespace}§:x:§\color{red}\texttt{\textvisiblespace}§" | 4; 3352 3352 \end{cfa} 3353 3353 \begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] … … 3366 3366 \begin{cfa}[mathescape=off,belowskip=0pt] 3367 3367 sepSet( sout, ", $" ); §\C{// set separator from " " to ", \$"}§ 3368 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;3368 sout | 1 | 2 | 3 | " \"" | ®sep® | "\""; 3369 3369 \end{cfa} 3370 3370 %$ … … 3375 3375 \begin{cfa}[belowskip=0pt] 3376 3376 sepSet( sout, " " ); §\C{// reset separator to " "}§ 3377 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;3377 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\""; 3378 3378 \end{cfa} 3379 3379 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3385 3385 strcpy( store, sepGet( sout ) ); §\C{// copy current separator}§ 3386 3386 sepSet( sout, "_" ); §\C{// change separator to underscore}§ 3387 sout | 1 | 2 | 3 | endl;3387 sout | 1 | 2 | 3; 3388 3388 \end{cfa} 3389 3389 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3392 3392 \begin{cfa}[belowskip=0pt] 3393 3393 sepSet( sout, store ); §\C{// change separator back to original}§ 3394 sout | 1 | 2 | 3 | endl;3394 sout | 1 | 2 | 3; 3395 3395 \end{cfa} 3396 3396 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3403 3403 \begin{cfa}[belowskip=0pt] 3404 3404 sepSetTuple( sout, " " ); §\C{// set tuple separator from ", " to " "}§ 3405 sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;3405 sout | t1 | t2 | " \"" | ®sepTuple® | "\""; 3406 3406 \end{cfa} 3407 3407 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3410 3410 \begin{cfa}[belowskip=0pt] 3411 3411 sepSetTuple( sout, ", " ); §\C{// reset tuple separator to ", "}§ 3412 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;3412 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\""; 3413 3413 \end{cfa} 3414 3414 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3420 3420 Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, \ie the seperator is adjusted with respect to all subsequent printed items. 3421 3421 \begin{cfa}[belowskip=0pt] 3422 sout | sepDisable | 1 | 2 | 3 | endl;§\C{// globally turn off implicit separator}§3422 sout | sepDisable | 1 | 2 | 3; §\C{// globally turn off implicit separator}§ 3423 3423 \end{cfa} 3424 3424 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3426 3426 \end{cfa} 3427 3427 \begin{cfa}[belowskip=0pt] 3428 sout | sepEnable | 1 | 2 | 3 | endl; §\C{// globally turn on implicit separator}§3428 sout | sepEnable | 1 | 2 | 3; §\C{// globally turn on implicit separator}§ 3429 3429 \end{cfa} 3430 3430 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3435 3435 Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, \ie the seperator is adjusted only with respect to the next printed item. 3436 3436 \begin{cfa}[belowskip=0pt] 3437 sout | 1 | sepOff | 2 | 3 | endl; §\C{// locally turn off implicit separator}§3437 sout | 1 | sepOff | 2 | 3; §\C{// locally turn off implicit separator}§ 3438 3438 \end{cfa} 3439 3439 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3441 3441 \end{cfa} 3442 3442 \begin{cfa}[belowskip=0pt] 3443 sout | sepDisable | 1 | sepOn | 2 | 3 | endl; §\C{// locally turn on implicit separator}§3443 sout | sepDisable | 1 | sepOn | 2 | 3; §\C{// locally turn on implicit separator}§ 3444 3444 \end{cfa} 3445 3445 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3448 3448 The tuple separator also responses to being turned on and off. 3449 3449 \begin{cfa}[belowskip=0pt] 3450 sout | t1 | sepOff | t2 | endl; §\C{// locally turn on/off implicit separator}§3450 sout | t1 | sepOff | t2; §\C{// locally turn on/off implicit separator}§ 3451 3451 \end{cfa} 3452 3452 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3456 3456 use ©sep© to accomplish this functionality. 3457 3457 \begin{cfa}[belowskip=0pt] 3458 sout | sepOn | 1 | 2 | 3 | sepOn | endl; §\C{// sepOn does nothing at start/end of line}§3458 sout | sepOn | 1 | 2 | 3 | sepOn; §\C{// sepOn does nothing at start/end of line}§ 3459 3459 \end{cfa} 3460 3460 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3462 3462 \end{cfa} 3463 3463 \begin{cfa}[belowskip=0pt] 3464 sout | sep | 1 | 2 | 3 | sep | endl; §\C{// use sep to print separator at start/end of line}§3464 sout | sep | 1 | 2 | 3 | sep ; §\C{// use sep to print separator at start/end of line}§ 3465 3465 \end{cfa} 3466 3466 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3475 3475 int main( void ) { 3476 3476 int x = 1, y = 2, z = 3; 3477 sout | x | y | z | endl;3477 sout | x | y | z; 3478 3478 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 3479 sout | t1 | t2 | endl; // print tuples3480 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;3481 sout | 1 | 2 | 3 | endl;3482 sout | '1' | '2' | '3' | endl;3483 sout | 1 | "" | 2 | "" | 3 | endl;3479 sout | t1 | t2; // print tuples 3480 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2); 3481 sout | 1 | 2 | 3; 3482 sout | '1' | '2' | '3'; 3483 sout | 1 | "" | 2 | "" | 3; 3484 3484 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" 3485 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;3485 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10; 3486 3486 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" 3487 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;3488 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;3489 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;3487 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x"; 3488 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx"; 3489 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4; 3490 3490 3491 3491 sepSet( sout, ", $" ); // set separator from " " to ", $" 3492 sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;3492 sout | 1 | 2 | 3 | " \"" | sep | "\""; 3493 3493 sepSet( sout, " " ); // reset separator to " " 3494 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;3494 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\""; 3495 3495 3496 3496 char store[sepSize]; 3497 3497 strcpy( store, sepGet( sout ) ); 3498 3498 sepSet( sout, "_" ); 3499 sout | 1 | 2 | 3 | endl;3499 sout | 1 | 2 | 3; 3500 3500 sepSet( sout, store ); 3501 sout | 1 | 2 | 3 | endl;3501 sout | 1 | 2 | 3; 3502 3502 3503 3503 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 3504 sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;3504 sout | t1 | t2 | " \"" | sepTuple | "\""; 3505 3505 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 3506 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;3507 3508 sout | sepDisable | 1 | 2 | 3 | endl; // globally turn off implicit separator3509 sout | sepEnable | 1 | 2 | 3 | endl; // globally turn on implicit separator3510 3511 sout | 1 | sepOff | 2 | 3 | endl; // locally turn on implicit separator3512 sout | sepDisable | 1 | sepOn | 2 | 3 | endl; // globally turn off implicit separator3506 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\""; 3507 3508 sout | sepDisable | 1 | 2 | 3; // globally turn off implicit separator 3509 sout | sepEnable | 1 | 2 | 3; // globally turn on implicit separator 3510 3511 sout | 1 | sepOff | 2 | 3; // locally turn on implicit separator 3512 sout | sepDisable | 1 | sepOn | 2 | 3; // globally turn off implicit separator 3513 3513 sout | sepEnable; 3514 sout | t1 | sepOff | t2 | endl; // locally turn on/off implicit separator3515 3516 sout | sepOn | 1 | 2 | 3 | sepOn | endl; // sepOn does nothing at start/end of line3517 sout | sep | 1 | 2 | 3 | sep | endl; // use sep to print separator at start/end of line3514 sout | t1 | sepOff | t2; // locally turn on/off implicit separator 3515 3516 sout | sepOn | 1 | 2 | 3 | sepOn ; // sepOn does nothing at start/end of line 3517 sout | sep | 1 | 2 | 3 | sep ; // use sep to print separator at start/end of line 3518 3518 } 3519 3519 … … 4180 4180 Fibonacci f1, f2; 4181 4181 for ( int i = 1; i <= 10; i += 1 ) { 4182 sout | next( &f1 ) | ' ' | next( &f2 ) | endl;4182 sout | next( &f1 ) | ' ' | next( &f2 ); 4183 4183 } // for 4184 4184 } … … 4246 4246 MyThread f[4]; 4247 4247 } 4248 sout | global.value | endl;4248 sout | global.value; 4249 4249 } 4250 4250 \end{cfa} … … 4324 4324 void main( First * this ) { 4325 4325 for ( int i = 0; i < 10; i += 1 ) { 4326 sout | "First : Suspend No." | i + 1 | endl;4326 sout | "First : Suspend No." | i + 1; 4327 4327 yield(); 4328 4328 } … … 4333 4333 wait( this->lock ); 4334 4334 for ( int i = 0; i < 10; i += 1 ) { 4335 sout | "Second : Suspend No." | i + 1 | endl;4335 sout | "Second : Suspend No." | i + 1; 4336 4336 yield(); 4337 4337 } … … 4340 4340 int main( void ) { 4341 4341 signal_once lock; 4342 sout | "User main begin" | endl;4342 sout | "User main begin"; 4343 4343 { 4344 4344 processor p; … … 4348 4348 } 4349 4349 } 4350 sout | "User main end" | endl;4350 sout | "User main end"; 4351 4351 } 4352 4352 \end{cfa} … … 5045 5045 void ?{}( Line * l ) { 5046 5046 l->lnth = 0.0; 5047 sout | "default" | endl;5047 sout | "default"; 5048 5048 } 5049 5049 … … 5052 5052 void ?{}( Line * l, float lnth ) { 5053 5053 l->lnth = lnth; 5054 sout | "lnth" | l->lnth | endl;5054 sout | "lnth" | l->lnth; 5055 5055 5056 5056 } … … 5058 5058 // destructor 5059 5059 void ^?() { 5060 sout | "destroyed" | endl;5060 sout | "destroyed"; 5061 5061 l.lnth = 0.0; 5062 5062 } … … 5804 5804 In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character. 5805 5805 \begin{cfa} 5806 sout | 'x' | " " | (int)'x' | endl;5806 sout | 'x' | " " | (int)'x'; 5807 5807 x 120 5808 5808 \end{cfa} … … 7034 7034 #include <gmp>§\indexc{gmp}§ 7035 7035 int main( void ) { 7036 sout | "Factorial Numbers" | endl;7036 sout | "Factorial Numbers"; 7037 7037 Int fact = 1; 7038 7038 7039 sout | 0 | fact | endl;7039 sout | 0 | fact; 7040 7040 for ( unsigned int i = 1; i <= 40; i += 1 ) { 7041 7041 fact *= i; 7042 sout | i | fact | endl;7042 sout | i | fact; 7043 7043 } 7044 7044 } -
examples/ArrayN.c
r29207bf r5ebb1368 7 7 8 8 forall(otype index_t) 9 index_t offset_to_index(unsigned offset, index_t size) 10 { 9 index_t offset_to_index(unsigned offset, index_t size) { 11 10 return [offset / size.0, offset % size.1]; 12 11 } 13 12 14 int main(int argc, char* argv[]) 15 { 13 int main(int argc, char* argv[]) { 16 14 unsigned x = 0, y = 0, i = 0; 17 15 unsigned sx = 4, sy = 4; … … 20 18 [x, y] = offset_to_index(6, [sx, sy]); 21 19 22 sout | x | ' ' | y | endl;20 sout | x | ' ' | y; 23 21 24 22 return 0; -
examples/gc_no_raii/src/internal/collector.c
r29207bf r5ebb1368 38 38 void* gc_allocate(size_t target_size) 39 39 { 40 // sout | "Allocating " | target_size | " bytes" | endl;40 // sout | "Allocating " | target_size | " bytes"; 41 41 42 42 size_t size = gc_compute_size(target_size + sizeof(gc_object_header)); 43 43 44 // sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;45 // sout | "Actual allocation size: " | size | " bytes" | endl;44 // sout | "Object header size: " | sizeof(gc_object_header) | " bytes"; 45 // sout | "Actual allocation size: " | size | " bytes"; 46 46 47 47 check(size < POOL_SIZE_BYTES); -
examples/gc_no_raii/src/internal/state.h
r29207bf r5ebb1368 38 38 static inline bool gc_needs_collect(gc_state* state) 39 39 { 40 // sout | "Used Space: " | state->used_space | " bytes" | endl;40 // sout | "Used Space: " | state->used_space | " bytes"; 41 41 return state->used_space * 2 > state->total_space; 42 42 } -
examples/gc_no_raii/src/tools/print.h
r29207bf r5ebb1368 5 5 // #include <fstream.hfa> 6 6 // 7 // #define DEBUG_OUT(x) sout | x | endl;7 // #define DEBUG_OUT(x) sout | x; 8 8 // 9 9 // #else -
examples/multicore.c
r29207bf r5ebb1368 15 15 16 16 int main(int argc, char* argv[]) { 17 // sout | "User main begin" | endl;17 // sout | "User main begin"; 18 18 { 19 19 processor p; … … 22 22 } 23 23 } 24 // sout | "User main end" | endl;24 // sout | "User main end"; 25 25 } -
examples/prolog.c
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:09:39 201613 // Update Count : 512 // Last Modified On : Tue Dec 11 23:27:19 2018 13 // Update Count : 6 14 14 // 15 15 16 16 #include <fstream.hfa> 17 17 18 void printResult( int x ) { sout | "int" | endl; }19 void printResult( double x ) { sout | "double" | endl; }20 void printResult( char * x ) { sout | "char*" | endl; }18 void printResult( int x ) { sout | "int"; } 19 void printResult( double x ) { sout | "double"; } 20 void printResult( char * x ) { sout | "char*"; } 21 21 22 22 void is_arithmetic( int x ) {} -
examples/quad.c
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:07:02 201613 // Update Count : 812 // Last Modified On : Tue Dec 11 23:26:58 2018 13 // Update Count : 9 14 14 // 15 15 … … 28 28 int main() { 29 29 int N = 2; 30 sout | "result of quad of" | N | "is" | quad( N ) | endl;30 sout | "result of quad of" | N | "is" | quad( N ); 31 31 } 32 32 -
examples/square.c
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:05:48 201613 // Update Count : 2 712 // Last Modified On : Tue Dec 11 23:28:24 2018 13 // Update Count : 28 14 14 // 15 15 … … 23 23 int main() { 24 24 #if 0 25 sout | "result of squaring 9 is " | endl;25 sout | "result of squaring 9 is "; 26 26 27 27 // char does not have multiplication. … … 30 30 } // ?*? 31 31 char c = 9; 32 sout | "char\t\t\t" | square( c ) | endl;32 sout | "char\t\t\t" | square( c ); 33 33 34 sout | square( s ) | endl;34 sout | square( s ); 35 35 #endif 36 36 short s = 9; … … 38 38 #if 0 39 39 signed int i = 9; 40 sout | "signed int\t\t" | square( i ) | endl;40 sout | "signed int\t\t" | square( i ); 41 41 42 42 unsigned int ui = 9; 43 sout | "unsigned int\t\t" | square( ui ) | endl;43 sout | "unsigned int\t\t" | square( ui ); 44 44 45 45 long int li = 9; 46 sout | "signed long int\t\t" | square( li ) | endl;46 sout | "signed long int\t\t" | square( li ); 47 47 48 48 unsigned long int uli = 9; 49 sout | "unsigned long int\t" | square( uli ) | endl;49 sout | "unsigned long int\t" | square( uli ); 50 50 51 51 signed long long int lli = 9; 52 sout | "signed long long int\t" | square( lli ) | endl;52 sout | "signed long long int\t" | square( lli ); 53 53 54 54 unsigned long long int ulli = 9; 55 sout | "unsigned long long int\t" | square( ulli ) | endl;55 sout | "unsigned long long int\t" | square( ulli ); 56 56 57 57 float f = 9.0; 58 sout | "float\t\t\t" | square( f ) | endl;58 sout | "float\t\t\t" | square( f ); 59 59 60 60 double d = 9.0; 61 sout | "double\t\t\t" | square( d ) | endl;61 sout | "double\t\t\t" | square( d ); 62 62 63 63 long double ld = 9.0; 64 sout | "long double\t\t" | square( ld ) | endl;64 sout | "long double\t\t" | square( ld ); 65 65 #endif 66 66 } // main -
examples/twice.c
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Oct 19 21:52:57 201713 // Update Count : 4 612 // Last Modified On : Tue Dec 11 23:28:08 2018 13 // Update Count : 47 14 14 // 15 15 … … 28 28 29 29 int main( void ) { 30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ) | endl;30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ); 31 31 } 32 32 -
examples/wrapper/src/main.c
r29207bf r5ebb1368 1 1 #include "pointer.h" 2 2 3 wrapper_t make_copy(wrapper_t copy) 4 { 3 wrapper_t make_copy(wrapper_t copy) { 5 4 return copy; 6 5 } 7 6 8 int main(int argc, char const *argv[]) 9 { 7 int main(int argc, char const *argv[]) { 10 8 wrapper_t p = wrap(6); 11 12 sout | endl | "test started" | endl; 13 9 sout | nl | "test started"; 14 10 wrapper_t p2 = p; 15 16 11 clear(&p); 17 18 12 p = p2; 19 20 13 wrapper_t p3 = make_copy(p2); 21 22 sout | endl | "test ended" | endl; 23 14 sout | nl | "test ended"; 24 15 return 0; 25 16 } -
examples/wrapper/src/pointer.h
r29207bf r5ebb1368 34 34 void ?{}(content_t* this) 35 35 { 36 sout | "Constructing content" | endl;36 sout | "Constructing content"; 37 37 this->count = 0; 38 38 } … … 40 40 void ^?{}(content_t* this) 41 41 { 42 sout | "Destroying content" | endl;42 sout | "Destroying content"; 43 43 } 44 44 … … 53 53 void ?{}(wrapper_t* this) 54 54 { 55 sout | "Constructing empty ref pointer" | endl | endl;55 sout | "Constructing empty ref pointer" | nl; 56 56 this->ptr = NULL; 57 57 } … … 59 59 void ?{}(wrapper_t* this, wrapper_t rhs) 60 60 { 61 sout | "Constructing ref pointer from copy" | endl;61 sout | "Constructing ref pointer from copy"; 62 62 this->ptr = rhs.ptr; 63 63 this->ptr->count++; 64 sout | "Reference is " | this->ptr->count | endl | endl;64 sout | "Reference is " | this->ptr->count | nl; 65 65 } 66 66 … … 69 69 if(this->ptr) 70 70 { 71 sout | "Destroying ref pointer" | endl;71 sout | "Destroying ref pointer"; 72 72 this->ptr->count--; 73 sout | "Reference is " | this->ptr->count | endl | endl;73 sout | "Reference is " | this->ptr->count | nl; 74 74 if(!this->ptr->count) delete(this->ptr); 75 75 } 76 76 else 77 77 { 78 sout | "Destroying empty ref pointer" | endl | endl;78 sout | "Destroying empty ref pointer" | nl; 79 79 } 80 80 } … … 82 82 wrapper_t ?=?(wrapper_t* this, wrapper_t rhs) 83 83 { 84 sout | "Setting ref pointer" | endl;84 sout | "Setting ref pointer"; 85 85 if(this->ptr) 86 86 { 87 87 this->ptr->count--; 88 sout | "Reference is " | this->ptr->count | endl | endl;88 sout | "Reference is " | this->ptr->count | nl; 89 89 if(!this->ptr->count) delete(this->ptr); 90 90 } 91 91 this->ptr = rhs.ptr; 92 92 this->ptr->count++; 93 sout | "Reference is " | this->ptr->count | endl | endl;93 sout | "Reference is " | this->ptr->count | nl; 94 94 } 95 95 … … 98 98 this->ptr = c; 99 99 this->ptr->count++; 100 sout | "Setting ref pointer" | endl;101 sout | "Reference is " | this->ptr->count | endl | endl;100 sout | "Setting ref pointer"; 101 sout | "Reference is " | this->ptr->count | nl; 102 102 } 103 103 104 104 void clear(wrapper_t* this) 105 105 { 106 sout | "Clearing ref pointer" | endl;106 sout | "Clearing ref pointer"; 107 107 this->ptr->count--; 108 sout | "Reference is " | this->ptr->count | endl | endl;108 sout | "Reference is " | this->ptr->count | nl; 109 109 if(!this->ptr->count) delete(this->ptr); 110 110 this->ptr = NULL; -
examples/zero_one.c
r29207bf r5ebb1368 3 3 void foo(zero_t o) 4 4 { 5 sout | "It's a Zero!" | endl;5 sout | "It's a Zero!"; 6 6 } 7 7 8 8 void foo(one_t o) 9 9 { 10 sout | "It's a One!" | endl;10 sout | "It's a One!"; 11 11 } 12 12 13 13 void foo(int o) 14 14 { 15 sout | "It's a Number!" | endl;15 sout | "It's a Number!"; 16 16 } 17 17 -
libcfa/src/fstream.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 10 18:19:40201813 // Update Count : 2 8412 // Last Modified On : Wed Dec 12 08:34:28 2018 13 // Update Count : 298 14 14 // 15 15 … … 20 20 #include <stdarg.h> // varargs 21 21 #include <string.h> // strlen 22 #include <stdbool.h> // true/false23 22 #include <float.h> // DBL_DIG, LDBL_DIG 24 23 #include <complex.h> // creal, cimag … … 27 26 #define IO_MSG "I/O error: " 28 27 29 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, 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 ) { 30 29 os.file = file; 31 30 os.sepDefault = sepDefault; 32 31 os.sepOnOff = sepOnOff; 32 os.nlOnOff = nlOnOff; 33 os.nonlManip = nonlManip; 33 34 sepSet( os, separator ); 34 35 sepSetCur( os, sepGet( os ) ); … … 44 45 bool getNL( ofstream & os ) { return os.sawNL; } 45 46 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 47 bool getANL( ofstream & os ) { return os.nlOnOff; } 48 bool getNonl( ofstream & os ) { return os.nonlManip; } 49 void setNonl( ofstream & os, bool state ) { os.nonlManip = state; } 46 50 47 51 // public … … 72 76 } // sepEnable 73 77 78 void nlOn( ofstream & os ) { os.nlOnOff = true; } 79 void nlOff( ofstream & os ) { os.nlOnOff = false; } 80 74 81 const char * sepGet( ofstream & os ) { return os.separator; } 75 82 void sepSet( ofstream & os, const char * s ) { … … 103 110 } // if 104 111 #endif // __CFA_DEBUG__ 105 (os){ file, true, false, " ", ", " };112 (os){ file, true, false, true, false, " ", ", " }; 106 113 } // open 107 114 … … 147 154 } // fmt 148 155 149 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };156 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, true, false, " ", ", " }; 150 157 ofstream & sout = soutFile; 151 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };158 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, true, false, " ", ", " }; 152 159 ofstream & serr = serrFile; 153 160 -
libcfa/src/fstream.hfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 13:54:27201813 // Update Count : 1 3212 // Last Modified On : Wed Dec 12 07:52:41 2018 13 // Update Count : 143 14 14 // 15 15 … … 23 23 bool sepDefault; 24 24 bool sepOnOff; 25 bool nlOnOff; 26 bool nonlManip; 25 27 bool sawNL; 26 28 const char * sepCur; … … 37 39 bool getNL( ofstream & ); 38 40 void setNL( ofstream &, bool ); 41 bool getANL( ofstream & ); 42 bool getNonl( ofstream & ); 43 void setNonl( ofstream &, bool ); 39 44 40 45 // public … … 43 48 bool sepDisable( ofstream & ); 44 49 bool sepEnable( ofstream & ); 50 void nlOn( ofstream & ); 51 void nlOff( ofstream & ); 45 52 46 53 const char * sepGet( ofstream & ); -
libcfa/src/gmp.hfa
r29207bf r5ebb1368 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 7 09:10:41 201713 // Update Count : 2 112 // Last Modified On : Tue Dec 4 23:25:51 2018 13 // Update Count : 22 14 14 // 15 15 … … 262 262 } // ?|? 263 263 264 static inline forall( dtype ostype | ostream( ostype ) ) 265 ostype & ?|?( ostype & os, Int mp ) { 266 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 267 gmp_printf( "%Zd", mp.mpz ); 268 sepOn( os ); 269 return os; 270 } // ?|? 264 static inline forall( dtype ostype | ostream( ostype ) ) { 265 ostype & ?|?( ostype & os, Int mp ) { 266 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 267 gmp_printf( "%Zd", mp.mpz ); 268 sepOn( os ); 269 return os; 270 } // ?|? 271 272 void ?|?( ostype & os, Int mp ) { 273 (ostype)(os | mp); if ( getANL( os ) ) nl( os ); 274 } // ?|? 275 } // distribution 271 276 272 277 // Local Variables: // -
libcfa/src/iostream.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 2 07:17:05201813 // Update Count : 47412 // Last Modified On : Tue Dec 11 22:02:03 2018 13 // Update Count : 546 14 14 // 15 15 … … 19 19 #include <stdio.h> 20 20 #include <stdbool.h> // true/false 21 //#include <string.h> 21 //#include <string.h> // strlen, strcmp 22 22 extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); 23 23 extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); … … 32 32 return os; 33 33 } // ?|? 34 35 ostype & ?|?( ostype & os, char ch ) { 36 fmt( os, "%c", ch ); 37 if ( ch == '\n' ) setNL( os, true ); 38 sepOff( os ); 39 return os; 40 } // ?|? 41 42 ostype & ?|?( ostype & os, signed char c ) { 43 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 44 fmt( os, "%hhd", c ); 45 return os; 46 } // ?|? 47 48 ostype & ?|?( ostype & os, unsigned char c ) { 49 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 50 fmt( os, "%hhu", c ); 51 return os; 34 void ?|?( ostype & os, bool b ) { 35 (ostype)(os | b); if ( getANL( os ) ) nl( os ); 36 } // ?|? 37 38 ostype & ?|?( ostype & os, char c ) { 39 fmt( os, "%c", c ); 40 if ( c == '\n' ) setNL( os, true ); 41 return sepOff( os ); 42 } // ?|? 43 void ?|?( ostype & os, char c ) { 44 (ostype)(os | c); if ( getANL( os ) ) nl( os ); 45 } // ?|? 46 47 ostype & ?|?( ostype & os, signed char sc ) { 48 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 49 fmt( os, "%hhd", sc ); 50 return os; 51 } // ?|? 52 void ?|?( ostype & os, signed char sc ) { 53 (ostype)(os | sc); if ( getANL( os ) ) nl( os ); 54 } // ?|? 55 56 ostype & ?|?( ostype & os, unsigned char usc ) { 57 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 58 fmt( os, "%hhu", usc ); 59 return os; 60 } // ?|? 61 void ?|?( ostype & os, unsigned char usc ) { 62 (ostype)(os | usc); if ( getANL( os ) ) nl( os ); 52 63 } // ?|? 53 64 … … 57 68 return os; 58 69 } // ?|? 70 void & ?|?( ostype & os, short int si ) { 71 (ostype)(os | si); if ( getANL( os ) ) nl( os ); 72 } // ?|? 59 73 60 74 ostype & ?|?( ostype & os, unsigned short int usi ) { … … 63 77 return os; 64 78 } // ?|? 79 void & ?|?( ostype & os, unsigned short int usi ) { 80 (ostype)(os | usi); if ( getANL( os ) ) nl( os ); 81 } // ?|? 65 82 66 83 ostype & ?|?( ostype & os, int i ) { … … 69 86 return os; 70 87 } // ?|? 88 void & ?|?( ostype & os, int i ) { 89 (ostype)(os | i); if ( getANL( os ) ) nl( os ); 90 } // ?|? 71 91 72 92 ostype & ?|?( ostype & os, unsigned int ui ) { … … 75 95 return os; 76 96 } // ?|? 97 void & ?|?( ostype & os, unsigned int ui ) { 98 (ostype)(os | ui); if ( getANL( os ) ) nl( os ); 99 } // ?|? 77 100 78 101 ostype & ?|?( ostype & os, long int li ) { … … 81 104 return os; 82 105 } // ?|? 106 void & ?|?( ostype & os, long int li ) { 107 (ostype)(os | li); if ( getANL( os ) ) nl( os ); 108 } // ?|? 83 109 84 110 ostype & ?|?( ostype & os, unsigned long int uli ) { … … 87 113 return os; 88 114 } // ?|? 115 void & ?|?( ostype & os, unsigned long int uli ) { 116 (ostype)(os | uli); if ( getANL( os ) ) nl( os ); 117 } // ?|? 89 118 90 119 ostype & ?|?( ostype & os, long long int lli ) { … … 93 122 return os; 94 123 } // ?|? 124 void & ?|?( ostype & os, long long int lli ) { 125 (ostype)(os | lli); if ( getANL( os ) ) nl( os ); 126 } // ?|? 95 127 96 128 ostype & ?|?( ostype & os, unsigned long long int ulli ) { … … 99 131 return os; 100 132 } // ?|? 133 void & ?|?( ostype & os, unsigned long long int ulli ) { 134 (ostype)(os | ulli); if ( getANL( os ) ) nl( os ); 135 } // ?|? 101 136 102 137 ostype & ?|?( ostype & os, float f ) { … … 105 140 return os; 106 141 } // ?|? 142 void & ?|?( ostype & os, float f ) { 143 (ostype)(os | f); if ( getANL( os ) ) nl( os ); 144 } // ?|? 107 145 108 146 ostype & ?|?( ostype & os, double d ) { … … 111 149 return os; 112 150 } // ?|? 151 void & ?|?( ostype & os, double d ) { 152 (ostype)(os | d); if ( getANL( os ) ) nl( os ); 153 } // ?|? 113 154 114 155 ostype & ?|?( ostype & os, long double ld ) { … … 117 158 return os; 118 159 } // ?|? 160 void & ?|?( ostype & os, long double ld ) { 161 (ostype)(os | ld); if ( getANL( os ) ) nl( os ); 162 } // ?|? 119 163 120 164 ostype & ?|?( ostype & os, float _Complex fc ) { … … 123 167 return os; 124 168 } // ?|? 169 void & ?|?( ostype & os, float _Complex fc ) { 170 (ostype)(os | fc); if ( getANL( os ) ) nl( os ); 171 } // ?|? 125 172 126 173 ostype & ?|?( ostype & os, double _Complex dc ) { … … 129 176 return os; 130 177 } // ?|? 178 void & ?|?( ostype & os, double _Complex dc ) { 179 (ostype)(os | dc); if ( getANL( os ) ) nl( os ); 180 } // ?|? 131 181 132 182 ostype & ?|?( ostype & os, long double _Complex ldc ) { … … 134 184 fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) ); 135 185 return os; 186 } // ?|? 187 void & ?|?( ostype & os, long double _Complex ldc ) { 188 (ostype)(os | ldc); if ( getANL( os ) ) nl( os ); 136 189 } // ?|? 137 190 … … 174 227 return write( os, str, len ); 175 228 } // ?|? 229 void ?|?( ostype & os, const char * str ) { 230 (ostype)(os | str); if ( getANL( os ) ) nl( os ); 231 } // ?|? 176 232 177 233 // ostype & ?|?( ostype & os, const char16_t * str ) { … … 200 256 return os; 201 257 } // ?|? 202 258 void ?|?( ostype & os, const void * p ) { 259 (ostype)(os | p); if ( getANL( os ) ) nl( os ); 260 } // ?|? 203 261 204 262 // manipulators 205 263 ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 206 return manip( os ); 264 (ostype)(manip( os )); 265 setNonl( os, false ); // ignore nonl in middle 266 return os; 267 } // ?|? 268 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 269 (ostype)(manip( os )); 270 if ( getANL( os ) && ! getNonl( os ) ) nl( os ); // ignore nl if nonl at end 271 setNonl( os, false ); 207 272 } // ?|? 208 273 209 274 ostype & sep( ostype & os ) { 210 os | sepGet( os ); 211 return os; 275 return (ostype)(os | sepGet( os )); 212 276 } // sep 213 277 214 278 ostype & sepTuple( ostype & os ) { 215 os | sepGetTuple( os ); 216 return os; 279 return os | sepGetTuple( os ); 217 280 } // sepTuple 218 281 219 ostype & endl( ostype & os ) {220 os | '\n';282 ostype & nl( ostype & os ) { 283 (ostype)(os | '\n'); 221 284 setNL( os, true ); 222 285 flush( os ); 223 sepOff( os ); // prepare for next line 224 return os; 225 } // endl 286 return sepOff( os ); // prepare for next line 287 } // nl 288 289 ostype & nonl( ostype & os ) { 290 setNonl( os, true ); // indicate nonl manipulator 291 return os; 292 } // nonl 226 293 227 294 ostype & sepOn( ostype & os ) { 228 sepOn( os ); 295 sepOn( os ); // call void returning 229 296 return os; 230 297 } // sepOn 231 298 232 299 ostype & sepOff( ostype & os ) { 233 sepOff( os ); 300 sepOff( os ); // call void returning 234 301 return os; 235 302 } // sepOff 236 303 237 304 ostype & sepEnable( ostype & os ) { 238 sepEnable( os ); 305 sepEnable( os ); // call void returning 239 306 return os; 240 307 } // sepEnable 241 308 242 309 ostype & sepDisable( ostype & os ) { 243 sepDisable( os ); 310 sepDisable( os ); // call void returning 244 311 return os; 245 312 } // sepDisable 313 314 ostype & nlOn( ostype & os ) { 315 nlOn( os ); // call void returning 316 return os; 317 } // nlOn 318 319 ostype & nlOff( ostype & os ) { 320 nlOff( os ); // call void returning 321 return os; 322 } // nlOff 246 323 } // distribution 247 324 248 249 325 // tuples 250 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 251 ostype & ?|?( ostype & os, T arg, Params rest ) { 252 os | arg; // print first argument 253 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 254 os | rest; // print remaining arguments 255 sepSetCur( os, sepGet( os ) ); // switch to regular separator 256 return os; 257 } // ?|? 326 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 327 ostype & ?|?( ostype & os, T arg, Params rest ) { 328 (ostype)(os | arg); // print first argument 329 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 330 (ostype)(os | rest); // print remaining arguments 331 sepSetCur( os, sepGet( os ) ); // switch to regular separator 332 return os; 333 } // ?|? 334 void ?|?( ostype & os, T arg, Params rest ) { 335 // (ostype)(?|?( os, arg, rest )); if ( getANL( os ) ) nl( os ); 336 (ostype)(os | arg); // print first argument 337 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 338 (ostype)(os | rest); // print remaining arguments 339 sepSetCur( os, sepGet( os ) ); // switch to regular separator 340 if ( getANL( os ) ) nl( os ); 341 } // ?|? 342 } // distribution 258 343 259 344 //--------------------------------------- 260 345 261 346 // writes the range [begin, end) to the given stream 262 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 263 void write( iterator_type begin, iterator_type end, ostype & os ) {264 void print( elt_type i ) { os | i; }265 for_each( begin, end, print );266 } // ?|?267 268 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 269 void write_reverse( iterator_type begin, iterator_type end, ostype & os ) { 270 void print( elt_type i ) { os | i; }271 for_each_reverse( begin, end, print );272 } // ?|?347 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) { 348 void write( iterator_type begin, iterator_type end, ostype & os ) { 349 void print( elt_type i ) { os | i; } 350 for_each( begin, end, print ); 351 } // ?|? 352 353 void write_reverse( iterator_type begin, iterator_type end, ostype & os ) { 354 void print( elt_type i ) { os | i; } 355 for_each_reverse( begin, end, print ); 356 } // ?|? 357 } // distribution 273 358 274 359 //--------------------------------------- … … 386 471 } // ?|? 387 472 388 istype & endl( istype & is ) {473 istype & nl( istype & is ) { 389 474 fmt( is, "%*[ \t\f\n\r\v]" ); // ignore whitespace 390 475 return is; 391 } // endl476 } // nl 392 477 } // distribution 393 478 -
libcfa/src/iostream.hfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 08:22:49201813 // Update Count : 15612 // Last Modified On : Tue Dec 11 22:01:31 2018 13 // Update Count : 213 14 14 // 15 15 … … 25 25 const char * sepGetCur( ostype & ); // get current separator string 26 26 void sepSetCur( ostype &, const char * ); // set current separator string 27 bool getNL( ostype & ); // check newline27 bool getNL( ostype & ); // check newline 28 28 void setNL( ostype &, bool ); // saw newline 29 bool getANL( ostype & ); // check auto newline 30 bool getNonl( ostype & ); // check nonnl manipulator 31 void setNonl( ostype &, bool ); // set nonnl manipulator 29 32 // public 30 33 void sepOn( ostype & ); // turn separator state on 31 34 void sepOff( ostype & ); // turn separator state off 32 35 bool sepDisable( ostype & ); // set default state to off, and return previous state 33 bool sepEnable( ostype & ); // set default state to on, and return previous state 36 bool sepEnable( ostype & ); // set default state to on, and return previous state 37 void nlOn( ostype & ); // turn auto-newline state on 38 void nlOff( ostype & ); // turn auto-newline state off 34 39 35 40 const char * sepGet( ostype & ); // get separator string … … 58 63 forall( dtype ostype | ostream( ostype ) ) { 59 64 ostype & ?|?( ostype &, bool ); 65 void & ?|?( ostype &, bool ); 60 66 61 67 ostype & ?|?( ostype &, char ); 68 void & ?|?( ostype &, char ); 62 69 ostype & ?|?( ostype &, signed char ); 70 void & ?|?( ostype &, signed char ); 63 71 ostype & ?|?( ostype &, unsigned char ); 72 void & ?|?( ostype &, unsigned char ); 64 73 65 74 ostype & ?|?( ostype &, short int ); 75 void & ?|?( ostype &, short int ); 66 76 ostype & ?|?( ostype &, unsigned short int ); 77 void & ?|?( ostype &, unsigned short int ); 67 78 ostype & ?|?( ostype &, int ); 79 void & ?|?( ostype &, int ); 68 80 ostype & ?|?( ostype &, unsigned int ); 81 void & ?|?( ostype &, unsigned int ); 69 82 ostype & ?|?( ostype &, long int ); 83 void & ?|?( ostype &, long int ); 70 84 ostype & ?|?( ostype &, long long int ); 85 void & ?|?( ostype &, long long int ); 71 86 ostype & ?|?( ostype &, unsigned long int ); 87 void & ?|?( ostype &, unsigned long int ); 72 88 ostype & ?|?( ostype &, unsigned long long int ); 89 void & ?|?( ostype &, unsigned long long int ); 73 90 74 91 ostype & ?|?( ostype &, float ); // FIX ME: should not be required 92 void & ?|?( ostype &, float ); // FIX ME: should not be required 75 93 ostype & ?|?( ostype &, double ); 94 void & ?|?( ostype &, double ); 76 95 ostype & ?|?( ostype &, long double ); 96 void & ?|?( ostype &, long double ); 77 97 78 98 ostype & ?|?( ostype &, float _Complex ); 99 void & ?|?( ostype &, float _Complex ); 79 100 ostype & ?|?( ostype &, double _Complex ); 101 void & ?|?( ostype &, double _Complex ); 80 102 ostype & ?|?( ostype &, long double _Complex ); 103 void & ?|?( ostype &, long double _Complex ); 81 104 82 105 ostype & ?|?( ostype &, const char * ); 106 void & ?|?( ostype &, const char * ); 83 107 // ostype & ?|?( ostype &, const char16_t * ); 84 108 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 87 111 // ostype & ?|?( ostype &, const wchar_t * ); 88 112 ostype & ?|?( ostype &, const void * ); 113 void & ?|?( ostype &, const void * ); 89 114 90 115 // manipulators 91 116 ostype & ?|?( ostype &, ostype & (*)( ostype & ) ); 92 ostype & endl( ostype & ); 117 void ?|?( ostype &, ostype & (*)( ostype & ) ); 118 ostype & nl( ostype & ); 119 ostype & nonl( ostype & ); 93 120 ostype & sep( ostype & ); 94 121 ostype & sepTuple( ostype & ); … … 97 124 ostype & sepDisable( ostype & ); 98 125 ostype & sepEnable( ostype & ); 126 ostype & nlOn( ostype & ); 127 ostype & nlOff( ostype & ); 99 128 } // distribution 100 129 101 130 // tuples 102 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 103 ostype & ?|?( ostype & os, T arg, Params rest ); 131 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 132 ostype & ?|?( ostype & os, T arg, Params rest ); 133 void ?|?( ostype & os, T arg, Params rest ); 134 } // distribution 104 135 105 136 // writes the range [begin, end) to the given stream 106 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 107 void write( iterator_type begin, iterator_type end, ostype & os ); 108 109 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 110 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); 137 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) { 138 void write( iterator_type begin, iterator_type end, ostype & os ); 139 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); 140 } // distribution 111 141 112 142 //--------------------------------------- … … 152 182 // manipulators 153 183 istype & ?|?( istype &, istype & (*)( istype & ) ); 154 istype & endl( istype & is );184 istype & nl( istype & is ); 155 185 } // distribution 156 186 … … 164 194 165 195 166 #include <time_t.hfa> // Duration (constructors) / Time (constructors) 167 168 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur ); 169 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time ); 170 196 #include <time_t.hfa> // Duration (constructors) / Time (constructors) 197 198 forall( dtype ostype | ostream( ostype ) ) { 199 ostype & ?|?( ostype & os, Duration dur ); 200 void ?|?( ostype & os, Duration dur ); 201 ostype & ?|?( ostype & os, Time time ); 202 void ?|?( ostype & os, Time time ); 203 } // distribution 171 204 172 205 // Local Variables: // -
libcfa/src/rational.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 2 09:24:33201813 // Update Count : 16 212 // Last Modified On : Tue Dec 11 22:02:29 2018 13 // Update Count : 168 14 14 // 15 15 … … 35 35 static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) { 36 36 if ( d == (RationalImpl){0} ) { 37 serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;37 serr | "Invalid rational number construction: denominator cannot be equal to 0."; 38 38 exit( EXIT_FAILURE ); 39 39 } // exit … … 175 175 } // ?|? 176 176 177 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 178 ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) { 179 return os | r.numerator | '/' | r.denominator; 180 } // ?|? 177 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) { 178 ostype & ?|?( ostype & os, Rational(RationalImpl) r ) { 179 return os | r.numerator | '/' | r.denominator; 180 } // ?|? 181 182 void ?|?( ostype & os, Rational(RationalImpl) r ) { 183 (ostype)(os | r); if ( getANL( os ) ) nl( os ); 184 } // ?|? 185 } // distribution 181 186 } // distribution 182 187 -
libcfa/src/rational.hfa
r29207bf r5ebb1368 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Sat Jun 2 09:10:01201815 // Update Count : 10 514 // Last Modified On : Tue Dec 4 23:07:46 2018 15 // Update Count : 106 16 16 // 17 17 … … 92 92 istype & ?|?( istype &, Rational(RationalImpl) & ); 93 93 94 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 95 ostype & ?|?( ostype &, Rational(RationalImpl ) ); 94 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) { 95 ostype & ?|?( ostype &, Rational(RationalImpl) ); 96 void ?|?( ostype &, Rational(RationalImpl) ); 97 } // distribution 96 98 } // distribution 97 99 -
libcfa/src/time.cfa
r29207bf r5ebb1368 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:26:00201813 // Update Count : 3712 // Last Modified On : Tue Dec 11 21:32:15 2018 13 // Update Count : 53 14 14 // 15 15 … … 31 31 32 32 33 forall( dtype ostype | ostream( ostype ) ) 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 os | tv / TIMEGRAN; // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 if ( ns != 0 ) { // some ? 38 char buf[16]; 39 os | nanomsd( ns, buf ); // print nanoseconds 40 } // if 41 return os; 42 } // ?|? 33 forall( dtype ostype | ostream( ostype ) ) { 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 (ostype)(os | tv / TIMEGRAN); // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 if ( ns != 0 ) { // some ? 38 char buf[16]; 39 (ostype)(os | nanomsd( ns, buf )); // print nanoseconds 40 } // if 41 return os; 42 } // ?|? 43 44 void ?|?( ostype & os, Duration dur ) with( dur ) { 45 (ostype)(os | dur); if ( getANL( os ) ) nl( os ); 46 } // ?|? 47 } // distribution 43 48 44 49 … … 137 142 } // strftime 138 143 139 forall( dtype ostype | ostream( ostype ) ) 140 ostype & ?|?( ostype & os, Time time ) with( time ) { 141 char buf[32]; // at least 26 142 time_t s = tv / TIMEGRAN; 143 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 144 buf[24] = '\0'; // remove trailing '\n' 145 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 146 if ( ns == 0 ) { // none ? 147 os | buf; // print date/time/year 148 } else { 149 buf[19] = '\0'; // truncate to "Wed Jun 30 21:49:08" 150 os | buf; // print date/time 151 char buf2[16]; 152 nanomsd( ns, buf2 ); // compute nanoseconds 153 os | buf2 | ' ' | &buf[20]; // print nanoseconds and year 154 } // if 155 return os; 156 } // ?|? 144 forall( dtype ostype | ostream( ostype ) ) { 145 ostype & ?|?( ostype & os, Time time ) with( time ) { 146 char buf[32]; // at least 26 147 time_t s = tv / TIMEGRAN; 148 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 149 buf[24] = '\0'; // remove trailing '\n' 150 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 151 if ( ns == 0 ) { // none ? 152 (ostype)(os | buf); // print date/time/year 153 } else { 154 buf[19] = '\0'; // truncate to "Wed Jun 30 21:49:08" 155 char buf2[16]; 156 nanomsd( ns, buf2 ); // compute nanoseconds 157 (ostype)(os | buf | buf2 | ' ' | &buf[20]); // print date/time, nanoseconds and year 158 } // if 159 return os; 160 } // ?|? 161 162 void ?|?( ostype & os, Time time ) with( time ) { 163 (ostype)(os | time); if ( getANL( os ) ) nl( os ); 164 } // ?|? 165 } // distribution 157 166 158 167 // Local Variables: // -
tests/abs.cfa
r29207bf r5ebb1368 10 10 // Created On : Thu Jan 28 18:26:16 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:50:44201813 // Update Count : 5 412 // Last Modified On : Tue Dec 4 21:33:15 2018 13 // Update Count : 55 14 14 // 15 15 … … 19 19 int main( void ) { 20 20 signed char ch = -65; 21 sout | "char\t\t\t" | ch | "\tabs " | abs( ch ) | endl;22 sout | "signed int\t\t" | -65 | "\tabs" | abs( -65 ) | endl;23 sout | "signed long int\t\t" | -65l | "\tabs" | abs( -65l ) | endl;24 sout | "signed long long int\t" | -65ll | "\tabs" | abs( -65ll ) | endl;25 sout | "float\t\t\t" | -65.0f | "\tabs" | abs( -65.0f ) | endl;26 sout | "double\t\t\t" | -65.0 | "\tabs" | abs( -65.0 ) | endl;27 sout | "long double\t\t" | -65.0l | "\tabs" | abs( -65.0l ) | endl;28 sout | "float _Complex\t\t" | -65.0F-2.0iF | "\tabs" | abs( -65.0F-2.0iF ) | endl;29 sout | "double _Complex\t\t" | -65.0D-2.0iD | "\tabs" | abs( -65.0D-2.0iD ) | endl;30 sout | "long double _Complex\t" | -65.0L-2.0iL | "\tabs" | abs( -65.0L-2.0iL ) | endl;21 sout | "char\t\t\t" | ch | "\tabs " | abs( ch ); 22 sout | "signed int\t\t" | -65 | "\tabs" | abs( -65 ); 23 sout | "signed long int\t\t" | -65l | "\tabs" | abs( -65l ); 24 sout | "signed long long int\t" | -65ll | "\tabs" | abs( -65ll ); 25 sout | "float\t\t\t" | -65.0f | "\tabs" | abs( -65.0f ); 26 sout | "double\t\t\t" | -65.0 | "\tabs" | abs( -65.0 ); 27 sout | "long double\t\t" | -65.0l | "\tabs" | abs( -65.0l ); 28 sout | "float _Complex\t\t" | -65.0F-2.0iF | "\tabs" | abs( -65.0F-2.0iF ); 29 sout | "double _Complex\t\t" | -65.0D-2.0iD | "\tabs" | abs( -65.0D-2.0iD ); 30 sout | "long double _Complex\t" | -65.0L-2.0iL | "\tabs" | abs( -65.0L-2.0iL ); 31 31 } // main 32 32 -
tests/ato.cfa
r29207bf r5ebb1368 10 10 // Created On : Thu Feb 4 08:10:57 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:51:03 201813 // Update Count : 9 112 // Last Modified On : Tue Dec 4 21:33:53 2018 13 // Update Count : 92 14 14 // 15 15 … … 20 20 const char * sptr = "-123"; 21 21 int i = ato( sptr ); 22 sout | i | sptr | endl;22 sout | i | sptr; 23 23 sptr = "123"; 24 24 unsigned int ui = ato( sptr ); 25 sout | ui | sptr | endl;25 sout | ui | sptr; 26 26 27 27 sptr = "-123"; 28 28 long int li = ato( sptr ); 29 sout | li | sptr | endl;29 sout | li | sptr; 30 30 sptr = "123"; 31 31 unsigned long int uli = ato( sptr ); 32 sout | uli | sptr | endl;32 sout | uli | sptr; 33 33 34 34 sptr = "-123"; 35 35 long long int lli = ato( sptr ); 36 sout | lli | sptr | endl;36 sout | lli | sptr; 37 37 sptr = "123"; 38 38 unsigned long long int ulli = ato( sptr ); 39 sout | ulli | sptr | endl;39 sout | ulli | sptr; 40 40 41 41 sptr = "-123.456"; 42 42 float f = ato( sptr ); 43 sout | f | sptr | endl;43 sout | f | sptr; 44 44 sptr = "-123.4567890123456"; 45 45 double d = ato( sptr ); 46 sout | d | sptr | endl;46 sout | d | sptr; 47 47 sptr = "-123.45678901234567890123456789"; 48 48 long double ld = ato( sptr ); 49 sout | ld | sptr | endl;49 sout | ld | sptr; 50 50 51 51 sptr = "-123.456-123.456i"; 52 52 float _Complex fc = ato( sptr ); 53 sout | fc | sptr | endl;53 sout | fc | sptr; 54 54 sptr = "-123.4567890123456+123.4567890123456i"; 55 55 double _Complex dc = ato( sptr ); 56 sout | dc | sptr | endl;56 sout | dc | sptr; 57 57 sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; 58 58 long double _Complex ldc = ato( sptr ); 59 sout | ldc | sptr | endl;59 sout | ldc | sptr; 60 60 sptr = "123.45678901234-123.4567890i"; 61 61 long double _Complex ldc2 = ato( sptr ); 62 sout | ldc2 | sptr | endl;62 sout | ldc2 | sptr; 63 63 64 64 65 65 sptr = "-123"; 66 66 i = strto( sptr, 0, 10 ); 67 sout | i | sptr | endl;67 sout | i | sptr; 68 68 sptr = "123"; 69 69 ui = strto( sptr, 0, 10 ); 70 sout | ui | sptr | endl;70 sout | ui | sptr; 71 71 72 72 sptr = "-123"; 73 73 li = strto( sptr, 0, 10 ); 74 sout | li | sptr | endl;74 sout | li | sptr; 75 75 sptr = "123"; 76 76 uli = strto( sptr, 0, 10 ); 77 sout | uli | sptr | endl;77 sout | uli | sptr; 78 78 79 79 sptr = "-123"; 80 80 lli = strto( sptr, 0, 10 ); 81 sout | lli | sptr | endl;81 sout | lli | sptr; 82 82 sptr = "123"; 83 83 ulli = strto( sptr, 0, 10 ); 84 sout | ulli | sptr | endl;84 sout | ulli | sptr; 85 85 86 86 sptr = "-123.456"; 87 87 f = strto( sptr, 0 ); 88 sout | f | sptr | endl;88 sout | f | sptr; 89 89 sptr = "-123.4567890123456"; 90 90 d = strto( sptr, 0 ); 91 sout | d | sptr | endl;91 sout | d | sptr; 92 92 sptr = "-123.45678901234567890123456789"; 93 93 ld = strto( sptr, 0 ); 94 sout | ld | sptr | endl;94 sout | ld | sptr; 95 95 96 96 sptr = "-123.456-123.456i"; 97 97 fc = strto( sptr, 0 ); 98 sout | fc | sptr | endl;98 sout | fc | sptr; 99 99 100 100 char * eptr = 0; 101 101 // sptr = "2fred"; 102 102 // fc = strto( sptr, &eptr ); 103 // sout | fc | sptr | eptr | endl;103 // sout | fc | sptr | eptr; 104 104 105 105 sptr = "2 3"; 106 106 fc = strto( sptr, &eptr ); 107 sout | fc | sptr | eptr | endl;107 sout | fc | sptr | eptr; 108 108 109 109 sptr = "-123.4567890123456+123.4567890123456i"; 110 110 dc = strto( sptr, 0 ); 111 sout | dc | sptr | endl;111 sout | dc | sptr; 112 112 sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; 113 113 ldc = strto( sptr, 0 ); 114 sout | ldc | sptr | endl;114 sout | ldc | sptr; 115 115 sptr = "123.45678901234-123.4567890i"; 116 116 ldc2 = strto( sptr, 0 ); 117 sout | ldc2 | sptr | endl;117 sout | ldc2 | sptr; 118 118 } // main 119 119 -
tests/complex.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 24 22:07:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:51:22201813 // Update Count : 312 // Last Modified On : Tue Dec 4 21:34:21 2018 13 // Update Count : 4 14 14 // 15 15 … … 25 25 printf( "x:%g+%gi y:%g+%gi z:%g+%gi\n", creal(x), cimag(x), creal(y), cimag(y), creal(z), cimag(z) ); 26 26 #ifdef __CFA__ 27 sout | "x:" | x | "y:" | y | "z:" | z | endl;27 sout | "x:" | x | "y:" | y | "z:" | z; 28 28 #endif // __CFA 29 29 x = 2.1 + 1.3i; … … 32 32 printf( "x:%g+%gi y:%g+%gi z:%g+%gi\n", creal(x), cimag(x), creal(y), cimag(y), creal(z), cimag(z) ); 33 33 #ifdef __CFA__ 34 sout | "x:" | x | "y:" | y | "z:" | z | endl;34 sout | "x:" | x | "y:" | y | "z:" | z; 35 35 #endif // __CFA 36 36 } -
tests/concurrent/coroutineYield.c
r29207bf r5ebb1368 27 27 while(true) { 28 28 #if !defined(TEST_FOREVER) 29 sout | "Coroutine 1" | endl;29 sout | "Coroutine 1"; 30 30 #endif 31 31 yield(); 32 32 #if !defined(TEST_FOREVER) 33 sout | "Coroutine 2" | endl;33 sout | "Coroutine 2"; 34 34 #endif 35 35 suspend(); … … 42 42 for(int i = 0; TEST(i < N); i++) { 43 43 #if !defined(TEST_FOREVER) 44 sout | "Thread 1" | endl;44 sout | "Thread 1"; 45 45 #endif 46 46 resume(c); 47 47 #if !defined(TEST_FOREVER) 48 sout | "Thread 2" | endl;48 sout | "Thread 2"; 49 49 #endif 50 50 yield(); -
tests/concurrent/examples/boundedBufferEXT.c
r29207bf r5ebb1368 8 8 // Created On : Wed Apr 18 22:52:12 2018 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : T hu Aug 16 08:17:03201811 // Update Count : 810 // Last Modified On : Tue Dec 11 21:55:02 2018 11 // Update Count : 9 12 12 // 13 13 … … 115 115 sum += sums[i]; 116 116 } // for 117 sout | "total:" | sum | endl;117 sout | "total:" | sum; 118 118 } 119 119 -
tests/concurrent/examples/boundedBufferINT.c
r29207bf r5ebb1368 8 8 // Created On : Mon Oct 30 12:45:13 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : T hu Aug 16 08:17:58201811 // Update Count : 8 310 // Last Modified On : Tue Dec 11 21:55:45 2018 11 // Update Count : 84 12 12 // 13 13 … … 116 116 sum += sums[i]; 117 117 } // for 118 sout | "total:" | sum | endl;118 sout | "total:" | sum; 119 119 } 120 120 -
tests/concurrent/examples/datingService.c
r29207bf r5ebb1368 8 8 // Created On : Mon Oct 30 12:56:20 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Sun May 27 09:05:18201811 // Update Count : 2 610 // Last Modified On : Tue Dec 11 21:55:34 2018 11 // Update Count : 28 12 12 // 13 13 … … 58 58 yield( random( 100 ) ); // don't all start at the same time 59 59 unsigned int partner = girl( TheExchange, id, ccode ); 60 sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;60 sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode; 61 61 girlck[id] = partner; 62 62 } // Girl main … … 69 69 70 70 thread Boy { 71 DatingService & TheExchange;71 DatingService & TheExchange; 72 72 unsigned int id, ccode; 73 73 }; // Boy … … 76 76 yield( random( 100 ) ); // don't all start at the same time 77 77 unsigned int partner = boy( TheExchange, id, ccode ); 78 sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;78 sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode; 79 79 boyck[id] = partner; 80 80 } // Boy main -
tests/concurrent/examples/matrixSum.c
r29207bf r5ebb1368 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Nov 6 17:51:32201814 // Update Count : 1 413 // Last Modified On : Tue Dec 11 21:54:55 2018 14 // Update Count : 15 15 15 // 16 16 … … 54 54 total += subtotals[r]; // total subtotals 55 55 } // for 56 sout | total | endl;56 sout | total; 57 57 } 58 58 -
tests/concurrent/examples/quickSort.c
r29207bf r5ebb1368 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : T hu Aug 16 08:17:41201812 // Update Count : 16 311 // Last Modified On : Tue Dec 4 18:00:27 2018 12 // Update Count : 167 13 13 // 14 14 … … 88 88 89 89 void usage( char * argv[] ) { 90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl;90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )"; 91 91 exit( EXIT_FAILURE ); // TERMINATE! 92 92 } // usage … … 114 114 &sortedfile = new( (const char *)argv[2] ); // open the output file 115 115 if ( fail( sortedfile ) ) { 116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl;116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\""; 117 117 usage( argv ); 118 118 } // if … … 121 121 &unsortedfile = new( (const char *)argv[1] ); // open the input file 122 122 if ( fail( unsortedfile ) ) { 123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl;123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\""; 124 124 usage( argv ); 125 125 } // if … … 127 127 } // if 128 128 } // if 129 sortedfile | nlOff; // turn off auto newline 129 130 130 131 enum { ValuesPerLine = 22 }; // number of values printed per line … … 137 138 for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers 138 139 unsortedfile | values[counter]; 139 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";140 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 140 141 sortedfile | values[counter]; 141 142 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 142 143 } // for 143 sortedfile | endl;144 sortedfile | nl; 144 145 if ( size > 0 ) { // values to sort ? 145 146 Quicksort QS = { values, size - 1, 0 }; // sort values 146 147 } // wait until sort tasks terminate 147 148 for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list 148 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";149 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 149 150 sortedfile | values[counter]; 150 151 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 151 152 } // for 152 sortedfile | endl | endl;153 sortedfile | nl; 153 154 154 155 delete( values ); -
tests/concurrent/monitor.c
r29207bf r5ebb1368 40 40 MyThread f[4]; 41 41 } 42 sout | global.value | endl;42 sout | global.value; 43 43 } -
tests/concurrent/multi-monitor.c
r29207bf r5ebb1368 52 52 } 53 53 } 54 sout | global12 | global23 | global13 | endl;54 sout | global12 | global23 | global13; 55 55 } -
tests/concurrent/signal/block.c
r29207bf r5ebb1368 57 57 58 58 if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) { 59 sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread | endl;59 sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread; 60 60 abort(); 61 61 } … … 85 85 86 86 if( ! signal_block( cond ) ) { 87 sout | "ERROR expected to be able to signal" | endl;87 sout | "ERROR expected to be able to signal"; 88 88 abort(); 89 89 } … … 92 92 93 93 if(a.last_thread != next || b.last_thread != next) { 94 sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread | endl;94 sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread; 95 95 abort(); 96 96 } … … 130 130 Signaller s[4]; 131 131 Barger b[13]; 132 sout | "Starting waiters" | endl;132 sout | "Starting waiters"; 133 133 { 134 134 Waiter w[3]; 135 135 } 136 sout | "Waiters done" | endl;136 sout | "Waiters done"; 137 137 done = true; 138 138 } -
tests/concurrent/signal/disjoint.c
r29207bf r5ebb1368 66 66 wait( cond ); 67 67 if( d.state != SIGNAL ) { 68 sout | "ERROR barging!" | endl;68 sout | "ERROR barging!"; 69 69 } 70 70 71 71 #if !defined(TEST_FOREVER) 72 72 d.counter++; 73 if( (d.counter % 1000) == 0 ) sout | d.counter | endl;73 if( (d.counter % 1000) == 0 ) sout | d.counter; 74 74 #endif 75 75 … … 99 99 bool running = TEST(data.counter < N) && data.counter > 0; 100 100 if( data.state != SIGNAL && running ) { 101 sout | "ERROR Eager signal" | data.state | endl;101 sout | "ERROR Eager signal" | data.state; 102 102 } 103 103 } … … 124 124 Waiter w[4]; 125 125 } 126 sout | "All waiter done" | endl;126 sout | "All waiter done"; 127 127 all_done = true; 128 128 } -
tests/concurrent/signal/wait.c
r29207bf r5ebb1368 83 83 break; 84 84 default: 85 sout | "Something went wrong" | endl;85 sout | "Something went wrong"; 86 86 abort(); 87 87 } … … 140 140 waiter_left = 4; 141 141 processor p[2]; 142 sout | "Starting" | endl;142 sout | "Starting"; 143 143 { 144 144 Signaler e; … … 150 150 } 151 151 } 152 sout | "Done" | endl;152 sout | "Done"; 153 153 } -
tests/concurrent/thread.c
r29207bf r5ebb1368 12 12 void main(First& this) { 13 13 for(int i = 0; i < 10; i++) { 14 sout | "First : Suspend No." | i + 1 | endl;14 sout | "First : Suspend No." | i + 1; 15 15 yield(); 16 16 } … … 21 21 P(*this.lock); 22 22 for(int i = 0; i < 10; i++) { 23 sout | "Second : Suspend No." | i + 1 | endl;23 sout | "Second : Suspend No." | i + 1; 24 24 yield(); 25 25 } … … 29 29 int main(int argc, char* argv[]) { 30 30 semaphore lock = { 0 }; 31 sout | "User main begin" | endl;31 sout | "User main begin"; 32 32 { 33 33 processor p; … … 37 37 } 38 38 } 39 sout | "User main end" | endl;39 sout | "User main end"; 40 40 } -
tests/concurrent/waitfor/barge.c
r29207bf r5ebb1368 48 48 yield(random( 10 )); 49 49 if( this.state != WAITFOR && !this.done && this.started ) { 50 serr | "Barging before caller detected" | endl;50 serr | "Barging before caller detected"; 51 51 } 52 52 … … 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { 68 sout | i | endl;68 sout | i; 69 69 } 70 70 71 71 if( this.state != CALL ) { 72 serr | "Barging after caller detected" | endl;72 serr | "Barging after caller detected"; 73 73 } 74 74 } … … 83 83 84 84 int main() { 85 sout | "Starting" | endl;85 sout | "Starting"; 86 86 { 87 87 barger_t bargers[17]; … … 89 89 waiter_t waiters; 90 90 } 91 sout | "Stopping" | endl;91 sout | "Stopping"; 92 92 } -
tests/concurrent/waitfor/dtor.c
r29207bf r5ebb1368 29 29 switch(state) { 30 30 case CTOR : break; 31 case MAIN : if( this.state != CTOR ) { serr | "ERROR Expected state to be CTOR" | endl; abort(); } this.state = state; break;32 case AFTER : if( this.state != MAIN ) { serr | "ERROR Expected state to be MAIN" | endl; abort(); } this.state = state; break;33 case END : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER" | endl; abort(); } this.state = state; break;34 case DTOR : if( this.state != END ) { serr | "ERROR Expected state to be END" | endl; abort(); } this.state = state; break;31 case MAIN : if( this.state != CTOR ) { serr | "ERROR Expected state to be CTOR" ; abort(); } this.state = state; break; 32 case AFTER : if( this.state != MAIN ) { serr | "ERROR Expected state to be MAIN" ; abort(); } this.state = state; break; 33 case END : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER"; abort(); } this.state = state; break; 34 case DTOR : if( this.state != END ) { serr | "ERROR Expected state to be END" ; abort(); } this.state = state; break; 35 35 } 36 36 } … … 54 54 55 55 int main() { 56 sout | "Starting" | endl;56 sout | "Starting"; 57 57 processor p; 58 58 for( int i = 0; i < N; i++ ){ … … 60 60 yield( random( 100 ) ); 61 61 } 62 sout | "Stopping" | endl;62 sout | "Stopping"; 63 63 } -
tests/concurrent/waitfor/else.c
r29207bf r5ebb1368 12 12 void test( M & mutex m ) { 13 13 int i = 0; 14 sout | "Starting" | endl;14 sout | "Starting"; 15 15 16 16 when( false ) waitfor( notcalled, m ); 17 17 18 sout | "Step" | i++ | endl;18 sout | "Step" | i++; 19 19 20 20 waitfor( notcalled, m ); or else { 21 sout | "else called" | endl;21 sout | "else called"; 22 22 } 23 23 24 sout | "Step" | i++ | endl;24 sout | "Step" | i++; 25 25 26 26 when( true ) waitfor( notcalled, m ); or when( true ) else { 27 sout | "else called" | endl;27 sout | "else called"; 28 28 } 29 29 30 sout | "Step" | i++ | endl;30 sout | "Step" | i++; 31 31 32 32 when( false ) waitfor( notcalled, m ); or when( true ) else { 33 sout | "else called" | endl;33 sout | "else called"; 34 34 } 35 35 36 sout | "Step" | i++ | endl;36 sout | "Step" | i++; 37 37 38 38 when( false ) waitfor( notcalled, m ); or when( false ) else { 39 sout | "else called" | endl;39 sout | "else called"; 40 40 } 41 41 42 sout | "Done" | endl;42 sout | "Done"; 43 43 } 44 44 -
tests/concurrent/waitfor/recurse.c
r29207bf r5ebb1368 95 95 rand_yield(); 96 96 97 sout | "1st" | endl;97 sout | "1st" | nl; 98 98 99 99 return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP; … … 123 123 case THIRD : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break; 124 124 case LAST : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break; 125 case STOP : serr | "This should not happen" | endl;125 case STOP : serr | "This should not happen" | nl; 126 126 } 127 127 } … … 132 132 int main() { 133 133 srandom( time(NULL) ); 134 sout | "Starting" | endl; 134 sout | nlOff; // turn off auto newline 135 sout | "Starting" | nl; 135 136 { 136 137 waiter_t waiters[4] = { … … 142 143 the_threads = waiters; 143 144 } 144 sout | "Stopping" | endl;145 sout | "Stopping" | nl; 145 146 } -
tests/concurrent/waitfor/simple.c
r29207bf r5ebb1368 31 31 32 32 void do_wait( global_t * mutex a ) { 33 sout | "Waiting to accept" | endl;33 sout | "Waiting to accept"; 34 34 yield( random( 10 ) ); 35 35 36 sout | "Accepting" | endl;36 sout | "Accepting"; 37 37 38 38 __acceptable_t acceptable; … … 43 43 __waitfor_internal( 1, &acceptable ); 44 44 45 sout | "Accepted" | endl;45 sout | "Accepted"; 46 46 yield( random( 10 ) ); 47 47 } … … 50 50 for( int i = 0; i < N; i++ ) { 51 51 do_wait( &globalA ); 52 sout | i | endl;52 sout | i; 53 53 } 54 54 … … 76 76 srandom( time( NULL ) ); 77 77 printf("%p\n", &globalA); 78 sout | "Starting" | endl;78 sout | "Starting"; 79 79 { 80 80 Acceptor r; … … 82 82 83 83 } 84 sout | "Done" | endl;84 sout | "Done"; 85 85 } -
tests/concurrent/waitfor/statment.c
r29207bf r5ebb1368 84 84 case 7: return call7( m ); 85 85 default : 86 serr | "Incorrect index" | index | endl;86 serr | "Incorrect index" | index; 87 87 abort(); 88 88 } … … 102 102 while( !done ) { 103 103 waitfor( get_index, this ); 104 or waitfor( call1, this ) { sout | "Statement" | endl; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val | endl; } }105 or waitfor( call2, this ) { sout | "Statement" | endl; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val | endl; } }106 or waitfor( call3, this ) { sout | "Statement" | endl; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val | endl; } }107 or waitfor( call4, this ) { sout | "Statement" | endl; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val | endl; } }108 or waitfor( call5, this ) { sout | "Statement" | endl; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val | endl; } }109 or waitfor( call6, this ) { sout | "Statement" | endl; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val | endl; } }110 or waitfor( call7, this ) { sout | "Statement" | endl; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val | endl; } }104 or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } } 105 or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } } 106 or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } } 107 or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } } 108 or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } } 109 or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } } 110 or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } } 111 111 112 112 done = true; … … 128 128 int main() { 129 129 processor p[2]; 130 sout | "Starting" | endl;130 sout | "Starting"; 131 131 { 132 132 caller c[7]; 133 133 waiter w; 134 134 } 135 sout | "Stopping" | endl;135 sout | "Stopping"; 136 136 } -
tests/concurrent/waitfor/when.c
r29207bf r5ebb1368 58 58 void arbiter( global_t & mutex this ) { 59 59 for( int i = 0; i < N; i++ ) { 60 when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call | endl; } }61 or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call | endl; } }62 or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call | endl; } }63 or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call | endl; } }64 or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call | endl; } }65 or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call | endl; } }60 when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } } 61 or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } } 62 or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } } 63 or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } } 64 or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } } 65 or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } } 66 66 67 sout | this.last_call | endl;67 sout | this.last_call; 68 68 } 69 69 … … 78 78 int main() { 79 79 srandom( time(NULL) ); 80 sout | "Starting" | endl;80 sout | "Starting"; 81 81 { 82 82 arbiter_t arbiter; … … 84 84 85 85 } 86 sout | "Stopping" | endl;86 sout | "Stopping"; 87 87 } -
tests/coroutine/.expect/fmtLines.txt
r29207bf r5ebb1368 16 16 difi ed B y : Pete r A. 17 17 Buh r// Last Mod ifie 18 d On : M on S ep 1 8 1119 :3 5: 57 2 017/ / Up date20 Cou nt : 3 1/ /#in18 d On : T ue D ec 1 1 23 19 :31: 12 2 018/ / Up date 20 Cou nt : 32/ /#in 21 21 clud e <f stre am.h fa># 22 22 incl ude <cor outi ne.h … … 34 34 t ) { if ( fm t.g 35 35 != 0 || fmt. b != 0 ) 36 sou t | endl ;}vo id m 37 ain( For mat & fm t ) 38 { fo r ( ;; ) { 39 // f or a s ma ny c 40 hara cter s f or ( fmt 41 .g = 0; fmt. g < 5; f 42 mt.g += 1 ) { / / gr 43 oups of 5 bl ocks f 44 or ( fmt .b = 0; fmt. 45 b < 4; f mt.b += 1 ) 46 { // blo cks of 4 cha 47 ract ers f or ( ;; 48 ) { // for new 49 line cha ract ers 50 susp end( ); i f ( 51 fmt. ch ! = '\ n' ) bre 52 ak; // igno re n ewli 53 ne } // f or so 54 ut | fmt .ch; / 55 / pr int char acte r 56 } // for s out | " 57 "; / / pr int 58 bloc k se para tor } / 59 / fo r s out | en dl; 60 // p rint gro 61 up s epar ator } / / fo 62 r} / / ma invo id p rt( 63 Form at & fmt , ch ar c 64 h ) { fmt .ch = ch 65 ; res ume( fmt );} 66 // prti nt m ain( ) { 67 Form at f mt; char ch; 68 for ( ; ; ) { s in | 69 ch; // rea 70 d on e ch arac ter if 71 ( e of( sin ) ) brea 72 k; // eof ? p 73 rt( fmt, ch ); } // 74 for} // main // L ocal 75 Var iabl es: //// tab 76 -wid th: 4 // // c ompi 77 le-c omma nd: "cfa fmt 78 Line s.c" /// / En d: / 79 / 36 sou t | nl;} void mai 37 n( F orma t & fmt ) { 38 for ( ;; ) { 39 // for as many cha 40 ract ers for ( f mt.g 41 = 0 ; fm t.g < 5; fmt 42 .g + = 1 ) { // grou 43 ps o f 5 bloc ks for 44 ( f mt.b = 0 ; fm t.b 45 < 4; fmt .b + = 1 ) { 46 // b lock s of 4 c hara 47 cter s for ( ; ; ) 48 { // f or n ewli 49 ne c hara cter s su 50 spen d(); if ( fm 51 t.ch != '\n' ) b reak 52 ; / / ig nore new line 53 } // for sout 54 | f mt.c h; // 55 prin t ch arac ter } 56 // f or sou t | " " 57 ; // prin t bl 58 ock sepa rato r } // 59 for sou t | nl; 60 // p rint gro up s 61 epar ator } / / fo r} / 62 / ma invo id p rt( Form 63 at & fmt , ch ar c h ) 64 { fmt .ch = ch ; 65 res ume( fmt );} // 66 prti nt m ain( ) { Form 67 at f mt; char ch; for 68 ( ; ; ) { s in | ch; 69 // rea d on 70 e ch arac ter if ( e 71 of( sin ) ) brea k; 72 // eof ? p rt( 73 fmt, ch ); } // for} 74 // main // L ocal Var 75 iabl es: //// tab -wid 76 th: 4 // // c ompi le-c 77 omma nd: "cfa fmt Line 78 s.c" /// / En d: / / -
tests/coroutine/.in/fmtLines.txt
r29207bf r5ebb1368 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 18 11:35:57 201713 // Update Count : 3 112 // Last Modified On : Tue Dec 11 23:31:12 2018 13 // Update Count : 32 14 14 // 15 15 … … 27 27 28 28 void ^?{}( Format & fmt ) { 29 if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;29 if ( fmt.g != 0 || fmt.b != 0 ) sout | nl; 30 30 } 31 31 … … 42 42 sout | " "; // print block separator 43 43 } // for 44 sout | endl; // print group separator44 sout | nl; // print group separator 45 45 } // for 46 46 } // main -
tests/coroutine/fibonacci.c
r29207bf r5ebb1368 10 10 // Created On : Thu Jun 8 07:29:37 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:21:58201813 // Update Count : 2 412 // Last Modified On : Tue Dec 11 21:57:33 2018 13 // Update Count : 25 14 14 // 15 15 … … 39 39 Fibonacci f1, f2; 40 40 for ( 10 ) { // print N Fibonacci values 41 sout | next( f1 ) | next( f2 ) | endl;41 sout | next( f1 ) | next( f2 ); 42 42 } // for 43 43 } -
tests/coroutine/fibonacci_1.c
r29207bf r5ebb1368 10 10 // Created On : Thu Apr 26 23:20:08 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:21:02201813 // Update Count : 1 312 // Last Modified On : Tue Dec 11 21:57:54 2018 13 // Update Count : 14 14 14 // 15 15 … … 36 36 Fibonacci f1, f2; 37 37 for ( 10 ) { // print N Fibonacci values 38 sout | next( f1 ) | next( f2 ) | endl;38 sout | next( f1 ) | next( f2 ); 39 39 } // for 40 40 } -
tests/coroutine/fmtLines.c
r29207bf r5ebb1368 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:20:54201813 // Update Count : 4 512 // Last Modified On : Tue Dec 11 21:58:49 2018 13 // Update Count : 47 14 14 // 15 15 … … 34 34 sout | " "; // print block separator 35 35 } // for 36 sout | endl;// print group separator36 sout | nl; // print group separator 37 37 } // for 38 38 } // main … … 43 43 44 44 void ^?{}( Format & fmt ) with( fmt ) { 45 if ( g != 0 || b != 0 ) sout | endl;45 if ( g != 0 || b != 0 ) sout | nl; 46 46 } 47 47 … … 52 52 int main() { 53 53 Format fmt; 54 sout | nlOff; // turn off auto newline 54 55 55 56 eof: for () { // read until end of file -
tests/coroutine/pingpong.c
r29207bf r5ebb1368 10 10 // Created On : Wed Sep 20 11:55:23 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:31:11201813 // Update Count : 2 812 // Last Modified On : Tue Dec 11 21:58:06 2018 13 // Update Count : 29 14 14 // 15 15 … … 40 40 void main( PingPong & pingpong ) { // ping's starter ::main, pong's starter ping 41 41 for ( pingpong.N ) { // N ping-pongs 42 sout | pingpong.name | endl;42 sout | pingpong.name; 43 43 cycle( *pingpong.part ); 44 44 } // for -
tests/coroutine/prodcons.c
r29207bf r5ebb1368 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 12:55:10201813 // Update Count : 5 112 // Last Modified On : Tue Dec 11 21:58:25 2018 13 // Update Count : 52 14 14 // 15 15 … … 32 32 int p1 = random( 100 ); 33 33 int p2 = random( 100 ); 34 sout | p1 | " " | p2 | endl;34 sout | p1 | " " | p2; 35 35 int status = delivery( *c, p1, p2 ); 36 sout | " $" | money | endl;37 sout | status | endl;36 sout | " $" | money; 37 sout | status; 38 38 receipt += 1; 39 39 } 40 40 stop( *c ); 41 sout | "prod stops" | endl;41 sout | "prod stops"; 42 42 } 43 43 int payment( Prod & prod, int money ) { … … 68 68 int money = 1, receipt; 69 69 for ( ; ! done; ) { 70 sout | p1 | " " | p2 | endl;71 sout | " $" | money | endl;70 sout | p1 | " " | p2; 71 sout | " $" | money; 72 72 status += 1; 73 73 receipt = payment( *p, money ); 74 sout | " #" | receipt | endl;74 sout | " #" | receipt; 75 75 money += 1; 76 76 } 77 sout | "cons stops" | endl;77 sout | "cons stops"; 78 78 } 79 79 int delivery( Cons & cons, int p1, int p2 ) { … … 92 92 srandom( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 sout | "main stops" | endl;94 sout | "main stops"; 95 95 } 96 96 -
tests/coroutine/runningTotal.c
r29207bf r5ebb1368 10 10 // Created On : Wed Dec 6 08:05:27 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:22:29201813 // Update Count : 312 // Last Modified On : Tue Dec 11 21:59:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 42 42 RunTotal rntl; 43 43 for ( i; 10 ) { 44 sout | i | add( rntl, i ) | endl;44 sout | i | add( rntl, i ); 45 45 } // for 46 46 } -
tests/div.cfa
r29207bf r5ebb1368 10 10 // Created On : Tue Aug 8 16:28:43 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:53:10201813 // Update Count : 1912 // Last Modified On : Tue Dec 4 21:35:01 2018 13 // Update Count : 20 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include <stdlib.hfa> 17 #include <stdlib.hfa> // div 18 18 19 19 struct T { int i; }; … … 23 23 24 24 int main( void ) { 25 sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL ) | endl;25 sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL ); 26 26 short s1 = 13, s2 = 5; 27 sout | "div" | div( s1, s2 ) | endl;27 sout | "div" | div( s1, s2 ); 28 28 T t1 = { 13 }, t2 = { 5 }; 29 sout | "div" | div( t1, t2 ) | endl;// polymorphic div29 sout | "div" | div( t1, t2 ); // polymorphic div 30 30 } // main 31 31 -
tests/except-0.cfa
r29207bf r5ebb1368 25 25 void ^?{}(signal_exit * this) { 26 26 printf("Exiting: %s\n", this->area); 27 // sout | "Exiting:" | this->area | endl;27 // sout | "Exiting:" | this->area; 28 28 } 29 29 -
tests/fallthrough.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed Mar 14 10:06:25 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 8 09:09:09201813 // Update Count : 1 612 // Last Modified On : Tue Dec 4 21:36:14 2018 13 // Update Count : 17 14 14 // 15 15 … … 19 19 choose ( choice ) { 20 20 case 1: 21 sout | "case 1" | endl;21 sout | "case 1"; 22 22 fallthru; 23 23 case 2: 24 sout | "case 2" | endl;24 sout | "case 2"; 25 25 fallthru; 26 sout | "did not fallthru" | endl;26 sout | "did not fallthru"; 27 27 if ( 7 ) fallthru common2; 28 28 fallthru common1; 29 29 case 3: 30 sout | "case 3" | endl;30 sout | "case 3"; 31 31 fallthru default; 32 32 fallthru common1; 33 33 common1: 34 sout | "common1" | endl;34 sout | "common1"; 35 35 // break 36 36 case 4: 37 sout | "case 4" | endl;37 sout | "case 4"; 38 38 fallthru common2; 39 39 case 5: 40 sout | "case 5" | endl;40 sout | "case 5"; 41 41 fallthru common2; 42 42 fallthru default; 43 43 case 6: 44 sout | "case 6" | endl;44 sout | "case 6"; 45 45 fallthru common2; 46 46 common2: 47 sout | "common2" | endl;47 sout | "common2"; 48 48 // break 49 49 default: 50 sout | "default" | endl;50 sout | "default"; 51 51 fallthru; 52 52 } 53 53 54 sout | endl;54 sout | nl; 55 55 56 56 switch ( choice ) { 57 57 case 1: 58 sout | "case 1" | endl;58 sout | "case 1"; 59 59 switch ( choice ) { 60 60 case 1: 61 sout | "case 1" | endl;61 sout | "case 1"; 62 62 for ( int i = 0; i < 4; i += 1 ) { 63 63 printf("%d\n", i); … … 67 67 break; 68 68 case 5: 69 sout | "case 5" | endl;69 sout | "case 5"; 70 70 if ( choice == 5 ) { 71 71 if ( choice != 5 ) { 72 sout | "error" | endl;72 sout | "error"; 73 73 } else { 74 sout | "check" | endl;74 sout | "check"; 75 75 fallthru common; 76 76 } // if … … 117 117 int main() { 118 118 test( 1 ); 119 sout | endl;119 sout | nl; 120 120 test( 5 ); 121 121 } -
tests/fstream_test.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:53:56201813 // Update Count : 6 612 // Last Modified On : Tue Dec 4 21:36:34 2018 13 // Update Count : 67 14 14 // 15 15 … … 18 18 int main( void ) { 19 19 int nombre; 20 sout | "Entrez un nombre, s'il vous plaît:" | endl;20 sout | "Entrez un nombre, s'il vous plaît:"; 21 21 sin | nombre; 22 sout | "Vous avez entré" | nombre | endl;22 sout | "Vous avez entré" | nombre; 23 23 sout | "le nombre" | nombre | "est" 24 | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif") | endl;24 | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif"); 25 25 26 sout | "Entrez trois nombres, s'il vous plaît: " | endl;26 sout | "Entrez trois nombres, s'il vous plaît: "; 27 27 int i, j, k; 28 28 sin | i | j | k; 29 sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k | endl;29 sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k; 30 30 } 31 31 -
tests/function-operator.cfa
r29207bf r5ebb1368 10 10 // Created On : Fri Aug 25 15:21:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 2 09:27:53201813 // Update Count : 812 // Last Modified On : Tue Dec 4 21:37:09 2018 13 // Update Count : 9 14 14 // 15 15 … … 83 83 // TODO: abstract over (os, T) 84 84 os_wrapper ?=?(os_wrapper & wrapper, int x) { 85 *wrapper.out | x | endl;85 *wrapper.out | x; 86 86 return wrapper; 87 87 } -
tests/gmp.cfa
r29207bf r5ebb1368 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:54:34201813 // Update Count : 55 712 // Last Modified On : Tue Dec 4 21:37:29 2018 13 // Update Count : 558 14 14 // 15 15 … … 19 19 20 20 int main( void ) { 21 sout | "constructors" | endl;21 sout | "constructors"; 22 22 short int si = 3; 23 23 Int x = { "50000000000000000000" }, y = { si }, z = x + y; 24 sout | x | y | z | endl;25 sout | "x:" | x | "y:" | y | "z:" | z | endl;24 sout | x | y | z; 25 sout | "x:" | x | "y:" | y | "z:" | z; 26 26 27 sout | "conversions" | endl;27 sout | "conversions"; 28 28 y = 'a'; 29 sout | "y:" | y | endl;29 sout | "y:" | y; 30 30 y = "12345678901234567890123456789"; 31 sout | "y:" | y | endl;31 sout | "y:" | y; 32 32 y = 100`mp + 100`mp; 33 sout | "y:" | y | endl;33 sout | "y:" | y; 34 34 y = -200u`mp + -200u`mp; 35 sout | "y:" | y | endl;35 sout | "y:" | y; 36 36 y = "12345678901234567890123456789"`mp + "12345678901234567890123456789"`mp; 37 sout | "y:" | y | endl;37 sout | "y:" | y; 38 38 y = si; 39 sout | "y:" | y | endl;39 sout | "y:" | y; 40 40 y = -3; 41 sout | "y:" | y | endl;41 sout | "y:" | y; 42 42 y += 7; 43 sout | "y:" | y | endl;43 sout | "y:" | y; 44 44 y -= 1; 45 sout | "y:" | y | endl;45 sout | "y:" | y; 46 46 int b; 47 47 b = y; 48 48 si = y; 49 sout | "y:" | y | "b:" | b | "si:" | si | endl;49 sout | "y:" | y | "b:" | b | "si:" | si; 50 50 51 sout | "comparison" | endl;52 sout | x == x | endl;53 sout | x != x | endl;54 sout | x < x | endl;55 sout | x <= x | endl;56 sout | x > x | endl;57 sout | x >= x | endl;51 sout | "comparison"; 52 sout | x == x; 53 sout | x != x; 54 sout | x < x; 55 sout | x <= x; 56 sout | x > x; 57 sout | x >= x; 58 58 59 sout | "arithmetic" | endl;59 sout | "arithmetic"; 60 60 z = x + y + z; 61 sout | "z:" | z | endl;61 sout | "z:" | z; 62 62 z = z = x; 63 sout | "z:" | z | endl;63 sout | "z:" | z; 64 64 z = x - y - z; 65 sout | "z:" | z | endl;65 sout | "z:" | z; 66 66 z = x * y * z; 67 sout | "z:" | z | endl;67 sout | "z:" | z; 68 68 z = x * 3; 69 sout | "z:" | z | endl;69 sout | "z:" | z; 70 70 z = 3 * x; 71 sout | "z:" | z | endl;71 sout | "z:" | z; 72 72 z = x / 3; 73 sout | "z:" | z | endl;74 sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;73 sout | "z:" | z; 74 sout | div( x, 3 ) | x / 3 | "," | x % 3; 75 75 [ x, y ] = div( x, 3 ); 76 sout | "x:" | x | "y:" | y | endl;76 sout | "x:" | x | "y:" | y; 77 77 78 sout | endl;78 sout; 79 79 80 80 sin | x | y | z; 81 sout | x | y | z | endl;81 sout | x | y | z; 82 82 83 sout | endl;83 sout; 84 84 85 sout | "Fibonacci Numbers" | endl;85 sout | "Fibonacci Numbers"; 86 86 Int fn, fn1, fn2; 87 87 fn = (Int){0}; fn1 = fn; // 1st case 88 sout | (int)0 | fn | endl;88 sout | (int)0 | fn; 89 89 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 90 sout | 1 | fn | endl;90 sout | 1 | fn; 91 91 for ( i; 2u ~= 200 ) { 92 92 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 93 sout | i | fn | endl;93 sout | i | fn; 94 94 } // for 95 95 96 sout | endl;96 sout; 97 97 98 sout | "Factorial Numbers" | endl;98 sout | "Factorial Numbers"; 99 99 Int fact = 1; // 1st case 100 sout | (int)0 | fact | endl;100 sout | (int)0 | fact; 101 101 for ( i; 1u ~= 40u ) { 102 102 fact *= i; // general case 103 sout | i | fact | endl;103 sout | i | fact; 104 104 } // for 105 105 } // main -
tests/heap.cfa
r29207bf r5ebb1368 10 10 // Created On : Tue Nov 6 17:54:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 8 09:03:54201813 // Update Count : 1 712 // Last Modified On : Tue Dec 11 21:52:40 2018 13 // Update Count : 18 14 14 // 15 15 … … 45 45 for ( i; NoOfAllocs ) { 46 46 locns[i] = alloc( i ); 47 //sout | (void *)locns[i] | endl;47 //sout | (void *)locns[i]; 48 48 for ( k; i ) locns[i][k] = '\345'; 49 49 } // for 50 //sout | (char *)sbrk(0) - start | " bytes" | endl;50 //sout | (char *)sbrk(0) - start | " bytes"; 51 51 52 52 for ( i; NoOfAllocs ) { 53 //sout | (void *)locns[i] | endl;53 //sout | (void *)locns[i]; 54 54 for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage1" ); 55 55 free( locns[i] ); 56 56 } // for 57 //sout | (char *)sbrk(0) - start | " bytes" | endl;57 //sout | (char *)sbrk(0) - start | " bytes"; 58 58 59 59 for ( i; NoOfAllocs ) { 60 60 locns[i] = alloc( i ); 61 //sout | (void *)locns[i] | endl;61 //sout | (void *)locns[i]; 62 62 for ( k; i ) locns[i][k] = '\345'; 63 63 } // for 64 64 for ( i; NoOfAllocs - 1 -~= 0 ) { 65 //sout | (void *)locns[i] | endl;65 //sout | (void *)locns[i]; 66 66 for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage2" ); 67 67 free( locns[i] ); … … 186 186 187 187 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 188 //sout | alignments[a] | endl;188 //sout | alignments[a]; 189 189 for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null 190 190 char * area = (char *)memalign( a, s ); 191 191 if ( area == 0 ) abort( "memalign/free out of memory" ); 192 //sout | i | " " | area | endl;192 //sout | i | " " | area; 193 193 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 194 194 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area ); … … 203 203 204 204 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 205 //sout | alignments[a] | endl;205 //sout | alignments[a]; 206 206 for ( i; 1 ~ NoOfMmaps ) { 207 207 size_t s = i + default_mmap_start(); // cross over point 208 208 char * area = (char *)memalign( a, s ); 209 209 if ( area == 0 ) abort( "memalign/free out of memory" ); 210 //sout | i | " " | area | endl;210 //sout | i | " " | area; 211 211 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 212 212 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area ); … … 268 268 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 269 269 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 270 //sout | alignments[a] | " " | area | endl;270 //sout | alignments[a] | " " | area; 271 271 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 272 272 abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 279 279 area = (char *)realloc( area, s ); // attempt to reuse storage 280 280 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 281 //sout | i | " " | area | endl;281 //sout | i | " " | area; 282 282 if ( (size_t)area % a != 0 ) { // check for initial alignment 283 283 abort( "memalign/realloc/free bad alignment %p", area ); … … 291 291 292 292 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 293 //sout | alignments[a] | endl;293 //sout | alignments[a]; 294 294 for ( s; 1 ~ limit ) { // allocation of size 0 can return null 295 295 char * area = (char *)cmemalign( a, 1, s ); 296 296 if ( area == 0 ) abort( "cmemalign/free out of memory" ); 297 //sout | i | " " | area | endl;297 //sout | i | " " | area; 298 298 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 299 299 abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area ); … … 314 314 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 315 315 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 316 //sout | alignments[a] | " " | area | endl;316 //sout | alignments[a] | " " | area; 317 317 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 318 318 abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 328 328 area = (char *)realloc( area, s ); // attempt to reuse storage 329 329 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 330 //sout | i | " " | area | endl;330 //sout | i | " " | area; 331 331 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 332 332 abort( "cmemalign/realloc/free bad alignment %p", area ); … … 339 339 free( area ); 340 340 } // for 341 //sout | "worker" | thisTask() | "successful completion" | endl;341 //sout | "worker" | thisTask() | "successful completion"; 342 342 } // Worker main 343 343 -
tests/hello.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:56:22201813 // Update Count : 1 612 // Last Modified On : Tue Dec 4 21:38:39 2018 13 // Update Count : 17 14 14 // 15 15 … … 17 17 18 18 int main() { 19 sout | "Hello world!" | endl;20 sout | "Bonjour le monde!" | endl;21 sout | "Hola Mundo!" | endl;22 sout | "Hallo Welt!" | endl;23 sout | "Kaixo Mundua!" | endl;24 sout | "Chào thế giới!" | endl;25 sout | "Привет мир!" | endl;26 sout | "שלום עולם!" | endl;27 sout | "你好,世界!" | endl;28 sout | "こんにちは世界!" | endl;29 sout | "안녕하세요 세계!" | endl;30 sout | "नमस्ते दुनिया!" | endl;19 sout | "Hello world!"; 20 sout | "Bonjour le monde!"; 21 sout | "Hola Mundo!"; 22 sout | "Hallo Welt!"; 23 sout | "Kaixo Mundua!"; 24 sout | "Chào thế giới!"; 25 sout | "Привет мир!"; 26 sout | "שלום עולם!"; 27 sout | "你好,世界!"; 28 sout | "こんにちは世界!"; 29 sout | "안녕하세요 세계!"; 30 sout | "नमस्ते दुनिया!"; 31 31 } 32 32 -
tests/identity.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:56:54201813 // Update Count : 1912 // Last Modified On : Tue Dec 4 21:38:59 2018 13 // Update Count : 20 14 14 // 15 15 … … 22 22 23 23 int main() { 24 sout | "char\t\t\t" | identity( 'z' ) | endl;25 sout | "signed int\t\t" | identity( 4 ) | endl;26 sout | "unsigned int\t\t" | identity( 4u ) | endl;27 sout | "signed long int\t\t" | identity( 4l ) | endl;28 sout | "unsigned long int\t" | identity( 4ul ) | endl;29 sout | "signed long long int\t" | identity( 4ll ) | endl;30 sout | "unsigned long long int\t" | identity( 4ull ) | endl;31 sout | "float\t\t\t" | identity( 4.1f ) | endl;32 sout | "double\t\t\t" | identity( 4.1 ) | endl;33 sout | "long double\t\t" | identity( 4.1l ) | endl;34 sout | "float _Complex\t\t" | identity( -4.1F-2.0iF ) | endl;35 sout | "double _Complex\t\t" | identity( -4.1D-2.0iD ) | endl;36 sout | "long double _Complex\t" | identity( -4.1L-2.0iL ) | endl;24 sout | "char\t\t\t" | identity( 'z' ); 25 sout | "signed int\t\t" | identity( 4 ); 26 sout | "unsigned int\t\t" | identity( 4u ); 27 sout | "signed long int\t\t" | identity( 4l ); 28 sout | "unsigned long int\t" | identity( 4ul ); 29 sout | "signed long long int\t" | identity( 4ll ); 30 sout | "unsigned long long int\t" | identity( 4ull ); 31 sout | "float\t\t\t" | identity( 4.1f ); 32 sout | "double\t\t\t" | identity( 4.1 ); 33 sout | "long double\t\t" | identity( 4.1l ); 34 sout | "float _Complex\t\t" | identity( -4.1F-2.0iF ); 35 sout | "double _Complex\t\t" | identity( -4.1D-2.0iD ); 36 sout | "long double _Complex\t" | identity( -4.1L-2.0iL ); 37 37 } 38 38 -
tests/ifwhileCtl.cfa
r29207bf r5ebb1368 10 10 // Created On : Sat Aug 26 10:13:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:57:07201813 // Update Count : 2 212 // Last Modified On : Tue Dec 4 21:39:18 2018 13 // Update Count : 23 14 14 // 15 15 … … 22 22 23 23 if ( int x = 1 ) { 24 sout | "x != 0 correct" | endl;24 sout | "x != 0 correct"; 25 25 } else { 26 sout | "x == 0 incorrect" | endl;26 sout | "x == 0 incorrect"; 27 27 } // if 28 28 29 29 if ( int x = 4, y = 0 ) { 30 sout | "x != 0 && y != 0 incorrect" | endl;30 sout | "x != 0 && y != 0 incorrect"; 31 31 } else if ( int x = 4, y = 1 ) { 32 sout | "x != 0 && y != 0 correct" | endl;32 sout | "x != 0 && y != 0 correct"; 33 33 } else { 34 sout | "x == 0 || y == 0 incorrect" | endl;34 sout | "x == 0 || y == 0 incorrect"; 35 35 } // if 36 36 37 37 if ( int x = 5, y = f( x ); x == y ) { 38 sout | "x == y correct" | endl;38 sout | "x == y correct"; 39 39 } else { 40 sout | "x != y incorrect" | endl;40 sout | "x != y incorrect"; 41 41 } // if 42 42 43 43 if ( struct S { int i; } s = { 3 }; s.i < 4 ) { 44 44 S s1; 45 sout | "s.i < 4 correct" | endl;45 sout | "s.i < 4 correct"; 46 46 } else { 47 47 S s1; 48 sout | "s.i >= 4 incorrect" | endl;48 sout | "s.i >= 4 incorrect"; 49 49 } // if 50 50 51 51 while ( int x = 1 ) { 52 sout | "x != 0 correct" | endl;52 sout | "x != 0 correct"; 53 53 break; 54 54 } // while 55 55 56 56 while ( int x = 4, y = 0 ) { 57 sout | "x != 0 && y != 0 incorrect" | endl;57 sout | "x != 0 && y != 0 incorrect"; 58 58 } // while 59 59 60 60 while ( int x = 5, y = f( x ); x == y ) { 61 sout | "x == y correct" | endl;61 sout | "x == y correct"; 62 62 break; 63 63 } // while … … 65 65 while ( struct S { int i; } s = { 3 }; s.i < 4 ) { 66 66 S s1; 67 sout | "s.i < 4 correct" | endl;67 sout | "s.i < 4 correct"; 68 68 break; 69 69 } // while -
tests/io1.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:57:17201813 // Update Count : 10 512 // Last Modified On : Tue Dec 4 21:40:28 2018 13 // Update Count : 106 14 14 // 15 15 … … 18 18 int main() { 19 19 int x = 3, y = 5, z = 7; 20 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;21 sout | 1 | 2 | 3 | endl;22 sout | '1' | '2' | '3' | endl;23 sout | 1 | "" | 2 | "" | 3 | endl;24 sout | endl;20 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2); 21 sout | 1 | 2 | 3; 22 sout | '1' | '2' | '3'; 23 sout | 1 | "" | 2 | "" | 3; 24 sout; 25 25 26 sout | "opening delimiters" | endl;26 sout | "opening delimiters"; 27 27 sout 28 28 | "x (" | 1 … … 36 36 | "x ¿" | 9 37 37 | "x «" | 10 38 | endl | endl;38 | nl; 39 39 40 sout | "closing delimiters" | endl;40 sout | "closing delimiters"; 41 41 sout 42 42 | 1 | ", x" … … 51 51 | 10 | "] x" 52 52 | 11 | "} x" 53 | endl | endl;53 | nl; 54 54 55 sout | "opening/closing delimiters" | endl;55 sout | "opening/closing delimiters"; 56 56 sout 57 57 | "x`" | 1 | "`x'" | 2 … … 61 61 | "\vx\n" | 9 | "\nx\r" | 10 62 62 | "\rx" 63 | endl | endl;63 | nl; 64 64 65 sout | "override opening/closing delimiters" | endl;66 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;67 sout | endl;65 sout | "override opening/closing delimiters"; 66 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4; 67 sout; 68 68 } 69 69 -
tests/io2.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:57:28201813 // Update Count : 10 412 // Last Modified On : Tue Dec 11 21:51:52 2018 13 // Update Count : 109 14 14 // 15 15 16 16 #include <fstream.hfa> 17 17 18 18 #define xstr(s) str(s) 19 19 #define str(s) #s 20 20 … … 41 41 char s1[size], s2[size]; 42 42 43 ifstream in = { xstr(IN_DIR) "io.data" }; 43 ifstream in = { xstr(IN_DIR) "io.data" }; // create / open file 44 44 45 sout | "input bacis types" | endl;45 sout | "input bacis types"; 46 46 in | b // boolean 47 47 | c | sc | usc // character … … 50 50 | fc | dc | ldc // floating-point complex 51 51 | cstr( s1 ) | cstr( s2, size ); // C string, length unchecked and checked 52 sout | endl;52 sout | nl; 53 53 54 sout | "output basic types" | endl;55 sout | b | endl // boolean56 | c | ' ' | sc | ' ' | usc | endl // character57 | si | usi | i | ui | li | uli | lli | ulli | endl // integral58 | f | d | ld | endl// floating point59 | fc | dc | ldc | endl;// complex60 sout | endl;54 sout | "output basic types"; 55 sout | b | nl // boolean 56 | c | ' ' | sc | ' ' | usc | nl // character 57 | si | usi | i | ui | li | uli | lli | ulli | nl // integral 58 | f | d | ld | nl // floating point 59 | fc | dc | ldc; // complex 60 sout | nl; 61 61 62 sout | "tuples" | endl;62 sout | "tuples"; 63 63 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 64 sout | t1 | t2 | endl;// print tuple65 sout | endl;64 sout | t1 | t2; // print tuple 65 sout | nl; 66 66 67 sout | "toggle separator" | endl;68 sout | f | "" | d | "" | ld | endl // floating point without separator69 | sepDisable | fc | dc | ldc | endl// complex without separator70 | fc | sepOn | dc | ldc | endl // local separator add71 | sepEnable | fc | dc | ldc | endl // complex with separator72 | fc | sepOff | dc | ldc | endl// local separator removal73 | s1 | sepOff | s2 | endl // local separator removal74 | s1 | "" | s2 | endl;// local separator removal75 sout | endl;67 sout | "toggle separator"; 68 sout | f | "" | d | "" | ld | nl // floating point without separator 69 | sepDisable | fc | dc | ldc | nl // complex without separator 70 | fc | sepOn | dc | ldc | nl // local separator add 71 | sepEnable | fc | dc | ldc | nl // complex with separator 72 | fc | sepOff | dc | ldc | nl // local separator removal 73 | s1 | sepOff | s2 | nl // local separator removal 74 | s1 | "" | s2; // local separator removal 75 sout | nl; 76 76 77 sout | "change separator" | endl;78 sout | "from \"" | sep | "\"" ;77 sout | "change separator"; 78 sout | "from \"" | sep | "\"" | nonl; 79 79 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 80 sout | " to \"" | sep | "\"" | endl;81 sout | f | d | ld | endl82 | fc | dc | ldc | endl83 | s1 | s2 | endl84 | t1 | t2 | endl;// print tuple85 sout | endl;86 sout | "from \"" | sep | "\" " ;80 sout | " to \"" | sep | "\""; 81 sout | f | d | ld | nl 82 | fc | dc | ldc | nl 83 | s1 | s2 | nl 84 | t1 | t2; // print tuple 85 sout | nl; 86 sout | "from \"" | sep | "\" " | nonl; 87 87 sepSet( sout, " " ); // restore separator 88 sout | "to \"" | sep | "\"" | endl;89 sout | f | d | ld | endl90 | fc | dc | ldc | endl91 | s1 | s2 | endl92 | t1 | t2 | endl;// print tuple93 sout | endl;88 sout | "to \"" | sep | "\""; 89 sout | f | d | ld | nl 90 | fc | dc | ldc | nl 91 | s1 | s2 | nl 92 | t1 | t2; // print tuple 93 sout | nl; 94 94 95 sout | "check sepOn/sepOff" | endl;96 sout | sepOn | 1 | 2 | 3 | sepOn | endl;// no separator at start/end of line97 sout | 1 | sepOff | 2 | 3 | endl;// locally turn off implicit separator95 sout | "check sepOn/sepOff"; 96 sout | sepOn | 1 | 2 | 3 | sepOn; // no separator at start/end of line 97 sout | 1 | sepOff | 2 | 3; // locally turn off implicit separator 98 98 sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line 99 99 sout | 1 | 2 | 3 | "\n\n" | sepOn; // no separator at start of next line 100 sout | 1 | 2 | 3 | endl;101 sout | endl;100 sout | 1 | 2 | 3; 101 sout | nl; 102 102 103 sout | "check enable/disable" | endl;104 sout | sepDisable | 1 | 2 | 3 | endl;// globally turn off implicit separation105 sout | 1 | sepOn | 2 | 3 | endl;// locally turn on implicit separator106 sout | sepEnable | 1 | 2 | 3 | endl | sepDisable;// globally turn on/off implicit separation107 sout | 1 | 2 | 3 | endl | sepEnable;// globally turn on implicit separation108 sout | 1 | 2 | 3 | sepOn | sepDisable | endl;// ignore seperate at end of line109 sout | 1 | 2 | 3 | sepOn | sepEnable | endl;// separator at end of line110 sout | 1 | 2 | 3 | endl;111 sout | endl;103 sout | "check enable/disable"; 104 sout | sepDisable | 1 | 2 | 3; // globally turn off implicit separation 105 sout | 1 | sepOn | 2 | 3; // locally turn on implicit separator 106 sout | sepEnable | 1 | 2 | 3 | sepDisable; // globally turn on/off implicit separation 107 sout | 1 | 2 | 3 | sepEnable; // globally turn on implicit separation 108 sout | 1 | 2 | 3 | sepOn | sepDisable; // ignore seperate at end of line 109 sout | 1 | 2 | 3 | sepOn | sepEnable; // separator at end of line 110 sout | 1 | 2 | 3; 111 sout | nl; 112 112 113 // sout | fmt( d, "%8.3f" ) || endl; 114 // sout | endl; 113 // sout | fmt( d, "%8.3f" ); 115 114 116 115 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 117 sout | t1 | t2 | " \"" | sep | "\"" | endl;116 sout | t1 | t2 | " \"" | sep | "\""; 118 117 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 119 sout | t1 | t2 | " \"" | sep | "\"" | endl;120 sout | t1 | t2 | endl;// print tuple121 sout | endl;118 sout | t1 | t2 | " \"" | sep | "\""; 119 sout | t1 | t2; // print tuple 120 sout | nl; 122 121 123 122 [int, int, const char *, double] t3 = { 3, 4, "a", 7.2 }; 124 sout | [ 3, 4, "a", 7.2 ] | endl;125 sout | t3 | endl;123 sout | [ 3, 4, "a", 7.2 ]; 124 sout | t3; 126 125 sepSetTuple( sout, " " ); 127 sout | t3 | endl;128 sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3 | endl;126 sout | t3; 127 sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3; 129 128 sepSet( sout, "^" ); 130 129 sepSetTuple( sout, "-" ); 131 sout | t3 | 3 | 4 | t3 | endl;130 sout | t3 | 3 | 4 | t3; 132 131 } 133 132 -
tests/literals.cfa
r29207bf r5ebb1368 10 10 // Created On : Sat Sep 9 16:34:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:58:07201813 // Update Count : 13 812 // Last Modified On : Tue Dec 4 21:44:01 2018 13 // Update Count : 139 14 14 // 15 15 … … 18 18 #include <fstream.hfa> 19 19 20 void f( char v ) { sout | "char " | v | endl; }21 void f( signed char v ) { sout | "signed char " | v | endl; }22 void f( unsigned char v ) { sout | "unsigned char " | v | endl; }23 void f( signed short v ) { sout | "signed short int" | v | endl; }24 void f( unsigned short v ) { sout | "unsigned short int" | v | endl; }25 void f( size_t v ) { sout | "size_t" | v | endl; }20 void f( char v ) { sout | "char " | v; } 21 void f( signed char v ) { sout | "signed char " | v; } 22 void f( unsigned char v ) { sout | "unsigned char " | v; } 23 void f( signed short v ) { sout | "signed short int" | v; } 24 void f( unsigned short v ) { sout | "unsigned short int" | v; } 25 void f( size_t v ) { sout | "size_t" | v; } 26 26 #endif // __CFA__ 27 27 -
tests/loopctrl.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Nov 7 16:54:11201813 // Update Count : 6212 // 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); if ( getANL( os ) ) nl( os ); } 34 35 35 36 int main() { 36 while () { sout | "empty"; break; } sout | endl; 37 do { sout | "empty"; break; } while (); sout | endl; 38 for () { sout | "empty"; break; } sout | endl | endl; 37 sout | nlOff; // turn off auto newline 38 while () { sout | "empty"; break; } sout | nl; 39 do { sout | "empty"; break; } while (); sout | nl; 40 for () { sout | "empty"; break; } sout | nl; 39 41 40 for ( 0 ) { sout | "A"; } sout | "zero" | endl;41 for ( 1 ) { sout | "A"; } sout | endl;42 for ( 10 ) { sout | "A"; } sout | endl;43 for ( 1 ~= 10 ~ 2 ) { sout | "B"; } sout | endl;44 for ( 10 -~= 1 ~ 2 ) { sout | "C"; } sout | endl;45 for ( 0.5 ~ 5.5 ) { sout | "D"; } sout | endl;46 for ( 5.5 -~ 0.5 ) { sout | "E"; } sout | endl | endl;42 for ( 0 ) { sout | "A"; } sout | "zero" | nl; 43 for ( 1 ) { sout | "A"; } sout | nl; 44 for ( 10 ) { sout | "A"; } sout | nl; 45 for ( 1 ~= 10 ~ 2 ) { sout | "B"; } sout | nl; 46 for ( 10 -~= 1 ~ 2 ) { sout | "C"; } sout | nl; 47 for ( 0.5 ~ 5.5 ) { sout | "D"; } sout | nl; 48 for ( 5.5 -~ 0.5 ) { sout | "E"; } sout | nl | nl; 47 49 48 for ( i; 10 ) { sout | i; } sout | endl;49 for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | endl;50 for ( i; 10 -~= 1 ~ 2 ) { sout | i; } sout | endl;51 for ( i; 0.5 ~ 5.5 ) { sout | i; } sout | endl;52 for ( i; 5.5 -~ 0.5 ) { sout | i; } sout | endl;53 for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | endl;54 for ( ui; 10u -~= 2u ~ 2u ) { sout | ui; } sout | endl | endl | endl;50 for ( i; 10 ) { sout | i; } sout | nl; 51 for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | nl; 52 for ( i; 10 -~= 1 ~ 2 ) { sout | i; } sout | nl; 53 for ( i; 0.5 ~ 5.5 ) { sout | i; } sout | nl; 54 for ( i; 5.5 -~ 0.5 ) { sout | i; } sout | nl; 55 for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | nl; 56 for ( ui; 10u -~= 2u ~ 2u ) { sout | ui; } sout | nl | nl | nl; 55 57 56 58 enum { N = 10 }; 57 for ( N ) { sout | "N"; } sout | endl;58 for ( i; N ) { sout | i; } sout | endl;59 for ( i; N -~ 0 ) { sout | i; } sout | endl | endl | endl;59 for ( N ) { sout | "N"; } sout | nl; 60 for ( i; N ) { sout | i; } sout | nl; 61 for ( i; N -~ 0 ) { sout | i; } sout | nl | nl | nl; 60 62 61 63 const int start = 3, comp = 10, inc = 2; 62 for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | endl | endl;64 for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | nl | nl; 63 65 64 sout | endl;65 for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | endl;66 for ( s; (S){10,10} ) { sout | s; } sout | endl;67 sout | endl;68 for ( s; (S){0} ~ (S){10,10} ) { sout | s; } sout | endl;69 for ( s; (S){0} ~ (S){10,10} ~ (S){1} ) { sout | s; } sout | endl;70 for ( s; (S){0} ~= (S){10,10} ) { sout | s; } sout | endl;71 for ( s; (S){0} ~= (S){10,10} ~ (S){1} ) { sout | s; } sout | endl;72 sout | endl;73 for ( s; (S){10,10} -~ (S){0} ) { sout | s; } sout | endl;74 for ( s; (S){10,10} -~ (S){0} ~ (S){1} ) { sout | s; } sout | endl;75 for ( s; (S){10,10} -~= (S){0} ) { sout | s; } sout | endl;76 for ( s; (S){10,10} -~= (S){0} ~ (S){1} ) { sout | s; } sout | endl;66 sout | nl; 67 for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | nl; 68 for ( s; (S){10,10} ) { sout | s; } sout | nl; 69 sout | nl; 70 for ( s; (S){0} ~ (S){10,10} ) { sout | s; } sout | nl; 71 for ( s; (S){0} ~ (S){10,10} ~ (S){1} ) { sout | s; } sout | nl; 72 for ( s; (S){0} ~= (S){10,10} ) { sout | s; } sout | nl; 73 for ( s; (S){0} ~= (S){10,10} ~ (S){1} ) { sout | s; } sout | nl; 74 sout | nl; 75 for ( s; (S){10,10} -~ (S){0} ) { sout | s; } sout | nl; 76 for ( s; (S){10,10} -~ (S){0} ~ (S){1} ) { sout | s; } sout | nl; 77 for ( s; (S){10,10} -~= (S){0} ) { sout | s; } sout | nl; 78 for ( s; (S){10,10} -~= (S){0} ~ (S){1} ) { sout | s; } sout | nl; 77 79 } 78 80 -
tests/math1.cfa
r29207bf r5ebb1368 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:58:37201813 // Update Count : 8 612 // Last Modified On : Tue Dec 11 10:24:31 2018 13 // Update Count : 88 14 14 // 15 15 … … 22 22 long double l; 23 23 24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ) | endl;25 sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ) | endl;24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ); 25 sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ); 26 26 int quot; 27 27 f = remquo( 3.6F, 0.5F, " ); 28 sout | "remquo:" | quot | f ;28 sout | "remquo:" | quot | f | nonl; 29 29 d = remquo( 3.6D, 0.5F, " ); 30 sout | quot | d ;30 sout | quot | d | nonl; 31 31 l = remquo( 3.6L, 0.5L, " ); 32 sout | quot | l | endl;33 sout | "div:" | div( 3.6F, 0.5F ) | div( 3.6D, 0.5D ) | div( 3.6L, 0.5L ) | endl;34 sout | "fma:" | fma( 3.0F, -1.0F, 1.0F ) | fma( 3.0D, -1.0D, 1.0D ) | fma( 3.0L, -1.0L, , 1.0L ) | endl;35 sout | "fdim:" | fdim( 1.0F, -1.0F ) | fdim( 1.0D, -1.0D ) | fdim( 1.0L, -1.0L ) | endl;36 sout | "nan:" | (float)nan( "" ) | (double)nan( "" ) | (long double)nan( "" ) | endl;32 sout | quot | l; 33 sout | "div:" | div( 3.6F, 0.5F ) | div( 3.6D, 0.5D ) | div( 3.6L, 0.5L ); 34 sout | "fma:" | fma( 3.0F, -1.0F, 1.0F ) | fma( 3.0D, -1.0D, 1.0D ) | fma( 3.0L, -1.0L, , 1.0L ); 35 sout | "fdim:" | fdim( 1.0F, -1.0F ) | fdim( 1.0D, -1.0D ) | fdim( 1.0L, -1.0L ); 36 sout | "nan:" | (float)nan( "" ) | (double)nan( "" ) | (long double)nan( "" ); 37 37 38 38 //---------------------- Exponential ---------------------- 39 39 40 sout | "exp:" | exp( 1.0F ) | exp( 1.0D ) | exp( 1.0L ) | exp( 1.0F+1.0FI ) | exp( 1.0D+1.0DI ) | exp( 1.0DL+1.0LI ) | endl;41 sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ) | endl;42 sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ) | endl;43 sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI ) | endl;40 sout | "exp:" | exp( 1.0F ) | exp( 1.0D ) | exp( 1.0L ) | exp( 1.0F+1.0FI ) | exp( 1.0D+1.0DI ) | exp( 1.0DL+1.0LI ); 41 sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ); 42 sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ); 43 sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI ); 44 44 45 45 int b = 4; 46 46 unsigned int e = 2; 47 47 b \= e; 48 sout | "\\" | b | b \ e | endl;49 sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi) | endl;48 sout | "\\" | b | b \ e; 49 sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi); 50 50 } // main 51 51 -
tests/math2.cfa
r29207bf r5ebb1368 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:58:55201813 // Update Count : 8 312 // Last Modified On : Tue Dec 4 23:11:12 2018 13 // Update Count : 85 14 14 // 15 15 … … 24 24 //---------------------- Logarithm ---------------------- 25 25 26 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ) | endl;27 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ) | endl;28 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ) | endl;29 sout | "log1p:" | log1p( 1.0F ) | log1p( 1.0D ) | log1p( 1.0L ) | endl;30 sout | "ilogb:" | ilogb( 1.0F ) | ilogb( 1.0D ) | ilogb( 1.0L ) | endl;31 sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ) | endl;26 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ); 27 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ); 28 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ); 29 sout | "log1p:" | log1p( 1.0F ) | log1p( 1.0D ) | log1p( 1.0L ); 30 sout | "ilogb:" | ilogb( 1.0F ) | ilogb( 1.0D ) | ilogb( 1.0L ); 31 sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ); 32 32 33 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ) | endl;34 sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ) | endl;35 sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ) | endl;33 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ); 34 sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ); 35 sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ); 36 36 37 37 //---------------------- Trigonometric ---------------------- 38 38 39 sout | "sin:" | sin( 1.0F ) | sin( 1.0D ) | sin( 1.0L ) | sin( 1.0F+1.0FI ) | sin( 1.0D+1.0DI ) | sin( 1.0DL+1.0LI ) | endl;40 sout | "cos:" | cos( 1.0F ) | cos( 1.0D ) | cos( 1.0L ) | cos( 1.0F+1.0FI ) | cos( 1.0D+1.0DI ) | cos( 1.0DL+1.0LI ) | endl;41 sout | "tan:" | tan( 1.0F ) | tan( 1.0D ) | tan( 1.0L ) | tan( 1.0F+1.0FI ) | tan( 1.0D+1.0DI ) | tan( 1.0DL+1.0LI ) | endl;42 sout | "asin:" | asin( 1.0F ) | asin( 1.0D ) | asin( 1.0L ) | asin( 1.0F+1.0FI ) | asin( 1.0D+1.0DI ) | asin( 1.0DL+1.0LI ) | endl;43 sout | "acos:" | acos( 1.0F ) | acos( 1.0D ) | acos( 1.0L ) | acos( 1.0F+1.0FI ) | acos( 1.0D+1.0DI ) | acos( 1.0DL+1.0LI ) | endl;44 sout | "atan:" | atan( 1.0F ) | atan( 1.0D ) | atan( 1.0L ) | atan( 1.0F+1.0FI ) | atan( 1.0D+1.0DI ) | atan( 1.0DL+1.0LI ) | endl;45 sout | "atan2:" | atan2( 1.0F, 1.0F ) | atan2( 1.0D, 1.0D ) | atan2( 1.0L, 1.0L ) ;46 sout | "atan:" | atan( 1.0F, 1.0F ) | atan( 1.0D, 1.0D ) | atan( 1.0L, 1.0L ) | endl;39 sout | "sin:" | sin( 1.0F ) | sin( 1.0D ) | sin( 1.0L ) | sin( 1.0F+1.0FI ) | sin( 1.0D+1.0DI ) | sin( 1.0DL+1.0LI ); 40 sout | "cos:" | cos( 1.0F ) | cos( 1.0D ) | cos( 1.0L ) | cos( 1.0F+1.0FI ) | cos( 1.0D+1.0DI ) | cos( 1.0DL+1.0LI ); 41 sout | "tan:" | tan( 1.0F ) | tan( 1.0D ) | tan( 1.0L ) | tan( 1.0F+1.0FI ) | tan( 1.0D+1.0DI ) | tan( 1.0DL+1.0LI ); 42 sout | "asin:" | asin( 1.0F ) | asin( 1.0D ) | asin( 1.0L ) | asin( 1.0F+1.0FI ) | asin( 1.0D+1.0DI ) | asin( 1.0DL+1.0LI ); 43 sout | "acos:" | acos( 1.0F ) | acos( 1.0D ) | acos( 1.0L ) | acos( 1.0F+1.0FI ) | acos( 1.0D+1.0DI ) | acos( 1.0DL+1.0LI ); 44 sout | "atan:" | atan( 1.0F ) | atan( 1.0D ) | atan( 1.0L ) | atan( 1.0F+1.0FI ) | atan( 1.0D+1.0DI ) | atan( 1.0DL+1.0LI ); 45 sout | "atan2:" | atan2( 1.0F, 1.0F ) | atan2( 1.0D, 1.0D ) | atan2( 1.0L, 1.0L ) | nonl; 46 sout | "atan:" | atan( 1.0F, 1.0F ) | atan( 1.0D, 1.0D ) | atan( 1.0L, 1.0L ); 47 47 } // main 48 48 -
tests/math3.cfa
r29207bf r5ebb1368 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:59:05201813 // Update Count : 8 312 // Last Modified On : Tue Dec 11 10:15:49 2018 13 // Update Count : 85 14 14 // 15 15 … … 24 24 //---------------------- Hyperbolic ---------------------- 25 25 26 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ) | endl;27 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ) | endl;28 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ) | endl;29 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ) | endl;30 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ) | endl;31 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ) | endl;26 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ); 27 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ); 28 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ); 29 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ); 30 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ); 31 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ); 32 32 33 33 //---------------------- Error / Gamma ---------------------- 34 34 35 sout | "erf:" | erf( 1.0F ) | erf( 1.0D ) | erf( 1.0L ) | endl;36 sout | "erfc:" | erfc( 1.0F ) | erfc( 1.0D ) | erfc( 1.0L ) | endl;37 sout | "lgamma:" | lgamma( 4.0F ) | lgamma( 4.0D ) | lgamma( 4.0L ) | endl;35 sout | "erf:" | erf( 1.0F ) | erf( 1.0D ) | erf( 1.0L ); 36 sout | "erfc:" | erfc( 1.0F ) | erfc( 1.0D ) | erfc( 1.0L ); 37 sout | "lgamma:" | lgamma( 4.0F ) | lgamma( 4.0D ) | lgamma( 4.0L ); 38 38 int sign; 39 39 f = lgamma( 4.0F, &sign ); 40 sout | "lgamma:" | f | sign ;40 sout | "lgamma:" | f | sign | nonl; 41 41 d = lgamma( 4.0D, &sign ); 42 sout | d | sign ;42 sout | d | sign | nonl; 43 43 l = lgamma( 4.0L, &sign ); 44 sout | l | sign | endl;45 sout | "tgamma:" | tgamma( 4.0F ) | tgamma( 4.0D ) | tgamma( 4.0L ) | endl;44 sout | l | sign; 45 sout | "tgamma:" | tgamma( 4.0F ) | tgamma( 4.0D ) | tgamma( 4.0L ); 46 46 } // main 47 47 -
tests/math4.cfa
r29207bf r5ebb1368 10 10 // Created On : Thu May 24 20:56:54 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:59:14201813 // Update Count : 312 // Last Modified On : Tue Dec 4 18:15:01 2018 13 // Update Count : 4 14 14 // 15 15 … … 24 24 //---------------------- Nearest Integer ---------------------- 25 25 26 sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L ) | endl;27 sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L ) | endl;28 sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L ) | endl;29 sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L ) | endl;30 sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L ) | endl;31 sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L ) | endl;32 sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L ) | endl;33 sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L ) | endl;34 sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L ) | endl;35 sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L ) | endl;36 sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L ) | endl;37 sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L ) | endl;38 sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L ) | endl;39 sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L ) | endl;26 sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L ); 27 sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L ); 28 sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L ); 29 sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L ); 30 sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L ); 31 sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L ); 32 sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L ); 33 sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L ); 34 sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L ); 35 sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L ); 36 sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L ); 37 sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L ); 38 sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L ); 39 sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L ); 40 40 41 41 //---------------------- Manipulation ---------------------- 42 42 43 sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L ) | endl;43 sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L ); 44 44 int exp; 45 45 f = frexp( 4.0F, &exp ); 46 sout | "frexp:" | f | exp ;46 sout | "frexp:" | f | exp | nonl; 47 47 d = frexp( 4.0D, &exp ); 48 sout | d | exp ;48 sout | d | exp | nonl; 49 49 l = frexp( 4.0L, &exp ); 50 sout | l | exp | endl;51 sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 ) | endl;50 sout | l | exp; 51 sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 ); 52 52 float fi; 53 53 double di; 54 54 long double ldi; 55 55 f = modf( 2.3F, &fi ); 56 sout | "modf:" | fi | f ;56 sout | "modf:" | fi | f | nonl; 57 57 d = modf( 2.3D, &di ); 58 sout | di | d ;58 sout | di | d | nonl; 59 59 l = modf( 2.3L, &ldi ); 60 sout | ldi | l | endl;61 sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L ) | endl;62 sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L ) | endl;63 sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L ) | endl;60 sout | ldi | l; 61 sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L ); 62 sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L ); 63 sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L ); 64 64 65 sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 ) | endl;66 sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L ) | endl;65 sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 ); 66 sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L ); 67 67 } // main 68 68 -
tests/minmax.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:59:26201813 // Update Count : 5 112 // Last Modified On : Tue Dec 4 21:45:31 2018 13 // Update Count : 52 14 14 // 15 15 … … 22 22 int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; } 23 23 24 sout | "char\t\t\t" | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;25 sout | "signed int\t\t" | 4 | 3 | "\tmin" | min( 4, 3 ) | endl;26 sout | "unsigned int\t\t" | 4u | 3u | "\tmin" | min( 4u, 3u ) | endl;27 sout | "signed long int\t\t" | 4l | 3l | "\tmin" | min( 4l, 3l ) | endl;28 sout | "unsigned long int\t" | 4ul | 3ul | "\tmin" | min( 4ul, 3ul ) | endl;29 sout | "signed long long int\t" | 4ll | 3ll | "\tmin" | min( 4ll, 3ll ) | endl;30 sout | "unsigned long long int\t" | 4ull | 3ull | "\tmin" | min( 4ull, 3ull ) | endl;31 sout | "float\t\t\t" | 4.0f | 3.1f | "\tmin" | min( 4.0f, 3.1f ) | endl;32 sout | "double\t\t\t" | 4.0 | 3.1 | "\tmin" | min( 4.0, 3.1 ) | endl;33 sout | "long double\t\t" | 4.0l | 3.1l | "\tmin" | min( 4.0l, 3.1l ) | endl;24 sout | "char\t\t\t" | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ); 25 sout | "signed int\t\t" | 4 | 3 | "\tmin" | min( 4, 3 ); 26 sout | "unsigned int\t\t" | 4u | 3u | "\tmin" | min( 4u, 3u ); 27 sout | "signed long int\t\t" | 4l | 3l | "\tmin" | min( 4l, 3l ); 28 sout | "unsigned long int\t" | 4ul | 3ul | "\tmin" | min( 4ul, 3ul ); 29 sout | "signed long long int\t" | 4ll | 3ll | "\tmin" | min( 4ll, 3ll ); 30 sout | "unsigned long long int\t" | 4ull | 3ull | "\tmin" | min( 4ull, 3ull ); 31 sout | "float\t\t\t" | 4.0f | 3.1f | "\tmin" | min( 4.0f, 3.1f ); 32 sout | "double\t\t\t" | 4.0 | 3.1 | "\tmin" | min( 4.0, 3.1 ); 33 sout | "long double\t\t" | 4.0l | 3.1l | "\tmin" | min( 4.0l, 3.1l ); 34 34 35 sout | endl;35 sout | nl; 36 36 37 sout | "char\t\t\t" | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;38 sout | "signed int\t\t" | 4 | 3 | "\tmax" | max( 4, 3 ) | endl;39 sout | "unsigned int\t\t" | 4u | 3u | "\tmax" | max( 4u, 3u ) | endl;40 sout | "signed long int\t\t" | 4l | 3l | "\tmax" | max( 4l, 3l ) | endl;41 sout | "unsigned long int\t" | 4ul | 3ul | "\tmax" | max( 4ul, 3ul ) | endl;42 sout | "signed long long int\t" | 4ll | 3ll | "\tmax" | max( 4ll, 3ll ) | endl;43 sout | "unsigned long long int\t" | 4ull | 3ull | "\tmax" | max( 4ull, 3ull ) | endl;44 sout | "float\t\t\t" | 4.0f | 3.1f | "\tmax" | max( 4.0f, 3.1f ) | endl;45 sout | "double\t\t\t" | 4.0 | 3.1 | "\tmax" | max( 4.0, 3.1 ) | endl;46 sout | "long double\t\t" | 4.0l | 3.1l | "\tmax" | max( 4.0l, 3.1l ) | endl;37 sout | "char\t\t\t" | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ); 38 sout | "signed int\t\t" | 4 | 3 | "\tmax" | max( 4, 3 ); 39 sout | "unsigned int\t\t" | 4u | 3u | "\tmax" | max( 4u, 3u ); 40 sout | "signed long int\t\t" | 4l | 3l | "\tmax" | max( 4l, 3l ); 41 sout | "unsigned long int\t" | 4ul | 3ul | "\tmax" | max( 4ul, 3ul ); 42 sout | "signed long long int\t" | 4ll | 3ll | "\tmax" | max( 4ll, 3ll ); 43 sout | "unsigned long long int\t" | 4ull | 3ull | "\tmax" | max( 4ull, 3ull ); 44 sout | "float\t\t\t" | 4.0f | 3.1f | "\tmax" | max( 4.0f, 3.1f ); 45 sout | "double\t\t\t" | 4.0 | 3.1 | "\tmax" | max( 4.0, 3.1 ); 46 sout | "long double\t\t" | 4.0l | 3.1l | "\tmax" | max( 4.0l, 3.1l ); 47 47 } // main 48 48 -
tests/quotedKeyword.cfa
r29207bf r5ebb1368 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:46:20201813 // Update Count : 2 212 // Last Modified On : Tue Dec 4 21:45:53 2018 13 // Update Count : 23 14 14 // 15 15 … … 41 41 st.`struct` = 3; 42 42 `throw` = 4; 43 sout | `catch` + st.`otype` + st.`struct` + `throw` | endl;43 sout | `catch` + st.`otype` + st.`struct` + `throw`; 44 44 } 45 45 -
tests/raii/dtor-early-exit.c
r29207bf r5ebb1368 10 10 // Created On : Wed Aug 17 08:26:25 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 07:58:39201813 // Update Count : 812 // Last Modified On : Tue Dec 11 22:05:24 2018 13 // Update Count : 9 14 14 // 15 15 … … 25 25 // don't want these called 26 26 void ?{}(A & a) { assert( false ); } 27 void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name | endl; a.x = (int*)malloc(); }27 void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name; a.x = (int*)malloc(); } 28 28 void ?{}(A & a, const char * name, int * ptr) { assert( false ); } 29 29 30 30 A ?=?(A & a, A b) { sout | "assign " | a.name | " " | b.name; return a; } 31 void ?{}(A & a, A b) { sout | "copy construct " | b.name | endl; a.x = (int*)malloc(); }32 void ^?{}(A & a) { sout | "destruct " | a.name | endl; free(a.x); }31 void ?{}(A & a, A b) { sout | "copy construct " | b.name; a.x = (int*)malloc(); } 32 void ^?{}(A & a) { sout | "destruct " | a.name; free(a.x); } 33 33 34 34 // test returns 35 35 void f(int i) { 36 sout | "f i=" | i | endl;36 sout | "f i=" | i; 37 37 A x = { "x" }; // construct x 38 38 { … … 55 55 void g() { 56 56 for (int i = 0; i < 10; i++) { 57 sout | "g for i=" | i | endl;57 sout | "g for i=" | i; 58 58 A x = { "x" }; 59 59 // construct x 60 60 // destruct x 61 61 } 62 sout | endl;62 sout | nl; 63 63 { 64 64 int i = 0; 65 65 while (i < 10) { 66 sout | "g while i=" | i | endl;66 sout | "g while i=" | i; 67 67 A x = { "x" }; 68 68 // construct x … … 71 71 } 72 72 } 73 sout | endl;73 sout; 74 74 for (int i = 0; i < 10; i++) { 75 75 switch(10) { … … 78 78 case 10: { 79 79 A y = { "y" }; 80 sout | "g switch i=" | i | endl;80 sout | "g switch i=" | i; 81 81 // construct y 82 82 break; // destruct y 83 83 } 84 84 default: { 85 sout | "g switch i=" | i | endl;85 sout | "g switch i=" | i; 86 86 A x = { "x" }; 87 87 // construct x … … 90 90 } 91 91 } 92 sout | endl;92 sout | nl; 93 93 for (int k = 0; k < 2; k++) { 94 sout | "g for k=" | k | endl;94 sout | "g for k=" | k; 95 95 L1: for (int i = 0; i < 10; i++) { 96 sout | "g for i=" | i | endl;96 sout | "g for i=" | i; 97 97 98 98 A x = { "x" }; 99 99 if (i == 2) { 100 sout | "continue L1" | endl;100 sout | "continue L1"; 101 101 continue; // destruct x 102 102 } else if (i == 3) { 103 sout | "break L1" | endl;103 sout | "break L1"; 104 104 break; // destruct x 105 105 } 106 106 107 107 L2: for (int j = 0; j < 10; j++) { 108 sout | "g for j=" | j | endl;108 sout | "g for j=" | j; 109 109 A y = { "y" }; 110 110 if (j == 0) { 111 sout | "continue L2" | endl;111 sout | "continue L2"; 112 112 continue; // destruct y - missing because object that needs to be destructed is not a part of this block, it's a part of the for's block 113 113 } else if (j == 1) { 114 sout | "break L2" | endl;114 sout | "break L2"; 115 115 break; // destruct y 116 116 } else if (i == 1) { 117 sout | "continue L1" | endl;117 sout | "continue L1"; 118 118 continue L1; // destruct x,y - note: continue takes you to destructors for block, so only generate destructor for y 119 119 } else if (k == 1) { 120 sout | "break L1" | endl;120 sout | "break L1"; 121 121 break L1; // destruct x,y 122 122 } … … 125 125 } 126 126 127 sout | endl;127 sout | nl; 128 128 L3: if( 3 ) { 129 129 A w = { "w" }; 130 130 if( 4 ) { 131 131 A v = { "v" }; 132 sout | "break L3" | endl;132 sout | "break L3"; 133 133 break L3; 134 134 } … … 144 144 // * if S_L-S_G is non-empty, error 145 145 // * emit destructors for all variables in S_G-S_L 146 sout | "h" | endl;146 sout | "h"; 147 147 { 148 148 L0: ; … … 152 152 A y = { "y" }; 153 153 // S_L1 = { y } 154 L1: sout | "L1" | endl;154 L1: sout | "L1"; 155 155 A x = { "x" }; 156 156 // S_L2 = { y, x } 157 L2: sout | "L2" | endl;157 L2: sout | "L2"; 158 158 if (i == 0) { 159 159 ++i; 160 sout | "goto L1" | endl;160 sout | "goto L1"; 161 161 // S_G = { y, x } 162 162 goto L1; // jump back, destruct b/c before x definition … … 165 165 } else if (i == 1) { 166 166 ++i; 167 sout | "goto L2" | endl;167 sout | "goto L2"; 168 168 // S_G = { y, x } 169 169 goto L2; // jump back, do not destruct … … 172 172 } else if (i == 2) { 173 173 ++i; 174 sout | "goto L3" | endl;174 sout | "goto L3"; 175 175 // S_G = { y, x } 176 176 goto L3; // jump ahead, do not destruct … … 180 180 ++i; 181 181 A z = { "z" }; 182 sout | "goto L3-2" | endl;182 sout | "goto L3-2"; 183 183 // S_G = { z, y, x } 184 184 goto L3; … … 187 187 } else { 188 188 ++i; 189 sout | "goto L4" | endl;189 sout | "goto L4"; 190 190 // S_G = { y, x } 191 191 goto L4; // jump ahead, destruct b/c left block x was defined in … … 194 194 } 195 195 // S_L3 = { y, x } 196 L3: sout | "L3" | endl;197 sout | "goto L2-2" | endl;196 L3: sout | "L3"; 197 sout | "goto L2-2"; 198 198 // S_G = { y, x } 199 199 goto L2; // jump back, do not destruct …