Changeset 515a037
- Timestamp:
- Dec 12, 2018, 3:52:19 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 1b8f13f0
- Parents:
- cdc02f2 (diff), 85acec94 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Files:
-
- 6 added
- 7 deleted
- 86 edited
- 81 moved
-
benchmark/Makefile.am (modified) (2 diffs)
-
benchmark/Makefile.in (modified) (1 diff)
-
benchmark/Monitor.c (modified) (1 diff)
-
doc/bibliography/pl.bib (modified) (21 diffs)
-
doc/papers/concurrency/Paper.tex (modified) (14 diffs)
-
doc/proposals/flags.md (modified) (2 diffs)
-
doc/theses/aaron_moss_PhD/phd/thesis.tex (modified) (1 diff)
-
doc/theses/aaron_moss_PhD/phd/type-environment.tex (modified) (4 diffs)
-
doc/user/user.tex (modified) (45 diffs)
-
examples/ArrayN.c (modified) (2 diffs)
-
examples/gc_no_raii/src/internal/collector.c (modified) (1 diff)
-
examples/gc_no_raii/src/internal/state.h (modified) (1 diff)
-
examples/gc_no_raii/src/tools/print.h (modified) (1 diff)
-
examples/multicore.c (modified) (2 diffs)
-
examples/prolog.c (modified) (1 diff)
-
examples/quad.c (modified) (2 diffs)
-
examples/square.c (modified) (4 diffs)
-
examples/twice.c (modified) (2 diffs)
-
examples/wrapper/src/main.c (modified) (1 diff)
-
examples/wrapper/src/pointer.h (modified) (7 diffs)
-
examples/zero_one.c (modified) (1 diff)
-
libcfa/src/fstream.cfa (modified) (7 diffs)
-
libcfa/src/fstream.hfa (modified) (4 diffs)
-
libcfa/src/gmp.hfa (modified) (2 diffs)
-
libcfa/src/iostream.cfa (modified) (21 diffs)
-
libcfa/src/iostream.hfa (modified) (7 diffs)
-
libcfa/src/iterator.cfa (modified) (1 diff)
-
libcfa/src/rational.cfa (modified) (3 diffs)
-
libcfa/src/rational.hfa (modified) (2 diffs)
-
libcfa/src/time.cfa (modified) (3 diffs)
-
src/Parser/DeclarationNode.cc (modified) (2 diffs)
-
src/Parser/ParseNode.h (modified) (2 diffs)
-
src/Parser/TypeData.cc (modified) (8 diffs)
-
src/Parser/TypeData.h (modified) (2 diffs)
-
src/Parser/lex.ll (modified) (1 diff)
-
src/Parser/parser.yy (modified) (7 diffs)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (2 diffs)
-
src/ResolvExpr/ResolveTypeof.cc (modified) (1 diff)
-
src/SynTree/Type.h (modified) (1 diff)
-
src/SynTree/TypeofType.cc (modified) (2 diffs)
-
tests/.expect/alloc-ERROR.txt (modified) (4 diffs)
-
tests/.expect/castError.txt (modified) (1 diff)
-
tests/.expect/completeTypeError.txt (modified) (1 diff)
-
tests/.expect/declarationErrors.txt (modified) (3 diffs)
-
tests/.expect/loopctrl.txt (modified) (1 diff)
-
tests/.expect/nested-types-ERR1.txt (modified) (1 diff)
-
tests/.expect/nested-types-ERR2.txt (modified) (1 diff)
-
tests/.expect/quotedKeyword.txt (moved) (moved from tests/.expect/quoted_keyword.txt )
-
tests/.expect/scopeErrors.txt (modified) (1 diff)
-
tests/.expect/typedefRedef-ERR1.txt (modified) (1 diff)
-
tests/.expect/user_literals.txt (deleted)
-
tests/.expect/with-statement.txt (deleted)
-
tests/KRfunctions.cfa (moved) (moved from tests/KRfunctions.c ) (2 diffs)
-
tests/Makefile.am (modified) (5 diffs)
-
tests/Makefile.in (modified) (14 diffs)
-
tests/abs.cfa (moved) (moved from tests/abs.c ) (2 diffs)
-
tests/alloc.cfa (moved) (moved from tests/alloc.c ) (2 diffs)
-
tests/array.cfa (moved) (moved from tests/array.c )
-
tests/ato.cfa (moved) (moved from tests/ato.c ) (2 diffs)
-
tests/attributes.cfa (moved) (moved from tests/attributes.c ) (2 diffs)
-
tests/cast.cfa (moved) (moved from tests/cast.c )
-
tests/castError.cfa (moved) (moved from tests/castError.c )
-
tests/commentMisc.cfa (moved) (moved from tests/commentMisc.c )
-
tests/completeTypeError.cfa (moved) (moved from tests/completeTypeError.c )
-
tests/complex.cfa (moved) (moved from tests/complex.c ) (4 diffs)
-
tests/concurrent/coroutineYield.c (modified) (3 diffs)
-
tests/concurrent/examples/boundedBufferEXT.c (modified) (2 diffs)
-
tests/concurrent/examples/boundedBufferINT.c (modified) (2 diffs)
-
tests/concurrent/examples/datingService.c (modified) (4 diffs)
-
tests/concurrent/examples/matrixSum.c (modified) (2 diffs)
-
tests/concurrent/examples/quickSort.c (modified) (6 diffs)
-
tests/concurrent/monitor.c (modified) (1 diff)
-
tests/concurrent/multi-monitor.c (modified) (1 diff)
-
tests/concurrent/preempt.c (modified) (1 diff)
-
tests/concurrent/signal/block.c (modified) (5 diffs)
-
tests/concurrent/signal/disjoint.c (modified) (4 diffs)
-
tests/concurrent/signal/wait.c (modified) (4 diffs)
-
tests/concurrent/thread.c (modified) (4 diffs)
-
tests/concurrent/waitfor/barge.c (modified) (4 diffs)
-
tests/concurrent/waitfor/dtor.c (modified) (3 diffs)
-
tests/concurrent/waitfor/else.c (modified) (1 diff)
-
tests/concurrent/waitfor/recurse.c (modified) (4 diffs)
-
tests/concurrent/waitfor/simple.c (modified) (5 diffs)
-
tests/concurrent/waitfor/statment.c (modified) (3 diffs)
-
tests/concurrent/waitfor/when.c (modified) (3 diffs)
-
tests/context.cfa (moved) (moved from tests/context.c )
-
tests/coroutine/.expect/fmtLines.txt (modified) (2 diffs)
-
tests/coroutine/.in/fmtLines.txt (modified) (3 diffs)
-
tests/coroutine/fibonacci.c (modified) (2 diffs)
-
tests/coroutine/fibonacci_1.c (modified) (2 diffs)
-
tests/coroutine/fmtLines.c (modified) (4 diffs)
-
tests/coroutine/pingpong.c (modified) (2 diffs)
-
tests/coroutine/prodcons.c (modified) (4 diffs)
-
tests/coroutine/runningTotal.c (modified) (2 diffs)
-
tests/counter.cfa (moved) (moved from tests/counter.c ) (2 diffs)
-
tests/declarationErrors.cfa (moved) (moved from tests/declarationErrors.c ) (2 diffs)
-
tests/declarationSpecifier.cfa (moved) (moved from tests/declarationSpecifier.c ) (2 diffs)
-
tests/designations.cfa (moved) (moved from tests/designations.c )
-
tests/div.cfa (moved) (moved from tests/div.c ) (2 diffs)
-
tests/enum.cfa (moved) (moved from tests/enum.c )
-
tests/except-0.cfa (moved) (moved from tests/except-0.c ) (2 diffs)
-
tests/except-1.cfa (moved) (moved from tests/except-1.c ) (1 diff)
-
tests/except-2.cfa (moved) (moved from tests/except-2.c ) (1 diff)
-
tests/except-3.cfa (moved) (moved from tests/except-3.c ) (1 diff)
-
tests/except-mac.hfa (moved) (moved from tests/except-mac.h )
-
tests/expression.cfa (moved) (moved from tests/expression.c )
-
tests/extension.cfa (moved) (moved from tests/extension.c ) (2 diffs)
-
tests/fallthrough.cfa (moved) (moved from tests/fallthrough.c ) (3 diffs)
-
tests/forall.cfa (moved) (moved from tests/forall.c ) (2 diffs)
-
tests/fstream_test.cfa (moved) (moved from tests/fstream_test.c ) (2 diffs)
-
tests/function-operator.cfa (moved) (moved from tests/function-operator.c ) (2 diffs)
-
tests/functions.cfa (moved) (moved from tests/functions.c ) (2 diffs)
-
tests/gccExtensions.cfa (moved) (moved from tests/gccExtensions.c ) (2 diffs)
-
tests/genericUnion.cfa (moved) (moved from tests/genericUnion.c )
-
tests/gmp.cfa (moved) (moved from tests/gmp.c ) (3 diffs)
-
tests/heap.cfa (moved) (moved from tests/heap.c ) (27 diffs)
-
tests/hello.c (deleted)
-
tests/hello.cfa (added)
-
tests/identFuncDeclarator.cfa (moved) (moved from tests/identFuncDeclarator.c ) (2 diffs)
-
tests/identParamDeclarator.cfa (moved) (moved from tests/identParamDeclarator.c ) (2 diffs)
-
tests/identity.c (deleted)
-
tests/identity.cfa (added)
-
tests/ifwhileCtl.cfa (moved) (moved from tests/ifwhileCtl.c ) (4 diffs)
-
tests/io1.cfa (moved) (moved from tests/io1.c ) (5 diffs)
-
tests/io2.c (deleted)
-
tests/io2.cfa (added)
-
tests/labelledExit.cfa (moved) (moved from tests/labelledExit.c ) (2 diffs)
-
tests/limits.cfa (moved) (moved from tests/limits.c ) (2 diffs)
-
tests/literals.cfa (moved) (moved from tests/literals.c ) (3 diffs)
-
tests/long_tests.hfa (moved) (moved from tests/long_tests.h )
-
tests/loopctrl.cfa (added)
-
tests/math1.cfa (moved) (moved from tests/math1.c ) (2 diffs)
-
tests/math2.cfa (moved) (moved from tests/math2.c ) (2 diffs)
-
tests/math3.cfa (moved) (moved from tests/math3.c ) (2 diffs)
-
tests/math4.cfa (moved) (moved from tests/math4.c ) (2 diffs)
-
tests/maybe.cfa (moved) (moved from tests/maybe.c )
-
tests/minmax.cfa (moved) (moved from tests/minmax.c ) (2 diffs)
-
tests/namedParmArg.cfa (moved) (moved from tests/namedParmArg.c )
-
tests/nested-types.cfa (moved) (moved from tests/nested-types.c ) (2 diffs)
-
tests/numericConstants.cfa (moved) (moved from tests/numericConstants.c ) (2 diffs)
-
tests/occursError.cfa (moved) (moved from tests/occursError.c )
-
tests/operators.cfa (moved) (moved from tests/operators.c )
-
tests/polymorphism.cfa (moved) (moved from tests/polymorphism.c )
-
tests/preempt_longrun/create.c (modified) (1 diff)
-
tests/preempt_longrun/enter3.c (modified) (1 diff)
-
tests/preempt_longrun/processor.c (modified) (1 diff)
-
tests/preempt_longrun/yield.c (modified) (1 diff)
-
tests/quotedKeyword.cfa (moved) (moved from tests/quoted_keyword.c ) (2 diffs)
-
tests/raii/dtor-early-exit.c (modified) (16 diffs)
-
tests/raii/globals.c (modified) (1 diff)
-
tests/random.cfa (moved) (moved from tests/random.c ) (2 diffs)
-
tests/rational.cfa (moved) (moved from tests/rational.c ) (2 diffs)
-
tests/references.cfa (moved) (moved from tests/references.c )
-
tests/result.cfa (moved) (moved from tests/result.c )
-
tests/scope.cfa (moved) (moved from tests/scope.c )
-
tests/scopeErrors.cfa (moved) (moved from tests/scopeErrors.c )
-
tests/searchsort.cfa (moved) (moved from tests/searchsort.c ) (14 diffs)
-
tests/shortCircuit.c (deleted)
-
tests/shortCircuit.cfa (added)
-
tests/simpleGenericTriple.cfa (moved) (moved from tests/simpleGenericTriple.c )
-
tests/stdincludes.cfa (moved) (moved from tests/stdincludes.c ) (2 diffs)
-
tests/structMember.cfa (moved) (moved from tests/structMember.c )
-
tests/subrange.cfa (moved) (moved from tests/subrange.c )
-
tests/sum.cfa (moved) (moved from tests/sum.c ) (9 diffs)
-
tests/swap.cfa (moved) (moved from tests/swap.c ) (2 diffs)
-
tests/switch.cfa (moved) (moved from tests/switch.c ) (2 diffs)
-
tests/time.c (deleted)
-
tests/time.cfa (added)
-
tests/tuple/tupleAssign.c (modified) (4 diffs)
-
tests/typeGenerator.cfa (moved) (moved from tests/typeGenerator.c )
-
tests/typedef.cfa (moved) (moved from tests/typedef.c )
-
tests/typedefDeclarator.cfa (moved) (moved from tests/typedefDeclarator.c )
-
tests/typedefRedef.cfa (moved) (moved from tests/typedefRedef.c )
-
tests/typeof.cfa (moved) (moved from tests/typeof.c )
-
tests/userLiterals.cfa (moved) (moved from tests/user_literals.c ) (4 diffs)
-
tests/variableDeclarator.cfa (moved) (moved from tests/variableDeclarator.c ) (2 diffs)
-
tests/vector.cfa (moved) (moved from tests/vector.c ) (4 diffs)
-
tests/virtualCast.cfa (moved) (moved from tests/virtualCast.c )
-
tests/voidPtr.cfa (moved) (moved from tests/voidPtr.c )
-
tests/withStatement.cfa (moved) (moved from tests/with-statement.c )
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.am
rcdc02f2 r515a037 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Jan 25 22:31:42 201614 ## Update Count : 2 513 ## Last Modified On : Tue Nov 6 09:01:23 2018 14 ## Update Count : 26 15 15 ############################################################################### 16 16 … … 308 308 309 309 compile-attributes$(EXEEXT): 310 $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.c 310 $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 311 311 312 312 compile-empty$(EXEEXT): -
benchmark/Makefile.in
rcdc02f2 r515a037 879 879 880 880 compile-attributes$(EXEEXT): 881 $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.c 881 $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 882 882 883 883 compile-empty$(EXEEXT): -
benchmark/Monitor.c
rcdc02f2 r515a037 29 29 EndTime = Time(); 30 30 31 sout | ( EndTime - StartTime ) / N | endl;31 sout | ( EndTime - StartTime ) / N; 32 32 } -
doc/bibliography/pl.bib
rcdc02f2 r515a037 21 21 % toplas: ACM Trans. on Prog. Lang. & Sys. 22 22 % tcs: Theoretical Computer Science 23 @string{ieeepds="IEEE Transactions on Parallel and Distributed Systems"} 24 % @string{ieeepds="IEEE Trans. Parallel Distrib. Syst."} 25 @string{ieeese="IEEE Transactions on Software Engineering"} 26 % @string{ieeese="IEEE Trans. Softw. Eng."} 27 @string{spe="Software---\-Practice and Experience"} 28 % @string{spe="Softw. Pract. Exp."} 29 @string{ccpe="Concurrency and Computation: Practice and Experience"} 30 % @string{ccpe="Concurrency Comput: Pract Experience"} 31 @string{sigplan="SIGPLAN Notices"} 32 % @string{sigplan="SIGPLAN Not."} 33 @string{joop="Journal of Object-Oriented Programming"} 34 % @string{joop="J. of Object-Oriented Program."} 23 24 string{ieeepds="IEEE Transactions on Parallel and Distributed Systems"} 25 @string{ieeepds="IEEE Trans. Parallel Distrib. Syst."} 26 string{ieeese="IEEE Transactions on Software Engineering"} 27 @string{ieeese="IEEE Trans. Softw. Eng."} 28 string{spe="Software---\-Practice and Experience"} 29 @string{spe="Softw. Pract. Exper."} 30 string{ccpe="Concurrency and Computation: Practice and Experience"} 31 @string{ccpe="Concurrency Comput.: Pract. Exper."} 32 string{sigplan="SIGPLAN Notices"} 33 @string{sigplan="SIGPLAN Not."} 34 string{joop="Journal of Object-Oriented Programming"} 35 @string{joop="J. of Object-Oriented Program."} 35 36 @string{popl="Conference Record of the ACM Symposium on Principles of Programming Languages"} 36 37 @string{osr="Operating Systems Review"} 37 38 @string{pldi="Programming Language Design and Implementation"} 38 39 @string{toplas="Transactions on Programming Languages and Systems"} 39 @string{mathann="Mathematische Annalen"}40 %@string{mathann="Math. Ann."}40 string{mathann="Mathematische Annalen"} 41 @string{mathann="Math. Ann."} 41 42 42 43 % A … … 566 567 } 567 568 569 @inproceedings {Qin18, 570 author = {Henry Qin and Qian Li and Jacqueline Speiser and Peter Kraft and John Ousterhout}, 571 title = {Arachne: Core-Aware Thread Management}, 572 booktitle = {13th {USENIX} Symp. on Oper. Sys. Design and Impl. ({OSDI} 18)}, 573 year = {2018}, 574 address = {Carlsbad, CA}, 575 pages = {145-160}, 576 publisher = {{USENIX} Association}, 577 note = {\href{https://www.usenix.org/conference/osdi18/presentation/qin}{https://\-www.usenix.org/\-conference/\-osdi18/\-presentation/\-qin}}, 578 } 579 568 580 @article{Kessels82, 569 581 keywords = {concurrency, critical section}, … … 653 665 author = {Joung, Yuh-Jzer}, 654 666 title = {Asynchronous group mutual exclusion}, 655 journal = {Distributed Computing}, 667 journal = {Dist. Comput.}, 668 optjournal = {Distributed Computing}, 656 669 year = {2000}, 657 670 month = {Nov}, … … 796 809 time computable inheritance hierarchy. 797 810 }, 798 comment = {811 comment = { 799 812 Classes are predicates; if object {\tt o} is in class {\tt C}, then 800 813 {\tt C} is true of {\tt o}. Classes are combined with {\tt :AND}, … … 950 963 951 964 @article{Moss18, 952 keywords = {type systems, tuples, Cforall},965 keywords = {type systems, polymorphism, tuples, Cforall}, 953 966 contributer = {pabuhr@plg}, 954 967 author = {Aaron Moss and Robert Schluntz and Peter A. Buhr}, 955 968 title = {\textsf{C}$\mathbf{\forall}$ : Adding Modern Programming Language Features to C}, 969 journal = spe, 970 volume = 48, 971 number = 12, 972 month = dec, 956 973 year = 2018, 957 month = aug, 958 journal = spe, 974 pages = {2111-2146}, 959 975 note = {\href{http://dx.doi.org/10.1002/spe.2624}{http://\-dx.doi.org/\-10.1002/\-spe.2624}}, 960 976 } … … 989 1005 journal = {Dr. Dobb's Journal of Software Tools}, 990 1006 year = 1989, 991 month = feb, volume = 14, number = 2, pages = {45-51}, 1007 month = feb, 1008 volume = 14, 1009 number = 2, 1010 pages = {45-51}, 992 1011 comment = { 993 1012 A light-weight multitasking kernel for MS-DOS. A task\_control … … 1507 1526 } 1508 1527 1509 @ techreport{uC++,1528 @manual{uC++, 1510 1529 keywords = {C++, concurrency, light-weight process, shared memory}, 1511 1530 contributer = {pabuhr@plg}, 1531 key = {uC++}, 1512 1532 author = {Peter A. Buhr}, 1513 1533 title = {$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Annotated Reference Manual, Version 7.0.0}, 1514 institution = {School of Computer Science, University of Waterloo}, 1515 address = {Waterloo, Ontario, Canada, N2L 3G1}, 1516 month = dec, 1517 year = 2017, 1534 organization= {University of Waterloo}, 1535 month = sep, 1536 year = 2018, 1518 1537 note = {\href{https://plg.uwaterloo.ca/~usystem/pub/uSystem/uC++.pdf}{https://\-plg.uwaterloo.ca/\-$\sim$usystem/\-pub/\-uSystem/uC++.pdf}}, 1519 1538 } … … 1586 1605 author = {Sun, Xianda}, 1587 1606 title = {Concurrent High-performance Persistent Hash Table In {J}ava}, 1588 school = {School of Computer Sc ience, University of Waterloo},1607 school = {School of Computer Sc., University of Waterloo}, 1589 1608 year = 2015, 1590 1609 optaddress = {Waterloo, Ontario, Canada, N2L 3G1}, … … 1936 1955 note = {Svensk Standard SS 63 61 14}, 1937 1956 year = 1987, 1938 abstract = { 1939 Standard for the programming language SIMULA. Written in English. 1940 } 1957 abstract = {Standard for the programming language SIMULA. Written in English.} 1958 } 1959 1960 @article{Galil91, 1961 keywords = {union-find}, 1962 contributer = {a3moss@uwaterloo.ca}, 1963 title = {Data structures and algorithms for disjoint set union problems}, 1964 author = {Galil, Zvi and Italiano, Giuseppe F}, 1965 journal = {ACM Computing Surveys (CSUR)}, 1966 volume = 23, 1967 number = 3, 1968 pages = {319--344}, 1969 year = 1991, 1970 publisher = {ACM}, 1941 1971 } 1942 1972 … … 2078 2108 year = {1998}, 2079 2109 pages = {393-407}, 2110 } 2111 2112 @book{Aho74, 2113 keywords = {algorithms, textbook, union-find}, 2114 contributer = {a3moss@uwaterloo.ca}, 2115 title = {The Design and Analysis of Computer Algorithms}, 2116 author = {Aho, Alfred V and Hopcroft, John E and Ullman, Jeffrey D}, 2117 year = {1974}, 2118 publisher = {Addison-Wesley}, 2119 address = {Reading, MA, USA} 2080 2120 } 2081 2121 … … 2880 2920 } 2881 2921 2922 @inproceedings{Patwary10, 2923 keywords = {union-find}, 2924 contributer = {a3moss@uwaterloo.ca}, 2925 author = {Patwary, Md. Mostofa Ali and Blair, Jean and Manne, Fredrik}, 2926 editor = {Festa, Paola}, 2927 title = {Experiments on Union-Find Algorithms for the Disjoint-Set Data Structure}, 2928 booktitle = {Experimental Algorithms}, 2929 year = 2010, 2930 publisher = {Springer Berlin Heidelberg}, 2931 address = {Berlin, Heidelberg}, 2932 pages = {411--423}, 2933 isbn = {978-3-642-13193-6} 2934 } 2935 2882 2936 % F 2883 2937 … … 3223 3277 keywords = {Go programming language}, 3224 3278 contributer = {pabuhr@plg}, 3279 author = {Robert Griesemer and Rob Pike and Ken Thompson}, 3225 3280 title = {{Go} Programming Language}, 3226 author = {Robert Griesemer and Rob Pike and Ken Thompson},3227 3281 organization= {Google}, 3228 3282 year = 2009, … … 3416 3470 month = sep, 3417 3471 publisher = {John Wiley \& Sons}, 3418 note = {\href{https://doi -org.proxy.lib.uwaterloo.ca/10.1002/cpe.4475}{https://\-doi-org.proxy.lib.uwaterloo.ca/\-10.1002/\-cpe.4475}},3472 note = {\href{https://doi.org/10.1002/cpe.4475}{https://\-doi.org/\-10.1002/\-cpe.4475}}, 3419 3473 } 3420 3474 … … 3554 3608 publisher = {ACM Press}, 3555 3609 address = {New York, NY, USA}, 3610 } 3611 3612 @article{Galler64, 3613 keywords = {union-find, original}, 3614 contributer = {a3moss@uwaterloo.ca}, 3615 title = {An improved equivalence algorithm}, 3616 author = {Galler, Bernard A and Fisher, Michael J}, 3617 journal = {Communications of the ACM}, 3618 volume = {7}, 3619 number = {5}, 3620 pages = {301--303}, 3621 year = {1964}, 3622 publisher = {ACM} 3556 3623 } 3557 3624 … … 3898 3965 author = {Peter A. Buhr and Martin Karsten and Jun Shih}, 3899 3966 title = {{\small\textsf{KDB}}: A Multi-threaded Debugger for Multi-threaded Applications}, 3900 booktitle = {Proc eedings of SPDT'96: SIGMETRICS Symposiumon Parallel and Distributed Tools},3967 booktitle = {Proc. of SPDT'96: SIGMETRICS Symp. on Parallel and Distributed Tools}, 3901 3968 publisher = {ACM Press}, 3902 3969 address = {Philadelphia, Pennsylvania, U.S.A.}, … … 5389 5456 } 5390 5457 5458 @inproceedings{Conchon07, 5459 keywords = {persistent array, union-find}, 5460 contributer = {a3moss@uwaterloo.ca}, 5461 title = {A persistent union-find data structure}, 5462 author = {Conchon, Sylvain and Filli{\^a}tre, Jean-Christophe}, 5463 booktitle = {Proceedings of the 2007 workshop on Workshop on ML}, 5464 pages = {37--46}, 5465 year = {2007}, 5466 organization= {ACM} 5467 } 5468 5391 5469 @article{poly, 5392 5470 keywords = {Poly, Standard ML, Russell, persistence}, … … 5603 5681 author = {Peter A. Buhr and Robert Denda}, 5604 5682 title = {{$\mu$Profiler} : Profiling User-Level Threads in a Shared-Memory Programming Environment}, 5605 booktitle = {Proc eedings of the Second International Symposium on Computing in Object-Oriented Parallel Environments (ISCOPE'98)},5683 booktitle = {Proc. of 2nd Inter. Symp. on Computing in Object-Oriented Parallel Environments}, 5606 5684 series = {Lecture Notes in Computer Science}, 5607 5685 publisher = {Springer-Verlag}, … … 5974 6052 issn = {0164-0925}, 5975 6053 pages = {429-475}, 5976 url = {http://doi.acm.org .proxy.lib.uwaterloo.ca/10.1145/1133651.1133653},6054 url = {http://doi.acm.org/10.1145/1133651.1133653}, 5977 6055 doi = {10.1145/1133651.1133653}, 5978 6056 acmid = {1133653}, … … 6241 6319 contributer = {pabuhr@plg}, 6242 6320 key = {Rust}, 6243 title = { The{R}ust Programming Language},6244 address = {TheRust Project Developers},6321 title = {{R}ust Programming Language}, 6322 optaddress = {Rust Project Developers}, 6245 6323 year = 2015, 6246 6324 note = {\href{https://doc.rust-lang.org/reference.html}{https://\-doc.rust-lang\-.org/\-reference.html}}, … … 6308 6386 publisher = {Springer}, 6309 6387 note = {Lecture Notes in Computer Science v. 173}, 6388 } 6389 6390 @article{Baker78, 6391 keywords = {Algol display, FUNARG's, Lisp 1.5, deep binding, environment trees, multiprogramming, shallow binding}, 6392 contributer = {a3moss@uwaterloo.ca}, 6393 author = {Baker,Jr., Henry G.}, 6394 title = {Shallow Binding in Lisp 1.5}, 6395 journal = {Commun. ACM}, 6396 issue_date = {July 1978}, 6397 volume = 21, 6398 number = 7, 6399 month = jul, 6400 year = 1978, 6401 issn = {0001-0782}, 6402 pages = {565--569}, 6403 numpages = {5}, 6404 url = {http://doi.acm.org/10.1145/359545.359566}, 6405 doi = {10.1145/359545.359566}, 6406 acmid = {359566}, 6407 publisher = {ACM}, 6408 address = {New York, NY, USA} 6409 } 6410 6411 @article{Baker91, 6412 keywords = {shallow binding, functional arrays}, 6413 contributer = {a3moss@uwaterloo.ca}, 6414 author = {Baker, Henry G.}, 6415 title = {Shallow Binding Makes Functional Arrays Fast}, 6416 journal = {SIGPLAN Not.}, 6417 issue_date = {Aug. 1991}, 6418 volume = 26, 6419 number = 8, 6420 month = aug, 6421 year = 1991, 6422 issn = {0362-1340}, 6423 pages = {145--147}, 6424 numpages = {3}, 6425 url = {http://doi.acm.org/10.1145/122598.122614}, 6426 doi = {10.1145/122598.122614}, 6427 acmid = {122614}, 6428 publisher = {ACM}, 6429 address = {New York, NY, USA}, 6310 6430 } 6311 6431 … … 7476 7596 } 7477 7597 7598 @article{Tarjan84, 7599 keywords = {union-find}, 7600 contributer = {a3moss@uwaterloo.ca}, 7601 author = {Tarjan, Robert E. and van Leeuwen, Jan}, 7602 title = {Worst-case Analysis of Set Union Algorithms}, 7603 journal = {J. ACM}, 7604 issue_date = {April 1984}, 7605 volume = 31, 7606 number = 2, 7607 month = mar, 7608 year = 1984, 7609 issn = {0004-5411}, 7610 pages = {245--281}, 7611 numpages = {37}, 7612 url = {http://doi.acm.org/10.1145/62.2160}, 7613 doi = {10.1145/62.2160}, 7614 acmid = {2160}, 7615 publisher = {ACM}, 7616 address = {New York, NY, USA}, 7617 } 7618 7478 7619 % X 7479 7620 -
doc/papers/concurrency/Paper.tex
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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/theses/aaron_moss_PhD/phd/thesis.tex
rcdc02f2 r515a037 23 23 % \usepackage[pdftex]{graphicx} % For including graphics N.B. pdftex graphics driver 24 24 \usepackage{graphicx} 25 26 \usepackage{amsthm} % for theorem environment 27 \newtheorem{theorem}{Theorem} 25 28 26 29 \usepackage{footmisc} % for double refs to the same footnote -
doc/theses/aaron_moss_PhD/phd/type-environment.tex
rcdc02f2 r515a037 5 5 As discussed in Chapter~\ref{resolution-chap}, being able to efficiently determine which type variables are bound to which concrete types or whether two type environments are compatible is a core requirement of the resolution algorithm. 6 6 Furthermore, expression resolution involves a search through many related possible solutions, so being able to re-use shared subsets of type environment data and to switch between environments quickly is desirable for performance. 7 In this chapter I discuss and empirically compare a number of type environment data structure variants, including some novel variations on the union-find\cit {} data structure introduced in this thesis.8 9 \section{Definitions} 7 In this chapter I discuss and empirically compare a number of type environment data structure variants, including some novel variations on the union-find\cite{Galler64} data structure introduced in this thesis. 8 9 \section{Definitions} \label{env-defn-sec} 10 10 11 11 For purposes of this chapter, a \emph{type environment} $T$ is a set of \emph{type classes} $\myset{T_1, T_2, \cdots, T_{|T|}}$. … … 24 24 $add(T_i, v_{i,j})$ & & Add variable to class \\ 25 25 $bind(T_i, b_i)$ & & Set or update class bound \\ 26 $remove(T, T_i)$ & & Remove class from environment \\27 26 $unify(T, T_i, T_j)$ & $\rightarrow \top | \bot$ & Combine two type classes \\ 27 $split(T, T_i)$ & $\rightarrow T'$ & Revert the last $unify$ operation on $T_i$ \\ 28 28 $combine(T, T')$ & $\rightarrow \top | \bot$ & Merge two environments \\ 29 29 $save(T)$ & $\rightarrow H$ & Get handle for current state \\ … … 40 40 The $add(T_i, v_{i,j})$ operation adds a new type variable $v_{i,j}$ to class $T_i$; again, $v_{i,j}$ cannot exist elsewhere in $T$. 41 41 $bind(T_i, b_i)$ mutates the bound for a type class, setting or updating the current bound. 42 The final basic mutation operation is $remove(T, T_i)$, which removes a class $T_i$ and all its type variables from an environment $T$.43 42 44 43 The $unify$ operation is the fundamental non-trivial operation a type environment data structure must support. 45 44 $unify(T, T_i, T_j)$ merges a type class $T_j$ into another $T_i$, producing a failure result and leaving $T$ in an invalid state if this merge fails. 46 45 It is always possible to unify the type variables of both classes by simply taking the union of both sets; given the disjointness property, no checks for set containment are required, and the variable sets can simply be concatenated if supported by the underlying data structure. 47 $unify$ depends on an internal $unify _bound$ operation which may fail.48 In \CFACC{}, $unify _bound(b_i, b_j) \rightarrow b'_i|\bot$ checks that the type classes contain the same sort of variable, takes the tighter of the two conversion permissions, and checks if the bound types can be unified.49 If the bound types cannot be unified (\eg{} !struct A! with !int*!), then $unify _bound$ fails, while other combinations of bound types may result in recursive calls.50 For instance, unifying !R*! with !S*! for type variables !R! and !S! will result in a call to $unify(T, find($!R!$), find($!S!$))$, while unifying !R*! with !int*! will result in a call to $unify _bound$ on !int! and the bound type of the class containing !R!.46 $unify$ depends on an internal $unifyBound$ operation which may fail. 47 In \CFACC{}, $unifyBound(b_i, b_j) \rightarrow b'_i|\bot$ checks that the type classes contain the same sort of variable, takes the tighter of the two conversion permissions, and checks if the bound types can be unified. 48 If the bound types cannot be unified (\eg{} !struct A! with !int*!), then $unifyBound$ fails, while other combinations of bound types may result in recursive calls. 49 For instance, unifying !R*! with !S*! for type variables !R! and !S! will result in a call to $unify(T, find($!R!$), find($!S!$))$, while unifying !R*! with !int*! will result in a call to $unifyBound$ on !int! and the bound type of the class containing !R!. 51 50 As such, a call to $unify(T, T_i, T_j)$ may touch every type class in $T$, not just $T_i$ and $T_j$, collapsing the entirety of $T$ into a single type class in extreme cases. 51 For more information on \CFA{} unification, see \cite{Bilson03}. 52 The inverse of $unify$ is $split(T, T_i)$, which produces a new environment $T'$ which is the same as $T$ except that $T_i$ has been replaced by two classes corresponding to the arguments to the previous call to $unify$ on $T_i$. 53 If there has been no call to $unify$ on $T_i$ (\ie{} $T_i$ is a single-element class) $T_i$ is absent in $T'$. 52 54 53 55 Given the nature of the expression resolution problem as backtracking search, caching and concurrency are both useful tools to decrease runtime. … … 57 59 The invalid state of $T$ on failure is not important, given that a combination failure will result in the resolution algorithm backtracking to a different environment. 58 60 $combine$ proceeds by calls to $insert$, $add$, and $unify$ as needed, and can be roughly thought of as calling $unify$ on every pair of classes in $T$ that have variables $v'_{i,j}$ and $v'_{i,k}$ in the same class $T'_i$ in $T'$. 59 Like for $unify$, $combine$ can always find a mutually-consistent division of type variables into classes (in the extreme case, all type variables from $T$ and $T'$ in a single type class), but may fail due to inconsistent bounds on merged type classes.61 Like $unify$, $combine$ can always find a mutually-consistent partition of type variables into classes (in the extreme case, all type variables from $T$ and $T'$ in a single type class), but may fail due to inconsistent bounds on merged type classes. 60 62 61 63 Finally, the backtracking access patterns of the compiler can be exploited to reduce memory usage or runtime through use of an appropriately designed data structure. 62 64 The set of mutations to a type environment across the execution of the resolution algorithm produce an implicit tree of related environments, and the backtracking search typically focuses only on one leaf of the tree at once, or at most a small number of closely-related nodes as arguments to $combine$. 63 65 As such, the ability to save and restore particular type environment states is useful, and supported by the $save(T) \rightarrow H$ and $backtrack(T, H)$ operations, which produce a handle for the current environment state and mutate an environment back to a previous state, respectively. 64 These operations can be naively implemented by a deep copy of $T$ into $H$ and vice versa, but have more efficient implementations in persistency-aware data structures. 66 These operations can be naively implemented by a deep copy of $T$ into $H$ and vice versa, but have more efficient implementations in persistency-aware data structures. 67 68 \section{Approaches} 69 70 \subsection{Na\"{\i}ve} 71 72 The type environment data structure used in Bilson's\cite{Bilson03} original implementation of \CFACC{} is a straightforward translation of the definitions in Section~\ref{env-defn-sec} to \CC{} code; a !TypeEnvironment! contains a list of !EqvClass! type equivalence classes, each of which contains the type bound information and a tree-based sorted set of type variables. 73 This approach has the benefit of being easy to understand and not imposing life-cycle or inheritance constraints on its use, but, as can be seen in Table~\ref{env-bounds-table}, does not support many of the desired operations with any particular efficiency. 74 Some variations on this structure may improve performance somewhat; for instance, replacing the !EqvClass! variable storage with a hash-based set would reduce search and update times from $O(\log n)$ to amortized $O(1)$, while adding an index for the type variables in the entire environment would remove the need to check each type class individually to maintain the disjointness property. 75 These improvements do not change the fundamental issues with this data structure, however. 76 77 \subsection{Incremental Inheritance} 78 79 One more invasive modification to this data structure which I investigated is to support swifter combinations of closely-related environments in the backtracking tree by storing a reference to a \emph{parent} environment within each environment, and having that environment only store type classes which have been modified with respect to the parent. 80 This approach provides constant-time copying of environments, as a new environment simply consists of an empty list of type classes and a reference to its (logically identical) parent; since many type environments are no different than their parent, this speeds backtracking in this common case. 81 Since all mutations made to a child environment are by definition compatible with the parent environment, two descendants of a common ancestor environment can be combined by iteratively combining the changes made in one environment then that environment's parent until the common ancestor is reached, again re-using storage and reducing computation in many cases. 82 83 For this environment I also employed a lazily-generated index of type variables to their containing class, which could be in either the current environment or an ancestor. 84 Any mutation of a type class in an ancestor environment would cause that class to be copied into the current environment before mutation, as well as added to the index, ensuring that all local changes to the type environment are listed in its index. 85 However, not adding type variables to the index until lookup or mutation preserves the constant-time environment copy operation in the common case in which the copy is not mutated from its parent during its life-cycle. 86 87 This approach imposes some performance penalty on $combine$ if related environments are not properly linked together, as the entire environment needs to be combined rather than just the diff, but is correct as long as the ``null parent'' base case is properly handled. 88 The life-cycle issues are somewhat more complex, as many environments may descend from a common parent, and all of these need their parent to stay alive for purposes of lookup. 89 These issues can be solved by ``flattening'' parent nodes into their children before the parents leave scope, but given the tree structure of the inheritance graph it is more straightforward to store the parent nodes in reference-counted or otherwise automatically garbage-collected heap storage. 90 91 \subsection{Union-Find} \label{env-union-find-approach} 92 93 Given the nature of the classes of type variables as disjoint sets, another natural approach to implementing a type environment is the union-find disjoint set data structure\cite{Galler64}. 94 Union-find efficiently implements two operations over a partition of a collection of elements into disjoint sets; $find(x)$ locates the \emph{representative} of $x$, the element which canonically names its set, while $union(r, s)$ merges two sets represented by $r$ and $s$, respectively. 95 The union-find data structure is based on providing each element with a reference to its parent element, such that the root of a tree of elements is the representative of the set of elements contained in the tree. 96 $find$ is then implemented by a search up to the parent, generally combined with a \emph{path compression} step that links nodes more directly to their ancestors to speed up subsequent searches. 97 $union$ involves making the representative of one set a child of the representative of the other, generally employing a rank- or size-based heuristic to ensure that the tree remains somewhat balanced. 98 If both path compression and a balancing heuristic are employed, both $union$ and $find$ run in amortized $O(\alpha(n))$ worst-case time; this bound by the inverse Ackermann function is a small constant for all practical values of $n$. 99 100 The union-find $find$ and $union$ operations have obvious applicability to the $find$ and $unify$ type environment operations in Table~\ref{env-op-table}, but the union-find data structure must be augmented to fully implement the type environment operations. 101 In particular, the type class bound cannot be easily included in the union-find data structure, as the requirement to make it the class representative breaks the balancing properties of $union$, and requires too-close integration of the type environment $unifyBound$ internal operation. 102 This issue can be solved by including a side map from class representatives to the type class bound. 103 If placeholder values are inserted in this map for type classes without bounds than this also has the useful property that the key set of the map provides an easily obtainable list of all the class representatives, a list which cannot be derived from the union-find data structure without a linear search for class representatives through all elements. 104 105 \subsection{Union-Find with Classes} \label{env-union-find-classes-approach} 106 107 Another type environment operation not supported directly by the union-find data structure is $report$, which lists the type variables in a given class, and similarly $split$, which reverts a $unify$ operation. 108 Since the union-find data structure stores only links from children to parents and not vice-versa, there is no way to reconstruct a class from one of its elements without a linear search over the entire data structure, with $find$ called on each element to check its membership in the class. 109 The situation is even worse for the $split$ operation, which would require extra information to maintain the order that each child was added to its parent node. 110 Unfortunately, the literature\cite{Tarjan84,Galil91,Patwary10} on union-find does not present a way to keep references to children without breaking the asymptotic time bounds of the algorithm; I have discovered a method to do so which, despite its simplicity, seems to be novel. 111 112 \TODO{port figure from slideshow} 113 114 The core idea of this ``union-find with classes'' data structure and algorithm is to keep the members of each class stored in a circularly-linked list. 115 Aho, Hopcroft, and Ullman also include a circularly-linked list in their 1974 textbook~\cite{Aho74}. 116 However, the algorithm presented by Aho~\etal{} has an entirely flat class hierarchy, where all elements are direct children of the representative, giving constant-time $find$ at the cost of linear-time $union$ operations. 117 In my version, the list data structure does not affect the layout of the union-find tree, maintaining the same asymptotic bounds as union-find. 118 In more detail, each element is given a !next! pointer to another element in the same class; this !next! pointer initially points to the element itself. 119 When two classes are unified, the !next! pointers of the representatives of those classes are swapped, splicing the two circularly-linked lists together. 120 Importantly, though this approach requires an extra pointer per element, it does maintain the linear space bound of union-find, and because it only requires updating the two root nodes in $union$ it does not asymptotically increase runtime either. 121 The basic approach is compatible with all path-compression techniques, and allows the members of any class to be retrieved in time linear in the size of the class simply by following the !next! pointers from any element. 122 123 If the path-compression optimization is abandoned, union-find with classes also encodes a reversible history of all the $union$ operations applied to a given class. 124 Theorem~\ref{env-reverse-thm} demonstrates that the !next! pointer of the representative of a class always points to a leaf from the last-added subtree. 125 This property is sufficient to reverse the most-recent $union$ operation by finding the ancestor of that leaf that is an immediate child of the representative, breaking its parent link, and swapping the !next! pointers back\footnote{Union-by-size may be a more appropriate approach than union-by-rank in this instance, as adding two known sizes is a reversible operation, but the rank increment operation cannot be reliably reversed.}. 126 Once the $union$ operation has been reversed, Theorem~\ref{env-reverse-thm} still holds for the reduced class, and the process can be repeated recursively until the entire set is split into its component elements. 127 128 \begin{theorem} \label{env-reverse-thm} 129 The !next! pointer of a class representative in the union-find with classes algorithm without path compression points to a leaf from the most-recently-added subtree. 130 \end{theorem} 131 132 \begin{proof} 133 By induction on the height of the tree. \\ 134 \emph{Base case:} A height 1 tree by definition includes only a single item. In such a case, the representative's !next! pointer points to itself by construction, and the representative is the most-recently-added (and only) leaf in the tree. \\ 135 \emph{Inductive case:} By construction, a tree $T$ of height greater than 1 has children of the root (representative) node that were representative nodes of classes merged by $union$. By definition, the most-recently-added subtree $T'$ has a smaller height than $T$, thus by the inductive hypothesis before the most-recent $union$ operation the !next! pointer of the root of $T'$ pointed to one of the leaf nodes of $T'$; by construction the !next! pointer of the root of $T$ points to this leaf after the $union$ operation. 136 \end{proof} 137 138 On its own, union-find, like the na\"{\i}ve approach, has no special constraints on life-cycle or inheritance, but it can be used as a building block in more sophisticated type environment data structures. 139 140 \subsection{Persistent Union-Find} 141 142 Given the backtracking nature of the resolution algorithm discussed in Section~\ref{env-defn-sec}, the abilities to quickly switch between related versions of a type environment and to de-duplicate shared data between environments are both assets to performance. 143 Conchon and Filli\^{a}tre~\cite{Conchon07} present a persistent union-find data structure based on the persistent array of Baker~\cite{Baker78,Baker91}. 144 145 \TODO{port figure from slideshow} 146 147 In Baker's persistent array, an array reference contains either a pointer to the array or a pointer to an \emph{edit node}; these edit nodes contain an array index, the value in that index, and another array reference pointing either to the array or a different edit node. 148 In this manner, a tree of edits is formed, rooted at the actual array. 149 Read from the actual array at the root can be performed in constant time, as with a non-persistent array. 150 The persistent array can be mutated in constant time by directly modifying the underlying array, then replacing its array reference with an edit node containing the mutated index, the previous value at that index, and a reference to the mutated array. If the current array reference is not the root, mutation consists simply of constructing a new edit node encoding the change and referring to the current array reference. 151 The mutation algorithm at the root is in some sense a special case of the key operation on persistent arrays, $reroot$. 152 153 A rerooting operation takes any array reference and makes it the root node of the array. 154 This is accomplished by tracing the path from some edit node to the root node of the array (always the underlying array), recursively applying the edits to the underlying array and replacing each edit node's successor with the inverse edit. 155 In this way, any previous state of the persistent array can be restored in time proportional to the number of edits to the current state of the array. 156 While $reroot$ does maintain the same value mapping in every version of the persistent array, the internal mutations it performs means that it is not thread-safe, and must be used behind a lock in a concurrent context. 157 Also, the root node with the actual array may in principle be anywhere in the tree, and does not provide information to report its leaf nodes, so some form of automatic garbage collection is generally required for the data structure. 158 Since the graph of edit nodes is tree-structured, reference counting approaches suffice for garbage collection; Conchon and Filli\^{a}tre~\cite{Conchon07} also observe that if the only $reroot$ operations are for backtracking then the tail of inverse edit nodes may be elided, suggesting the possibility of stack-based memory management. 159 160 While Conchon and Filli\^{a}tre~\cite{Conchon07} implement their persistent union-find data structure over a universe of integer elements in the fixed range $[1,N]$, the type environment problem needs more flexibility. 161 In particular, an arbitrary number of type variables must be added to the environment. 162 As such, a persistent hash table is a more suitable structure than a persistent array, providing the same expected asymptotic time bounds while allowing a dynamic number of elements. 163 Besides replacing the underlying array with a hash table, the other major change in this approach is to replace the two types of array references, !Array! and !Edit!, with four node types, !Table!, !Edit!, !Add!, and !Remove!, where !Add! adds a new key-value pair, !Remove! removes a key, and !Edit! mutates an existing key-value pair. 164 In this variant of \CFACC{}, this persistent hash table is used as the side map discussed in Section~\ref{env-union-find-approach} for class bounds. 165 The actual union-find data structure is slightly modified from this approach, with a !Base! node containing the root union-find data structure, !Add! nodes adding new elements, !AddTo! nodes defining the union of two type classes, and !Remove! and !RemoveFrom! nodes as inverses of the previous two elements, for purposes of maintaining the edit list. 166 Making !AddTo! and !RemoveFrom! single nodes shortens the edit path for improved performance, while also providing semantic information missing from the raw array updates in Conchon and Filli\^{a}tre's data structure. 167 The single-node approach, does, however, break under most path-compression algorithms; !RemoveFrom! can be applied to the underlying data structure using the ``leaf of last union'' approach discussed in in Section~\ref{env-union-find-classes-approach}; this was judged an acceptable trade-off for the added semantic information and shortened paths. 168 169 Maintaining explicit information on $union$ operations in the persistent union-find edit tree in the form of !AddTo! and !RemoveFrom! nodes exposes a new option for combining type environments. 170 If the type environments are part of the same edit tree, one environment $T'$ can be combined with another $T$ by only testing the edits on the path from $T'$ to $T$ in both the persistent union-find data structure describing the classes and the persistent hash table containing the class bounds. 171 This is generally more efficient than testing the compatibility of all type classes in $T'$, as only those that are actually different than those in $T$ must be considered. 172 173 The procedure for $combine(T, T')$ based on edit paths is as follows: 174 The shared edit trees for classes and bindings are rerooted at $T$, and the path from $T'$ to $T$ is followed to create a list of actual edits. 175 By tracking the state of each element, redundant changes such as an !Edit! followed by an !Edit! can be reduced to their form in $T'$ by dropping the later (more like $T$) !Edit! for the same key; !Add! and !Remove! cancel similarly. 176 This procedure is repeated for both the class edit tree and the binding edit tree. 177 When the list of net changes to the environment has been produced, the additive changes are applied to $T$. 178 For example, if a type class exists in $T'$ but not $T$, the corresponding !Add! edit will be applied to $T$, but in the reverse situation the !Remove! edit will not be applied to $T$, as the intention is to produce a new environment representing the union of the two sets of type classes; similarly, !AddTo! edits are applied to unify type-classes in $T$ that are united in $T'$, but !RemoveFrom! edits that split type classes are not. 179 The new environment, $T''$ can always be constructed with a consistent partitioning of type variables; in the extreme case, all variables from both $T$ and $T'$ will be united in a single type class in $T''$. 180 Where $combine$ can fail is in unifying the bound types; if any class in $T'$ has a class bound which does not unify with the merged class in $T''$ than $combine$ fails. 181 182 \section{Analysis} 183 184 In this section I present asymptotic analyses of the various approaches to a type environment data structure discussed in the previous section. 185 186 \begin{table} 187 \caption[Type environment operation bounds]{Worst-case analysis of type environment operations. $n$ is the number of type classes, $m$ the maximum size of a type class, and $p$ the edit distance between two environments or a single environment and the empty environment; $u(n)$ captures the recursive cost of class unification.} 188 \label{env-bounds-table} 189 \centering 190 \begin{tabular}{rllll} 191 \hline 192 & \textbf{Na\"{\i}ve} & \textbf{Incremental} & \textbf{Union-Find} & \textbf{U-F with Classes} \\ 193 \hline 194 $find$ & $O(n)$ & $O(p)$ & $O(\alpha(m))$ & $O(\log m)$ \\ 195 $report$ & $O(m)$ & $O(m)$ & $O(n \log m)$ & $O(m)$ \\ 196 $bound$ & $O(1)$ & $O(1)$ & $O(1)$ & $O(1)$ \\ 197 $insert$ & $O(1)$ & $O(1)$ & $O(1)$ & $O(1)$ \\ 198 $add$ & $O(1)$ & $O(1)$ & $O(1)$ & $O(1)$ \\ 199 $bind$ & $O(1)$ & $O(1)$ & $O(1)$ & $O(1)$ \\ 200 $unify$ & $O(m + u(n))$ & $O(m + u(n))$ & $O(\log m + u(n))$ & $O(\log m + u(n))$ \\ 201 $split$ & --- & --- & --- & $O(\log m)$ \\ 202 $combine$ & $O(nm \cdot u(n))$ & $O(pm \cdot u(n))$ & $O(n \log m \cdot u(n))$ & $O(p \log m \cdot u(n))$ \\ 203 $save$ & $O(nm)$ & $O(1)$ & $O(nm)$ & $O(1)$ \\ 204 $backtrack$ & $O(nm)$ & $O(pm)$ & $O(nm)$ & $O(p)$ \\ 205 \hline 206 \end{tabular} 207 \end{table} 65 208 66 209 % Future work: design multi-threaded version of C&F persistent map --- core idea is some sort of thread-boundary edit node -
doc/user/user.tex
rcdc02f2 r515a037 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Aug 31 07:54:50201814 %% Update Count : 3 39613 %% 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} … … 547 547 548 548 549 %\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}} 550 \subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}} 549 \subsection{Loop Control} 551 550 552 551 The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges. … … 557 556 the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M]. 558 557 ©0© is the implicit start value; 559 ©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range. 558 ©1© is the implicit increment value. 559 The up-to range uses ©+=© for increment; 560 the down-to range uses ©-=© for decrement. 560 561 The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©. 561 562 \begin{cquote} 562 563 \begin{tabular}{@{}ll|l@{}} 563 \multicolumn{2}{c|}{ forcontrol} & \multicolumn{1}{c}{output} \\564 \multicolumn{2}{c|}{loop control} & \multicolumn{1}{c}{output} \\ 564 565 \hline 565 566 \begin{cfa} … … 571 572 for ( ®10® ) { sout | "A"; } 572 573 for ( ®1 ~= 10 ~ 2® ) { sout | "B"; } 573 for ( ®10 -~= 1 ~ -2® ) { sout | "C"; }574 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; } 574 575 for ( ®0.5 ~ 5.5® ) { sout | "D"; } 575 576 for ( ®5.5 -~ 0.5® ) { sout | "E"; } 576 577 for ( ®i; 10® ) { sout | i; } 577 578 for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; } 578 for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; }579 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; } 579 580 for ( ®i; 0.5 ~ 5.5® ) { sout | i; } 580 581 for ( ®i; 5.5 -~ 0.5® ) { sout | i; } 581 582 for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; } 582 for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; } 583 int start = 3, comp = 10, inc = 2; 583 for ( ®ui; 10u -~= 2u ~ 2u® ) { sout | ui; } 584 enum { N = 10 }; 585 for ( ®N® ) { sout | "N"; } 586 for ( ®i; N® ) { sout | i; } 587 for ( ®i; N -~ 0® ) { sout | i; } 588 const int start = 3, comp = 10, inc = 2; 584 589 for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; } 585 590 \end{cfa} 586 591 & 587 592 \begin{cfa} 588 sout | endl; 589 sout | endl; 590 sout | endl; 591 sout | endl; 592 sout | endl; 593 sout | endl; 594 sout | endl; 595 sout | endl; 596 sout | 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 606 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; 607 616 \end{cfa} 608 617 & … … 611 620 empty 612 621 empty 613 622 zero 614 623 A 615 624 A A A A A A A A A A … … 625 634 2 4 6 8 10 626 635 10 8 6 4 2 636 637 N N N N N N N N N N 638 0 1 2 3 4 5 6 7 8 9 639 10 9 8 7 6 5 4 3 2 1 627 640 628 641 3 6 9 … … 2446 2459 int bar( int p ) { 2447 2460 ®i® += 1; §\C{// dependent on local variable}§ 2448 sout | ®i® | endl;2461 sout | ®i®; 2449 2462 } 2450 2463 return bar; §\C{// undefined because of local dependence}§ … … 2452 2465 int main() { 2453 2466 * [int]( int ) fp = foo(); §\C{// int (* fp)( int )}§ 2454 sout | fp( 3 ) | endl;2467 sout | fp( 3 ); 2455 2468 } 2456 2469 \end{cfa} … … 3218 3231 \begin{cfa} 3219 3232 int x = 1, y = 2, z = 3; 3220 sout | x ®|® y ®|® z | endl;3233 sout | x ®|® y ®|® z; 3221 3234 \end{cfa} 3222 3235 & … … 3239 3252 \begin{cfa} 3240 3253 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 3241 sout | t1 | t2 | endl;§\C{// print tuples}§3254 sout | t1 | t2; §\C{// print tuples}§ 3242 3255 \end{cfa} 3243 3256 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3251 3264 & 3252 3265 \begin{cfa} 3253 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); 3254 3267 \end{cfa} 3255 3268 \\ … … 3277 3290 A separator does not appear at the start or end of a line. 3278 3291 \begin{cfa}[belowskip=0pt] 3279 sout | 1 | 2 | 3 | endl;3292 sout | 1 | 2 | 3; 3280 3293 \end{cfa} 3281 3294 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3286 3299 A separator does not appear before or after a character literal or variable. 3287 3300 \begin{cfa} 3288 sout | '1' | '2' | '3' | endl;3301 sout | '1' | '2' | '3'; 3289 3302 123 3290 3303 \end{cfa} … … 3293 3306 A separator does not appear before or after a null (empty) C string. 3294 3307 \begin{cfa} 3295 sout | 1 | "" | 2 | "" | 3 | endl;3308 sout | 1 | "" | 2 | "" | 3; 3296 3309 123 3297 3310 \end{cfa} … … 3303 3316 \begin{cfa}[mathescape=off] 3304 3317 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" 3305 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;3318 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10; 3306 3319 \end{cfa} 3307 3320 %$ … … 3317 3330 \begin{cfa}[belowskip=0pt] 3318 3331 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" 3319 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;3332 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x"; 3320 3333 \end{cfa} 3321 3334 \begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3327 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@ 3328 3341 \begin{cfa}[belowskip=0pt] 3329 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"; 3330 3343 \end{cfa} 3331 3344 \begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] … … 3336 3349 If a space is desired before or after one of the special string start/end characters, simply insert a space. 3337 3350 \begin{cfa}[belowskip=0pt] 3338 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; 3339 3352 \end{cfa} 3340 3353 \begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] … … 3353 3366 \begin{cfa}[mathescape=off,belowskip=0pt] 3354 3367 sepSet( sout, ", $" ); §\C{// set separator from " " to ", \$"}§ 3355 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;3368 sout | 1 | 2 | 3 | " \"" | ®sep® | "\""; 3356 3369 \end{cfa} 3357 3370 %$ … … 3362 3375 \begin{cfa}[belowskip=0pt] 3363 3376 sepSet( sout, " " ); §\C{// reset separator to " "}§ 3364 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;3377 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\""; 3365 3378 \end{cfa} 3366 3379 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3372 3385 strcpy( store, sepGet( sout ) ); §\C{// copy current separator}§ 3373 3386 sepSet( sout, "_" ); §\C{// change separator to underscore}§ 3374 sout | 1 | 2 | 3 | endl;3387 sout | 1 | 2 | 3; 3375 3388 \end{cfa} 3376 3389 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3379 3392 \begin{cfa}[belowskip=0pt] 3380 3393 sepSet( sout, store ); §\C{// change separator back to original}§ 3381 sout | 1 | 2 | 3 | endl;3394 sout | 1 | 2 | 3; 3382 3395 \end{cfa} 3383 3396 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3390 3403 \begin{cfa}[belowskip=0pt] 3391 3404 sepSetTuple( sout, " " ); §\C{// set tuple separator from ", " to " "}§ 3392 sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;3405 sout | t1 | t2 | " \"" | ®sepTuple® | "\""; 3393 3406 \end{cfa} 3394 3407 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3397 3410 \begin{cfa}[belowskip=0pt] 3398 3411 sepSetTuple( sout, ", " ); §\C{// reset tuple separator to ", "}§ 3399 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;3412 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\""; 3400 3413 \end{cfa} 3401 3414 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 3407 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. 3408 3421 \begin{cfa}[belowskip=0pt] 3409 sout | sepDisable | 1 | 2 | 3 | endl;§\C{// globally turn off implicit separator}§3422 sout | sepDisable | 1 | 2 | 3; §\C{// globally turn off implicit separator}§ 3410 3423 \end{cfa} 3411 3424 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3413 3426 \end{cfa} 3414 3427 \begin{cfa}[belowskip=0pt] 3415 sout | sepEnable | 1 | 2 | 3 | endl; §\C{// globally turn on implicit separator}§3428 sout | sepEnable | 1 | 2 | 3; §\C{// globally turn on implicit separator}§ 3416 3429 \end{cfa} 3417 3430 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3422 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. 3423 3436 \begin{cfa}[belowskip=0pt] 3424 sout | 1 | sepOff | 2 | 3 | endl; §\C{// locally turn off implicit separator}§3437 sout | 1 | sepOff | 2 | 3; §\C{// locally turn off implicit separator}§ 3425 3438 \end{cfa} 3426 3439 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3428 3441 \end{cfa} 3429 3442 \begin{cfa}[belowskip=0pt] 3430 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}§ 3431 3444 \end{cfa} 3432 3445 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3435 3448 The tuple separator also responses to being turned on and off. 3436 3449 \begin{cfa}[belowskip=0pt] 3437 sout | t1 | sepOff | t2 | endl; §\C{// locally turn on/off implicit separator}§3450 sout | t1 | sepOff | t2; §\C{// locally turn on/off implicit separator}§ 3438 3451 \end{cfa} 3439 3452 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3443 3456 use ©sep© to accomplish this functionality. 3444 3457 \begin{cfa}[belowskip=0pt] 3445 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}§ 3446 3459 \end{cfa} 3447 3460 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3449 3462 \end{cfa} 3450 3463 \begin{cfa}[belowskip=0pt] 3451 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}§ 3452 3465 \end{cfa} 3453 3466 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3462 3475 int main( void ) { 3463 3476 int x = 1, y = 2, z = 3; 3464 sout | x | y | z | endl;3477 sout | x | y | z; 3465 3478 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 3466 sout | t1 | t2 | endl; // print tuples3467 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;3468 sout | 1 | 2 | 3 | endl;3469 sout | '1' | '2' | '3' | endl;3470 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; 3471 3484 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥" 3472 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;3485 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10; 3473 3486 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" 3474 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;3475 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;3476 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; 3477 3490 3478 3491 sepSet( sout, ", $" ); // set separator from " " to ", $" 3479 sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;3492 sout | 1 | 2 | 3 | " \"" | sep | "\""; 3480 3493 sepSet( sout, " " ); // reset separator to " " 3481 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;3494 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\""; 3482 3495 3483 3496 char store[sepSize]; 3484 3497 strcpy( store, sepGet( sout ) ); 3485 3498 sepSet( sout, "_" ); 3486 sout | 1 | 2 | 3 | endl;3499 sout | 1 | 2 | 3; 3487 3500 sepSet( sout, store ); 3488 sout | 1 | 2 | 3 | endl;3501 sout | 1 | 2 | 3; 3489 3502 3490 3503 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 3491 sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;3504 sout | t1 | t2 | " \"" | sepTuple | "\""; 3492 3505 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 3493 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;3494 3495 sout | sepDisable | 1 | 2 | 3 | endl; // globally turn off implicit separator3496 sout | sepEnable | 1 | 2 | 3 | endl; // globally turn on implicit separator3497 3498 sout | 1 | sepOff | 2 | 3 | endl; // locally turn on implicit separator3499 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 3500 3513 sout | sepEnable; 3501 sout | t1 | sepOff | t2 | endl; // locally turn on/off implicit separator3502 3503 sout | sepOn | 1 | 2 | 3 | sepOn | endl; // sepOn does nothing at start/end of line3504 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 3505 3518 } 3506 3519 … … 4167 4180 Fibonacci f1, f2; 4168 4181 for ( int i = 1; i <= 10; i += 1 ) { 4169 sout | next( &f1 ) | ' ' | next( &f2 ) | endl;4182 sout | next( &f1 ) | ' ' | next( &f2 ); 4170 4183 } // for 4171 4184 } … … 4233 4246 MyThread f[4]; 4234 4247 } 4235 sout | global.value | endl;4248 sout | global.value; 4236 4249 } 4237 4250 \end{cfa} … … 4311 4324 void main( First * this ) { 4312 4325 for ( int i = 0; i < 10; i += 1 ) { 4313 sout | "First : Suspend No." | i + 1 | endl;4326 sout | "First : Suspend No." | i + 1; 4314 4327 yield(); 4315 4328 } … … 4320 4333 wait( this->lock ); 4321 4334 for ( int i = 0; i < 10; i += 1 ) { 4322 sout | "Second : Suspend No." | i + 1 | endl;4335 sout | "Second : Suspend No." | i + 1; 4323 4336 yield(); 4324 4337 } … … 4327 4340 int main( void ) { 4328 4341 signal_once lock; 4329 sout | "User main begin" | endl;4342 sout | "User main begin"; 4330 4343 { 4331 4344 processor p; … … 4335 4348 } 4336 4349 } 4337 sout | "User main end" | endl;4350 sout | "User main end"; 4338 4351 } 4339 4352 \end{cfa} … … 5032 5045 void ?{}( Line * l ) { 5033 5046 l->lnth = 0.0; 5034 sout | "default" | endl;5047 sout | "default"; 5035 5048 } 5036 5049 … … 5039 5052 void ?{}( Line * l, float lnth ) { 5040 5053 l->lnth = lnth; 5041 sout | "lnth" | l->lnth | endl;5054 sout | "lnth" | l->lnth; 5042 5055 5043 5056 } … … 5045 5058 // destructor 5046 5059 void ^?() { 5047 sout | "destroyed" | endl;5060 sout | "destroyed"; 5048 5061 l.lnth = 0.0; 5049 5062 } … … 5791 5804 In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character. 5792 5805 \begin{cfa} 5793 sout | 'x' | " " | (int)'x' | endl;5806 sout | 'x' | " " | (int)'x'; 5794 5807 x 120 5795 5808 \end{cfa} … … 7021 7034 #include <gmp>§\indexc{gmp}§ 7022 7035 int main( void ) { 7023 sout | "Factorial Numbers" | endl;7036 sout | "Factorial Numbers"; 7024 7037 Int fact = 1; 7025 7038 7026 sout | 0 | fact | endl;7039 sout | 0 | fact; 7027 7040 for ( unsigned int i = 1; i <= 40; i += 1 ) { 7028 7041 fact *= i; 7029 sout | i | fact | endl;7042 sout | i | fact; 7030 7043 } 7031 7044 } -
examples/ArrayN.c
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Sep 26 18:22:57201813 // 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> // strlen, strcmp21 //#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 … … 141 194 // opening delimiters, no space after 142 195 ['('] : Open, ['['] : Open, ['{'] : Open, 143 ['='] : Open, ['$'] : Open, [(unsigned char)' £'] : Open, [(unsigned char)'¥'] : Open,144 [(unsigned char)' ¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,196 ['='] : Open, ['$'] : Open, [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open, 197 [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open, 145 198 // closing delimiters, no space before 146 199 [','] : Close, ['.'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, 147 ['%'] : Close, [(unsigned char)' ¢'] : Close, [(unsigned char)'»'] : Close,200 ['%'] : Close, [(unsigned char)'�'] : Close, [(unsigned char)'�'] : Close, 148 201 [')'] : Close, [']'] : Close, ['}'] : Close, 149 202 // opening-closing delimiters, no space before or after … … 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
rcdc02f2 r515a037 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/iterator.cfa
rcdc02f2 r515a037 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Sep 26 18:23:10201812 // Last Modified On : Fri Nov 2 07:17:37 2018 13 13 // Update Count : 29 14 14 // -
libcfa/src/rational.cfa
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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: // -
src/Parser/DeclarationNode.cc
rcdc02f2 r515a037 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 20 14:56:54201813 // Update Count : 110 712 // Last Modified On : Thu Nov 1 20:54:26 2018 13 // Update Count : 1108 14 14 // 15 15 … … 402 402 } 403 403 404 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) {405 DeclarationNode * newnode = new DeclarationNode; 406 newnode->type = new TypeData( TypeData::Typeof );404 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr, bool basetypeof ) { 405 DeclarationNode * newnode = new DeclarationNode; 406 newnode->type = new TypeData( basetypeof ? TypeData::Basetypeof : TypeData::Typeof ); 407 407 newnode->type->typeexpr = expr; 408 408 return newnode; -
src/Parser/ParseNode.h
rcdc02f2 r515a037 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 4 09:39:40201813 // Update Count : 85 312 // Last Modified On : Thu Nov 1 20:54:53 2018 13 // Update Count : 854 14 14 // 15 15 … … 249 249 static DeclarationNode * newBitfield( ExpressionNode * size ); 250 250 static DeclarationNode * newTuple( DeclarationNode * members ); 251 static DeclarationNode * newTypeof( ExpressionNode * expr );251 static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false ); 252 252 static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes 253 253 static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes -
src/Parser/TypeData.cc
rcdc02f2 r515a037 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 20 14:39:31201813 // Update Count : 62 212 // Last Modified On : Fri Nov 2 07:54:26 2018 13 // Update Count : 624 14 14 // 15 15 … … 96 96 break; 97 97 case Typeof: 98 case Basetypeof: 98 99 // typeexpr = new Typeof_t; 99 100 typeexpr = nullptr; … … 166 167 break; 167 168 case Typeof: 169 case Basetypeof: 168 170 // delete typeexpr->expr; 169 171 delete typeexpr; … … 245 247 break; 246 248 case Typeof: 249 case Basetypeof: 247 250 newtype->typeexpr = maybeClone( typeexpr ); 248 251 break; … … 419 422 } // if 420 423 break; 424 case Basetypeof: 425 os << "base-"; 426 #if defined(__GNUC__) && __GNUC__ >= 7 427 __attribute__((fallthrough)); 428 #endif 421 429 case Typeof: 422 430 os << "type-of expression "; … … 457 465 case Tuple: 458 466 case Typeof: 467 case Basetypeof: 459 468 case Builtin: 460 469 assertf(false, "Tried to get leaf name from kind without a name: %d", kind); … … 513 522 switch ( td->kind ) { 514 523 case TypeData::Unknown: 515 // fill in implicit int516 return new BasicType( buildQualifiers( td ), BasicType::SignedInt );524 // fill in implicit int 525 return new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 517 526 case TypeData::Basic: 518 return buildBasicType( td );527 return buildBasicType( td ); 519 528 case TypeData::Pointer: 520 return buildPointer( td );529 return buildPointer( td ); 521 530 case TypeData::Array: 522 return buildArray( td );531 return buildArray( td ); 523 532 case TypeData::Reference: 524 return buildReference( td );533 return buildReference( td ); 525 534 case TypeData::Function: 526 return buildFunction( td );535 return buildFunction( td ); 527 536 case TypeData::AggregateInst: 528 return buildAggInst( td );537 return buildAggInst( td ); 529 538 case TypeData::EnumConstant: 530 // the name gets filled in later -- by SymTab::Validate531 return new EnumInstType( buildQualifiers( td ), "" );539 // the name gets filled in later -- by SymTab::Validate 540 return new EnumInstType( buildQualifiers( td ), "" ); 532 541 case TypeData::SymbolicInst: 533 return buildSymbolicInst( td );542 return buildSymbolicInst( td ); 534 543 case TypeData::Tuple: 535 return buildTuple( td );544 return buildTuple( td ); 536 545 case TypeData::Typeof: 537 return buildTypeof( td ); 546 case TypeData::Basetypeof: 547 return buildTypeof( td ); 538 548 case TypeData::Builtin: 539 if(td->builtintype == DeclarationNode::Zero) {540 return new ZeroType( noQualifiers );541 }542 else if(td->builtintype == DeclarationNode::One) {543 return new OneType( noQualifiers );544 }545 else {546 return new VarArgsType( buildQualifiers( td ) );547 }549 if (td->builtintype == DeclarationNode::Zero) { 550 return new ZeroType( noQualifiers ); 551 } 552 else if (td->builtintype == DeclarationNode::One) { 553 return new OneType( noQualifiers ); 554 } 555 else { 556 return new VarArgsType( buildQualifiers( td ) ); 557 } 548 558 case TypeData::GlobalScope: 549 return new GlobalScopeType();559 return new GlobalScopeType(); 550 560 case TypeData::Qualified: 551 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );561 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 552 562 case TypeData::Symbolic: 553 563 case TypeData::Enum: 554 564 case TypeData::Aggregate: 555 assert( false );565 assert( false ); 556 566 } // switch 557 567 … … 929 939 930 940 TypeofType * buildTypeof( const TypeData * td ) { 931 assert( td->kind == TypeData::Typeof );941 assert( td->kind == TypeData::Typeof || td->kind == TypeData::Basetypeof ); 932 942 assert( td->typeexpr ); 933 943 // assert( td->typeexpr->expr ); 934 return new TypeofType( buildQualifiers( td ), td->typeexpr->build() ); 944 return new TypeofType{ 945 buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof }; 935 946 } // buildTypeof 936 947 -
src/Parser/TypeData.h
rcdc02f2 r515a037 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 20 13:56:40201813 // Update Count : 19 512 // Last Modified On : Thu Nov 1 20:56:46 2018 13 // Update Count : 196 14 14 // 15 15 … … 27 27 struct TypeData { 28 28 enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, 29 SymbolicInst, Tuple, Typeof, B uiltin, GlobalScope, Qualified, Unknown };29 SymbolicInst, Tuple, Typeof, Basetypeof, Builtin, GlobalScope, Qualified, Unknown }; 30 30 31 31 struct Aggregate_t { -
src/Parser/lex.ll
rcdc02f2 r515a037 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Oct 20 09:42:45 201812 * Last Modified On : Thu Nov 1 20:57:35 2018 13 13 * Update Count : 687 14 14 */ -
src/Parser/parser.yy
rcdc02f2 r515a037 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 21 08:27:29201813 // Update Count : 40 4512 // Last Modified On : Thu Nov 8 18:08:23 2018 13 // Update Count : 4052 14 14 // 15 15 … … 187 187 188 188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 189 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->get_expr());189 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->get_expr()); 190 190 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 191 191 type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 192 192 } // if 193 193 return new ForCtrl( 194 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),194 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 195 195 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 196 196 new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 197 197 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 198 <<<<<<< HEAD 199 ======= 200 } // forCtrl 201 202 ForCtrl * forCtrl( ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 203 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) { 204 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc ); 205 } else { 206 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr; 207 } // if 208 >>>>>>> master 198 209 } // forCtrl 199 210 … … 1132 1143 | FOR '(' push for_control_expression ')' statement pop 1133 1144 { $$ = new StatementNode( build_for( $4, $6 ) ); } 1145 | FOR '(' ')' statement // CFA => for ( ;; ) 1146 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), $4 ) ); } 1134 1147 ; 1135 1148 1136 1149 for_control_expression: 1150 <<<<<<< HEAD 1137 1151 comma_expression_opt // CFA 1138 1152 { … … 1144 1158 } // if 1145 1159 } 1160 ======= 1161 comma_expression // CFA 1162 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1163 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1164 >>>>>>> master 1146 1165 | constant_expression inclexcl constant_expression // CFA 1147 1166 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1148 1167 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1149 1168 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1169 <<<<<<< HEAD 1150 1170 | comma_expression_opt ';' comma_expression // CFA 1151 1171 { … … 1188 1208 } 1189 1209 | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt 1210 ======= 1211 | comma_expression ';' comma_expression // CFA 1212 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1213 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1214 | comma_expression ';' constant_expression inclexcl constant_expression // CFA 1215 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1216 | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1217 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1218 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1219 >>>>>>> master 1190 1220 { $$ = new ForCtrl( $1, $3, $5 ); } 1221 | ';' comma_expression_opt ';' comma_expression_opt 1222 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1191 1223 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1192 1224 { $$ = new ForCtrl( $1, $2, $4 ); } … … 1850 1882 1851 1883 indirect_type: 1852 TYPEOF '(' type ')' // GCC: typeof( x) y;1884 TYPEOF '(' type ')' // GCC: typeof( x ) y; 1853 1885 { $$ = $3; } 1854 | TYPEOF '(' comma_expression ')' // GCC: typeof( a+b) y;1886 | TYPEOF '(' comma_expression ')' // GCC: typeof( a+b ) y; 1855 1887 { $$ = DeclarationNode::newTypeof( $3 ); } 1888 <<<<<<< HEAD 1856 1889 | BASETYPEOF '(' type ')' // CFA: basetypeof(x) y; 1857 1890 { $$ = $3; } … … 1859 1892 { $$ = DeclarationNode::newTypeof( $3 ); } 1860 1893 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1894 ======= 1895 | BASETYPEOF '(' type ')' // CFA: basetypeof( x ) y; 1896 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ), true ); } 1897 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1898 { $$ = DeclarationNode::newTypeof( $3, true ); } 1899 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y; 1900 >>>>>>> master 1861 1901 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1862 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b) y;1902 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y; 1863 1903 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1864 1904 | ZERO_T // CFA -
src/ResolvExpr/AlternativeFinder.cc
rcdc02f2 r515a037 10 10 // Created On : Sat May 16 23:52:08 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 17 11:19:39201813 // Update Count : 3 312 // Last Modified On : Thu Nov 1 21:00:56 2018 13 // Update Count : 34 14 14 // 15 15 … … 1344 1344 /// Gets name from untyped member expression (member must be NameExpr) 1345 1345 const std::string& get_member_name( UntypedMemberExpr *memberExpr ) { 1346 if ( dynamic_cast< ConstantExpr * >( memberExpr->get_member() ) ) { 1347 SemanticError( memberExpr, "Indexed access to struct fields unsupported: " ); 1348 } // if 1346 1349 NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() ); 1347 1350 assert( nameExpr ); -
src/ResolvExpr/ResolveTypeof.cc
rcdc02f2 r515a037 67 67 std::cerr << std::endl; 68 68 #endif 69 if ( typeofType->expr ) { 69 // pass on null expression 70 if ( ! typeofType->expr ) return typeofType; 71 72 bool isBasetypeof = typeofType->is_basetypeof; 73 auto oldQuals = typeofType->get_qualifiers().val; 74 75 Type* newType; 76 if ( TypeExpr* tyExpr = dynamic_cast<TypeExpr*>(typeofType->expr) ) { 77 // typeof wrapping type 78 newType = tyExpr->type; 79 tyExpr->type = nullptr; 80 delete tyExpr; 81 } else { 82 // typeof wrapping expression 70 83 Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer ); 71 84 assert( newExpr->result && ! newExpr->result->isVoid() ); 72 Type *newType = newExpr->result;85 newType = newExpr->result; 73 86 newExpr->result = nullptr; 74 87 delete typeofType; 75 88 delete newExpr; 76 return newType; 77 } // if 78 return typeofType; 89 } 90 91 // clear qualifiers for base, combine with typeoftype quals in any case 92 if ( isBasetypeof ) { 93 // replace basetypeof(<enum>) by int 94 if ( dynamic_cast<EnumInstType*>(newType) ) { 95 Type* newerType = 96 new BasicType{ newType->get_qualifiers(), BasicType::SignedInt, 97 newType->attributes }; 98 delete newType; 99 newType = newerType; 100 } 101 newType->get_qualifiers().val 102 = ( newType->get_qualifiers().val & ~Type::Qualifiers::Mask ) | oldQuals; 103 } else { 104 newType->get_qualifiers().val |= oldQuals; 105 } 106 107 return newType; 79 108 } 80 109 } // namespace ResolvExpr -
src/SynTree/Type.h
rcdc02f2 r515a037 598 598 class TypeofType : public Type { 599 599 public: 600 Expression *expr; 601 602 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 600 Expression *expr; ///< expression to take the type of 601 bool is_basetypeof; ///< true iff is basetypeof type 602 603 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 604 TypeofType( const Type::Qualifiers & tq, Expression *expr, bool is_basetypeof, 605 const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 603 606 TypeofType( const TypeofType& ); 604 607 virtual ~TypeofType(); -
src/SynTree/TypeofType.cc
rcdc02f2 r515a037 23 23 class Attribute; 24 24 25 TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), expr( expr ) { 26 } 25 TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, 26 const std::list< Attribute * > & attributes ) 27 : Type( tq, attributes ), expr( expr ), is_basetypeof(false) {} 27 28 28 TypeofType::TypeofType( const TypeofType &other ) : Type( other ), expr( maybeClone( other.expr ) ) { 29 } 29 TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, bool is_basetypeof, 30 const std::list< Attribute * > & attributes ) 31 : Type( tq, attributes ), expr( expr ), is_basetypeof( is_basetypeof ) {} 32 33 TypeofType::TypeofType( const TypeofType &other ) 34 : Type( other ), expr( maybeClone( other.expr ) ), is_basetypeof( other.is_basetypeof ) {} 30 35 31 36 TypeofType::~TypeofType() { … … 35 40 void TypeofType::print( std::ostream &os, Indenter indent ) const { 36 41 Type::print( os, indent ); 42 if ( is_basetypeof ) { os << "base-"; } 37 43 os << "type-of expression "; 38 44 if ( expr ) { -
tests/.expect/alloc-ERROR.txt
rcdc02f2 r515a037 1 alloc.c :265:1 error: No reasonable alternatives for expression Applying untyped:1 alloc.cfa:265:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: ?=? 3 3 ...to: … … 19 19 20 20 21 alloc.c :266:1 error: No reasonable alternatives for expression Applying untyped:21 alloc.cfa:266:1 error: No reasonable alternatives for expression Applying untyped: 22 22 Name: ?=? 23 23 ...to: … … 39 39 40 40 41 alloc.c :267:1 error: No reasonable alternatives for expression Applying untyped:41 alloc.cfa:267:1 error: No reasonable alternatives for expression Applying untyped: 42 42 Name: ?=? 43 43 ...to: … … 50 50 51 51 52 alloc.c :268:1 error: No reasonable alternatives for expression Applying untyped:52 alloc.cfa:268:1 error: No reasonable alternatives for expression Applying untyped: 53 53 Name: ?=? 54 54 ...to: -
tests/.expect/castError.txt
rcdc02f2 r515a037 1 castError.c :7:1 error: Cannot choose between 3 alternatives for expression1 castError.cfa:7:1 error: Cannot choose between 3 alternatives for expression 2 2 Cast of: 3 3 Name: f 4 4 ... to: 5 char Alternatives are:5 char Alternatives are: 6 6 Cost ( 1, 0, 0, 0 ): Cast of: 7 7 Variable Expression: f: function -
tests/.expect/completeTypeError.txt
rcdc02f2 r515a037 1 completeTypeError.c :33:1 error: No reasonable alternatives for expression Applying untyped:1 completeTypeError.cfa:33:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: *? 3 3 ...to: 4 4 Name: v 5 5 6 completeTypeError.c :34:1 error: No reasonable alternatives for expression Applying untyped:6 completeTypeError.cfa:34:1 error: No reasonable alternatives for expression Applying untyped: 7 7 Name: *? 8 8 ...to: 9 9 Name: y 10 10 11 completeTypeError.c :35:1 error: No reasonable alternatives for expression Applying untyped:11 completeTypeError.cfa:35:1 error: No reasonable alternatives for expression Applying untyped: 12 12 Name: foo 13 13 ...to: 14 14 Name: v 15 15 16 completeTypeError.c :36:1 error: No reasonable alternatives for expression Applying untyped:16 completeTypeError.cfa:36:1 error: No reasonable alternatives for expression Applying untyped: 17 17 Name: baz 18 18 ...to: 19 19 Name: v 20 20 21 completeTypeError.c :37:1 error: No reasonable alternatives for expression Applying untyped:21 completeTypeError.cfa:37:1 error: No reasonable alternatives for expression Applying untyped: 22 22 Name: quux 23 23 ...to: 24 24 Name: v 25 25 26 completeTypeError.c :58:1 error: No reasonable alternatives for expression Applying untyped:26 completeTypeError.cfa:58:1 error: No reasonable alternatives for expression Applying untyped: 27 27 Name: baz 28 28 ...to: 29 29 Name: y 30 30 31 completeTypeError.c :59:1 error: No reasonable alternatives for expression Applying untyped:31 completeTypeError.cfa:59:1 error: No reasonable alternatives for expression Applying untyped: 32 32 Name: quux 33 33 ...to: 34 34 Name: y 35 35 36 completeTypeError.c :60:1 error: No reasonable alternatives for expression Applying untyped:36 completeTypeError.cfa:60:1 error: No reasonable alternatives for expression Applying untyped: 37 37 Name: *? 38 38 ...to: 39 39 Name: y 40 40 41 completeTypeError.c :72:1 error: No reasonable alternatives for expression Applying untyped:41 completeTypeError.cfa:72:1 error: No reasonable alternatives for expression Applying untyped: 42 42 Name: baz 43 43 ...to: -
tests/.expect/declarationErrors.txt
rcdc02f2 r515a037 1 declarationErrors.c :16:1 error: duplicate static in declaration of x1: static const volatile short int1 declarationErrors.cfa:16:1 error: duplicate static in declaration of x1: static const volatile short int 2 2 3 declarationErrors.c :17:1 error: conflicting extern & static in declaration of x2: extern const volatile short int3 declarationErrors.cfa:17:1 error: conflicting extern & static in declaration of x2: extern const volatile short int 4 4 5 declarationErrors.c :18:1 error: conflicting extern & auto, conflicting extern & static, conflicting extern & static, duplicate extern in declaration of x3: extern const volatile short int5 declarationErrors.cfa:18:1 error: conflicting extern & auto, conflicting extern & static, conflicting extern & static, duplicate extern in declaration of x3: extern const volatile short int 6 6 7 declarationErrors.c :19:1 error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous07 declarationErrors.cfa:19:1 error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous0 8 8 with members 9 9 i: int … … 11 11 12 12 13 declarationErrors.c :20:1 error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous113 declarationErrors.cfa:20:1 error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous1 14 14 with members 15 15 i: int … … 17 17 18 18 19 declarationErrors.c :22:1 error: duplicate static in declaration of x6: static const volatile Int19 declarationErrors.cfa:22:1 error: duplicate static in declaration of x6: static const volatile Int 20 20 21 declarationErrors.c :24:1 error: duplicate const in declaration of f01: static inline function21 declarationErrors.cfa:24:1 error: duplicate const in declaration of f01: static inline function 22 22 with no parameters 23 23 returning const volatile int 24 24 25 25 26 declarationErrors.c :25:1 error: duplicate volatile in declaration of f02: static inline function26 declarationErrors.cfa:25:1 error: duplicate volatile in declaration of f02: static inline function 27 27 with no parameters 28 28 returning const volatile int 29 29 30 30 31 declarationErrors.c :26:1 error: duplicate const in declaration of f03: static inline function31 declarationErrors.cfa:26:1 error: duplicate const in declaration of f03: static inline function 32 32 with no parameters 33 33 returning const volatile int 34 34 35 35 36 declarationErrors.c :27:1 error: duplicate volatile in declaration of f04: static inline function36 declarationErrors.cfa:27:1 error: duplicate volatile in declaration of f04: static inline function 37 37 with no parameters 38 38 returning const volatile int 39 39 40 40 41 declarationErrors.c :28:1 error: duplicate const in declaration of f05: static inline function41 declarationErrors.cfa:28:1 error: duplicate const in declaration of f05: static inline function 42 42 with no parameters 43 43 returning const volatile int 44 44 45 45 46 declarationErrors.c :29:1 error: duplicate volatile in declaration of f06: static inline function46 declarationErrors.cfa:29:1 error: duplicate volatile in declaration of f06: static inline function 47 47 with no parameters 48 48 returning const volatile int 49 49 50 50 51 declarationErrors.c :30:1 error: duplicate const in declaration of f07: static inline function51 declarationErrors.cfa:30:1 error: duplicate const in declaration of f07: static inline function 52 52 with no parameters 53 53 returning const volatile int 54 54 55 55 56 declarationErrors.c :31:1 error: duplicate const, duplicate volatile in declaration of f08: static inline function56 declarationErrors.cfa:31:1 error: duplicate const, duplicate volatile in declaration of f08: static inline function 57 57 with no parameters 58 58 returning const volatile int 59 59 60 60 61 declarationErrors.c :33:1 error: duplicate const, duplicate volatile in declaration of f09: static inline function61 declarationErrors.cfa:33:1 error: duplicate const, duplicate volatile in declaration of f09: static inline function 62 62 with no parameters 63 63 returning const volatile int 64 64 65 65 66 declarationErrors.c :34:1 error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function66 declarationErrors.cfa:34:1 error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function 67 67 with no parameters 68 68 returning const restrict volatile _Atomic int -
tests/.expect/loopctrl.txt
rcdc02f2 r515a037 20 20 21 21 22 N N N N N N N N N N 23 0 1 2 3 4 5 6 7 8 9 24 10 9 8 7 6 5 4 3 2 1 25 26 22 27 3 6 9 28 23 29 24 30 (0 0)(1 1)(2 2)(3 3)(4 4)(5 5)(6 6)(7 7)(8 8)(9 9) -
tests/.expect/nested-types-ERR1.txt
rcdc02f2 r515a037 1 nested-types.c :70:1 error: Use of undefined type T1 nested-types.cfa:70:1 error: Use of undefined type T -
tests/.expect/nested-types-ERR2.txt
rcdc02f2 r515a037 1 nested-types.c :73:1 error: Use of undefined global type Z2 nested-types.c :74:1 error: Qualified type requires an aggregate on the left, but has: signed int3 nested-types.c :75:1 error: Undefined type in qualified type: Qualified Type:1 nested-types.cfa:73:1 error: Use of undefined global type Z 2 nested-types.cfa:74:1 error: Qualified type requires an aggregate on the left, but has: signed int 3 nested-types.cfa:75:1 error: Undefined type in qualified type: Qualified Type: 4 4 instance of struct S with body 1 5 5 instance of type Z (not function type) -
tests/.expect/scopeErrors.txt
rcdc02f2 r515a037 1 scopeErrors.c :2:1 error: duplicate object definition for thisIsAnError: signed int2 scopeErrors.c :20:1 error: duplicate function definition for butThisIsAnError: function1 scopeErrors.cfa:2:1 error: duplicate object definition for thisIsAnError: signed int 2 scopeErrors.cfa:20:1 error: duplicate function definition for butThisIsAnError: function 3 3 ... with parameters 4 4 double -
tests/.expect/typedefRedef-ERR1.txt
rcdc02f2 r515a037 1 typedefRedef.c :4:1 error: Cannot redefine typedef: Foo2 typedefRedef.c :60:1 error: Cannot redefine typedef: ARR1 typedefRedef.cfa:4:1 error: Cannot redefine typedef: Foo 2 typedefRedef.cfa:60:1 error: Cannot redefine typedef: ARR -
tests/KRfunctions.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // KRfunctions.c --7 // KRfunctions.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Thu Feb 16 15:23:17 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 20 07:34:17 201713 // Update Count : 712 // Last Modified On : Tue Nov 6 17:50:34 2018 13 // Update Count : 9 14 14 // 15 15 … … 49 49 // Local Variables: // 50 50 // tab-width: 4 // 51 // compile-command: "cfa KRfunctions.c " //51 // compile-command: "cfa KRfunctions.cfa" // 52 52 // End: // -
tests/Makefile.am
rcdc02f2 r515a037 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Wed Jun 6 16:42:20201814 ## Update Count : 4913 ## Last Modified On : Tue Nov 20 11:18:51 2018 14 ## Update Count : 68 15 15 ############################################################################### 16 16 17 17 AUTOMAKE_OPTIONS = foreign # do not require all the GNU file names 18 19 include $(top_srcdir)/src/cfa.make 18 20 19 21 debug=yes … … 36 38 37 39 AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 38 39 40 CC = @CFACC@ 40 41 … … 42 43 43 44 .PHONY: list .validate 44 .INTERMEDIATE: .validate .validate.c 45 EXTRA_PROGRAMS = fstream_test avl_test # build but do not install 46 47 fstream_test_SOURCES = fstream_test.c 45 .INTERMEDIATE: .validate .validate.cfa 46 EXTRA_PROGRAMS = avl_test # build but do not install 48 47 49 48 avl_test_SOURCES = avltree/avl_test.c avltree/avl0.c avltree/avl1.c avltree/avl2.c avltree/avl3.c avltree/avl4.c avltree/avl-private.c … … 62 61 @+${TEST_PY} --list ${concurrent} 63 62 64 .validate: .validate.c 65 $(C OMPILE) .validate.c-fsyntax-only -Wall -Wextra -Werror63 .validate: .validate.cfa 64 $(CFACOMPILE) .validate.cfa -fsyntax-only -Wall -Wextra -Werror 66 65 67 .validate.c: 66 .validate.cfa: 67 @echo "int main() { return 0; }" > ${@} 68 69 dummy_hack.c: 68 70 @echo "int main() { return 0; }" > ${@} 69 71 … … 72 74 73 75 #---------------------------------------------------------------------------------------------------------------- 76 74 77 # implicit rule so not all test require a rule 75 % : %.c $(C C)76 $(PRETTY_PATH) $(C OMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})78 % : %.c $(CFACC) 79 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 77 80 78 declarationSpecifier: declarationSpecifier.c $(CC)79 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p$(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})81 % : %.cfa $(CFACC) 82 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 80 83 81 gccExtensions : gccExtensions.c $(CC)82 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})84 declarationSpecifier: declarationSpecifier.cfa $(CFACC) 85 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 83 86 84 extension : extension.c $(CC)85 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})87 gccExtensions : gccExtensions.cfa $(CFACC) 88 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 86 89 87 attributes : attributes.c $(CC)88 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})90 extension : extension.cfa $(CFACC) 91 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 89 92 90 functions: functions.c $(CC)91 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})93 attributes : attributes.cfa $(CFACC) 94 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 92 95 93 KRfunctions : KRfunctions.c $(CC)94 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})96 functions: functions.cfa $(CFACC) 97 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 95 98 96 sched-ext-parse : sched-ext-parse.c $(CC)97 $(PRETTY_PATH) $(C OMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})99 KRfunctions : KRfunctions.cfa $(CFACC) 100 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 98 101 99 gmp : gmp.c $(CC) 100 $(PRETTY_PATH) $(COMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 102 sched-ext-parse : sched-ext-parse.c $(CFACC) 103 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 104 105 gmp : gmp.cfa $(CFACC) 106 $(PRETTY_PATH) $(CFACOMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 101 107 102 108 #builtins 103 builtins/sync: builtins/sync.c $(C C)104 $(PRETTY_PATH) $(C OMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only109 builtins/sync: builtins/sync.c $(CFACC) 110 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only 105 111 106 112 #------------------------------------------------------------------------------ 113 107 114 #To make errors path independent we need to cd into the correct directories 108 completeTypeError : completeTypeError.c $(CC)109 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})115 completeTypeError : completeTypeError.cfa $(CFACC) 116 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 110 117 111 typedefRedef-ERR1: typedefRedef.c $(CC)112 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})118 typedefRedef-ERR1: typedefRedef.cfa $(CFACC) 119 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 113 120 114 alloc-ERROR: alloc.c $(CC)115 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})121 alloc-ERROR: alloc.cfa $(CFACC) 122 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 116 123 117 fallthrough-ERROR: fallthrough.c $(CC)118 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})124 fallthrough-ERROR: fallthrough.cfa $(CFACC) 125 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 119 126 120 nested-types-ERR1: nested-types.c $(CC)121 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})127 nested-types-ERR1: nested-types.cfa $(CFACC) 128 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 122 129 123 nested-types-ERR2: nested-types.c $(CC)124 $(PRETTY_PATH) $(C OMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})130 nested-types-ERR2: nested-types.cfa $(CFACC) 131 $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 125 132 126 133 # Constructor/destructor tests 127 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(C C)128 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})134 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CFACC) 135 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 129 136 130 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(C C)131 $(PRETTY_PATH) $(C OMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})137 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CFACC) 138 $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 132 139 133 raii/memberCtors-ERR1: raii/memberCtors.c $(C C)134 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})140 raii/memberCtors-ERR1: raii/memberCtors.c $(CFACC) 141 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 135 142 136 raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(C C)137 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})143 raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CFACC) 144 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 138 145 139 146 # Warnings 140 warnings/self-assignment: warnings/self-assignment.c $(C C)141 $(PRETTY_PATH) $(C OMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only147 warnings/self-assignment: warnings/self-assignment.c $(CFACC) 148 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only -
tests/Makefile.in
rcdc02f2 r515a037 91 91 build_triplet = @build@ 92 92 host_triplet = @host@ 93 EXTRA_PROGRAMS = fstream_test$(EXEEXT)avl_test$(EXEEXT)93 EXTRA_PROGRAMS = avl_test$(EXEEXT) 94 94 subdir = tests 95 95 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 110 110 avl_test_OBJECTS = $(am_avl_test_OBJECTS) 111 111 avl_test_LDADD = $(LDADD) 112 am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)113 fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)114 fstream_test_LDADD = $(LDADD)115 112 AM_V_P = $(am__v_P_@AM_V@) 116 113 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) … … 141 138 am__v_CCLD_0 = @echo " CCLD " $@; 142 139 am__v_CCLD_1 = 143 SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)144 DIST_SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)140 SOURCES = $(avl_test_SOURCES) 141 DIST_SOURCES = $(avl_test_SOURCES) 145 142 am__can_run_installinfo = \ 146 143 case $$AM_UPDATE_INFO_DIR in \ … … 168 165 CTAGS = ctags 169 166 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.py.in \ 170 $(srcdir)/test.py $(top_srcdir)/automake/depcomp 167 $(srcdir)/test.py $(top_srcdir)/automake/depcomp \ 168 $(top_srcdir)/src/cfa.make 171 169 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 172 170 ACLOCAL = @ACLOCAL@ … … 297 295 top_srcdir = @top_srcdir@ 298 296 AUTOMAKE_OPTIONS = foreign # do not require all the GNU file names 297 CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS) 298 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 299 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 300 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 301 $(AM_CFLAGS) $(CFLAGS) 302 303 AM_V_CFA = $(am__v_CFA_@AM_V@) 304 am__v_CFA_ = $(am__v_CFA_@AM_DEFAULT_V@) 305 am__v_CFA_0 = @echo " CFA " $@; 306 am__v_CFA_1 = 307 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 308 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 309 am__v_JAVAC_0 = @echo " JAVAC " $@; 310 am__v_JAVAC_1 = 311 AM_V_GOC = $(am__v_GOC_@AM_V@) 312 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 313 am__v_GOC_0 = @echo " GOC " $@; 314 am__v_GOC_1 = 315 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) 316 AM_V_UPP = $(am__v_UPP_@AM_V@) 317 am__v_UPP_ = $(am__v_UPP_@AM_DEFAULT_V@) 318 am__v_UPP_0 = @echo " UPP " $@; 319 am__v_UPP_1 = 299 320 debug = yes 300 321 installed = no … … 309 330 ${INSTALL_FLAGS} ${ARCH_FLAGS} 310 331 PRETTY_PATH = cd ${srcdir} && 311 fstream_test_SOURCES = fstream_test.c312 332 avl_test_SOURCES = avltree/avl_test.c avltree/avl0.c avltree/avl1.c avltree/avl2.c avltree/avl3.c avltree/avl4.c avltree/avl-private.c 313 333 all: all-am 314 334 315 335 .SUFFIXES: 316 .SUFFIXES: .c . o .obj .validate317 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)336 .SUFFIXES: .c .cfa .lo .o .obj .validate 337 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/src/cfa.make $(am__configure_deps) 318 338 @for dep in $?; do \ 319 339 case '$(am__configure_deps)' in \ … … 335 355 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 336 356 esac; 357 $(top_srcdir)/src/cfa.make $(am__empty): 337 358 338 359 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 371 392 $(AM_V_CCLD)$(LINK) $(avl_test_OBJECTS) $(avl_test_LDADD) $(LIBS) 372 393 373 fstream_test$(EXEEXT): $(fstream_test_OBJECTS) $(fstream_test_DEPENDENCIES) $(EXTRA_fstream_test_DEPENDENCIES)374 @rm -f fstream_test$(EXEEXT)375 $(AM_V_CCLD)$(LINK) $(fstream_test_OBJECTS) $(fstream_test_LDADD) $(LIBS)376 377 394 mostlyclean-compile: 378 395 -rm -f *.$(OBJEXT) … … 382 399 -rm -f *.tab.c 383 400 384 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@385 401 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl-private.Po@am__quote@ 386 402 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl0.Po@am__quote@ … … 530 546 531 547 distclean: distclean-am 532 -rm -rf ./$(DEPDIR)avltree/$(DEPDIR)548 -rm -rf avltree/$(DEPDIR) 533 549 -rm -f Makefile 534 550 distclean-am: clean-am distclean-compile distclean-generic \ … … 576 592 577 593 maintainer-clean: maintainer-clean-am 578 -rm -rf ./$(DEPDIR)avltree/$(DEPDIR)594 -rm -rf avltree/$(DEPDIR) 579 595 -rm -f Makefile 580 596 maintainer-clean-am: distclean-am maintainer-clean-generic … … 612 628 613 629 630 .cfa.o: 631 $(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ 632 $(CFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 633 $(am__mv) $$depbase.Tpo $$depbase.Po 634 635 .cfa.lo: 636 $(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ 637 $(LTCFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 638 $(am__mv) $$depbase.Tpo $$depbase.Plo 639 614 640 .PHONY: list .validate 615 .INTERMEDIATE: .validate .validate.c 641 .INTERMEDIATE: .validate .validate.cfa 616 642 617 643 #---------------------------------------------------------------------------------------------------------------- … … 628 654 @+${TEST_PY} --list ${concurrent} 629 655 630 .validate: .validate.c 631 $(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror 632 633 .validate.c: 656 .validate: .validate.cfa 657 $(CFACOMPILE) .validate.cfa -fsyntax-only -Wall -Wextra -Werror 658 659 .validate.cfa: 660 @echo "int main() { return 0; }" > ${@} 661 662 dummy_hack.c: 634 663 @echo "int main() { return 0; }" > ${@} 635 664 … … 638 667 639 668 #---------------------------------------------------------------------------------------------------------------- 669 640 670 # implicit rule so not all test require a rule 641 % : %.c $(CC) 642 $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 643 644 declarationSpecifier: declarationSpecifier.c $(CC) 645 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 646 647 gccExtensions : gccExtensions.c $(CC) 648 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 649 650 extension : extension.c $(CC) 651 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 652 653 attributes : attributes.c $(CC) 654 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 655 656 functions: functions.c $(CC) 657 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 658 659 KRfunctions : KRfunctions.c $(CC) 660 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 661 662 sched-ext-parse : sched-ext-parse.c $(CC) 663 $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 664 665 gmp : gmp.c $(CC) 666 $(PRETTY_PATH) $(COMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 671 % : %.c $(CFACC) 672 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 673 674 % : %.cfa $(CFACC) 675 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 676 677 declarationSpecifier: declarationSpecifier.cfa $(CFACC) 678 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 679 680 gccExtensions : gccExtensions.cfa $(CFACC) 681 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 682 683 extension : extension.cfa $(CFACC) 684 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 685 686 attributes : attributes.cfa $(CFACC) 687 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 688 689 functions: functions.cfa $(CFACC) 690 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 691 692 KRfunctions : KRfunctions.cfa $(CFACC) 693 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 694 695 sched-ext-parse : sched-ext-parse.c $(CFACC) 696 $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 697 698 gmp : gmp.cfa $(CFACC) 699 $(PRETTY_PATH) $(CFACOMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 667 700 668 701 #builtins 669 builtins/sync: builtins/sync.c $(C C)670 $(PRETTY_PATH) $(C OMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only702 builtins/sync: builtins/sync.c $(CFACC) 703 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only 671 704 672 705 #------------------------------------------------------------------------------ 706 673 707 #To make errors path independent we need to cd into the correct directories 674 completeTypeError : completeTypeError.c $(CC)675 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})676 677 typedefRedef-ERR1: typedefRedef.c $(CC)678 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})679 680 alloc-ERROR: alloc.c $(CC)681 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})682 683 fallthrough-ERROR: fallthrough.c $(CC)684 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})685 686 nested-types-ERR1: nested-types.c $(CC)687 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})688 689 nested-types-ERR2: nested-types.c $(CC)690 $(PRETTY_PATH) $(C OMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})708 completeTypeError : completeTypeError.cfa $(CFACC) 709 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 710 711 typedefRedef-ERR1: typedefRedef.cfa $(CFACC) 712 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 713 714 alloc-ERROR: alloc.cfa $(CFACC) 715 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 716 717 fallthrough-ERROR: fallthrough.cfa $(CFACC) 718 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 719 720 nested-types-ERR1: nested-types.cfa $(CFACC) 721 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 722 723 nested-types-ERR2: nested-types.cfa $(CFACC) 724 $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 691 725 692 726 # Constructor/destructor tests 693 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(C C)694 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})695 696 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(C C)697 $(PRETTY_PATH) $(C OMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})698 699 raii/memberCtors-ERR1: raii/memberCtors.c $(C C)700 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})701 702 raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(C C)703 $(PRETTY_PATH) $(C OMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})727 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CFACC) 728 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 729 730 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CFACC) 731 $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 732 733 raii/memberCtors-ERR1: raii/memberCtors.c $(CFACC) 734 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 735 736 raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CFACC) 737 $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 704 738 705 739 # Warnings 706 warnings/self-assignment: warnings/self-assignment.c $(C C)707 $(PRETTY_PATH) $(C OMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only740 warnings/self-assignment: warnings/self-assignment.c $(CFACC) 741 $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only 708 742 709 743 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
tests/abs.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // abs.c --7 // abs.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Thu Jan 28 18:26:16 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 22 22:31:03 201713 // Update Count : 5 212 // 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 33 33 // Local Variables: // 34 34 // tab-width: 4 // 35 // compile-command: "cfa abs.c " //35 // compile-command: "cfa abs.cfa" // 36 36 // End: // -
tests/alloc.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // alloc.c --7 // alloc.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 9 06:21:35201813 // Update Count : 33 712 // Last Modified On : Tue Nov 6 17:50:52 2018 13 // Update Count : 339 14 14 // 15 15 … … 272 272 // Local Variables: // 273 273 // tab-width: 4 // 274 // compile-command: "cfa alloc.c " //274 // compile-command: "cfa alloc.cfa" // 275 275 // End: // -
tests/ato.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ato.c --7 // ato.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Thu Feb 4 08:10:57 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 16 18:31:56 201713 // Update Count : 8912 // 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 120 120 // Local Variables: // 121 121 // tab-width: 4 // 122 // compile-command: "cfa ato.c " //122 // compile-command: "cfa ato.cfa" // 123 123 // End: // -
tests/attributes.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // attributes.c --7 // attributes.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Mon Feb 6 16:07:02 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jul 19 13:50:51201813 // Update Count : 1 512 // Last Modified On : Tue Nov 6 17:51:12 2018 13 // Update Count : 17 14 14 // 15 15 … … 154 154 // Local Variables: // 155 155 // tab-width: 4 // 156 // compile-command: "cfa attributes.c " //156 // compile-command: "cfa attributes.cfa" // 157 157 // End: // -
tests/complex.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // complex.c --7 // complex.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 24 22:07:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 24 22:08:01 201713 // Update Count : 112 // 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 } … … 38 38 // Local Variables: // 39 39 // tab-width: 4 // 40 // compile-command: "cfa complex.c " //40 // compile-command: "cfa complex.cfa" // 41 41 // End: // -
tests/concurrent/coroutineYield.c
rcdc02f2 r515a037 6 6 7 7 #define __kick_rate 150000ul 8 #include "long_tests.h "8 #include "long_tests.hfa" 9 9 10 10 #ifndef PREEMPTION_RATE … … 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // matrixSum.c --8 // matrixSum.cfa -- 9 9 // 10 10 // Author : Peter A. Buhr 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : T hu Aug 9 09:17:30201814 // Update Count : 1 313 // 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 59 59 // Local Variables: // 60 60 // tab-width: 4 // 61 // compile-command: "cfa matrixSum.c " //61 // compile-command: "cfa matrixSum.cfa" // 62 62 // End: // -
tests/concurrent/examples/quickSort.c
rcdc02f2 r515a037 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
rcdc02f2 r515a037 40 40 MyThread f[4]; 41 41 } 42 sout | global.value | endl;42 sout | global.value; 43 43 } -
tests/concurrent/multi-monitor.c
rcdc02f2 r515a037 52 52 } 53 53 } 54 sout | global12 | global23 | global13 | endl;54 sout | global12 | global23 | global13; 55 55 } -
tests/concurrent/preempt.c
rcdc02f2 r515a037 3 3 #include <time.hfa> 4 4 5 #include "long_tests.h "5 #include "long_tests.hfa" 6 6 7 7 #ifndef PREEMPTION_RATE -
tests/concurrent/signal/block.c
rcdc02f2 r515a037 14 14 #include <time.hfa> 15 15 16 #include "long_tests.h "16 #include "long_tests.hfa" 17 17 18 18 #ifndef PREEMPTION_RATE … … 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
rcdc02f2 r515a037 5 5 #include <time.hfa> 6 6 7 #include "long_tests.h "7 #include "long_tests.hfa" 8 8 9 9 #ifndef PREEMPTION_RATE … … 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
rcdc02f2 r515a037 13 13 14 14 #define __kick_rate 12000ul 15 #include "long_tests.h "15 #include "long_tests.hfa" 16 16 17 17 #ifndef PREEMPTION_RATE … … 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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
rcdc02f2 r515a037 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/counter.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // counter.c --7 // counter.cfa -- 8 8 // 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu Feb 22 15:27:00 2018 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : T hu Feb 22 15:27:00201813 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:50:23 2018 13 // Update Count : 2 14 14 // 15 15 … … 37 37 // Local Variables: // 38 38 // tab-width: 4 // 39 // compile-command: "cfa counter.c " //39 // compile-command: "cfa counter.cfa" // 40 40 // End: // -
tests/declarationErrors.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // declarationErrors.c --7 // declarationErrors.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:23:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 9 22:57:52 201613 // Update Count : 3 112 // Last Modified On : Tue Nov 6 17:52:47 2018 13 // Update Count : 32 14 14 // 15 15 … … 42 42 // Local Variables: // 43 43 // tab-width: 4 // 44 // compile-command: "cfa declarationErrors.c " //44 // compile-command: "cfa declarationErrors.cfa" // 45 45 // End: // -
tests/declarationSpecifier.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // declarationSpecifier.c --7 // declarationSpecifier.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:21:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 08:24:33 201613 // Update Count : 212 // Last Modified On : Tue Nov 6 17:52:59 2018 13 // Update Count : 3 14 14 // 15 15 … … 96 96 // Local Variables: // 97 97 // tab-width: 4 // 98 // compile-command: "cfa declarationSpecifier.c " //98 // compile-command: "cfa declarationSpecifier.cfa" // 99 99 // End: // -
tests/div.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // div.c --7 // div.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue Aug 8 16:28:43 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 7 09:06:52 201713 // Update Count : 1812 // 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> // div17 #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 32 32 // Local Variables: // 33 33 // tab-width: 4 // 34 // compile-command: "cfa div.c " //34 // compile-command: "cfa div.cfa" // 35 35 // End: // -
tests/except-0.cfa
rcdc02f2 r515a037 8 8 #include <stdbool.h> 9 9 10 #include "except-mac.h "10 #include "except-mac.hfa" 11 11 TRIVIAL_EXCEPTION(yin) 12 12 TRIVIAL_EXCEPTION(yang) … … 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/except-1.cfa
rcdc02f2 r515a037 5 5 #include <stdio.h> 6 6 7 #include "except-mac.h "7 #include "except-mac.hfa" 8 8 TRIVIAL_EXCEPTION(yin) 9 9 TRIVIAL_EXCEPTION(yang) -
tests/except-2.cfa
rcdc02f2 r515a037 3 3 4 4 #include <stdlib.hfa> 5 #include "except-mac.h "5 #include "except-mac.hfa" 6 6 7 7 TRIVIAL_EXCEPTION(yin) -
tests/except-3.cfa
rcdc02f2 r515a037 2 2 3 3 #include <stdio.h> 4 #include "except-mac.h "4 #include "except-mac.hfa" 5 5 TRIVIAL_EXCEPTION(myth) 6 6 -
tests/extension.cfa
rcdc02f2 r515a037 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 // extension.c --4 // extension.cfa -- 5 5 // 6 6 // Author : Peter A. Buhr 7 7 // Created On : Mon Jul 4 20:42:43 2016 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Mon Feb 6 15:44:39 201710 // Update Count : 4 69 // Last Modified On : Tue Nov 6 17:53:21 2018 10 // Update Count : 47 11 11 // 12 12 … … 56 56 // Local Variables: // 57 57 // tab-width: 4 // 58 // compile-command: "cfa extension.c " //58 // compile-command: "cfa extension.cfa" // 59 59 // End: // -
tests/fallthrough.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fallthrough.c --7 // fallthrough.cfa -- 8 8 // 9 9 // Author : Rob Schluntz 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 Aug 16 08:21:46201813 // Update Count : 1 412 // Last Modified On : Tue Dec 4 21:36:14 2018 13 // Update Count : 17 14 14 // 15 16 #include <fstream.hfa> 15 17 16 18 void test(int choice) { 17 19 choose ( choice ) { 18 20 case 1: 19 printf("case 1\n");21 sout | "case 1"; 20 22 fallthru; 21 23 case 2: 22 printf("case 2\n");24 sout | "case 2"; 23 25 fallthru; 24 printf("did not fallthru\n");26 sout | "did not fallthru"; 25 27 if ( 7 ) fallthru common2; 26 28 fallthru common1; 27 29 case 3: 28 printf("case 3\n");30 sout | "case 3"; 29 31 fallthru default; 30 32 fallthru common1; 31 33 common1: 32 printf("common1\n");34 sout | "common1"; 33 35 // break 34 36 case 4: 35 printf("case 4\n");37 sout | "case 4"; 36 38 fallthru common2; 37 39 case 5: 38 printf("case 5\n");40 sout | "case 5"; 39 41 fallthru common2; 40 42 fallthru default; 41 43 case 6: 42 printf("case 6\n");44 sout | "case 6"; 43 45 fallthru common2; 44 46 common2: 45 printf("common2\n");47 sout | "common2"; 46 48 // break 47 49 default: 48 printf("default\n");50 sout | "default"; 49 51 fallthru; 50 52 } 51 53 52 printf("\n");54 sout | nl; 53 55 54 56 switch ( choice ) { 55 57 case 1: 56 printf("case 1\n");58 sout | "case 1"; 57 59 switch ( choice ) { 58 60 case 1: 59 printf("case 1\n");61 sout | "case 1"; 60 62 for ( int i = 0; i < 4; i += 1 ) { 61 63 printf("%d\n", i); … … 65 67 break; 66 68 case 5: 67 printf("case 5\n");69 sout | "case 5"; 68 70 if ( choice == 5 ) { 69 71 if ( choice != 5 ) { 70 printf("error\n");72 sout | "error"; 71 73 } else { 72 printf("check\n");74 sout | "check"; 73 75 fallthru common; 74 76 } // if … … 114 116 115 117 int main() { 116 test( 1);117 printf("\n");118 test( 5);118 test( 1 ); 119 sout | nl; 120 test( 5 ); 119 121 } 120 122 121 123 // Local Variables: // 122 124 // tab-width: 4 // 123 // compile-command: "cfa fallthrough.c " //125 // compile-command: "cfa fallthrough.cfa" // 124 126 // End: // -
tests/forall.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // forall.c --7 // forall.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 9 08:48:15 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jul 12 16:19:08201813 // Update Count : 3 012 // Last Modified On : Tue Nov 6 17:53:43 2018 13 // Update Count : 31 14 14 // 15 15 … … 219 219 // Local Variables: // 220 220 // tab-width: 4 // 221 // compile-command: "cfa forall.c " //221 // compile-command: "cfa forall.cfa" // 222 222 // End: // -
tests/fstream_test.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fstream_test.c --7 // fstream_test.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 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 Aug 24 11:30:26 201713 // Update Count : 6 512 // 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 32 32 // Local Variables: // 33 33 // tab-width: 4 // 34 // compile-command: "cfa fstream_test.c " //34 // compile-command: "cfa fstream_test.cfa" // 35 35 // End: // -
tests/function-operator.cfa
rcdc02f2 r515a037 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/functions.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // functions.c --7 // functions.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:39:58 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 17 22:44:12201813 // Update Count : 1 212 // Last Modified On : Tue Nov 6 17:54:09 2018 13 // Update Count : 13 14 14 // 15 15 … … 188 188 // Local Variables: // 189 189 // tab-width: 4 // 190 // compile-command: "cfa functions.c " //190 // compile-command: "cfa functions.cfa" // 191 191 // End: // -
tests/gccExtensions.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // gccExtensions.c --7 // gccExtensions.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sun Aug 14 17:28:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 09:26:50 201613 // Update Count : 1 012 // Last Modified On : Tue Nov 6 17:54:20 2018 13 // Update Count : 11 14 14 // 15 15 … … 120 120 // Local Variables: // 121 121 // tab-width: 4 // 122 // compile-command: "cfa gccExtensions.c " //122 // compile-command: "cfa gccExtensions.cfa" // 123 123 // End: // -
tests/gmp.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // gmp.c --7 // gmp.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 12:43:13201813 // Update Count : 55 612 // 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 … … 107 107 // Local Variables: // 108 108 // tab-width: 4 // 109 // compile-command: "cfa gmp.c -lgmp" //109 // compile-command: "cfa gmp.cfa -lgmp" // 110 110 // End: // -
tests/heap.cfa
rcdc02f2 r515a037 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // heap.cfa -- 8 // 9 // Author : Peter A. Buhr 10 // Created On : Tue Nov 6 17:54:56 2018 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 11 21:52:40 2018 13 // Update Count : 18 14 // 15 1 16 #include <thread.hfa> 2 #include <kernel.hfa> // processor3 #include <stdlib.hfa> // *allocs17 #include <kernel.hfa> // processor 18 #include <stdlib.hfa> // *allocs 4 19 #include <malloc.h> // malloc_* 5 20 … … 22 37 void main( Worker & ) { 23 38 enum { NoOfAllocs = 5000, NoOfMmaps = 10 }; 24 char * locns[NoOfAllocs];39 char * locns[NoOfAllocs]; 25 40 int i; 26 41 27 42 // check alloc/free 28 43 29 for ( int j = 0; j < 40; j += 1) {30 for ( i = 0; i < NoOfAllocs; i += 1) {44 for ( j; 40 ) { 45 for ( i; NoOfAllocs ) { 31 46 locns[i] = alloc( i ); 32 //sout | (void *)locns[i] | endl;33 for ( int k = 0; k < i; k += 1) locns[i][k] = '\345';34 } // for 35 //sout | (char *)sbrk(0) - start | " bytes" | endl;36 37 for ( i = 0; i < NoOfAllocs; i += 1) {38 //sout | (void *)locns[i] | endl;39 for ( int k = 0; k < i; k += 1) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage1" );47 //sout | (void *)locns[i]; 48 for ( k; i ) locns[i][k] = '\345'; 49 } // for 50 //sout | (char *)sbrk(0) - start | " bytes"; 51 52 for ( i; NoOfAllocs ) { 53 //sout | (void *)locns[i]; 54 for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage1" ); 40 55 free( locns[i] ); 41 56 } // for 42 //sout | (char *)sbrk(0) - start | " bytes" | endl;43 44 for ( i = 0; i < NoOfAllocs; i += 1) {57 //sout | (char *)sbrk(0) - start | " bytes"; 58 59 for ( i; NoOfAllocs ) { 45 60 locns[i] = alloc( i ); 46 //sout | (void *)locns[i] | endl;47 for ( int k = 0; k < i; k += 1) locns[i][k] = '\345';48 } // for 49 for ( i = NoOfAllocs - 1; i >=0 ; i -= 1) {50 //sout | (void *)locns[i] | endl;51 for ( int k = 0; k < i; k += 1) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage2" );61 //sout | (void *)locns[i]; 62 for ( k; i ) locns[i][k] = '\345'; 63 } // for 64 for ( i; NoOfAllocs - 1 -~= 0 ) { 65 //sout | (void *)locns[i]; 66 for ( k; i ) if ( locns[i][k] != '\345' ) abort( "new/delete corrupt storage2" ); 52 67 free( locns[i] ); 53 68 } // for … … 56 71 // check malloc/free (sbrk) 57 72 58 for ( i = 0; i < NoOfAllocs; i += 1) {73 for ( i; NoOfAllocs ) { 59 74 size_t s = (i + 1) * 20; 60 char * area = (char *)malloc( s );75 char * area = (char *)malloc( s ); 61 76 if ( area == 0 ) abort( "malloc/free out of memory" ); 62 77 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last … … 65 80 } // for 66 81 67 for ( i = 0; i < NoOfAllocs; i += 1) {68 size_t s = i + 1; // +1 to make initialization simpler82 for ( i; NoOfAllocs ) { 83 size_t s = i + 1; // +1 to make initialization simpler 69 84 locns[i] = (char *)malloc( s ); 70 85 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); … … 72 87 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte 73 88 } // for 74 for ( i = 0; i < NoOfAllocs; i += 1) {89 for ( i; NoOfAllocs ) { 75 90 size_t s = i + 1; 76 91 if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || … … 81 96 // check malloc/free (mmap) 82 97 83 for ( i = 0; i < NoOfMmaps; i += 1) {84 size_t s = i + default_mmap_start(); // cross over point85 char * area = (char *)malloc( s );98 for ( i; NoOfMmaps ) { 99 size_t s = i + default_mmap_start(); // cross over point 100 char * area = (char *)malloc( s ); 86 101 if ( area == 0 ) abort( "malloc/free out of memory" ); 87 102 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last … … 90 105 } // for 91 106 92 for ( i = 0; i < NoOfMmaps; i += 1) {93 size_t s = i + default_mmap_start(); // cross over point107 for ( i; NoOfMmaps ) { 108 size_t s = i + default_mmap_start(); // cross over point 94 109 locns[i] = (char *)malloc( s ); 95 110 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); … … 97 112 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte 98 113 } // for 99 for ( i = 0; i < NoOfMmaps; i += 1) {100 size_t s = i + default_mmap_start(); // cross over point114 for ( i; NoOfMmaps ) { 115 size_t s = i + default_mmap_start(); // cross over point 101 116 if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || 102 117 locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "malloc/free corrupt storage" ); … … 106 121 // check calloc/free (sbrk) 107 122 108 for ( i = 0; i < NoOfAllocs; i += 1) {123 for ( i; NoOfAllocs ) { 109 124 size_t s = (i + 1) * 20; 110 char * area = (char *)calloc( 5, s );125 char * area = (char *)calloc( 5, s ); 111 126 if ( area == 0 ) abort( "calloc/free out of memory" ); 112 127 if ( area[0] != '\0' || area[s - 1] != '\0' || … … 118 133 } // for 119 134 120 for ( i = 0; i < NoOfAllocs; i += 1) {135 for ( i; NoOfAllocs ) { 121 136 size_t s = i + 1; 122 137 locns[i] = (char *)calloc( 5, s ); … … 128 143 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte 129 144 } // for 130 for ( i = 0; i < NoOfAllocs; i += 1) {145 for ( i; NoOfAllocs ) { 131 146 size_t s = i + 1; 132 147 if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || … … 137 152 // check calloc/free (mmap) 138 153 139 for ( i = 0; i < NoOfMmaps; i += 1) {140 size_t s = i + default_mmap_start(); // cross over point141 char * area = (char *)calloc( 1, s );154 for ( i; NoOfMmaps ) { 155 size_t s = i + default_mmap_start(); // cross over point 156 char * area = (char *)calloc( 1, s ); 142 157 if ( area == 0 ) abort( "calloc/free out of memory" ); 143 158 if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" ); … … 149 164 } // for 150 165 151 for ( i = 0; i < NoOfMmaps; i += 1) {152 size_t s = i + default_mmap_start(); // cross over point166 for ( i; NoOfMmaps ) { 167 size_t s = i + default_mmap_start(); // cross over point 153 168 locns[i] = (char *)calloc( 1, s ); 154 169 if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); … … 159 174 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte 160 175 } // for 161 for ( i = 0; i < NoOfMmaps; i += 1) {162 size_t s = i + default_mmap_start(); // cross over point176 for ( i; NoOfMmaps ) { 177 size_t s = i + default_mmap_start(); // cross over point 163 178 if ( locns[i][0] != '\345' || locns[i][s - 1] != '\345' || 164 179 locns[i][malloc_usable_size( locns[i] ) - 1] != '\345' ) abort( "calloc/free corrupt storage6" ); … … 170 185 enum { limit = 64 * 1024 }; // check alignments up to here 171 186 172 for ( size_t a = libAlign(); a <= limit; a += a ) {// generate powers of 2173 //sout | alignments[a] | endl;174 for ( int s = 1; s < NoOfAllocs; s += 1 ) {// allocation of size 0 can return null175 char * area = (char *)memalign( a, s );187 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 188 //sout | alignments[a]; 189 for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null 190 char * area = (char *)memalign( a, s ); 176 191 if ( area == 0 ) abort( "memalign/free out of memory" ); 177 //sout | i | " " | area | endl;192 //sout | i | " " | area; 178 193 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 179 194 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area ); … … 187 202 // check memalign/free (mmap) 188 203 189 for ( size_t a = libAlign(); a <= limit; a += a ) {// generate powers of 2190 //sout | alignments[a] | endl;191 for ( i = 1; i < NoOfMmaps; i += 1) {192 size_t s = i + default_mmap_start(); // cross over point193 char * area = (char *)memalign( a, s );204 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 205 //sout | alignments[a]; 206 for ( i; 1 ~ NoOfMmaps ) { 207 size_t s = i + default_mmap_start(); // cross over point 208 char * area = (char *)memalign( a, s ); 194 209 if ( area == 0 ) abort( "memalign/free out of memory" ); 195 //sout | i | " " | area | endl;210 //sout | i | " " | area; 196 211 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 197 212 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area ); … … 205 220 // check calloc/realloc/free (sbrk) 206 221 207 for ( i = 1; i < 10000; i +=12 ) {222 for ( i; 1 ~ 10_000 ~ 12 ) { 208 223 // initial N byte allocation 209 char * area = (char *)calloc( 5, i );224 char * area = (char *)calloc( 5, i ); 210 225 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 211 226 if ( area[0] != '\0' || area[i - 1] != '\0' || … … 214 229 215 230 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. 216 for ( int s = i; s < 256 * 1024; s += 26 ) {// start at initial memory request231 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 217 232 area = (char *)realloc( area, s ); // attempt to reuse storage 218 233 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); … … 226 241 // check calloc/realloc/free (mmap) 227 242 228 for ( i = 1; i < 1000; i +=12 ) {243 for ( i; 1 ~ 10_000 ~ 12 ) { 229 244 // initial N byte allocation 230 size_t s = i + default_mmap_start(); // cross over point231 char * area = (char *)calloc( 1, s );245 size_t s = i + default_mmap_start(); // cross over point 246 char * area = (char *)calloc( 1, s ); 232 247 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 233 248 if ( area[0] != '\0' || area[s - 1] != '\0' || … … 236 251 237 252 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. 238 for ( int r = i; r < 256 * 1024; r += 26 ) {// start at initial memory request239 area = (char *)realloc( area, r ); // attempt to reuse storage253 for ( r; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 254 area = (char *)realloc( area, r ); // attempt to reuse storage 240 255 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 241 256 if ( area[0] != '\0' || area[r - 1] != '\0' || … … 249 264 250 265 size_t amount = 2; 251 for ( size_t a = libAlign(); a <= limit; a += a ) {// generate powers of 2266 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 252 267 // initial N byte allocation 253 char * area = (char *)memalign( a, amount );// aligned N-byte allocation268 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 254 269 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 255 //sout | alignments[a] | " " | area | endl;270 //sout | alignments[a] | " " | area; 256 271 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 257 272 abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 260 275 261 276 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. 262 for ( int s = amount; s < 256 * 1024; s += 1 ) {// start at initial memory request277 for ( s; amount ~ 256 * 1024 ) { // start at initial memory request 263 278 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); 264 279 area = (char *)realloc( area, s ); // attempt to reuse storage 265 280 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 266 //sout | i | " " | area | endl;281 //sout | i | " " | area; 267 282 if ( (size_t)area % a != 0 ) { // check for initial alignment 268 283 abort( "memalign/realloc/free bad alignment %p", area ); … … 275 290 // check cmemalign/free 276 291 277 for ( size_t a = libAlign(); a <= limit; a += a ) {// generate powers of 2278 //sout | alignments[a] | endl;279 for ( int s = 1; s < limit; s += 1 ) {// allocation of size 0 can return null280 char * area = (char *)cmemalign( a, 1, s );292 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 293 //sout | alignments[a]; 294 for ( s; 1 ~ limit ) { // allocation of size 0 can return null 295 char * area = (char *)cmemalign( a, 1, s ); 281 296 if ( area == 0 ) abort( "cmemalign/free out of memory" ); 282 //sout | i | " " | area | endl;297 //sout | i | " " | area; 283 298 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 284 299 abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area ); … … 295 310 296 311 amount = 2; 297 for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) {// generate powers of 2312 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 298 313 // initial N byte allocation 299 char * area = (char *)cmemalign( a, 1, amount );// aligned N-byte allocation314 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 300 315 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 301 //sout | alignments[a] | " " | area | endl;316 //sout | alignments[a] | " " | area; 302 317 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 303 318 abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 309 324 310 325 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. 311 for ( int s = amount; s < 256 * 1024; s += 1 ) {// start at initial memory request326 for ( s; amount ~ 256 * 1024 ) { // start at initial memory request 312 327 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" ); 313 328 area = (char *)realloc( area, s ); // attempt to reuse storage 314 329 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 315 //sout | i | " " | area | endl;330 //sout | i | " " | area; 316 331 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 317 332 abort( "cmemalign/realloc/free bad alignment %p", area ); … … 324 339 free( area ); 325 340 } // for 326 //sout | "worker" | thisTask() | "successful completion" | endl;341 //sout | "worker" | thisTask() | "successful completion"; 327 342 } // Worker main 328 343 … … 339 354 // Local Variables: // 340 355 // tab-width: 4 // 341 // compile-command: "cfa -nodebug -O2 heap.c " //356 // compile-command: "cfa -nodebug -O2 heap.cfa" // 342 357 // End: // -
tests/identFuncDeclarator.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // identFuncDeclarator.c --7 // identFuncDeclarator.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:36:34 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 17 22:39:13 201813 // Update Count : 212 // Last Modified On : Tue Nov 6 17:56:33 2018 13 // Update Count : 3 14 14 // 15 15 … … 115 115 // Local Variables: // 116 116 // tab-width: 4 // 117 // compile-command: "cfa identFuncDeclarator.c " //117 // compile-command: "cfa identFuncDeclarator.cfa" // 118 118 // End: // -
tests/identParamDeclarator.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // identParamDeclarator.c --7 // identParamDeclarator.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:37:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 17 22:36:11201813 // Update Count : 212 // Last Modified On : Tue Nov 6 17:56:44 2018 13 // Update Count : 3 14 14 // 15 15 … … 163 163 // Local Variables: // 164 164 // tab-width: 4 // 165 // compile-command: "cfa identParamDeclarator.c " //165 // compile-command: "cfa identParamDeclarator.cfa" // 166 166 // End: // -
tests/ifwhileCtl.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ifwhileCtl.c --7 // ifwhileCtl.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Aug 26 10:13:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 6 17:15:09201813 // Update Count : 2 112 // 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 … … 72 72 // Local Variables: // 73 73 // tab-width: 4 // 74 // compile-command: "cfa ifwhileCtl.c " //74 // compile-command: "cfa ifwhileCtl.cfa" // 75 75 // End: // -
tests/io1.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // io1.c --7 // io1.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 24 21:17:56201813 // Update Count : 10 412 // 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 70 70 // Local Variables: // 71 71 // tab-width: 4 // 72 // compile-command: "cfa io1.c " //72 // compile-command: "cfa io1.cfa" // 73 73 // End: // -
tests/labelledExit.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // labelledExit.c --7 // labelledExit.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 10 07:29:39 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:55:39201813 // Update Count : 312 // Last Modified On : Tue Nov 6 17:57:42 2018 13 // Update Count : 4 14 14 // 15 15 … … 159 159 // Local Variables: // 160 160 // tab-width: 4 // 161 // compile-command: "cfa labelledExit.c " //161 // compile-command: "cfa labelledExit.cfa" // 162 162 // End: // -
tests/limits.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // limits.c --7 // limits.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue May 10 20:44:20 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 1 16:21:55 201813 // Update Count : 712 // Last Modified On : Tue Nov 6 17:57:55 2018 13 // Update Count : 8 14 14 // 15 15 … … 153 153 // Local Variables: // 154 154 // tab-width: 4 // 155 // compile-command: "cfa limits.c " //155 // compile-command: "cfa limits.cfa" // 156 156 // End: // -
tests/literals.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // literals.c --7 // literals.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 9 16:34:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 1 15:12:15201813 // Update Count : 13 712 // 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 … … 324 324 // Local Variables: // 325 325 // tab-width: 4 // 326 // compile-command: "cfa literals.c " //326 // compile-command: "cfa literals.cfa" // 327 327 // End: // -
tests/math1.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // math1.c --7 // math1.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 24 21:01:15201813 // Update Count : 8 512 // 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 52 52 // Local Variables: // 53 53 // tab-width: 4 // 54 // compile-command: "cfa math1.c " //54 // compile-command: "cfa math1.cfa" // 55 55 // End: // -
tests/math2.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // math2.c --7 // math2.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 24 21:06:10201813 // Update Count : 8 212 // 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 49 49 // Local Variables: // 50 50 // tab-width: 4 // 51 // compile-command: "cfa math2.c " //51 // compile-command: "cfa math2.cfa" // 52 52 // End: // -
tests/math3.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // math3.c --7 // math3.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 24 21:06:12201813 // Update Count : 8 212 // 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 48 48 // Local Variables: // 49 49 // tab-width: 4 // 50 // compile-command: "cfa math3.c " //50 // compile-command: "cfa math3.cfa" // 51 51 // End: // -
tests/math4.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // math4.c --7 // math4.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Thu May 24 20:56:54 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 24 20:58:06201813 // Update Count : 212 // 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 69 69 // Local Variables: // 70 70 // tab-width: 4 // 71 // compile-command: "cfa math3.c " //71 // compile-command: "cfa math3.cfa" // 72 72 // End: // -
tests/minmax.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // minmax.c --7 // minmax.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 10 17:29:09201813 // Update Count : 5 012 // 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 49 49 // Local Variables: // 50 50 // tab-width: 4 // 51 // compile-command: "cfa minmax.c " //51 // compile-command: "cfa minmax.cfa" // 52 52 // End: // -
tests/nested-types.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // nested-types.c --7 // nested-types.cfa -- 8 8 // 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon Jul 9 10:20:03 2018 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon Jul 9 10:20:03 201713 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:59:40 2018 13 // Update Count : 2 14 14 // 15 15 … … 88 88 // Local Variables: // 89 89 // tab-width: 4 // 90 // compile-command: "cfa nested-types.c " //90 // compile-command: "cfa nested-types.cfa" // 91 91 // End: // -
tests/numericConstants.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // numericConstants.c --7 // numericConstants.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 24 22:10:36 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 24 22:11:36 201713 // Update Count : 212 // Last Modified On : Tue Nov 6 17:59:53 2018 13 // Update Count : 3 14 14 // 15 15 … … 67 67 // Local Variables: // 68 68 // tab-width: 4 // 69 // compile-command: "cfa minmax.c " //69 // compile-command: "cfa minmax.cfa" // 70 70 // End: // -
tests/preempt_longrun/create.c
rcdc02f2 r515a037 3 3 #include <time.hfa> 4 4 5 #include "long_tests.h "5 #include "long_tests.hfa" 6 6 7 7 #ifndef PREEMPTION_RATE -
tests/preempt_longrun/enter3.c
rcdc02f2 r515a037 5 5 6 6 #define __kick_rate 75000ul 7 #include "long_tests.h "7 #include "long_tests.hfa" 8 8 9 9 #ifndef PREEMPTION_RATE -
tests/preempt_longrun/processor.c
rcdc02f2 r515a037 5 5 #include <unistd.h> 6 6 7 #include "long_tests.h "7 #include "long_tests.hfa" 8 8 9 9 #ifndef PREEMPTION_RATE -
tests/preempt_longrun/yield.c
rcdc02f2 r515a037 4 4 5 5 #define __kick_rate 550000ul 6 #include "long_tests.h "6 #include "long_tests.hfa" 7 7 8 8 #ifndef PREEMPTION_RATE -
tests/quotedKeyword.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // quoted _keyword.c-- test quoted keyword usage7 // quotedKeyword.cfa -- test quoted keyword usage 8 8 // 9 9 // Author : Peter A. Buhr 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 Jun 30 14:03:59 201613 // Update Count : 1912 // 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 46 46 // Local Variables: // 47 47 // tab-width: 4 // 48 // compile-command: "cfa quoted _keyword.c" //48 // compile-command: "cfa quotedKeyword.cfa" // 49 49 // End: // -
tests/raii/dtor-early-exit.c
rcdc02f2 r515a037 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 … … 202 202 } 203 203 // S_L4 = {} 204 L4: sout | "L4" | endl;204 L4: sout | "L4"; 205 205 if (i == 4) { 206 sout | "goto L0" | endl;206 sout | "goto L0"; 207 207 // S_G = {} 208 208 goto L0; … … 240 240 f(i); 241 241 } 242 sout | endl;242 sout | nl; 243 243 g(); 244 sout | endl;244 sout | nl; 245 245 h(); 246 246 -
tests/raii/globals.c
rcdc02f2 r515a037 70 70 71 71 int main() { 72 sout | "static\t\tinline\t\tautogen\t\tvalue" | endl;72 sout | "static\t\tinline\t\tautogen\t\tvalue"; 73 73 74 sout | "no \t\tno \t\tno \t\t" | g.val.value | endl;75 sout | "no \t\tno \t\tyes\t\t" | ga.val.value | endl;76 sout | "no \t\tyes\t\tno \t\t" | gi.val.value | endl;77 sout | "no \t\tyes\t\tyes\t\t" | gia.val.value | endl;78 sout | "yes\t\tno \t\tno \t\t" | gs.val.value | endl;79 sout | "yes\t\tno \t\tyes\t\t" | gsa.val.value | endl;80 sout | "yes\t\tyes\t\tno \t\t" | gsi.val.value | endl;81 sout | "yes\t\tyes\t\tyes\t\t" | gsia.val.value | endl;74 sout | "no \t\tno \t\tno \t\t" | g.val.value; 75 sout | "no \t\tno \t\tyes\t\t" | ga.val.value; 76 sout | "no \t\tyes\t\tno \t\t" | gi.val.value; 77 sout | "no \t\tyes\t\tyes\t\t" | gia.val.value; 78 sout | "yes\t\tno \t\tno \t\t" | gs.val.value; 79 sout | "yes\t\tno \t\tyes\t\t" | gsa.val.value; 80 sout | "yes\t\tyes\t\tno \t\t" | gsi.val.value; 81 sout | "yes\t\tyes\t\tyes\t\t" | gsia.val.value; 82 82 83 83 } -
tests/random.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // random.c --7 // random.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 2 12:19:34201813 // Update Count : 1912 // Last Modified On : Tue Dec 4 21:46:25 2018 13 // Update Count : 22 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include <stdlib.hfa> // random17 #include <stdlib.hfa> // random 18 18 #include <unistd.h> // getpid 19 19 … … 24 24 // test polymorphic calls to random and stream 25 25 char c = random(); 26 sout | c | endl;26 sout | c; 27 27 c = random( 'A' ); 28 sout | c | endl;28 sout | c; 29 29 c = random( 'A', 'Z' ); 30 sout | c | endl;30 sout | c; 31 31 32 32 int i = random(); 33 sout | i | endl;33 sout | i; 34 34 i = random( 10 ); 35 sout | i | endl;35 sout | i; 36 36 i = random( -10, 20 ); 37 sout | i | endl;37 sout | i; 38 38 39 39 unsigned int ui = random(); 40 sout | ui | endl;40 sout | ui; 41 41 ui = random( 10u ); 42 sout | ui | endl;42 sout | ui; 43 43 ui = random( 10u, 20u ); 44 sout | ui | endl;44 sout | ui; 45 45 46 46 long int li = random(); 47 sout | li | endl;47 sout | li; 48 48 li = random( 10l ); 49 sout | li | endl;49 sout | li; 50 50 li = random( -10l, 20l ); 51 sout | li | endl;51 sout | li; 52 52 53 53 unsigned long int uli = random(); 54 sout | uli | endl;54 sout | uli; 55 55 uli = random( 10ul ); 56 sout | uli | endl;56 sout | uli; 57 57 uli = random( 10ul, 20ul ); 58 sout | uli | endl;58 sout | uli; 59 59 60 60 float f = random(); 61 sout | f | endl;61 sout | f; 62 62 63 63 double d = random(); 64 sout | d | endl;64 sout | d; 65 65 66 66 float _Complex fc = random(); 67 sout | fc | endl;67 sout | fc; 68 68 69 69 double _Complex dc = random(); 70 sout | dc | endl;70 sout | dc; 71 71 72 72 long double _Complex ldc = random(); 73 sout | ldc | endl;73 sout | ldc; 74 74 } // main 75 75 76 76 // Local Variables: // 77 77 // tab-width: 4 // 78 // compile-command: "cfa random.c " //78 // compile-command: "cfa random.cfa" // 79 79 // End: // -
tests/rational.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // rational.c -- test rational number package7 // rational.cfa -- test rational number package 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 10 23:25:04 201713 // Update Count : 6 712 // Last Modified On : Tue Dec 4 21:46:42 2018 13 // Update Count : 69 14 14 // 15 15 … … 27 27 28 28 int main() { 29 sout | "constructor" | endl;29 sout | "constructor"; 30 30 Rational(int) a = { 3 }, b = { 4 }, c; 31 sout | a | b | c | endl;31 sout | a | b | c; 32 32 33 33 a = (Rational(int)){ 4, 8 }; 34 34 b = (Rational(int)){ 5, 7 }; 35 sout | a | b | endl;35 sout | a | b; 36 36 a = (Rational(int)){ -2, -3 }; 37 37 b = (Rational(int)){ 3, -2 }; 38 sout | a | b | endl;38 sout | a | b; 39 39 a = (Rational(int)){ -2, 3 }; 40 40 b = (Rational(int)){ 3, 2 }; 41 sout | a | b | endl;41 sout | a | b; 42 42 43 sout | "logical" | endl;43 sout | "logical"; 44 44 a = (Rational(int)){ -2 }; 45 45 b = (Rational(int)){ -3, 2 }; 46 sout | a | b | endl;47 // sout | a == 1 | endl; // FIX ME48 sout | a != b | endl;49 sout | a < b | endl;50 sout | a <= b | endl;51 sout | a > b | endl;52 sout | a >= b | endl;46 sout | a | b; 47 // sout | a == 1; // FIX ME 48 sout | a != b; 49 sout | a < b; 50 sout | a <= b; 51 sout | a > b; 52 sout | a >= b; 53 53 54 sout | "arithmetic" | endl;55 sout | a | b | endl;56 sout | a + b | endl;57 sout | a - b | endl;58 sout | a * b | endl;59 sout | a / b | endl;54 sout | "arithmetic"; 55 sout | a | b; 56 sout | a + b; 57 sout | a - b; 58 sout | a * b; 59 sout | a / b; 60 60 61 sout | "conversion" | endl;61 sout | "conversion"; 62 62 a = (Rational(int)){ 3, 4 }; 63 sout | widen( a ) | endl;63 sout | widen( a ); 64 64 a = (Rational(int)){ 1, 7 }; 65 sout | widen( a ) | endl;65 sout | widen( a ); 66 66 a = (Rational(int)){ 355, 113 }; 67 sout | widen( a ) | endl;68 sout | narrow( 0.75, 4 ) | endl;69 sout | narrow( 0.14285714285714, 16 ) | endl;70 sout | narrow( 3.14159265358979, 256 ) | endl;67 sout | widen( a ); 68 sout | narrow( 0.75, 4 ); 69 sout | narrow( 0.14285714285714, 16 ); 70 sout | narrow( 3.14159265358979, 256 ); 71 71 72 sout | "decompose" | endl;72 sout | "decompose"; 73 73 int n, d; 74 74 // [n, d] = a; 75 // sout | a | n | d | endl;75 // sout | a | n | d; 76 76 77 sout | "more tests" | endl;77 sout | "more tests"; 78 78 Rational(int) x = { 1, 2 }, y = { 2 }; 79 sout | x - y | endl;80 sout | x > y | endl;81 sout | x | numerator( x, 2 ) | x | endl;82 sout | y | denominator( y, -2 ) | y | endl;79 sout | x - y; 80 sout | x > y; 81 sout | x | numerator( x, 2 ) | x; 82 sout | y | denominator( y, -2 ) | y; 83 83 84 84 Rational(int) z = { 0, 5 }; 85 sout | z | endl;85 sout | z; 86 86 87 sout | x | numerator( x, 0 ) | x | endl;87 sout | x | numerator( x, 0 ) | x; 88 88 89 89 x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX }; 90 sout | x | endl;90 sout | x; 91 91 x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX }; 92 sout | x | endl;92 sout | x; 93 93 94 94 sin | a | b; 95 sout | a | b | endl;95 sout | a | b; 96 96 } // main 97 97 98 98 // Local Variables: // 99 99 // tab-width: 4 // 100 // compile-command: "cfa rational.c " //100 // compile-command: "cfa rational.cfa" // 101 101 // End: // -
tests/searchsort.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // searchsort.c --7 // searchsort.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Thu Feb 4 18:17:50 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 9 07:54:57201813 // Update Count : 10 112 // Last Modified On : Wed Dec 5 08:18:42 2018 13 // Update Count : 106 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include <stdlib.hfa> // bsearch, qsort17 #include <stdlib.hfa> // bsearch, qsort 18 18 #include <stdlib.h> // C version of bsearch 19 19 … … 24 24 int iarr[size]; 25 25 26 sout | nlOff; // turn off auto newline 27 26 28 for ( i; 0u ~ size ) { 27 29 iarr[i] = size - i; 28 30 sout | iarr[i] | ", "; 29 31 } // for 30 sout | endl | endl;32 sout | nl; 31 33 32 34 // ascending sort/search by changing < to > … … 35 37 sout | iarr[i] | ", "; 36 38 } // for 37 sout | endl;39 sout | nl; 38 40 for ( i; 0u ~ size ) { // C version 39 41 int key = size - i; … … 41 43 sout | key | ':' | *v | ", "; 42 44 } // for 43 sout | endl;45 sout | nl; 44 46 45 47 for ( i; 0u ~ size ) { … … 47 49 sout | size - i | ':' | *v | ", "; 48 50 } // for 49 sout | endl;51 sout | nl; 50 52 for ( i; 0u ~ size ) { 51 53 unsigned int posn = bsearch( size - i, iarr, size ); 52 54 sout | size - i | ':' | iarr[posn] | ", "; 53 55 } // for 54 sout | endl | endl;56 sout | nl; 55 57 56 58 // descending sort/search by changing < to > … … 59 61 sout | iarr[i] | ", "; 60 62 } // for 61 sout | endl;63 sout | nl; 62 64 { 63 65 int ?<?( int x, int y ) { return x > y; } … … 66 68 sout | iarr[i] | ", "; 67 69 } // for 68 sout | endl;70 sout | nl; 69 71 for ( i; 0u ~ size ) { 70 72 int * v = bsearch( size - i, iarr, size ); 71 73 sout | size - i | ':' | *v | ", "; 72 74 } // for 73 sout | endl;75 sout | nl; 74 76 for ( i; 0u ~ size ) { 75 77 unsigned int posn = bsearch( size - i, iarr, size ); … … 77 79 } // for 78 80 } 79 sout | endl | endl;81 sout | nl; 80 82 81 83 double darr[size]; … … 84 86 sout | darr[i] | ", "; 85 87 } // for 86 sout | endl;88 sout | nl; 87 89 qsort( darr, size ); 88 90 for ( i; 0u ~ size ) { 89 91 sout | darr[i] | ", "; 90 92 } // for 91 sout | endl;93 sout | nl; 92 94 for ( i; 0u ~ size ) { 93 95 double * v = bsearch( size - i + 0.5, darr, size ); 94 96 sout | size - i + 0.5 | ':' | *v | ", "; 95 97 } // for 96 sout | endl;98 sout | nl; 97 99 for ( i; 0u ~ size ) { 98 100 unsigned int posn = bsearch( size - i + 0.5, darr, size ); 99 101 sout | size - i + 0.5 | ':' | darr[posn] | ", "; 100 102 } // for 101 sout | endl | endl;103 sout | nl; 102 104 103 105 struct S { int i, j; } sarr[size]; … … 109 111 sout | sarr[i] | ", "; 110 112 } // for 111 sout | endl;113 sout | nl; 112 114 qsort( sarr, size ); 113 115 for ( i; 0u ~ size ) { 114 116 sout | sarr[i] | ", "; 115 117 } // for 116 sout | endl;118 sout | nl; 117 119 for ( i; 0u ~ size ) { 118 120 S temp = { size - i, size - i + 1 }; … … 120 122 sout | temp | ':' | *v | ", "; 121 123 } // for 122 sout | endl;124 sout | nl; 123 125 for ( i; 0u ~ size ) { 124 126 S temp = { size - i, size - i + 1 }; … … 126 128 sout | temp | ':' | sarr[posn] | ", "; 127 129 } // for 128 sout | endl | endl;130 sout | nl; 129 131 { 130 132 unsigned int getKey( const S & s ) { return s.j; } … … 132 134 sout | sarr[i] | ", "; 133 135 } // for 134 sout | endl;136 sout | nl; 135 137 for ( i; 0u ~ size ) { 136 138 S * v = bsearch( size - i + 1, sarr, size ); 137 139 sout | size - i + 1 | ':' | *v | ", "; 138 140 } // for 139 sout | endl;141 sout | nl; 140 142 for ( i; 0u ~ size ) { 141 143 unsigned int posn = bsearch( size - i + 1, sarr, size ); 142 144 sout | size - i + 1 | ':' | sarr[posn] | ", "; 143 145 } // for 144 sout | endl | endl;146 sout | nl; 145 147 } 146 148 } // main … … 148 150 // Local Variables: // 149 151 // tab-width: 4 // 150 // compile-command: "cfa searchsort.c " //152 // compile-command: "cfa searchsort.cfa" // 151 153 // End: // -
tests/stdincludes.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // stdincludes.c --7 // stdincludes.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue Aug 29 08:26:14 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 30 07:56:39 201713 // Update Count : 512 // Last Modified On : Tue Nov 6 18:00:53 2018 13 // Update Count : 6 14 14 // 15 15 … … 51 51 // Local Variables: // 52 52 // tab-width: 4 // 53 // compile-command: "cfa stdincludes.c " //53 // compile-command: "cfa stdincludes.cfa" // 54 54 // End: // -
tests/sum.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // sum.c -- test resolvers ability to deal with many variables with the same name and to use the minimum number of casts8 // necessary to disambiguate overloaded variable names.7 // sum.cfa -- test resolvers ability to deal with many variables with the same name and to use the minimum number of 8 // casts necessary to disambiguate overloaded variable names. 9 9 // 10 10 // Author : Peter A. Buhr 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : T hu Aug 2 08:03:09201814 // Update Count : 2 7913 // Last Modified On : Tue Dec 11 21:50:41 2018 14 // Update Count : 285 15 15 // 16 16 … … 56 56 } // for 57 57 sout | "sum from" | low | "to" | High | "is" 58 | sum( size, (unsigned char *)a ) | ", check" | (int)s | endl;58 | sum( size, (unsigned char *)a ) | ", check" | (int)s; 59 59 60 60 int s = 0, a[size], v = low; … … 64 64 } // for 65 65 sout | "sum from" | low | "to" | High | "is" 66 | sum( size, (int *)a ) | ", check" | (int)s | endl;66 | sum( size, (int *)a ) | ", check" | (int)s; 67 67 68 68 float s = 0.0f, a[size], v = low / 10.0f; … … 72 72 } // for 73 73 sout | "sum from" | low / 10.0f | "to" | High / 10.0f | "is" 74 | sum( size, (float *)a ) | ", check" | (float)s | endl;74 | sum( size, (float *)a ) | ", check" | (float)s; 75 75 76 76 double s = 0.0, a[size], v = low / 10.0; … … 80 80 } // for 81 81 sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is" 82 | sum( size, (double *)a ) | ", check" | (double)s | endl;82 | sum( size, (double *)a ) | ", check" | (double)s; 83 83 84 84 struct S { int i, j; }; … … 93 93 S ?++( S & t ) { S temp = t; t += (S){1}; return temp; } 94 94 ofstream & ?|?( ofstream & os, S v ) { return os | v.i | v.j; } 95 void ?|?( ofstream & os, S v ) { (ofstream)(os | v); if ( getANL( os ) ) nl( os ); } 95 96 96 97 S s = (S){0}, a[size], v = { low, low }; … … 100 101 } // for 101 102 sout | "sum from" | low | "to" | High | "is" 102 | sum( size, (S *)a ) | ", check" | (S)s | endl;103 | sum( size, (S *)a ) | ", check" | (S)s; 103 104 104 105 forall( otype Impl | sumable( Impl ) ) … … 114 115 } // for 115 116 sout | "sum from" | low | "to" | High | "is" 116 | sum( size, gs.x ) | ", check" | (int)s | endl;// add field array in generic type117 | sum( size, gs.x ) | ", check" | (int)s; // add field array in generic type 117 118 delete( gs.x ); 118 119 } // main … … 120 121 // Local Variables: // 121 122 // tab-width: 4 // 122 // compile-command: "cfa sum.c " //123 // compile-command: "cfa sum.cfa" // 123 124 // End: // -
tests/swap.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // swap.c --7 // swap.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 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 Dec 7 09:13:13 201713 // Update Count : 7 112 // Last Modified On : Tue Dec 11 10:17:40 2018 13 // Update Count : 74 14 14 // 15 15 … … 19 19 int main( void ) { 20 20 char c1 = 'a', c2 = 'b'; 21 sout | "char\t\t\t" | c1 | ' ' | c2 | "\t\t\tswap " ;21 sout | "char\t\t\t" | c1 | ' ' | c2 | "\t\t\tswap " | nonl; 22 22 swap( c1, c2 ); 23 sout | '\t' | c1 | ' ' | c2 | endl;23 sout | '\t' | c1 | ' ' | c2; 24 24 25 25 signed int i1 = -1, i2 = -2; 26 sout | "signed int\t\t" | i1 | i2 | "\t\t\tswap " ;26 sout | "signed int\t\t" | i1 | i2 | "\t\t\tswap " | nonl; 27 27 swap( i1, i2 ); 28 sout | '\t' | i1 | i2 | endl;28 sout | '\t' | i1 | i2; 29 29 30 30 unsigned int ui1 = 1, ui2 = 2; 31 sout | "unsigned int\t\t" | ui1 | ui2 | "\t\t\tswap " ;31 sout | "unsigned int\t\t" | ui1 | ui2 | "\t\t\tswap " | nonl; 32 32 swap( ui1, ui2 ); 33 sout | '\t' | ui1 | ui2 | endl;33 sout | '\t' | ui1 | ui2; 34 34 35 35 signed long int li1 = -1, li2 = -2; 36 sout | "signed long int\t\t" | li1 | li2 | "\t\t\tswap " ;36 sout | "signed long int\t\t" | li1 | li2 | "\t\t\tswap " | nonl; 37 37 swap( li1, li2 ); 38 sout | '\t' | li1 | li2 | endl;38 sout | '\t' | li1 | li2; 39 39 40 40 unsigned long int uli1 = 1, uli2 = 2; 41 sout | "unsigned long int\t" | uli1 | uli2 | "\t\t\tswap " ;41 sout | "unsigned long int\t" | uli1 | uli2 | "\t\t\tswap " | nonl; 42 42 swap( uli1, uli2 ); 43 sout | '\t' | uli1 | uli2 | endl;43 sout | '\t' | uli1 | uli2; 44 44 45 45 signed long long int lli1 = -1, lli2 = -2; 46 sout | "signed long long int\t" | lli1 | lli2 | "\t\t\tswap " ;46 sout | "signed long long int\t" | lli1 | lli2 | "\t\t\tswap " | nonl; 47 47 swap( lli1, lli2 ); 48 sout | '\t' | lli1 | lli2 | endl;48 sout | '\t' | lli1 | lli2; 49 49 50 50 unsigned long long int ulli1 = 1, ulli2 = 2; 51 sout | "unsigned long long int\t" | ulli1 | ulli2 | "\t\t\tswap " ;51 sout | "unsigned long long int\t" | ulli1 | ulli2 | "\t\t\tswap " | nonl; 52 52 swap( ulli1, ulli2 ); 53 sout | '\t' | ulli1 | ulli2 | endl;53 sout | '\t' | ulli1 | ulli2; 54 54 55 55 float f1 = 1.5, f2 = 2.5; 56 sout | "float\t\t\t" | f1 | f2 | "\t\t\tswap " ;56 sout | "float\t\t\t" | f1 | f2 | "\t\t\tswap " | nonl; 57 57 swap( f1, f2 ); 58 sout | '\t' | f1 | f2 | endl;58 sout | '\t' | f1 | f2; 59 59 60 60 double d1 = 1.5, d2 = 2.5; 61 sout | "double\t\t\t" | d1 | d2 | "\t\t\tswap " ;61 sout | "double\t\t\t" | d1 | d2 | "\t\t\tswap " | nonl; 62 62 swap( d1, d2 ); 63 sout | '\t' | d1 | d2 | endl;63 sout | '\t' | d1 | d2; 64 64 65 65 long double ld1 = 1.5, ld2 = 2.5; 66 sout | "long double\t\t" | ld1 | ld2 | "\t\t\tswap " ;66 sout | "long double\t\t" | ld1 | ld2 | "\t\t\tswap " | nonl; 67 67 swap( ld1, ld2 ); 68 sout | '\t' | ld1 | ld2 | endl;68 sout | '\t' | ld1 | ld2; 69 69 70 70 float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if; 71 sout | "float _Complex\t\t" | fc1 | fc2 | "\tswap " ;71 sout | "float _Complex\t\t" | fc1 | fc2 | "\tswap " | nonl; 72 72 swap( fc1, fc2 ); 73 sout | '\t' | fc1 | fc2 | endl;73 sout | '\t' | fc1 | fc2; 74 74 75 75 double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id; 76 sout | "double _Complex\t\t" | dc1 | dc2 | "\tswap " ;76 sout | "double _Complex\t\t" | dc1 | dc2 | "\tswap " | nonl; 77 77 swap( dc1, dc2 ); 78 sout | '\t' | dc1 | dc2 | endl;78 sout | '\t' | dc1 | dc2; 79 79 80 80 long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il; 81 sout | "long double _Complex\t" | ldc1 | ldc2 | "\tswap " ;81 sout | "long double _Complex\t" | ldc1 | ldc2 | "\tswap " | nonl; 82 82 swap( ldc1, ldc2 ); 83 sout | '\t' | ldc1 | ldc2 | endl;83 sout | '\t' | ldc1 | ldc2; 84 84 85 85 struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 }; 86 86 ofstream & ?|?( ofstream & os, S s ) { return os | s.i | s.j; } 87 sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap " ;87 sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap " | nonl; 88 88 swap( s1, s2 ); 89 sout | '\t' | s1 | "," | s2 | endl;89 sout | '\t' | s1 | "," | s2; 90 90 } // main 91 91 92 92 // Local Variables: // 93 93 // tab-width: 4 // 94 // compile-command: "cfa swap.c " //94 // compile-command: "cfa swap.cfa" // 95 95 // End: // -
tests/switch.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // switch.c --7 // switch.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Tue Jul 12 06:50:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 8 07:33:05201813 // Update Count : 3 612 // Last Modified On : Tue Nov 6 18:01:34 2018 13 // Update Count : 37 14 14 // 15 15 … … 104 104 // Local Variables: // 105 105 // tab-width: 4 // 106 // compile-command: "cfa switch.c " //106 // compile-command: "cfa switch.cfa" // 107 107 // End: // -
tests/tuple/tupleAssign.c
rcdc02f2 r515a037 10 10 // Created On : Tue Nov 15 17:24:32 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 21:23:58 201713 // Update Count : 3 412 // Last Modified On : Tue Dec 4 22:03:48 2018 13 // Update Count : 35 14 14 // 15 15 … … 24 24 // swap x, y and store the new [x, y] in [u, v] and in z; 25 25 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 26 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;26 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]"; 27 27 z = [u, v] = [x, y] = [y, x]; 28 28 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 29 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;29 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]"; 30 30 31 31 // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v 32 32 [v, z, u] = [z, u, v]; 33 33 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 34 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;34 sout | "u=" | u | "v=" | v | "z=[" | z | "]"; 35 35 36 36 // multiple assignment with tuple expression on right … … 38 38 [u, v] = [123, 456]; 39 39 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 40 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;40 sout | "u=" | u | "v=" | v | "z=[" | z | "]"; 41 41 } 42 42 { … … 55 55 [t, x, d, i, c, x] = (double)94.12; 56 56 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, (int)c, t ); 57 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;57 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]"; 58 58 [x, c, i, d, x, t] = (double)-94.12; 59 59 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, c, t ); 60 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;60 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]"; 61 61 } 62 62 } -
tests/userLiterals.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // user_literals.c --7 // user_literals.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Sep 6 21:40:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 29 16:51:42201813 // Update Count : 5 412 // Last Modified On : Tue Dec 4 22:03:10 2018 13 // Update Count : 56 14 14 // 15 15 … … 18 18 #include <uchar.h> 19 19 20 int ?`s( int s ) { sout | "secs" | s | endl; return s; }21 int ?`m( int m ) { sout | "mins" | m | endl; return m * 60; }22 int ?`h( int h ) { sout | "hours" | h | endl; return h * 3600; }23 int ?`_A_( int x ) { sout | "_A_" | x | endl; return x; }24 int ?`__thingy_( int x ) { sout | "_thingy_" | x | endl; return x; }20 int ?`s( int s ) { sout | "secs" | s; return s; } 21 int ?`m( int m ) { sout | "mins" | m; return m * 60; } 22 int ?`h( int h ) { sout | "hours" | h; return h * 3600; } 23 int ?`_A_( int x ) { sout | "_A_" | x; return x; } 24 int ?`__thingy_( int x ) { sout | "_thingy_" | x; return x; } 25 25 26 int ?`s( const char * s ) { sout | "secs" | s | endl; return 0; }27 int ?`m( const char16_t * m ) { sout | "mins" | m | endl; return 0;}28 int ?`h( const char32_t * h ) { sout | "hours" | h | endl; return 0; }29 int ?`_A_( const wchar_t * str ) { sout | "_A_" | str | endl; return 0; }30 int ?`__thingy_( const char * str ) { sout | "_thingy_" | str | endl; return 0; }26 int ?`s( const char * s ) { sout | "secs" | s; return 0; } 27 int ?`m( const char16_t * m ) { sout | "mins" | m; return 0;} 28 int ?`h( const char32_t * h ) { sout | "hours" | h; return 0; } 29 int ?`_A_( const wchar_t * str ) { sout | "_A_" | str; return 0; } 30 int ?`__thingy_( const char * str ) { sout | "_thingy_" | str; return 0; } 31 31 32 32 … … 46 46 Weight w, heavy = { 20 }; // 20 stone 47 47 w = 155`lb; 48 sout | w | endl;48 sout | w; 49 49 w = 0b_1111`st; 50 sout | w | endl;50 sout | w; 51 51 w = 0_233`lb; // octal weight (155) 52 sout | w | endl;52 sout | w; 53 53 w = 0x_9b_u`kg; 54 sout | w | endl;54 sout | w; 55 55 w = 70.3`kg; 56 sout | w | endl;56 sout | w; 57 57 w = 11`st + 1`lb; 58 sout | w | endl;58 sout | w; 59 59 w = 5`st + 8`kg + 25`lb + heavy; 60 sout | w | endl;60 sout | w; 61 61 62 62 // 0`secs; … … 90 90 // Local Variables: // 91 91 // tab-width: 4 // 92 // compile-command: "cfa user_literals.c " //92 // compile-command: "cfa user_literals.cfa" // 93 93 // End: // -
tests/variableDeclarator.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // variableDeclarator.c --7 // variableDeclarator.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Aug 17 08:41:42 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 17 08:42:21 201613 // Update Count : 112 // Last Modified On : Tue Nov 6 18:02:16 2018 13 // Update Count : 2 14 14 // 15 15 … … 182 182 // Local Variables: // 183 183 // tab-width: 4 // 184 // compile-command: "cfa variableDeclarator.c " //184 // compile-command: "cfa variableDeclarator.cfa" // 185 185 // End: // -
tests/vector.cfa
rcdc02f2 r515a037 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // vector.c --7 // vector.cfa -- 8 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Mon Jul 4 23:36:19 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jan 18 17:08:08201813 // Update Count : 2 712 // Last Modified On : Tue Dec 4 22:02:39 2018 13 // Update Count : 29 14 14 // 15 15 … … 21 21 do { \ 22 22 if ( !(x) ) { \ 23 sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__ | endl; \23 sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__; \ 24 24 abort(); \ 25 25 } \ … … 31 31 assert( empty( &iv ) ); 32 32 assert( size( &iv ) == 0 ); 33 sout | size( &iv ) | endl;33 sout | size( &iv ); 34 34 35 35 push_back( &iv, 1 ); 36 36 assert( size( &iv ) == 1 ); 37 sout | size( &iv ) | endl;37 sout | size( &iv ); 38 38 39 39 push_back( &iv, 2 ); 40 40 assert( size( &iv ) == 2 ); 41 sout | size( &iv ) | endl;41 sout | size( &iv ); 42 42 43 43 push_back( &iv, 3 ); 44 44 assert( size( &iv ) == 3 ); 45 sout | size( &iv ) | endl;45 sout | size( &iv ); 46 46 47 47 assert( !empty( &iv ) ); … … 58 58 assert( empty( &iv ) ); 59 59 assert( size( &iv ) == 0 ); 60 sout | size( &iv ) | endl;60 sout | size( &iv ); 61 61 } 62 62 63 63 // Local Variables: // 64 64 // tab-width: 4 // 65 // compile-command: "cfa vector.c " //65 // compile-command: "cfa vector.cfa" // 66 66 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.