Changes in / [515a037:cdc02f2]


Ignore:
Files:
88 added
87 deleted
86 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    r515a037 rcdc02f2  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Nov  6 09:01:23 2018
    14 ## Update Count     : 26
     13## Last Modified On : Mon Jan 25 22:31:42 2016
     14## Update Count     : 25
    1515###############################################################################
    1616
     
    308308
    309309compile-attributes$(EXEEXT):
    310         $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     310        $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.c
    311311
    312312compile-empty$(EXEEXT):
  • benchmark/Makefile.in

    r515a037 rcdc02f2  
    879879
    880880compile-attributes$(EXEEXT):
    881         $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     881        $(AM_V_CFA)$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.c
    882882
    883883compile-empty$(EXEEXT):
  • benchmark/Monitor.c

    r515a037 rcdc02f2  
    2929        EndTime = Time();
    3030
    31         sout | ( EndTime - StartTime ) / N;
     31        sout | ( EndTime - StartTime ) / N | endl;
    3232}
  • doc/bibliography/pl.bib

    r515a037 rcdc02f2  
    2121%  toplas: ACM Trans. on Prog. Lang. & Sys.
    2222%  tcs: Theoretical Computer Science
    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."}
     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."}
    3635@string{popl="Conference Record of the ACM Symposium on Principles of Programming Languages"}
    3736@string{osr="Operating Systems Review"}
    3837@string{pldi="Programming Language Design and Implementation"}
    3938@string{toplas="Transactions on Programming Languages and Systems"}
    40 string{mathann="Mathematische Annalen"}
    41 @string{mathann="Math. Ann."}
     39@string{mathann="Mathematische Annalen"}
     40% @string{mathann="Math. Ann."}
    4241
    4342% A
     
    567566}
    568567
    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 
    580568@article{Kessels82,
    581569    keywords    = {concurrency, critical section},
     
    665653    author      = {Joung, Yuh-Jzer},
    666654    title       = {Asynchronous group mutual exclusion},
    667     journal     = {Dist. Comput.},
    668     optjournal  = {Distributed Computing},
     655    journal     = {Distributed Computing},
    669656    year        = {2000},
    670657    month       = {Nov},
     
    809796        time computable inheritance hierarchy.
    810797    },
    811     comment     = {
     798    comment = {
    812799        Classes are predicates; if object {\tt o} is in class {\tt C}, then
    813800        {\tt C} is true of {\tt o}.  Classes are combined with {\tt :AND},
     
    963950
    964951@article{Moss18,
    965     keywords    = {type systems, polymorphism, tuples, Cforall},
     952    keywords    = {type systems, tuples, Cforall},
    966953    contributer = {pabuhr@plg},
    967954    author      = {Aaron Moss and Robert Schluntz and Peter A. Buhr},
    968955    title       = {\textsf{C}$\mathbf{\forall}$ : Adding Modern Programming Language Features to C},
     956    year        = 2018,
     957    month       = aug,
    969958    journal     = spe,
    970     volume      = 48,
    971     number      = 12,
    972     month       = dec,
    973     year        = 2018,
    974     pages       = {2111-2146},
    975959    note        = {\href{http://dx.doi.org/10.1002/spe.2624}{http://\-dx.doi.org/\-10.1002/\-spe.2624}},
    976960}
     
    1005989    journal     = {Dr. Dobb's Journal of Software Tools},
    1006990    year        = 1989,
    1007     month       = feb,
    1008     volume      = 14,
    1009     number      = 2,
    1010     pages       = {45-51},
     991    month       = feb, volume = 14, number = 2, pages = {45-51},
    1011992    comment     = {
    1012993       A light-weight multitasking kernel for MS-DOS.  A task\_control
     
    15261507}
    15271508
    1528 @manual{uC++,
     1509@techreport{uC++,
    15291510    keywords    = {C++, concurrency, light-weight process, shared memory},
    15301511    contributer = {pabuhr@plg},
    1531     key         = {uC++},
    15321512    author      = {Peter A. Buhr},
    15331513    title       = {$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Annotated Reference Manual, Version 7.0.0},
    1534     organization= {University of Waterloo},
    1535     month       = sep,
    1536     year        = 2018,
     1514    institution = {School of Computer Science, University of Waterloo},
     1515    address     = {Waterloo, Ontario, Canada, N2L 3G1},
     1516    month       = dec,
     1517    year        = 2017,
    15371518    note        = {\href{https://plg.uwaterloo.ca/~usystem/pub/uSystem/uC++.pdf}{https://\-plg.uwaterloo.ca/\-$\sim$usystem/\-pub/\-uSystem/uC++.pdf}},
    15381519}
     
    16051586    author      = {Sun, Xianda},
    16061587    title       = {Concurrent High-performance Persistent Hash Table In {J}ava},
    1607     school      = {School of Computer Sc., University of Waterloo},
     1588    school      = {School of Computer Science, University of Waterloo},
    16081589    year        = 2015,
    16091590    optaddress  = {Waterloo, Ontario, Canada, N2L 3G1},
     
    19551936    note        = {Svensk Standard SS 63 61 14},
    19561937    year        = 1987,
    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},
     1938    abstract    = {
     1939        Standard for the programming language SIMULA.  Written in English.
     1940    }
    19711941}
    19721942
     
    21082078    year        = {1998},
    21092079    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}
    21202080}
    21212081
     
    29202880}
    29212881
    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 
    29362882% F
    29372883
     
    32773223    keywords    = {Go programming language},
    32783224    contributer = {pabuhr@plg},
     3225    title       = {{Go} Programming Language},
    32793226    author      = {Robert Griesemer and Rob Pike and Ken Thompson},
    3280     title       = {{Go} Programming Language},
    32813227    organization= {Google},
    32823228    year        = 2009,
     
    34703416    month       = sep,
    34713417    publisher   = {John Wiley \& Sons},
    3472     note        = {\href{https://doi.org/10.1002/cpe.4475}{https://\-doi.org/\-10.1002/\-cpe.4475}},
     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}},
    34733419}
    34743420
     
    36083554    publisher   = {ACM Press},
    36093555    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}
    36233556}
    36243557
     
    39653898    author      = {Peter A. Buhr and Martin Karsten and Jun Shih},
    39663899    title       = {{\small\textsf{KDB}}: A Multi-threaded Debugger for Multi-threaded Applications},
    3967     booktitle   = {Proc. of SPDT'96: SIGMETRICS Symp. on Parallel and Distributed Tools},
     3900    booktitle   = {Proceedings of SPDT'96: SIGMETRICS Symposium on Parallel and Distributed Tools},
    39683901    publisher   = {ACM Press},
    39693902    address     = {Philadelphia, Pennsylvania, U.S.A.},
     
    54565389}
    54575390
    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 
    54695391@article{poly,
    54705392    keywords    = {Poly, Standard ML, Russell, persistence},
     
    56815603    author      = {Peter A. Buhr and Robert Denda},
    56825604    title       = {{$\mu$Profiler} : Profiling User-Level Threads in a Shared-Memory Programming Environment},
    5683     booktitle   = {Proc. of 2nd Inter. Symp. on Computing in Object-Oriented Parallel Environments},
     5605    booktitle   = {Proceedings of the Second International Symposium on Computing in Object-Oriented Parallel Environments (ISCOPE'98)},
    56845606    series      = {Lecture Notes in Computer Science},
    56855607    publisher   = {Springer-Verlag},
     
    60525974    issn        = {0164-0925},
    60535975    pages       = {429-475},
    6054     url         = {http://doi.acm.org/10.1145/1133651.1133653},
     5976    url         = {http://doi.acm.org.proxy.lib.uwaterloo.ca/10.1145/1133651.1133653},
    60555977    doi         = {10.1145/1133651.1133653},
    60565978    acmid       = {1133653},
     
    63196241    contributer = {pabuhr@plg},
    63206242    key         = {Rust},
    6321     title       = {{R}ust Programming Language},
    6322     optaddress  = {Rust Project Developers},
     6243    title       = {The {R}ust Programming Language},
     6244    address     = {The Rust Project Developers},
    63236245    year        = 2015,
    63246246    note        = {\href{https://doc.rust-lang.org/reference.html}{https://\-doc.rust-lang\-.org/\-reference.html}},
     
    63866308    publisher   = {Springer},
    63876309    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},
    64306310}
    64316311
     
    75967476}
    75977477
    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 
    76197478% X
    76207479
  • doc/papers/concurrency/Paper.tex

    r515a037 rcdc02f2  
    686686        Fib f1, f2;
    687687        for ( int i = 1; i <= 10; i += 1 ) {
    688                 sout | next( f1 ) | next( f2 );
     688                sout | next( f1 ) | next( f2 ) | endl;
    689689        }
    690690}
     
    772772                        sout | "  ";               // separator
    773773                }
    774                 sout | nl;
     774                sout | endl;
    775775        }
    776776}
    777777void ?{}( Format & fmt ) { `resume( fmt );` }
    778778void ^?{}( Format & fmt ) with( fmt ) {
    779         if ( g != 0 || b != 0 ) sout | nl;
     779        if ( g != 0 || b != 0 ) sout | endl;
    780780}
    781781void format( Format & fmt ) {
     
    855855        for ( int i = 0; i < N; i += 1 ) {
    856856                int p1 = random( 100 ), p2 = random( 100 );
    857                 sout | p1 | " " | p2;
     857                sout | p1 | " " | p2 | endl;
    858858                int status = delivery( c, p1, p2 );
    859                 sout | " $" | money | nl | status;
     859                sout | " $" | money | endl | status | endl;
    860860                receipt += 1;
    861861        }
    862862        stop( c );
    863         sout | "prod stops";
     863        sout | "prod stops" | endl;
    864864}
    865865int payment( Prod & prod, int money ) {
     
    895895        int money = 1, receipt;
    896896        for ( ; ! done; ) {
    897                 sout | p1 | " " | p2 | nl | " $" | money;
     897                sout | p1 | " " | p2 | endl | " $" | money | endl;
    898898                status += 1;
    899899                receipt = payment( p, money );
    900                 sout | " #" | receipt;
     900                sout | " #" | receipt | endl;
    901901                money += 1;
    902902        }
    903         sout | "cons stops";
     903        sout | "cons stops" | endl;
    904904}
    905905int delivery( Cons & cons, int p1, int p2 ) {
     
    10991099
    11001100void main(foo & this) {
    1101         sout | "Hello World!";
     1101        sout | "Hello World!" | endl;
    11021102}
    11031103\end{cfa}
     
    11241124
    11251125void hello(/*unused*/ int) {
    1126         sout | "Hello World!";
     1126        sout | "Hello World!" | endl;
    11271127}
    11281128
     
    11411141thread World {};
    11421142void main( World & this ) {
    1143         sout | "World!";
     1143        sout | "World!" | endl;
    11441144}
    11451145int main() {
    11461146        World w`[10]`;                                                  $\C{// implicit forks after creation}$
    1147         sout | "Hello ";                                        $\C{// "Hello " and 10 "World!" printed concurrently}$
     1147        sout | "Hello " | endl;                                 $\C{// "Hello " and 10 "World!" printed concurrently}$
    11481148}                                                                                       $\C{// implicit joins before destruction}$
    11491149\end{cfa}
     
    11931193                total += subtotals[r];                          $\C{// total subtotal}$
    11941194    }
    1195     sout | total;
     1195    sout | total | endl;
    11961196}
    11971197\end{cfa}
     
    21922192        BENCH(
    21932193                for ( size_t i = 0; i < N; i += 1 ) { @resume( c );@ } )
    2194         sout | result`ns;
     2194        sout | result`ns | endl;
    21952195}
    21962196\end{cfa}
     
    22052205        BENCH(
    22062206                for ( size_t i = 0; i < N; i += 1 ) { @yield();@ } )
    2207         sout | result`ns;
     2207        sout | result`ns | endl;
    22082208}
    22092209\end{cfa}
     
    22442244int main() {
    22452245        BENCH( for( size_t i = 0; i < N; i += 1 ) { @do_call( m1/*, m2, m3, m4*/ );@ } )
    2246         sout | result`ns;
     2246        sout | result`ns | endl;
    22472247}
    22482248\end{cfa}
     
    23052305        BENCH( for ( size_t i = 0; i < N; i += 1 ) { @wait( c );@ } );
    23062306        go = 0; // stop other thread
    2307         sout | result`ns;
     2307        sout | result`ns | endl;
    23082308}
    23092309int main() {
     
    23562356        BENCH( for ( size_t i = 0; i < N; i += 1 ) { @waitfor( do_call, m );@ } )
    23572357        go = 0; // stop other thread
    2358         sout | result`ns;
     2358        sout | result`ns | endl;
    23592359}
    23602360int main() {
     
    23912391int main() {
    23922392        BENCH( for ( size_t i = 0; i < N; i += 1 ) { @MyThread m;@ } )
    2393         sout | result`ns;
     2393        sout | result`ns | endl;
    23942394}
    23952395\end{cfa}
  • doc/proposals/flags.md

    r515a037 rcdc02f2  
    6060        ```
    6161        FunFlags f = some_val();
    62         if ( f ) { sout | "f has some flag(s) set"; }
    63         if ( f & FOO ) { sout | "f has FOO set"; }
     62        if ( f ) { sout | "f has some flag(s) set" | endl; }
     63        if ( f & FOO ) { sout | "f has FOO set" | endl; }
    6464        f |= FOO; // set FOO
    6565        f -= FOO; // unset FOO
     
    8888        ```
    8989        FunFlags f = some_val();
    90         if ( f.FOO ) { sout | "f has FOO set"; }
     90        if ( f.FOO ) { sout | "f has FOO set" | endl; }
    9191        f.FOO = true;    // set FOO
    9292        f.FOO = false;   // unset FOO
  • doc/theses/aaron_moss_PhD/phd/thesis.tex

    r515a037 rcdc02f2  
    2323% \usepackage[pdftex]{graphicx} % For including graphics N.B. pdftex graphics driver
    2424\usepackage{graphicx}
    25 
    26 \usepackage{amsthm} % for theorem environment
    27 \newtheorem{theorem}{Theorem}
    2825
    2926\usepackage{footmisc} % for double refs to the same footnote
  • doc/theses/aaron_moss_PhD/phd/type-environment.tex

    r515a037 rcdc02f2  
    55As 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.
    66Furthermore, 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\cite{Galler64} data structure introduced in this thesis.
     7In 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.
    88
    9 \section{Definitions} \label{env-defn-sec}
     9\section{Definitions}
    1010
    1111For purposes of this chapter, a \emph{type environment} $T$ is a set of \emph{type classes} $\myset{T_1, T_2, \cdots, T_{|T|}}$.
     
    2424        $add(T_i, v_{i,j})$ &                                                           & Add variable to class                 \\
    2525        $bind(T_i, b_i)$ &                                                                      & Set or update class bound             \\
     26        $remove(T, T_i)$ &                                                                      & Remove class from environment \\
    2627        $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$            \\
    2828        $combine(T, T')$ & $\rightarrow \top | \bot$            & Merge two environments                \\
    2929        $save(T)$ & $\rightarrow H$                                                     & Get handle for current state  \\
     
    4040The $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$.
    4141$bind(T_i, b_i)$ mutates the bound for a type class, setting or updating the current bound.
     42The final basic mutation operation is $remove(T, T_i)$, which removes a class $T_i$ and all its type variables from an environment $T$.
    4243
    4344The $unify$ operation is the fundamental non-trivial operation a type environment data structure must support.
    4445$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.
    4546It 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.
    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!.
     47$unify$ depends on an internal $unify_bound$ operation which may fail.
     48In \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.
     49If 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.
     50For 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!.
    5051As 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'$.
    5452
    5553Given the nature of the expression resolution problem as backtracking search, caching and concurrency are both useful tools to decrease runtime.
     
    5957The 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.
    6058$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'$.
    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.
     59Like 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.
    6260
    6361Finally, the backtracking access patterns of the compiler can be exploited to reduce memory usage or runtime through use of an appropriately designed data structure.
    6462The 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$.
    6563As 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.
    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}
     64These 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.
    20865
    20966% 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

    r515a037 rcdc02f2  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue Dec 11 23:19:26 2018
    14 %% Update Count     : 3400
     13%% Last Modified On : Fri Aug 31 07:54:50 2018
     14%% Update Count     : 3396
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    178178int main( void ) {
    179179        int x = 0, y = 1, z = 2;
    180         ®sout | x | y | z;®§\indexc{sout}§
     180        ®sout | x | y | z | endl;®§\indexc{sout}§
    181181}
    182182\end{cfa}
     
    513513Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the base cannot be negative.
    514514\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);
     515sout | 2 ®\® 8u | 4 ®\® 3u | -4 ®\® 3u | 4 ®\® -3 | -4 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi) | endl;
    516516256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    517517\end{cfa}
     
    547547
    548548
    549 \subsection{Loop Control}
     549%\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}}
     550\subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}}
    550551
    551552The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges.
     
    556557the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M].
    557558©0© is the implicit start value;
    558 ©1© is the implicit increment value.
    559 The up-to range uses ©+=© for increment;
    560 the down-to range uses ©-=© for decrement.
     559©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range.
    561560The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©.
    562561\begin{cquote}
    563562\begin{tabular}{@{}ll|l@{}}
    564 \multicolumn{2}{c|}{loop control} & \multicolumn{1}{c}{output} \\
     563\multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\
    565564\hline
    566565\begin{cfa}
     
    572571for ( ®10® ) { sout | "A"; }
    573572for ( ®1 ~= 10 ~ 2® ) { sout | "B"; }
    574 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; }
     573for ( ®10 -~= 1 ~ -2® ) { sout | "C"; }
    575574for ( ®0.5 ~ 5.5® ) { sout | "D"; }
    576575for ( ®5.5 -~ 0.5® ) { sout | "E"; }
    577576for ( ®i; 10® ) { sout | i; }
    578577for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; }
    579 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; }
     578for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; }
    580579for ( ®i; 0.5 ~ 5.5® ) { sout | i; }
    581580for ( ®i; 5.5 -~ 0.5® ) { sout | i; }
    582581for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; }
    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;
     582for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; }
     583int start = 3, comp = 10, inc = 2;
    589584for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; }
    590585\end{cfa}
    591586&
    592587\begin{cfa}
    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;
     588sout | endl;
     589sout | endl;
     590sout | endl;
     591sout | endl;
     592sout | endl;
     593sout | endl;
     594sout | endl;
     595sout | endl;
     596sout | endl;
     597sout | endl;
     598sout | endl;
     599sout | endl;
     600sout | endl;
     601sout | endl;
     602sout | endl;
     603sout | endl;
     604sout | endl;
     605
     606sout | endl;
    616607\end{cfa}
    617608&
     
    620611empty
    621612empty
    622 zero
     613
    623614A
    624615A A A A A A A A A A
     
    6346252 4 6 8 10
    63562610 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
    640627
    6416283 6 9
     
    24592446        int bar( int p ) {
    24602447                ®i® += 1;                               §\C{// dependent on local variable}§
    2461                 sout | ®i®;
     2448                sout | ®i® | endl;
    24622449        }
    24632450        return bar;                                     §\C{// undefined because of local dependence}§
     
    24652452int main() {
    24662453        * [int]( int ) fp = foo();      §\C{// int (* fp)( int )}§
    2467         sout | fp( 3 );
     2454        sout | fp( 3 ) | endl;
    24682455}
    24692456\end{cfa}
     
    32313218\begin{cfa}
    32323219int x = 1, y = 2, z = 3;
    3233 sout | x ®|® y ®|® z;
     3220sout | x ®|® y ®|® z | endl;
    32343221\end{cfa}
    32353222&
     
    32523239\begin{cfa}
    32533240[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    3254 sout | t1 | t2;                                         §\C{// print tuples}§
     3241sout | t1 | t2 | endl;                                  §\C{// print tuples}§
    32553242\end{cfa}
    32563243\begin{cfa}[showspaces=true,aboveskip=0pt]
     
    32643251&
    32653252\begin{cfa}
    3266 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2);
     3253sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
    32673254\end{cfa}
    32683255\\
     
    32903277A separator does not appear at the start or end of a line.
    32913278\begin{cfa}[belowskip=0pt]
    3292 sout | 1 | 2 | 3;
     3279sout | 1 | 2 | 3 | endl;
    32933280\end{cfa}
    32943281\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    32993286A separator does not appear before or after a character literal or variable.
    33003287\begin{cfa}
    3301 sout | '1' | '2' | '3';
     3288sout | '1' | '2' | '3' | endl;
    33023289123
    33033290\end{cfa}
     
    33063293A separator does not appear before or after a null (empty) C string.
    33073294\begin{cfa}
    3308 sout | 1 | "" | 2 | "" | 3;
     3295sout | 1 | "" | 2 | "" | 3 | endl;
    33093296123
    33103297\end{cfa}
     
    33163303\begin{cfa}[mathescape=off]
    33173304sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥"
    3318                 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10;
     3305                | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;
    33193306\end{cfa}
    33203307%$
     
    33303317\begin{cfa}[belowskip=0pt]
    33313318sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x"
    3332                 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x";
     3319                | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;
    33333320\end{cfa}
    33343321\begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    33403327A 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@
    33413328\begin{cfa}[belowskip=0pt]
    3342 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx";
     3329sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;
    33433330\end{cfa}
    33443331\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     
    33493336If a space is desired before or after one of the special string start/end characters, simply insert a space.
    33503337\begin{cfa}[belowskip=0pt]
    3351 sout | "x (§\color{red}\texttt{\textvisiblespace}§" | 1 | "§\color{red}\texttt{\textvisiblespace}§) x" | 2 | "§\color{red}\texttt{\textvisiblespace}§, x" | 3 | "§\color{red}\texttt{\textvisiblespace}§:x:§\color{red}\texttt{\textvisiblespace}§" | 4;
     3338sout | "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;
    33523339\end{cfa}
    33533340\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     
    33663353\begin{cfa}[mathescape=off,belowskip=0pt]
    33673354sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    3368 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"";
     3355sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;
    33693356\end{cfa}
    33703357%$
     
    33753362\begin{cfa}[belowskip=0pt]
    33763363sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    3377 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"";
     3364sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    33783365\end{cfa}
    33793366\begin{cfa}[showspaces=true,aboveskip=0pt]
     
    33853372strcpy( store, sepGet( sout ) );                          §\C{// copy current separator}§
    33863373sepSet( sout, "_" );                                            §\C{// change separator to underscore}§
    3387 sout | 1 | 2 | 3;
     3374sout | 1 | 2 | 3 | endl;
    33883375\end{cfa}
    33893376\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    33923379\begin{cfa}[belowskip=0pt]
    33933380sepSet( sout, store );                                          §\C{// change separator back to original}§
    3394 sout | 1 | 2 | 3;
     3381sout | 1 | 2 | 3 | endl;
    33953382\end{cfa}
    33963383\begin{cfa}[showspaces=true,aboveskip=0pt]
     
    34033390\begin{cfa}[belowskip=0pt]
    34043391sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    3405 sout | t1 | t2 | " \"" | ®sepTuple® | "\"";
     3392sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;
    34063393\end{cfa}
    34073394\begin{cfa}[showspaces=true,aboveskip=0pt]
     
    34103397\begin{cfa}[belowskip=0pt]
    34113398sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    3412 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"";
     3399sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
    34133400\end{cfa}
    34143401\begin{cfa}[showspaces=true,aboveskip=0pt]
     
    34203407Manipulators \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.
    34213408\begin{cfa}[belowskip=0pt]
    3422 sout | sepDisable | 1 | 2 | 3                §\C{// globally turn off implicit separator}§
     3409sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separator}§
    34233410\end{cfa}
    34243411\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34263413\end{cfa}
    34273414\begin{cfa}[belowskip=0pt]
    3428 sout | sepEnable | 1 | 2 | 3;           §\C{// globally turn on implicit separator}§
     3415sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separator}§
    34293416\end{cfa}
    34303417\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34353422Manipulators \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.
    34363423\begin{cfa}[belowskip=0pt]
    3437 sout | 1 | sepOff | 2 | 3;                      §\C{// locally turn off implicit separator}§
     3424sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
    34383425\end{cfa}
    34393426\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34413428\end{cfa}
    34423429\begin{cfa}[belowskip=0pt]
    3443 sout | sepDisable | 1 | sepOn | 2 | 3; §\C{// locally turn on implicit separator}§
     3430sout | sepDisable | 1 | sepOn | 2 | 3 | endl; §\C{// locally turn on implicit separator}§
    34443431\end{cfa}
    34453432\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34483435The tuple separator also responses to being turned on and off.
    34493436\begin{cfa}[belowskip=0pt]
    3450 sout | t1 | sepOff | t2;                                §\C{// locally turn on/off implicit separator}§
     3437sout | t1 | sepOff | t2 | endl;                         §\C{// locally turn on/off implicit separator}§
    34513438\end{cfa}
    34523439\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34563443use ©sep© to accomplish this functionality.
    34573444\begin{cfa}[belowskip=0pt]
    3458 sout | sepOn | 1 | 2 | 3 | sepOn;       §\C{// sepOn does nothing at start/end of line}§
     3445sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       §\C{// sepOn does nothing at start/end of line}§
    34593446\end{cfa}
    34603447\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34623449\end{cfa}
    34633450\begin{cfa}[belowskip=0pt]
    3464 sout | sep | 1 | 2 | 3 | sep ;          §\C{// use sep to print separator at start/end of line}§
     3451sout | sep | 1 | 2 | 3 | sep | endl ;           §\C{// use sep to print separator at start/end of line}§
    34653452\end{cfa}
    34663453\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    34753462int main( void ) {
    34763463        int x = 1, y = 2, z = 3;
    3477         sout | x | y | z;
     3464        sout | x | y | z | endl;
    34783465        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    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;
     3466        sout | t1 | t2 | endl;                                          // print tuples
     3467        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;
    34843471        sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x =" | 4 | "x $" | 5 | "x £" | 6 | "x ¥"
    3485                 | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10;
     3472                | 7 | "x ¡" | 8 | "x ¿" | 9 | "x «" | 10 | endl;
    34863473        sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x"
    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;
     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;
    34903477
    34913478        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
    3492         sout | 1 | 2 | 3 | " \"" | sep | "\"";
     3479        sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;
    34933480        sepSet( sout, " " );                                            // reset separator to " "
    3494         sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"";
     3481        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    34953482
    34963483        char store[sepSize];
    34973484        strcpy( store, sepGet( sout ) );
    34983485        sepSet( sout, "_" );
    3499         sout | 1 | 2 | 3;
     3486        sout | 1 | 2 | 3 | endl;
    35003487        sepSet( sout, store );
    3501         sout | 1 | 2 | 3;
     3488        sout | 1 | 2 | 3 | endl;
    35023489
    35033490        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    3504         sout | t1 | t2 | " \"" | sepTuple | "\"";
     3491        sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;
    35053492        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    3506         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
     3493        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     3494
     3495        sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separator
     3496        sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separator
     3497
     3498        sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn on implicit separator
     3499        sout | sepDisable | 1 | sepOn | 2 | 3 | endl; // globally turn off implicit separator
    35133500        sout | sepEnable;
    3514         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
     3501        sout | t1 | sepOff | t2 | endl;                         // locally turn on/off implicit separator
     3502
     3503        sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       // sepOn does nothing at start/end of line
     3504        sout | sep | 1 | 2 | 3 | sep | endl ;           // use sep to print separator at start/end of line
    35183505}
    35193506
     
    41804167        Fibonacci f1, f2;
    41814168        for ( int i = 1; i <= 10; i += 1 ) {
    4182                 sout | next( &f1 ) | ' ' | next( &f2 );
     4169                sout | next( &f1 ) | ' ' | next( &f2 ) | endl;
    41834170        } // for
    41844171}
     
    42464233                MyThread f[4];
    42474234        }
    4248         sout | global.value;
     4235        sout | global.value | endl;
    42494236}
    42504237\end{cfa}
     
    43244311void main( First * this ) {
    43254312        for ( int i = 0; i < 10; i += 1 ) {
    4326                 sout | "First : Suspend No." | i + 1;
     4313                sout | "First : Suspend No." | i + 1 | endl;
    43274314                yield();
    43284315        }
     
    43334320        wait( this->lock );
    43344321        for ( int i = 0; i < 10; i += 1 ) {
    4335                 sout | "Second : Suspend No." | i + 1;
     4322                sout | "Second : Suspend No." | i + 1 | endl;
    43364323                yield();
    43374324        }
     
    43404327int main( void ) {
    43414328        signal_once lock;
    4342         sout | "User main begin";
     4329        sout | "User main begin" | endl;
    43434330        {
    43444331                processor p;
     
    43484335                }
    43494336        }
    4350         sout | "User main end";
     4337        sout | "User main end" | endl;
    43514338}
    43524339\end{cfa}
     
    50455032void ?{}( Line * l ) {
    50465033        l->lnth = 0.0;
    5047         sout | "default";
     5034        sout | "default" | endl;
    50485035}
    50495036
     
    50525039void ?{}( Line * l, float lnth ) {
    50535040        l->lnth = lnth;
    5054         sout | "lnth" | l->lnth;
     5041        sout | "lnth" | l->lnth | endl;
    50555042
    50565043}
     
    50585045// destructor
    50595046void ^?() {
    5060         sout | "destroyed";
     5047        sout | "destroyed" | endl;
    50615048        l.lnth = 0.0;
    50625049}
     
    58045791In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character.
    58055792\begin{cfa}
    5806 sout | 'x' | " " | (int)'x';
     5793sout | 'x' | " " | (int)'x' | endl;
    58075794x 120
    58085795\end{cfa}
     
    70347021#include <gmp>§\indexc{gmp}§
    70357022int main( void ) {
    7036         sout | "Factorial Numbers";
     7023        sout | "Factorial Numbers" | endl;
    70377024        Int fact = 1;
    70387025
    7039         sout | 0 | fact;
     7026        sout | 0 | fact | endl;
    70407027        for ( unsigned int i = 1; i <= 40; i += 1 ) {
    70417028                fact *= i;
    7042                 sout | i | fact;
     7029                sout | i | fact | endl;
    70437030        }
    70447031}
  • examples/ArrayN.c

    r515a037 rcdc02f2  
    77
    88forall(otype index_t)
    9 index_t offset_to_index(unsigned offset, index_t size) {
     9index_t offset_to_index(unsigned offset, index_t size)
     10{
    1011    return [offset / size.0, offset % size.1];
    1112}
    1213
    13 int main(int argc, char* argv[]) {
     14int main(int argc, char* argv[])
     15{
    1416    unsigned x = 0, y = 0, i = 0;
    1517    unsigned sx = 4, sy = 4;
     
    1820    [x, y] = offset_to_index(6, [sx, sy]);
    1921
    20     sout | x | ' ' | y;
     22    sout | x | ' ' | y | endl;
    2123
    2224    return 0;
  • examples/gc_no_raii/src/internal/collector.c

    r515a037 rcdc02f2  
    3838void* gc_allocate(size_t target_size)
    3939{
    40         // sout | "Allocating " | target_size | " bytes";
     40        // sout | "Allocating " | target_size | " bytes" | endl;
    4141
    4242        size_t size = gc_compute_size(target_size + sizeof(gc_object_header));
    4343
    44         // sout | "Object header size: " | sizeof(gc_object_header) | " bytes";
    45         // sout | "Actual allocation size: " | size | " bytes";
     44        // sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;
     45        // sout | "Actual allocation size: " | size | " bytes" | endl;
    4646
    4747        check(size < POOL_SIZE_BYTES);
  • examples/gc_no_raii/src/internal/state.h

    r515a037 rcdc02f2  
    3838static inline bool gc_needs_collect(gc_state* state)
    3939{
    40         // sout | "Used Space: " | state->used_space | " bytes";
     40        // sout | "Used Space: " | state->used_space | " bytes" | endl;
    4141        return state->used_space * 2 > state->total_space;
    4242}
  • examples/gc_no_raii/src/tools/print.h

    r515a037 rcdc02f2  
    55// #include <fstream.hfa>
    66//
    7 // #define DEBUG_OUT(x) sout | x;
     7// #define DEBUG_OUT(x) sout | x | endl;
    88//
    99// #else
  • examples/multicore.c

    r515a037 rcdc02f2  
    1515
    1616int main(int argc, char* argv[]) {
    17         // sout | "User main begin";
     17        // sout | "User main begin" | endl;
    1818        {
    1919                processor p;
     
    2222                }
    2323        }
    24         // sout | "User main end";
     24        // sout | "User main end" | endl;
    2525}
  • examples/prolog.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 23:27:19 2018
    13 // Update Count     : 6
     12// Last Modified On : Tue Mar  8 22:09:39 2016
     13// Update Count     : 5
    1414//
    1515
    1616#include <fstream.hfa>
    1717
    18 void printResult( int x ) { sout | "int"; }
    19 void printResult( double x ) { sout | "double"; }
    20 void printResult( char * x ) { sout | "char*"; }
     18void printResult( int x ) { sout | "int" | endl; }
     19void printResult( double x ) { sout | "double" | endl; }
     20void printResult( char * x ) { sout | "char*" | endl; }
    2121
    2222void is_arithmetic( int x ) {}
  • examples/quad.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 23:26:58 2018
    13 // Update Count     : 9
     12// Last Modified On : Tue Mar  8 22:07:02 2016
     13// Update Count     : 8
    1414//
    1515
     
    2828int main() {
    2929        int N = 2;
    30         sout | "result of quad of" | N | "is" | quad( N );
     30        sout | "result of quad of" | N | "is" | quad( N ) | endl;
    3131}
    3232
  • examples/square.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 23:28:24 2018
    13 // Update Count     : 28
     12// Last Modified On : Tue Mar  8 22:05:48 2016
     13// Update Count     : 27
    1414//
    1515
     
    2323int main() {
    2424#if 0
    25         sout | "result of squaring 9 is ";
     25        sout | "result of squaring 9 is " | endl;
    2626
    2727        // char does not have multiplication.
     
    3030        } // ?*?
    3131        char c = 9;
    32         sout | "char\t\t\t" | square( c );
     32        sout | "char\t\t\t" | square( c ) | endl;
    3333
    34         sout | square( s );
     34        sout | square( s ) | endl;
    3535#endif
    3636        short s = 9;
     
    3838#if 0
    3939        signed int i = 9;
    40         sout | "signed int\t\t" | square( i );
     40        sout | "signed int\t\t" | square( i ) | endl;
    4141
    4242        unsigned int ui = 9;
    43         sout | "unsigned int\t\t" | square( ui );
     43        sout | "unsigned int\t\t" | square( ui ) | endl;
    4444
    4545        long int li = 9;
    46         sout | "signed long int\t\t" | square( li );
     46        sout | "signed long int\t\t" | square( li ) | endl;
    4747
    4848        unsigned long int uli = 9;
    49         sout | "unsigned long int\t" | square( uli );
     49        sout | "unsigned long int\t" | square( uli ) | endl;
    5050
    5151        signed long long int lli = 9;
    52         sout | "signed long long int\t" | square( lli );
     52        sout | "signed long long int\t" | square( lli ) | endl;
    5353
    5454        unsigned long long int ulli = 9;
    55         sout | "unsigned long long int\t" | square( ulli );
     55        sout | "unsigned long long int\t" | square( ulli ) | endl;
    5656
    5757        float f = 9.0;
    58         sout | "float\t\t\t" | square( f );
     58        sout | "float\t\t\t" | square( f ) | endl;
    5959
    6060        double d = 9.0;
    61         sout | "double\t\t\t" | square( d );
     61        sout | "double\t\t\t" | square( d ) | endl;
    6262
    6363        long double ld = 9.0;
    64         sout | "long double\t\t" | square( ld );
     64        sout | "long double\t\t" | square( ld ) | endl;
    6565#endif
    6666} // main
  • examples/twice.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 23:28:08 2018
    13 // Update Count     : 47
     12// Last Modified On : Thu Oct 19 21:52:57 2017
     13// Update Count     : 46
    1414//
    1515
     
    2828
    2929int main( void ) {
    30         sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 );
     30        sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ) | endl;
    3131}
    3232
  • examples/wrapper/src/main.c

    r515a037 rcdc02f2  
    11#include "pointer.h"
    22
    3 wrapper_t make_copy(wrapper_t copy) {
     3wrapper_t make_copy(wrapper_t copy)
     4{
    45        return copy;
    56}
    67
    7 int main(int argc, char const *argv[]) {
     8int main(int argc, char const *argv[])
     9{
    810        wrapper_t p = wrap(6);
    9         sout | nl | "test started";
     11
     12        sout | endl | "test started" | endl;
     13
    1014        wrapper_t p2 = p;
     15
    1116        clear(&p);
     17
    1218        p = p2;
     19
    1320        wrapper_t p3 = make_copy(p2);
    14         sout | nl | "test ended";
     21
     22        sout | endl | "test ended" | endl;
     23
    1524        return 0;
    1625}
  • examples/wrapper/src/pointer.h

    r515a037 rcdc02f2  
    3434void ?{}(content_t* this)
    3535{
    36         sout | "Constructing content";
     36        sout | "Constructing content" | endl;
    3737        this->count = 0;
    3838}
     
    4040void ^?{}(content_t* this)
    4141{
    42         sout | "Destroying content";
     42        sout | "Destroying content" | endl;
    4343}
    4444
     
    5353void ?{}(wrapper_t* this)
    5454{
    55         sout | "Constructing empty ref pointer" | nl;
     55        sout | "Constructing empty ref pointer" | endl | endl;
    5656        this->ptr = NULL;
    5757}
     
    5959void ?{}(wrapper_t* this, wrapper_t rhs)
    6060{
    61         sout | "Constructing ref pointer from copy";
     61        sout | "Constructing ref pointer from copy" | endl;
    6262        this->ptr = rhs.ptr;
    6363        this->ptr->count++;
    64         sout | "Reference is " | this->ptr->count | nl;
     64        sout | "Reference is " | this->ptr->count | endl | endl;
    6565}
    6666
     
    6969        if(this->ptr)
    7070        {
    71                 sout | "Destroying ref pointer";
     71                sout | "Destroying ref pointer" | endl;
    7272                this->ptr->count--;
    73                 sout | "Reference is " | this->ptr->count | nl;
     73                sout | "Reference is " | this->ptr->count | endl | endl;
    7474                if(!this->ptr->count) delete(this->ptr);
    7575        }
    7676        else
    7777        {
    78                 sout | "Destroying empty ref pointer" | nl;
     78                sout | "Destroying empty ref pointer" | endl | endl;
    7979        }
    8080}
     
    8282wrapper_t ?=?(wrapper_t* this, wrapper_t rhs)
    8383{
    84         sout | "Setting ref pointer";
     84        sout | "Setting ref pointer" | endl;
    8585        if(this->ptr)
    8686        {
    8787                this->ptr->count--;
    88                 sout | "Reference is " | this->ptr->count | nl;
     88                sout | "Reference is " | this->ptr->count | endl | endl;
    8989                if(!this->ptr->count) delete(this->ptr);
    9090        }
    9191        this->ptr = rhs.ptr;
    9292        this->ptr->count++;
    93         sout | "Reference is " | this->ptr->count | nl;
     93        sout | "Reference is " | this->ptr->count | endl | endl;
    9494}
    9595
     
    9898        this->ptr = c;
    9999        this->ptr->count++;
    100         sout | "Setting ref pointer";
    101         sout | "Reference is " | this->ptr->count | nl;
     100        sout | "Setting ref pointer" | endl;
     101        sout | "Reference is " | this->ptr->count | endl | endl;
    102102}
    103103
    104104void clear(wrapper_t* this)
    105105{
    106         sout | "Clearing ref pointer";
     106        sout | "Clearing ref pointer" | endl;
    107107        this->ptr->count--;
    108         sout | "Reference is " | this->ptr->count | nl;
     108        sout | "Reference is " | this->ptr->count | endl | endl;
    109109        if(!this->ptr->count) delete(this->ptr);
    110110        this->ptr = NULL;
  • examples/zero_one.c

    r515a037 rcdc02f2  
    33void foo(zero_t o)
    44{
    5         sout | "It's a Zero!";
     5        sout | "It's a Zero!" | endl;
    66}
    77
    88void foo(one_t o)
    99{
    10         sout | "It's a One!";
     10        sout | "It's a One!" | endl;
    1111}
    1212
    1313void foo(int o)
    1414{
    15         sout | "It's a Number!";
     15        sout | "It's a Number!" | endl;
    1616}
    1717
  • libcfa/src/fstream.cfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 08:34:28 2018
    13 // Update Count     : 298
     12// Last Modified On : Fri Aug 10 18:19:40 2018
     13// Update Count     : 284
    1414//
    1515
     
    2020#include <stdarg.h>                                                                             // varargs
    2121#include <string.h>                                                                             // strlen
     22#include <stdbool.h>                                                                    // true/false
    2223#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    2324#include <complex.h>                                                                    // creal, cimag
     
    2627#define IO_MSG "I/O error: "
    2728
    28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool nonlManip, const char * separator, const char * tupleSeparator ) {
     29void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, const char * separator, const char * tupleSeparator ) {
    2930        os.file = file;
    3031        os.sepDefault = sepDefault;
    3132        os.sepOnOff = sepOnOff;
    32         os.nlOnOff = nlOnOff;
    33         os.nonlManip = nonlManip;
    3433        sepSet( os, separator );
    3534        sepSetCur( os, sepGet( os ) );
     
    4544bool getNL( ofstream & os ) { return os.sawNL; }
    4645void 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; }
    5046
    5147// public
     
    7672} // sepEnable
    7773
    78 void nlOn( ofstream & os ) { os.nlOnOff = true; }
    79 void nlOff( ofstream & os ) { os.nlOnOff = false; }
    80 
    8174const char * sepGet( ofstream & os ) { return os.separator; }
    8275void sepSet( ofstream & os, const char * s ) {
     
    110103        } // if
    111104        #endif // __CFA_DEBUG__
    112         (os){ file, true, false, true, false, " ", ", " };
     105        (os){ file, true, false, " ", ", " };
    113106} // open
    114107
     
    154147} // fmt
    155148
    156 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, true, false, " ", ", " };
     149static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
    157150ofstream & sout = soutFile;
    158 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, true, false, " ", ", " };
     151static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
    159152ofstream & serr = serrFile;
    160153
  • libcfa/src/fstream.hfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 07:52:41 2018
    13 // Update Count     : 143
     12// Last Modified On : Sat Aug 11 13:54:27 2018
     13// Update Count     : 132
    1414//
    1515
     
    2323        bool sepDefault;
    2424        bool sepOnOff;
    25         bool nlOnOff;
    26         bool nonlManip;
    2725        bool sawNL;
    2826        const char * sepCur;
     
    3937bool getNL( ofstream & );
    4038void setNL( ofstream &, bool );
    41 bool getANL( ofstream & );
    42 bool getNonl( ofstream & );
    43 void setNonl( ofstream &, bool );
    4439
    4540// public
     
    4843bool sepDisable( ofstream & );
    4944bool sepEnable( ofstream & );
    50 void nlOn( ofstream & );
    51 void nlOff( ofstream & );
    5245
    5346const char * sepGet( ofstream & );
  • libcfa/src/gmp.hfa

    r515a037 rcdc02f2  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 23:25:51 2018
    13 // Update Count     : 22
     12// Last Modified On : Thu Dec  7 09:10:41 2017
     13// Update Count     : 21
    1414//
    1515
     
    262262} // ?|?
    263263
    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
     264static inline forall( dtype ostype | ostream( ostype ) )
     265ostype & ?|?( 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} // ?|?
    276271
    277272// Local Variables: //
  • libcfa/src/iostream.cfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:02:03 2018
    13 // Update Count     : 546
     12// Last Modified On : Wed Sep 26 18:22:57 2018
     13// Update Count     : 474
    1414//
    1515
     
    1919#include <stdio.h>
    2020#include <stdbool.h>                                                                    // true/false
    21 //#include <string.h>                                                                   // strlen, strcmp
     21//#include <string.h>                                                                           // strlen, strcmp
    2222extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
    2323extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
     
    3232                return os;
    3333        } // ?|?
    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 );
     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;
    6352        } // ?|?
    6453
     
    6857                return os;
    6958        } // ?|?
    70         void & ?|?( ostype & os, short int si ) {
    71                 (ostype)(os | si); if ( getANL( os ) ) nl( os );
    72         } // ?|?
    7359
    7460        ostype & ?|?( ostype & os, unsigned short int usi ) {
     
    7763                return os;
    7864        } // ?|?
    79         void & ?|?( ostype & os, unsigned short int usi ) {
    80                 (ostype)(os | usi); if ( getANL( os ) ) nl( os );
    81         } // ?|?
    8265
    8366        ostype & ?|?( ostype & os, int i ) {
     
    8669                return os;
    8770        } // ?|?
    88         void & ?|?( ostype & os, int i ) {
    89                 (ostype)(os | i); if ( getANL( os ) ) nl( os );
    90         } // ?|?
    9171
    9272        ostype & ?|?( ostype & os, unsigned int ui ) {
     
    9575                return os;
    9676        } // ?|?
    97         void & ?|?( ostype & os, unsigned int ui ) {
    98                 (ostype)(os | ui); if ( getANL( os ) ) nl( os );
    99         } // ?|?
    10077
    10178        ostype & ?|?( ostype & os, long int li ) {
     
    10481                return os;
    10582        } // ?|?
    106         void & ?|?( ostype & os, long int li ) {
    107                 (ostype)(os | li); if ( getANL( os ) ) nl( os );
    108         } // ?|?
    10983
    11084        ostype & ?|?( ostype & os, unsigned long int uli ) {
     
    11387                return os;
    11488        } // ?|?
    115         void & ?|?( ostype & os, unsigned long int uli ) {
    116                 (ostype)(os | uli); if ( getANL( os ) ) nl( os );
    117         } // ?|?
    11889
    11990        ostype & ?|?( ostype & os, long long int lli ) {
     
    12293                return os;
    12394        } // ?|?
    124         void & ?|?( ostype & os, long long int lli ) {
    125                 (ostype)(os | lli); if ( getANL( os ) ) nl( os );
    126         } // ?|?
    12795
    12896        ostype & ?|?( ostype & os, unsigned long long int ulli ) {
     
    13199                return os;
    132100        } // ?|?
    133         void & ?|?( ostype & os, unsigned long long int ulli ) {
    134                 (ostype)(os | ulli); if ( getANL( os ) ) nl( os );
    135         } // ?|?
    136101
    137102        ostype & ?|?( ostype & os, float f ) {
     
    140105                return os;
    141106        } // ?|?
    142         void & ?|?( ostype & os, float f ) {
    143                 (ostype)(os | f); if ( getANL( os ) ) nl( os );
    144         } // ?|?
    145107
    146108        ostype & ?|?( ostype & os, double d ) {
     
    149111                return os;
    150112        } // ?|?
    151         void & ?|?( ostype & os, double d ) {
    152                 (ostype)(os | d); if ( getANL( os ) ) nl( os );
    153         } // ?|?
    154113
    155114        ostype & ?|?( ostype & os, long double ld ) {
     
    158117                return os;
    159118        } // ?|?
    160         void & ?|?( ostype & os, long double ld ) {
    161                 (ostype)(os | ld); if ( getANL( os ) ) nl( os );
    162         } // ?|?
    163119
    164120        ostype & ?|?( ostype & os, float _Complex fc ) {
     
    167123                return os;
    168124        } // ?|?
    169         void & ?|?( ostype & os, float _Complex fc ) {
    170                 (ostype)(os | fc); if ( getANL( os ) ) nl( os );
    171         } // ?|?
    172125
    173126        ostype & ?|?( ostype & os, double _Complex dc ) {
     
    176129                return os;
    177130        } // ?|?
    178         void & ?|?( ostype & os, double _Complex dc ) {
    179                 (ostype)(os | dc); if ( getANL( os ) ) nl( os );
    180         } // ?|?
    181131
    182132        ostype & ?|?( ostype & os, long double _Complex ldc ) {
     
    184134                fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) );
    185135                return os;
    186         } // ?|?
    187         void & ?|?( ostype & os, long double _Complex ldc ) {
    188                 (ostype)(os | ldc); if ( getANL( os ) ) nl( os );
    189136        } // ?|?
    190137
     
    194141                        // opening delimiters, no space after
    195142                        ['('] : Open, ['['] : Open, ['{'] : Open,
    196                         ['='] : Open, ['$'] : Open, [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open,
    197                         [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open, [(unsigned char)'�'] : Open,
     143                        ['='] : Open, ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,
     144                        [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
    198145                        // closing delimiters, no space before
    199146                        [','] : Close, ['.'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
    200                         ['%'] : Close, [(unsigned char)'�'] : Close, [(unsigned char)'�'] : Close,
     147                        ['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close,
    201148                        [')'] : Close, [']'] : Close, ['}'] : Close,
    202149                        // opening-closing delimiters, no space before or after
     
    227174                return write( os, str, len );
    228175        } // ?|?
    229         void ?|?( ostype & os, const char * str ) {
    230                 (ostype)(os | str); if ( getANL( os ) ) nl( os );
    231         } // ?|?
    232176
    233177//      ostype & ?|?( ostype & os, const char16_t * str ) {
     
    256200                return os;
    257201        } // ?|?
    258         void ?|?( ostype & os, const void * p ) {
    259                 (ostype)(os | p); if ( getANL( os ) ) nl( os );
    260         } // ?|?
     202
    261203
    262204        // manipulators
    263205        ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    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 );
     206                return manip( os );
    272207        } // ?|?
    273208
    274209        ostype & sep( ostype & os ) {
    275                 return (ostype)(os | sepGet( os ));
     210                os | sepGet( os );
     211                return os;
    276212        } // sep
    277213
    278214        ostype & sepTuple( ostype & os ) {
    279                 return os | sepGetTuple( os );
     215                os | sepGetTuple( os );
     216                return os;
    280217        } // sepTuple
    281218
    282         ostype & nl( ostype & os ) {
    283                 (ostype)(os | '\n');
     219        ostype & endl( ostype & os ) {
     220                os | '\n';
    284221                setNL( os, true );
    285222                flush( os );
    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
     223                sepOff( os );                                                                   // prepare for next line
     224                return os;
     225        } // endl
    293226
    294227        ostype & sepOn( ostype & os ) {
    295                 sepOn( os );                                                                    // call void returning
     228                sepOn( os );
    296229                return os;
    297230        } // sepOn
    298231
    299232        ostype & sepOff( ostype & os ) {
    300                 sepOff( os );                                                                   // call void returning
     233                sepOff( os );
    301234                return os;
    302235        } // sepOff
    303236
    304237        ostype & sepEnable( ostype & os ) {
    305                 sepEnable( os );                                                                // call void returning
     238                sepEnable( os );
    306239                return os;
    307240        } // sepEnable
    308241
    309242        ostype & sepDisable( ostype & os ) {
    310                 sepDisable( os );                                                               // call void returning
     243                sepDisable( os );
    311244                return os;
    312245        } // 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
    323246} // distribution
    324247
     248
    325249// tuples
    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
     250forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
     251ostype & ?|?( 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} // ?|?
    343258
    344259//---------------------------------------
    345260
    346261// writes the range [begin, end) to the given stream
    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
     262forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     263void 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
     268forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     269void 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} // ?|?
    358273
    359274//---------------------------------------
     
    471386        } // ?|?
    472387
    473         istype & nl( istype & is ) {
     388        istype & endl( istype & is ) {
    474389                fmt( is, "%*[ \t\f\n\r\v]" );                                   // ignore whitespace
    475390                return is;
    476         } // nl
     391        } // endl
    477392} // distribution
    478393
  • libcfa/src/iostream.hfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:01:31 2018
    13 // Update Count     : 213
     12// Last Modified On : Sat Aug 11 08:22:49 2018
     13// Update Count     : 156
    1414//
    1515
     
    2525        const char * sepGetCur( ostype & );                                     // get current separator string
    2626        void sepSetCur( ostype &, const char * );                       // set current separator string
    27         bool getNL( ostype & );                                                         // check newline
     27        bool getNL( ostype & );                                                 // check newline
    2828        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
    3229        // public
    3330        void sepOn( ostype & );                                                         // turn separator state on
    3431        void sepOff( ostype & );                                                        // turn separator state off
    3532        bool sepDisable( ostype & );                                            // set default state to off, 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
     33        bool sepEnable( ostype & );                                             // set default state to on, and return previous state
    3934
    4035        const char * sepGet( ostype & );                                        // get separator string
     
    6358forall( dtype ostype | ostream( ostype ) ) {
    6459        ostype & ?|?( ostype &, bool );
    65         void & ?|?( ostype &, bool );
    6660
    6761        ostype & ?|?( ostype &, char );
    68         void & ?|?( ostype &, char );
    6962        ostype & ?|?( ostype &, signed char );
    70         void & ?|?( ostype &, signed char );
    7163        ostype & ?|?( ostype &, unsigned char );
    72         void & ?|?( ostype &, unsigned char );
    7364
    7465        ostype & ?|?( ostype &, short int );
    75         void & ?|?( ostype &, short int );
    7666        ostype & ?|?( ostype &, unsigned short int );
    77         void & ?|?( ostype &, unsigned short int );
    7867        ostype & ?|?( ostype &, int );
    79         void & ?|?( ostype &, int );
    8068        ostype & ?|?( ostype &, unsigned int );
    81         void & ?|?( ostype &, unsigned int );
    8269        ostype & ?|?( ostype &, long int );
    83         void & ?|?( ostype &, long int );
    8470        ostype & ?|?( ostype &, long long int );
    85         void & ?|?( ostype &, long long int );
    8671        ostype & ?|?( ostype &, unsigned long int );
    87         void & ?|?( ostype &, unsigned long int );
    8872        ostype & ?|?( ostype &, unsigned long long int );
    89         void & ?|?( ostype &, unsigned long long int );
    9073
    9174        ostype & ?|?( ostype &, float ); // FIX ME: should not be required
    92         void & ?|?( ostype &, float ); // FIX ME: should not be required
    9375        ostype & ?|?( ostype &, double );
    94         void & ?|?( ostype &, double );
    9576        ostype & ?|?( ostype &, long double );
    96         void & ?|?( ostype &, long double );
    9777
    9878        ostype & ?|?( ostype &, float _Complex );
    99         void & ?|?( ostype &, float _Complex );
    10079        ostype & ?|?( ostype &, double _Complex );
    101         void & ?|?( ostype &, double _Complex );
    10280        ostype & ?|?( ostype &, long double _Complex );
    103         void & ?|?( ostype &, long double _Complex );
    10481
    10582        ostype & ?|?( ostype &, const char * );
    106         void & ?|?( ostype &, const char * );
    10783        // ostype & ?|?( ostype &, const char16_t * );
    10884#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    11187        // ostype & ?|?( ostype &, const wchar_t * );
    11288        ostype & ?|?( ostype &, const void * );
    113         void & ?|?( ostype &, const void * );
    11489
    11590        // manipulators
    11691        ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
    117         void ?|?( ostype &, ostype & (*)( ostype & ) );
    118         ostype & nl( ostype & );
    119         ostype & nonl( ostype & );
     92        ostype & endl( ostype & );
    12093        ostype & sep( ostype & );
    12194        ostype & sepTuple( ostype & );
     
    12497        ostype & sepDisable( ostype & );
    12598        ostype & sepEnable( ostype & );
    126         ostype & nlOn( ostype & );
    127         ostype & nlOff( ostype & );
    12899} // distribution
    129100
    130101// tuples
    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
     102forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
     103ostype & ?|?( ostype & os, T arg, Params rest );
    135104
    136105// writes the range [begin, end) to the given stream
    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
     106forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     107void write( iterator_type begin, iterator_type end, ostype & os );
     108
     109forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
     110void write_reverse( iterator_type begin, iterator_type end, ostype & os );
    141111
    142112//---------------------------------------
     
    182152        // manipulators
    183153        istype & ?|?( istype &, istype & (*)( istype & ) );
    184         istype & nl( istype & is );
     154        istype & endl( istype & is );
    185155} // distribution
    186156
     
    194164
    195165
    196 #include <time_t.hfa>                                                                   // Duration (constructors) / Time (constructors)
     166#include <time_t.hfa>                                                                           // Duration (constructors) / Time (constructors)
    197167
    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
     168forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
     169forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
     170
    204171
    205172// Local Variables: //
  • libcfa/src/iterator.cfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov  2 07:17:37 2018
     12// Last Modified On : Wed Sep 26 18:23:10 2018
    1313// Update Count     : 29
    1414//
  • libcfa/src/rational.cfa

    r515a037 rcdc02f2  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:02:29 2018
    13 // Update Count     : 168
     12// Last Modified On : Sat Jun  2 09:24:33 2018
     13// Update Count     : 162
    1414//
    1515
     
    3535        static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) {
    3636                if ( d == (RationalImpl){0} ) {
    37                         serr | "Invalid rational number construction: denominator cannot be equal to 0.";
     37                        serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
    3838                        exit( EXIT_FAILURE );
    3939                } // exit
     
    175175        } // ?|?
    176176
    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
     177        forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
     178        ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) {
     179                return os | r.numerator | '/' | r.denominator;
     180        } // ?|?
    186181} // distribution
    187182
  • libcfa/src/rational.hfa

    r515a037 rcdc02f2  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Tue Dec  4 23:07:46 2018
    15 // Update Count     : 106
     14// Last Modified On : Sat Jun  2 09:10:01 2018
     15// Update Count     : 105
    1616//
    1717
     
    9292        istype & ?|?( istype &, Rational(RationalImpl) & );
    9393
    94         forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) {
    95                 ostype & ?|?( ostype &, Rational(RationalImpl) );
    96                 void ?|?( ostype &, Rational(RationalImpl) );
    97         } // distribution
     94        forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
     95        ostype & ?|?( ostype &, Rational(RationalImpl ) );
    9896} // distribution
    9997
  • libcfa/src/time.cfa

    r515a037 rcdc02f2  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:32:15 2018
    13 // Update Count     : 53
     12// Last Modified On : Sun May  6 22:26:00 2018
     13// Update Count     : 37
    1414//
    1515
     
    3131
    3232
    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
     33forall( dtype ostype | ostream( ostype ) )
     34ostype & ?|?( 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} // ?|?
    4843
    4944
     
    142137} // strftime
    143138
    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
     139forall( dtype ostype | ostream( ostype ) )
     140ostype & ?|?( 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} // ?|?
    166157
    167158// Local Variables: //
  • src/Parser/DeclarationNode.cc

    r515a037 rcdc02f2  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:54:26 2018
    13 // Update Count     : 1108
     12// Last Modified On : Fri Jul 20 14:56:54 2018
     13// Update Count     : 1107
    1414//
    1515
     
    402402}
    403403
    404 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr, bool basetypeof ) {
    405         DeclarationNode * newnode = new DeclarationNode;
    406         newnode->type = new TypeData( basetypeof ? TypeData::Basetypeof : TypeData::Typeof );
     404DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) {
     405        DeclarationNode * newnode = new DeclarationNode;
     406        newnode->type = new TypeData( TypeData::Typeof );
    407407        newnode->type->typeexpr = expr;
    408408        return newnode;
  • src/Parser/ParseNode.h

    r515a037 rcdc02f2  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:54:53 2018
    13 // Update Count     : 854
     12// Last Modified On : Sat Aug  4 09:39:40 2018
     13// Update Count     : 853
    1414//
    1515
     
    249249        static DeclarationNode * newBitfield( ExpressionNode * size );
    250250        static DeclarationNode * newTuple( DeclarationNode * members );
    251         static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false );
     251        static DeclarationNode * newTypeof( ExpressionNode * expr );
    252252        static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes
    253253        static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes
  • src/Parser/TypeData.cc

    r515a037 rcdc02f2  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov  2 07:54:26 2018
    13 // Update Count     : 624
     12// Last Modified On : Fri Jul 20 14:39:31 2018
     13// Update Count     : 622
    1414//
    1515
     
    9696                break;
    9797          case Typeof:
    98           case Basetypeof:
    9998                // typeexpr = new Typeof_t;
    10099                typeexpr = nullptr;
     
    167166                break;
    168167          case Typeof:
    169           case Basetypeof:
    170168                // delete typeexpr->expr;
    171169                delete typeexpr;
     
    247245                break;
    248246          case Typeof:
    249           case Basetypeof:
    250247                newtype->typeexpr = maybeClone( typeexpr );
    251248                break;
     
    422419                } // if
    423420                break;
    424           case Basetypeof:
    425                 os << "base-";
    426                 #if defined(__GNUC__) && __GNUC__ >= 7
    427                         __attribute__((fallthrough));
    428                 #endif
    429421          case Typeof:
    430422                os << "type-of expression ";
     
    465457          case Tuple:
    466458          case Typeof:
    467           case Basetypeof:
    468459          case Builtin:
    469460                assertf(false, "Tried to get leaf name from kind without a name: %d", kind);
     
    522513        switch ( td->kind ) {
    523514          case TypeData::Unknown:
    524                         // fill in implicit int
    525                         return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
     515                // fill in implicit int
     516                return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
    526517          case TypeData::Basic:
    527                         return buildBasicType( td );
     518                return buildBasicType( td );
    528519          case TypeData::Pointer:
    529                         return buildPointer( td );
     520                return buildPointer( td );
    530521          case TypeData::Array:
    531                         return buildArray( td );
     522                return buildArray( td );
    532523          case TypeData::Reference:
    533                         return buildReference( td );
     524                return buildReference( td );
    534525          case TypeData::Function:
    535                         return buildFunction( td );
     526                return buildFunction( td );
    536527          case TypeData::AggregateInst:
    537                         return buildAggInst( td );
     528                return buildAggInst( td );
    538529          case TypeData::EnumConstant:
    539                         // the name gets filled in later -- by SymTab::Validate
    540                         return new EnumInstType( buildQualifiers( td ), "" );
     530                // the name gets filled in later -- by SymTab::Validate
     531                return new EnumInstType( buildQualifiers( td ), "" );
    541532          case TypeData::SymbolicInst:
    542                         return buildSymbolicInst( td );
     533                return buildSymbolicInst( td );
    543534          case TypeData::Tuple:
    544                         return buildTuple( td );
     535                return buildTuple( td );
    545536          case TypeData::Typeof:
    546           case TypeData::Basetypeof:
    547                         return buildTypeof( td );
     537                return buildTypeof( td );
    548538          case TypeData::Builtin:
    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                         }
     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                }
    558548          case TypeData::GlobalScope:
    559                         return new GlobalScopeType();
     549                return new GlobalScopeType();
    560550                case TypeData::Qualified:
    561                         return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
     551                return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
    562552          case TypeData::Symbolic:
    563553          case TypeData::Enum:
    564554          case TypeData::Aggregate:
    565                         assert( false );
     555                assert( false );
    566556        } // switch
    567557
     
    939929
    940930TypeofType * buildTypeof( const TypeData * td ) {
    941         assert( td->kind == TypeData::Typeof || td->kind == TypeData::Basetypeof );
     931        assert( td->kind == TypeData::Typeof );
    942932        assert( td->typeexpr );
    943933        // assert( td->typeexpr->expr );
    944         return new TypeofType{
    945                 buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
     934        return new TypeofType( buildQualifiers( td ), td->typeexpr->build() );
    946935} // buildTypeof
    947936
  • src/Parser/TypeData.h

    r515a037 rcdc02f2  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:56:46 2018
    13 // Update Count     : 196
     12// Last Modified On : Fri Jul 20 13:56:40 2018
     13// Update Count     : 195
    1414//
    1515
     
    2727struct TypeData {
    2828        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
    29                                 SymbolicInst, Tuple, Typeof, Basetypeof, Builtin, GlobalScope, Qualified, Unknown };
     29                                SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown };
    3030
    3131        struct Aggregate_t {
  • src/Parser/lex.ll

    r515a037 rcdc02f2  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Nov  1 20:57:35 2018
     12 * Last Modified On : Sat Oct 20 09:42:45 2018
    1313 * Update Count     : 687
    1414 */
  • src/Parser/parser.yy

    r515a037 rcdc02f2  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  8 18:08:23 2018
    13 // Update Count     : 4052
     12// Last Modified On : Sun Oct 21 08:27:29 2018
     13// Update Count     : 4045
    1414//
    1515
     
    187187
    188188ForCtrl * 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());
    190190        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
    191191        type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
    192192        } // if
    193193        return new ForCtrl(
    194                 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     194                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    195195                new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    196196                new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto
    197197                                                                                          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
    209198} // forCtrl
    210199
     
    11431132        | FOR '(' push for_control_expression ')' statement pop
    11441133                { $$ = 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 ) ); }
    11471134        ;
    11481135
    11491136for_control_expression:
    1150 <<<<<<< HEAD
    11511137        comma_expression_opt                                                            // CFA
    11521138                {
     
    11581144                        } // if
    11591145                }
    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
    11651146        | constant_expression inclexcl constant_expression      // CFA
    11661147                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11671148        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11681149                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
    1169 <<<<<<< HEAD
    11701150        | comma_expression_opt ';' comma_expression                     // CFA
    11711151                {
     
    12081188                }
    12091189        | 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
    12201190                { $$ = new ForCtrl( $1, $3, $5 ); }
    1221         | ';' comma_expression_opt ';' comma_expression_opt
    1222                 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
    12231191        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    12241192                { $$ = new ForCtrl( $1, $2, $4 ); }
     
    18821850
    18831851indirect_type:
    1884         TYPEOF '(' type ')'                                                                     // GCC: typeof( x ) y;
     1852        TYPEOF '(' type ')'                                                                     // GCC: typeof(x) y;
    18851853                { $$ = $3; }
    1886         | TYPEOF '(' comma_expression ')'                                       // GCC: typeof( a+b ) y;
     1854        | TYPEOF '(' comma_expression ')'                                       // GCC: typeof(a+b) y;
    18871855                { $$ = DeclarationNode::newTypeof( $3 ); }
    1888 <<<<<<< HEAD
    18891856        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof(x) y;
    18901857                { $$ = $3; }
     
    18921859                { $$ = DeclarationNode::newTypeof( $3 ); }
    18931860        | 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
    19011861                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    1902         | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type( a+b ) y;
     1862        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    19031863                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    19041864        | ZERO_T                                                                                        // CFA
  • src/ResolvExpr/AlternativeFinder.cc

    r515a037 rcdc02f2  
    1010// Created On       : Sat May 16 23:52:08 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 21:00:56 2018
    13 // Update Count     : 34
     12// Last Modified On : Sat Feb 17 11:19:39 2018
     13// Update Count     : 33
    1414//
    1515
     
    13441344                /// Gets name from untyped member expression (member must be NameExpr)
    13451345                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
    13491346                        NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() );
    13501347                        assert( nameExpr );
  • src/ResolvExpr/ResolveTypeof.cc

    r515a037 rcdc02f2  
    6767                std::cerr << std::endl;
    6868#endif
    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
     69                if ( typeofType->expr ) {
    8370                        Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer );
    8471                        assert( newExpr->result && ! newExpr->result->isVoid() );
    85                         newType = newExpr->result;
     72                        Type * newType = newExpr->result;
    8673                        newExpr->result = nullptr;
    8774                        delete typeofType;
    8875                        delete newExpr;
    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;
     76                        return newType;
     77                } // if
     78                return typeofType;
    10879        }
    10980} // namespace ResolvExpr
  • src/SynTree/Type.h

    r515a037 rcdc02f2  
    598598class TypeofType : public Type {
    599599  public:
    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 * >() );
     600        Expression *expr;
     601
     602        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    606603        TypeofType( const TypeofType& );
    607604        virtual ~TypeofType();
  • src/SynTree/TypeofType.cc

    r515a037 rcdc02f2  
    2323class Attribute;
    2424
    25 TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr,
    26         const std::list< Attribute * > & attributes )
    27 : Type( tq, attributes ), expr( expr ), is_basetypeof(false) {}
     25TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), expr( expr ) {
     26}
    2827
    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 ) {}
     28TypeofType::TypeofType( const TypeofType &other ) : Type( other ), expr( maybeClone( other.expr ) ) {
     29}
    3530
    3631TypeofType::~TypeofType() {
     
    4035void TypeofType::print( std::ostream &os, Indenter indent ) const {
    4136        Type::print( os, indent );
    42         if ( is_basetypeof ) { os << "base-"; }
    4337        os << "type-of expression ";
    4438        if ( expr ) {
  • tests/.expect/alloc-ERROR.txt

    r515a037 rcdc02f2  
    1 alloc.cfa:265:1 error: No reasonable alternatives for expression Applying untyped:
     1alloc.c:265:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: ?=?
    33...to:
     
    1919
    2020
    21 alloc.cfa:266:1 error: No reasonable alternatives for expression Applying untyped:
     21alloc.c:266:1 error: No reasonable alternatives for expression Applying untyped:
    2222  Name: ?=?
    2323...to:
     
    3939
    4040
    41 alloc.cfa:267:1 error: No reasonable alternatives for expression Applying untyped:
     41alloc.c:267:1 error: No reasonable alternatives for expression Applying untyped:
    4242  Name: ?=?
    4343...to:
     
    5050
    5151
    52 alloc.cfa:268:1 error: No reasonable alternatives for expression Applying untyped:
     52alloc.c:268:1 error: No reasonable alternatives for expression Applying untyped:
    5353  Name: ?=?
    5454...to:
  • tests/.expect/castError.txt

    r515a037 rcdc02f2  
    1 castError.cfa:7:1 error: Cannot choose between 3 alternatives for expression
     1castError.c:7:1 error: Cannot choose between 3 alternatives for expression
    22Cast of:
    33  Name: f
    44... to:
    5   char Alternatives are:
     5  charAlternatives are:
    66Cost ( 1, 0, 0, 0 ): Cast of:
    77     Variable Expression: f: function
  • tests/.expect/completeTypeError.txt

    r515a037 rcdc02f2  
    1 completeTypeError.cfa:33:1 error: No reasonable alternatives for expression Applying untyped:
     1completeTypeError.c:33:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: *?
    33...to:
    44  Name: v
    55
    6 completeTypeError.cfa:34:1 error: No reasonable alternatives for expression Applying untyped:
     6completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped:
    77  Name: *?
    88...to:
    99  Name: y
    1010
    11 completeTypeError.cfa:35:1 error: No reasonable alternatives for expression Applying untyped:
     11completeTypeError.c:35:1 error: No reasonable alternatives for expression Applying untyped:
    1212  Name: foo
    1313...to:
    1414  Name: v
    1515
    16 completeTypeError.cfa:36:1 error: No reasonable alternatives for expression Applying untyped:
     16completeTypeError.c:36:1 error: No reasonable alternatives for expression Applying untyped:
    1717  Name: baz
    1818...to:
    1919  Name: v
    2020
    21 completeTypeError.cfa:37:1 error: No reasonable alternatives for expression Applying untyped:
     21completeTypeError.c:37:1 error: No reasonable alternatives for expression Applying untyped:
    2222  Name: quux
    2323...to:
    2424  Name: v
    2525
    26 completeTypeError.cfa:58:1 error: No reasonable alternatives for expression Applying untyped:
     26completeTypeError.c:58:1 error: No reasonable alternatives for expression Applying untyped:
    2727  Name: baz
    2828...to:
    2929  Name: y
    3030
    31 completeTypeError.cfa:59:1 error: No reasonable alternatives for expression Applying untyped:
     31completeTypeError.c:59:1 error: No reasonable alternatives for expression Applying untyped:
    3232  Name: quux
    3333...to:
    3434  Name: y
    3535
    36 completeTypeError.cfa:60:1 error: No reasonable alternatives for expression Applying untyped:
     36completeTypeError.c:60:1 error: No reasonable alternatives for expression Applying untyped:
    3737  Name: *?
    3838...to:
    3939  Name: y
    4040
    41 completeTypeError.cfa:72:1 error: No reasonable alternatives for expression Applying untyped:
     41completeTypeError.c:72:1 error: No reasonable alternatives for expression Applying untyped:
    4242  Name: baz
    4343...to:
  • tests/.expect/declarationErrors.txt

    r515a037 rcdc02f2  
    1 declarationErrors.cfa:16:1 error: duplicate static in declaration of x1: static const volatile short int
     1declarationErrors.c:16:1 error: duplicate static in declaration of x1: static const volatile short int
    22
    3 declarationErrors.cfa:17:1 error: conflicting extern & static in declaration of x2: extern const volatile short int
     3declarationErrors.c:17:1 error: conflicting extern & static in declaration of x2: extern const volatile short int
    44
    5 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
     5declarationErrors.c:18:1 error: conflicting extern & auto, conflicting extern & static, conflicting extern & static, duplicate extern in declaration of x3: extern const volatile short int
    66
    7 declarationErrors.cfa:19:1 error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous0
     7declarationErrors.c:19:1 error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous0
    88  with members
    99    i: int
     
    1111
    1212
    13 declarationErrors.cfa:20:1 error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous1
     13declarationErrors.c:20:1 error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous1
    1414  with members
    1515    i: int
     
    1717
    1818
    19 declarationErrors.cfa:22:1 error: duplicate static in declaration of x6: static const volatile Int
     19declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile Int
    2020
    21 declarationErrors.cfa:24:1 error: duplicate const in declaration of f01: static inline function
     21declarationErrors.c:24:1 error: duplicate const in declaration of f01: static inline function
    2222  with no parameters
    2323  returning const volatile int
    2424
    2525
    26 declarationErrors.cfa:25:1 error: duplicate volatile in declaration of f02: static inline function
     26declarationErrors.c:25:1 error: duplicate volatile in declaration of f02: static inline function
    2727  with no parameters
    2828  returning const volatile int
    2929
    3030
    31 declarationErrors.cfa:26:1 error: duplicate const in declaration of f03: static inline function
     31declarationErrors.c:26:1 error: duplicate const in declaration of f03: static inline function
    3232  with no parameters
    3333  returning const volatile int
    3434
    3535
    36 declarationErrors.cfa:27:1 error: duplicate volatile in declaration of f04: static inline function
     36declarationErrors.c:27:1 error: duplicate volatile in declaration of f04: static inline function
    3737  with no parameters
    3838  returning const volatile int
    3939
    4040
    41 declarationErrors.cfa:28:1 error: duplicate const in declaration of f05: static inline function
     41declarationErrors.c:28:1 error: duplicate const in declaration of f05: static inline function
    4242  with no parameters
    4343  returning const volatile int
    4444
    4545
    46 declarationErrors.cfa:29:1 error: duplicate volatile in declaration of f06: static inline function
     46declarationErrors.c:29:1 error: duplicate volatile in declaration of f06: static inline function
    4747  with no parameters
    4848  returning const volatile int
    4949
    5050
    51 declarationErrors.cfa:30:1 error: duplicate const in declaration of f07: static inline function
     51declarationErrors.c:30:1 error: duplicate const in declaration of f07: static inline function
    5252  with no parameters
    5353  returning const volatile int
    5454
    5555
    56 declarationErrors.cfa:31:1 error: duplicate const, duplicate volatile in declaration of f08: static inline function
     56declarationErrors.c:31:1 error: duplicate const, duplicate volatile in declaration of f08: static inline function
    5757  with no parameters
    5858  returning const volatile int
    5959
    6060
    61 declarationErrors.cfa:33:1 error: duplicate const, duplicate volatile in declaration of f09: static inline function
     61declarationErrors.c:33:1 error: duplicate const, duplicate volatile in declaration of f09: static inline function
    6262  with no parameters
    6363  returning const volatile int
    6464
    6565
    66 declarationErrors.cfa:34:1 error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function
     66declarationErrors.c:34:1 error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function
    6767  with no parameters
    6868  returning const restrict volatile _Atomic int
  • tests/.expect/loopctrl.txt

    r515a037 rcdc02f2  
    2020
    2121
    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 
    27223 6 9
    28 
    2923
    3024(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

    r515a037 rcdc02f2  
    1 nested-types.cfa:70:1 error: Use of undefined type T
     1nested-types.c:70:1 error: Use of undefined type T
  • tests/.expect/nested-types-ERR2.txt

    r515a037 rcdc02f2  
    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:
     1nested-types.c:73:1 error: Use of undefined global type Z
     2nested-types.c:74:1 error: Qualified type requires an aggregate on the left, but has: signed int
     3nested-types.c:75:1 error: Undefined type in qualified type: Qualified Type:
    44  instance of struct S with body 1
    55  instance of type Z (not function type)
  • tests/.expect/scopeErrors.txt

    r515a037 rcdc02f2  
    1 scopeErrors.cfa:2:1 error: duplicate object definition for thisIsAnError: signed int
    2 scopeErrors.cfa:20:1 error: duplicate function definition for butThisIsAnError: function
     1scopeErrors.c:2:1 error: duplicate object definition for thisIsAnError: signed int
     2scopeErrors.c:20:1 error: duplicate function definition for butThisIsAnError: function
    33... with parameters
    44  double
  • tests/.expect/typedefRedef-ERR1.txt

    r515a037 rcdc02f2  
    1 typedefRedef.cfa:4:1 error: Cannot redefine typedef: Foo
    2 typedefRedef.cfa:60:1 error: Cannot redefine typedef: ARR
     1typedefRedef.c:4:1 error: Cannot redefine typedef: Foo
     2typedefRedef.c:60:1 error: Cannot redefine typedef: ARR
  • tests/Makefile.am

    r515a037 rcdc02f2  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Nov 20 11:18:51 2018
    14 ## Update Count     : 68
     13## Last Modified On : Wed Jun  6 16:42:20 2018
     14## Update Count     : 49
    1515###############################################################################
    1616
    1717AUTOMAKE_OPTIONS = foreign    # do not require all the GNU file names
    18 
    19 include $(top_srcdir)/src/cfa.make
    2018
    2119debug=yes
     
    3836
    3937AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
     38
    4039CC = @CFACC@
    4140
     
    4342
    4443.PHONY: list .validate
    45 .INTERMEDIATE: .validate .validate.cfa
    46 EXTRA_PROGRAMS = avl_test # build but do not install
     44.INTERMEDIATE: .validate .validate.c
     45EXTRA_PROGRAMS = fstream_test avl_test # build but do not install
     46
     47fstream_test_SOURCES = fstream_test.c
    4748
    4849avl_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
     
    6162        @+${TEST_PY} --list ${concurrent}
    6263
    63 .validate: .validate.cfa
    64         $(CFACOMPILE) .validate.cfa -fsyntax-only -Wall -Wextra -Werror
     64.validate: .validate.c
     65        $(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror
    6566
    66 .validate.cfa:
    67         @echo "int main() { return 0; }" > ${@}
    68 
    69 dummy_hack.c:
     67.validate.c:
    7068        @echo "int main() { return 0; }" > ${@}
    7169
     
    7472
    7573#----------------------------------------------------------------------------------------------------------------
     74# implicit rule so not all test require a rule
     75% : %.c $(CC)
     76        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    7677
    77 # implicit rule so not all test require a rule
    78 % : %.c $(CFACC)
    79         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     78declarationSpecifier: declarationSpecifier.c $(CC)
     79        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    8080
    81 % : %.cfa $(CFACC)
    82         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     81gccExtensions : gccExtensions.c $(CC)
     82        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    8383
    84 declarationSpecifier: declarationSpecifier.cfa $(CFACC)
    85         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     84extension : extension.c $(CC)
     85        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    8686
    87 gccExtensions : gccExtensions.cfa $(CFACC)
    88         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     87attributes : attributes.c $(CC)
     88        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    8989
    90 extension : extension.cfa $(CFACC)
    91         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     90functions: functions.c $(CC)
     91        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    9292
    93 attributes : attributes.cfa $(CFACC)
    94         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     93KRfunctions : KRfunctions.c $(CC)
     94        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    9595
    96 functions: functions.cfa $(CFACC)
    97         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     96sched-ext-parse : sched-ext-parse.c $(CC)
     97        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    9898
    99 KRfunctions : KRfunctions.cfa $(CFACC)
    100         $(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    101 
    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 ${@})
     99gmp : gmp.c $(CC)
     100        $(PRETTY_PATH) $(COMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    107101
    108102#builtins
    109 builtins/sync: builtins/sync.c $(CFACC)
    110         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
     103builtins/sync: builtins/sync.c $(CC)
     104        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
    111105
    112106#------------------------------------------------------------------------------
     107#To make errors path independent we need to cd into the correct directories
     108completeTypeError : completeTypeError.c $(CC)
     109        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    113110
    114 #To make errors path independent we need to cd into the correct directories
    115 completeTypeError : completeTypeError.cfa $(CFACC)
    116         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     111typedefRedef-ERR1: typedefRedef.c $(CC)
     112        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    117113
    118 typedefRedef-ERR1: typedefRedef.cfa $(CFACC)
    119         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     114alloc-ERROR: alloc.c $(CC)
     115        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    120116
    121 alloc-ERROR: alloc.cfa $(CFACC)
    122         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     117fallthrough-ERROR: fallthrough.c $(CC)
     118        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    123119
    124 fallthrough-ERROR: fallthrough.cfa $(CFACC)
    125         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     120nested-types-ERR1: nested-types.c $(CC)
     121        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    126122
    127 nested-types-ERR1: nested-types.cfa $(CFACC)
    128         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    129 
    130 nested-types-ERR2: nested-types.cfa $(CFACC)
    131         $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     123nested-types-ERR2: nested-types.c $(CC)
     124        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    132125
    133126# Constructor/destructor tests
    134 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CFACC)
    135         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     127raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CC)
     128        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    136129
    137 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CFACC)
    138         $(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     130raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CC)
     131        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    139132
    140 raii/memberCtors-ERR1: raii/memberCtors.c $(CFACC)
    141         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     133raii/memberCtors-ERR1: raii/memberCtors.c $(CC)
     134        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    142135
    143 raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CFACC)
    144         $(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     136raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CC)
     137        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    145138
    146139# Warnings
    147 warnings/self-assignment: warnings/self-assignment.c $(CFACC)
    148         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
     140warnings/self-assignment: warnings/self-assignment.c $(CC)
     141        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
  • tests/Makefile.in

    r515a037 rcdc02f2  
    9191build_triplet = @build@
    9292host_triplet = @host@
    93 EXTRA_PROGRAMS = avl_test$(EXEEXT)
     93EXTRA_PROGRAMS = fstream_test$(EXEEXT) avl_test$(EXEEXT)
    9494subdir = tests
    9595ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    110110avl_test_OBJECTS = $(am_avl_test_OBJECTS)
    111111avl_test_LDADD = $(LDADD)
     112am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)
     113fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
     114fstream_test_LDADD = $(LDADD)
    112115AM_V_P = $(am__v_P_@AM_V@)
    113116am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
     
    138141am__v_CCLD_0 = @echo "  CCLD    " $@;
    139142am__v_CCLD_1 =
    140 SOURCES = $(avl_test_SOURCES)
    141 DIST_SOURCES = $(avl_test_SOURCES)
     143SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)
     144DIST_SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)
    142145am__can_run_installinfo = \
    143146  case $$AM_UPDATE_INFO_DIR in \
     
    165168CTAGS = ctags
    166169am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.py.in \
    167         $(srcdir)/test.py $(top_srcdir)/automake/depcomp \
    168         $(top_srcdir)/src/cfa.make
     170        $(srcdir)/test.py $(top_srcdir)/automake/depcomp
    169171DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    170172ACLOCAL = @ACLOCAL@
     
    295297top_srcdir = @top_srcdir@
    296298AUTOMAKE_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 =
    320299debug = yes
    321300installed = no
     
    330309        ${INSTALL_FLAGS} ${ARCH_FLAGS}
    331310PRETTY_PATH = cd ${srcdir} &&
     311fstream_test_SOURCES = fstream_test.c
    332312avl_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
    333313all: all-am
    334314
    335315.SUFFIXES:
    336 .SUFFIXES: .c .cfa .lo .o .obj .validate
    337 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/src/cfa.make $(am__configure_deps)
     316.SUFFIXES: .c .o .obj .validate
     317$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(am__configure_deps)
    338318        @for dep in $?; do \
    339319          case '$(am__configure_deps)' in \
     
    355335            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    356336        esac;
    357 $(top_srcdir)/src/cfa.make $(am__empty):
    358337
    359338$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
     
    392371        $(AM_V_CCLD)$(LINK) $(avl_test_OBJECTS) $(avl_test_LDADD) $(LIBS)
    393372
     373fstream_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
    394377mostlyclean-compile:
    395378        -rm -f *.$(OBJEXT)
     
    399382        -rm -f *.tab.c
    400383
     384@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    401385@AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl-private.Po@am__quote@
    402386@AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl0.Po@am__quote@
     
    546530
    547531distclean: distclean-am
    548         -rm -rf avltree/$(DEPDIR)
     532        -rm -rf ./$(DEPDIR) avltree/$(DEPDIR)
    549533        -rm -f Makefile
    550534distclean-am: clean-am distclean-compile distclean-generic \
     
    592576
    593577maintainer-clean: maintainer-clean-am
    594         -rm -rf avltree/$(DEPDIR)
     578        -rm -rf ./$(DEPDIR) avltree/$(DEPDIR)
    595579        -rm -f Makefile
    596580maintainer-clean-am: distclean-am maintainer-clean-generic
     
    628612
    629613
    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 
    640614.PHONY: list .validate
    641 .INTERMEDIATE: .validate .validate.cfa
     615.INTERMEDIATE: .validate .validate.c
    642616
    643617#----------------------------------------------------------------------------------------------------------------
     
    654628        @+${TEST_PY} --list ${concurrent}
    655629
    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:
     630.validate: .validate.c
     631        $(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror
     632
     633.validate.c:
    663634        @echo "int main() { return 0; }" > ${@}
    664635
     
    667638
    668639#----------------------------------------------------------------------------------------------------------------
    669 
    670640# implicit rule so not all test require a rule
    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 ${@})
     641% : %.c $(CC)
     642        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     643
     644declarationSpecifier: declarationSpecifier.c $(CC)
     645        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     646
     647gccExtensions : gccExtensions.c $(CC)
     648        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     649
     650extension : extension.c $(CC)
     651        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     652
     653attributes : attributes.c $(CC)
     654        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     655
     656functions: functions.c $(CC)
     657        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     658
     659KRfunctions : KRfunctions.c $(CC)
     660        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     661
     662sched-ext-parse : sched-ext-parse.c $(CC)
     663        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     664
     665gmp : gmp.c $(CC)
     666        $(PRETTY_PATH) $(COMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    700667
    701668#builtins
    702 builtins/sync: builtins/sync.c $(CFACC)
    703         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
     669builtins/sync: builtins/sync.c $(CC)
     670        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
    704671
    705672#------------------------------------------------------------------------------
    706 
    707673#To make errors path independent we need to cd into the correct directories
    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 ${@})
     674completeTypeError : completeTypeError.c $(CC)
     675        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     676
     677typedefRedef-ERR1: typedefRedef.c $(CC)
     678        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     679
     680alloc-ERROR: alloc.c $(CC)
     681        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     682
     683fallthrough-ERROR: fallthrough.c $(CC)
     684        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     685
     686nested-types-ERR1: nested-types.c $(CC)
     687        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     688
     689nested-types-ERR2: nested-types.c $(CC)
     690        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    725691
    726692# Constructor/destructor tests
    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 ${@})
     693raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CC)
     694        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     695
     696raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CC)
     697        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     698
     699raii/memberCtors-ERR1: raii/memberCtors.c $(CC)
     700        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     701
     702raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CC)
     703        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
    738704
    739705# Warnings
    740 warnings/self-assignment: warnings/self-assignment.c $(CFACC)
    741         $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
     706warnings/self-assignment: warnings/self-assignment.c $(CC)
     707        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
    742708
    743709# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • tests/concurrent/coroutineYield.c

    r515a037 rcdc02f2  
    66
    77#define __kick_rate 150000ul
    8 #include "long_tests.hfa"
     8#include "long_tests.h"
    99
    1010#ifndef PREEMPTION_RATE
     
    2727        while(true) {
    2828                #if !defined(TEST_FOREVER)
    29                         sout | "Coroutine 1";
     29                        sout | "Coroutine 1" | endl;
    3030                #endif
    3131                yield();
    3232                #if !defined(TEST_FOREVER)
    33                         sout | "Coroutine 2";
     33                        sout | "Coroutine 2" | endl;
    3434                #endif
    3535                suspend();
     
    4242        for(int i = 0; TEST(i < N); i++) {
    4343                #if !defined(TEST_FOREVER)
    44                         sout | "Thread 1";
     44                        sout | "Thread 1" | endl;
    4545                #endif
    4646                resume(c);
    4747                #if !defined(TEST_FOREVER)
    48                         sout | "Thread 2";
     48                        sout | "Thread 2" | endl;
    4949                #endif
    5050                yield();
  • tests/concurrent/examples/boundedBufferEXT.c

    r515a037 rcdc02f2  
    88// Created On       : Wed Apr 18 22:52:12 2018
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue Dec 11 21:55:02 2018
    11 // Update Count     : 9
     10// Last Modified On : Thu Aug 16 08:17:03 2018
     11// Update Count     : 8
    1212//
    1313
     
    115115                sum += sums[i];
    116116        } // for
    117         sout | "total:" | sum;
     117        sout | "total:" | sum | endl;
    118118}
    119119
  • tests/concurrent/examples/boundedBufferINT.c

    r515a037 rcdc02f2  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue Dec 11 21:55:45 2018
    11 // Update Count     : 84
     10// Last Modified On : Thu Aug 16 08:17:58 2018
     11// Update Count     : 83
    1212//
    1313
     
    116116                sum += sums[i];
    117117        } // for
    118         sout | "total:" | sum;
     118        sout | "total:" | sum | endl;
    119119}
    120120
  • tests/concurrent/examples/datingService.c

    r515a037 rcdc02f2  
    88// Created On       : Mon Oct 30 12:56:20 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue Dec 11 21:55:34 2018
    11 // Update Count     : 28
     10// Last Modified On : Sun May 27 09:05:18 2018
     11// Update Count     : 26
    1212//
    1313
     
    5858        yield( random( 100 ) );                                                         // don't all start at the same time
    5959        unsigned int partner = girl( TheExchange, id, ccode );
    60         sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode;
     60        sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;
    6161        girlck[id] = partner;
    6262} // Girl main
     
    6969
    7070thread Boy {
    71         DatingService & TheExchange;
     71        DatingService &TheExchange;
    7272        unsigned int id, ccode;
    7373}; // Boy
     
    7676        yield( random( 100 ) );                                                         // don't all start at the same time
    7777        unsigned int partner = boy( TheExchange, id, ccode );
    78         sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode;
     78        sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;
    7979        boyck[id] = partner;
    8080} // Boy main
  • tests/concurrent/examples/matrixSum.c

    r515a037 rcdc02f2  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // matrixSum.cfa --
     8// matrixSum.c --
    99//
    1010// Author           : Peter A. Buhr
    1111// Created On       : Mon Oct  9 08:29:28 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Dec 11 21:54:55 2018
    14 // Update Count     : 15
     13// Last Modified On : Thu Aug  9 09:17:30 2018
     14// Update Count     : 13
    1515//
    1616
     
    5454                total += subtotals[r];                                                  // total subtotals
    5555        } // for
    56         sout | total;
     56        sout | total | endl;
    5757}
    5858
    5959// Local Variables: //
    6060// tab-width: 4 //
    61 // compile-command: "cfa matrixSum.cfa" //
     61// compile-command: "cfa matrixSum.c" //
    6262// End: //
  • tests/concurrent/examples/quickSort.c

    r515a037 rcdc02f2  
    99// Created On       : Wed Dec  6 12:15:52 2017
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Tue Dec  4 18:00:27 2018
    12 // Update Count     : 167
     11// Last Modified On : Thu Aug 16 08:17:41 2018
     12// Update Count     : 163
    1313//
    1414
     
    8888
    8989void usage( char * argv[] ) {
    90         sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )";
     90        sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl;
    9191        exit( EXIT_FAILURE );                                                           // TERMINATE!
    9292} // usage
     
    114114                                &sortedfile = new( (const char *)argv[2] ); // open the output file
    115115                                if ( fail( sortedfile ) ) {
    116                                         serr | "Error! Could not open sorted output file \"" | argv[2] | "\"";
     116                                        serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl;
    117117                                        usage( argv );
    118118                                } // if
     
    121121                                &unsortedfile = new( (const char *)argv[1] ); // open the input file
    122122                                if ( fail( unsortedfile ) ) {
    123                                         serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"";
     123                                        serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl;
    124124                                        usage( argv );
    125125                                } // if
     
    127127                } // if
    128128        } // if
    129         sortedfile | nlOff;                                                                     // turn off auto newline
    130129
    131130        enum { ValuesPerLine = 22 };                                            // number of values printed per line
     
    138137                        for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers
    139138                                unsortedfile | values[counter];
    140                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
     139                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
    141140                                sortedfile | values[counter];
    142141                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    143142                        } // for
    144                         sortedfile | nl;
     143                        sortedfile | endl;
    145144                        if ( size > 0 ) {                                                       // values to sort ?
    146145                                Quicksort QS = { values, size - 1, 0 }; // sort values
    147146                        } // wait until sort tasks terminate
    148147                        for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list
    149                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
     148                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
    150149                                sortedfile | values[counter];
    151150                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    152151                        } // for
    153                         sortedfile | nl;
     152                        sortedfile | endl | endl;
    154153
    155154                        delete( values );
  • tests/concurrent/monitor.c

    r515a037 rcdc02f2  
    4040                MyThread f[4];
    4141        }
    42         sout | global.value;
     42        sout | global.value | endl;
    4343}
  • tests/concurrent/multi-monitor.c

    r515a037 rcdc02f2  
    5252                }
    5353        }
    54         sout | global12 | global23 | global13;
     54        sout | global12 | global23 | global13 | endl;
    5555}
  • tests/concurrent/preempt.c

    r515a037 rcdc02f2  
    33#include <time.hfa>
    44
    5 #include "long_tests.hfa"
     5#include "long_tests.h"
    66
    77#ifndef PREEMPTION_RATE
  • tests/concurrent/signal/block.c

    r515a037 rcdc02f2  
    1414#include <time.hfa>
    1515
    16 #include "long_tests.hfa"
     16#include "long_tests.h"
    1717
    1818#ifndef PREEMPTION_RATE
     
    5757
    5858        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;
     59                sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread | endl;
    6060                abort();
    6161        }
     
    8585
    8686                if( ! signal_block( cond ) ) {
    87                         sout | "ERROR expected to be able to signal";
     87                        sout | "ERROR expected to be able to signal" | endl;
    8888                        abort();
    8989                }
     
    9292
    9393                if(a.last_thread != next || b.last_thread != next) {
    94                         sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread;
     94                        sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread | endl;
    9595                        abort();
    9696                }
     
    130130                Signaller s[4];
    131131                Barger b[13];
    132                 sout | "Starting waiters";
     132                sout | "Starting waiters" | endl;
    133133                {
    134134                        Waiter w[3];
    135135                }
    136                 sout | "Waiters done";
     136                sout | "Waiters done" | endl;
    137137                done = true;
    138138        }
  • tests/concurrent/signal/disjoint.c

    r515a037 rcdc02f2  
    55#include <time.hfa>
    66
    7 #include "long_tests.hfa"
     7#include "long_tests.h"
    88
    99#ifndef PREEMPTION_RATE
     
    6666        wait( cond );
    6767        if( d.state != SIGNAL ) {
    68                 sout | "ERROR barging!";
     68                sout | "ERROR barging!" | endl;
    6969        }
    7070
    7171        #if !defined(TEST_FOREVER)
    7272                d.counter++;
    73                 if( (d.counter % 1000) == 0 ) sout | d.counter;
     73                if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
    7474        #endif
    7575
     
    9999        bool running = TEST(data.counter < N) && data.counter > 0;
    100100        if( data.state != SIGNAL && running ) {
    101                 sout | "ERROR Eager signal" | data.state;
     101                sout | "ERROR Eager signal" | data.state | endl;
    102102        }
    103103}
     
    124124                        Waiter w[4];
    125125                }
    126                 sout | "All waiter done";
     126                sout | "All waiter done" | endl;
    127127                all_done = true;
    128128        }
  • tests/concurrent/signal/wait.c

    r515a037 rcdc02f2  
    1313
    1414#define __kick_rate 12000ul
    15 #include "long_tests.hfa"
     15#include "long_tests.h"
    1616
    1717#ifndef PREEMPTION_RATE
     
    8383                                break;
    8484                        default:
    85                                 sout | "Something went wrong";
     85                                sout | "Something went wrong" | endl;
    8686                                abort();
    8787                }
     
    140140        waiter_left = 4;
    141141        processor p[2];
    142         sout | "Starting";
     142        sout | "Starting" | endl;
    143143        {
    144144                Signaler  e;
     
    150150                }
    151151        }
    152         sout | "Done";
     152        sout | "Done" | endl;
    153153}
  • tests/concurrent/thread.c

    r515a037 rcdc02f2  
    1212void main(First& this) {
    1313        for(int i = 0; i < 10; i++) {
    14                 sout | "First : Suspend No." | i + 1;
     14                sout | "First : Suspend No." | i + 1 | endl;
    1515                yield();
    1616        }
     
    2121        P(*this.lock);
    2222        for(int i = 0; i < 10; i++) {
    23                 sout | "Second : Suspend No." | i + 1;
     23                sout | "Second : Suspend No." | i + 1 | endl;
    2424                yield();
    2525        }
     
    2929int main(int argc, char* argv[]) {
    3030        semaphore lock = { 0 };
    31         sout | "User main begin";
     31        sout | "User main begin" | endl;
    3232        {
    3333                processor p;
     
    3737                }
    3838        }
    39         sout | "User main end";
     39        sout | "User main end" | endl;
    4040}
  • tests/concurrent/waitfor/barge.c

    r515a037 rcdc02f2  
    4848        yield(random( 10 ));
    4949        if( this.state != WAITFOR && !this.done && this.started ) {
    50                 serr | "Barging before caller detected";
     50                serr | "Barging before caller detected" | endl;
    5151        }
    5252
     
    6666                this.state = WAITFOR;
    6767                waitfor(do_call, this) {
    68                         sout | i;
     68                        sout | i | endl;
    6969                }
    7070
    7171                if( this.state != CALL ) {
    72                         serr | "Barging after caller detected";
     72                        serr | "Barging after caller detected" | endl;
    7373                }
    7474        }
     
    8383
    8484int main() {
    85         sout | "Starting";
     85        sout | "Starting" | endl;
    8686        {
    8787                barger_t bargers[17];
     
    8989                waiter_t waiters;
    9090        }
    91         sout | "Stopping";
     91        sout | "Stopping" | endl;
    9292}
  • tests/concurrent/waitfor/dtor.c

    r515a037 rcdc02f2  
    2929        switch(state) {
    3030                case CTOR  : 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;
     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;
    3535        }
    3636}
     
    5454
    5555int main() {
    56         sout | "Starting";
     56        sout | "Starting" | endl;
    5757        processor p;
    5858        for( int i = 0; i < N; i++ ){
     
    6060                yield( random( 100 ) );
    6161        }
    62         sout | "Stopping";
     62        sout | "Stopping" | endl;
    6363}
  • tests/concurrent/waitfor/else.c

    r515a037 rcdc02f2  
    1212void test( M & mutex m ) {
    1313        int i = 0;
    14         sout | "Starting";
     14        sout | "Starting" | endl;
    1515
    1616        when( false ) waitfor( notcalled, m );
    1717
    18         sout | "Step" | i++;
     18        sout | "Step" | i++ | endl;
    1919
    2020        waitfor( notcalled, m ); or else {
    21                 sout | "else called";
     21                sout | "else called" | endl;
    2222        }
    2323
    24         sout | "Step" | i++;
     24        sout | "Step" | i++ | endl;
    2525
    2626        when( true ) waitfor( notcalled, m ); or when( true ) else {
    27                 sout | "else called";
     27                sout | "else called" | endl;
    2828        }
    2929
    30         sout | "Step" | i++;
     30        sout | "Step" | i++ | endl;
    3131
    3232        when( false ) waitfor( notcalled, m ); or when( true ) else {
    33                 sout | "else called";
     33                sout | "else called" | endl;
    3434        }
    3535
    36         sout | "Step" | i++;
     36        sout | "Step" | i++ | endl;
    3737
    3838        when( false ) waitfor( notcalled, m ); or when( false ) else {
    39                 sout | "else called";
     39                sout | "else called" | endl;
    4040        }
    4141
    42         sout | "Done";
     42        sout | "Done" | endl;
    4343}
    4444
  • tests/concurrent/waitfor/recurse.c

    r515a037 rcdc02f2  
    9595        rand_yield();
    9696
    97         sout | "1st" | nl;
     97        sout | "1st" | endl;
    9898
    9999        return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
     
    123123                        case THIRD  : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break;
    124124                        case LAST   : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break;
    125                         case STOP   : serr | "This should not happen" | nl;
     125                        case STOP   : serr | "This should not happen" | endl;
    126126                }
    127127        }
     
    132132int main() {
    133133        srandom( time(NULL) );
    134         sout | nlOff;                                   // turn off auto newline
    135         sout | "Starting" | nl;
     134        sout | "Starting" | endl;
    136135        {
    137136                waiter_t waiters[4] = {
     
    143142                the_threads = waiters;
    144143        }
    145         sout | "Stopping" | nl;
     144        sout | "Stopping" | endl;
    146145}
  • tests/concurrent/waitfor/simple.c

    r515a037 rcdc02f2  
    3131
    3232void do_wait( global_t * mutex a ) {
    33         sout | "Waiting to accept";
     33        sout | "Waiting to accept" | endl;
    3434        yield( random( 10 ) );
    3535
    36         sout | "Accepting";
     36        sout | "Accepting" | endl;
    3737
    3838        __acceptable_t acceptable;
     
    4343        __waitfor_internal( 1, &acceptable );
    4444
    45         sout | "Accepted";
     45        sout | "Accepted" | endl;
    4646        yield( random( 10 ) );
    4747}
     
    5050        for( int i = 0; i < N; i++ ) {
    5151                do_wait( &globalA );
    52                 sout | i;
     52                sout | i | endl;
    5353        }
    5454
     
    7676        srandom( time( NULL ) );
    7777        printf("%p\n", &globalA);
    78         sout | "Starting";
     78        sout | "Starting" | endl;
    7979        {
    8080                Acceptor r;
     
    8282
    8383        }
    84         sout | "Done";
     84        sout | "Done" | endl;
    8585}
  • tests/concurrent/waitfor/statment.c

    r515a037 rcdc02f2  
    8484                case 7: return call7( m );
    8585                default :
    86                         serr | "Incorrect index" | index;
     86                        serr | "Incorrect index" | index | endl;
    8787                        abort();
    8888        }
     
    102102        while( !done ) {
    103103                   waitfor( get_index, this );
    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; } }
     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; } }
    111111
    112112                done = true;
     
    128128int main() {
    129129        processor p[2];
    130         sout | "Starting";
     130        sout | "Starting" | endl;
    131131        {
    132132                caller c[7];
    133133                waiter w;
    134134        }
    135         sout | "Stopping";
     135        sout | "Stopping" | endl;
    136136}
  • tests/concurrent/waitfor/when.c

    r515a037 rcdc02f2  
    5858void arbiter( global_t & mutex this ) {
    5959        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; } }
    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; } }
     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; } }
    6666
    67                 sout | this.last_call;
     67                sout | this.last_call | endl;
    6868        }
    6969
     
    7878int main() {
    7979        srandom( time(NULL) );
    80         sout | "Starting";
     80        sout | "Starting" | endl;
    8181        {
    8282                arbiter_t arbiter;
     
    8484
    8585        }
    86         sout | "Stopping";
     86        sout | "Stopping" | endl;
    8787}
  • tests/coroutine/.expect/fmtLines.txt

    r515a037 rcdc02f2  
    1616difi  ed B  y :   Pete  r A. 
    1717 Buh  r//   Last   Mod  ifie 
    18 d On   : T  ue D  ec 1  1 23 
    19 :31:  12 2  018/  / Up  date 
    20  Cou  nt       :   32/  /#in 
     18d On   : M  on S  ep 1  8 11 
     19:35:  57 2  017/  / Up  date 
     20 Cou  nt       :   31/  /#in 
    2121clud  e <f  stre  am.h  fa># 
    2222incl  ude   <cor  outi  ne.h 
     
    3434t )   {      if   ( fm  t.g   
    3535!= 0   ||   fmt.  b !=   0 ) 
    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: /  /
     36 sou  t |   endl  ;}vo  id m 
     37ain(   For  mat   & fm  t )   
     38{       fo  r (   ;; )   {                                               
     39                                  // f  or a  s ma  ny c 
     40hara  cter  s           f  or (   fmt 
     41.g =   0;   fmt.  g <   5; f 
     42mt.g   +=   1 )   {             /  / gr 
     43oups   of   5 bl  ocks                          f 
     44or (   fmt  .b =   0;   fmt. 
     45b <   4; f  mt.b   +=   1 )   
     46{       //   blo  cks   of 4   cha 
     47ract  ers                               f  or (   ;;   
     48) {                                                     //   for   new 
     49line   cha  ract  ers                                     
     50susp  end(  );                                  i  f (   
     51fmt.  ch !  = '\  n' )   bre 
     52ak;             //   igno  re n  ewli 
     53ne                              }   // f  or                            so 
     54ut |   fmt  .ch;                                                        / 
     55/ pr  int   char  acte  r                         
     56} //   for                      s  out   | "   
     57 ";                                                             /  / pr  int   
     58bloc  k se  para  tor           } / 
     59/ fo  r         s  out   | en  dl;       
     60                                                                  // p  rint   gro 
     61up s  epar  ator        } /  / fo 
     62r} /  / ma  invo  id p  rt(   
     63Form  at &   fmt  , ch  ar c 
     64h )   {      fmt  .ch   = ch 
     65;      res  ume(   fmt   );} 
     66 //   prti  nt m  ain(  ) {       
     67Form  at f  mt;   char   ch; 
     68        for   ( ;  ; )   {              s  in | 
     69 ch;                                                                            //   rea 
     70d on  e ch  arac  ter       if 
     71 ( e  of(   sin   ) )   brea 
     72k;                                                      //   eof   ?            p 
     73rt(   fmt,   ch   );    }   //   
     74for}   //   main  // L  ocal 
     75 Var  iabl  es:   ////   tab 
     76-wid  th:   4 //  // c  ompi 
     77le-c  omma  nd:   "cfa   fmt 
     78Line  s.c"   ///  / En  d: / 
     79/
  • tests/coroutine/.in/fmtLines.txt

    r515a037 rcdc02f2  
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 23:31:12 2018
    13 // Update Count     : 32
     12// Last Modified On : Mon Sep 18 11:35:57 2017
     13// Update Count     : 31
    1414//
    1515
     
    2727
    2828void ^?{}( Format & fmt ) {
    29     if ( fmt.g != 0 || fmt.b != 0 ) sout | nl;
     29    if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;
    3030}
    3131
     
    4242                        sout | "  ";                                                            // print block separator
    4343                } // for
    44                 sout | nl;                                                                      // print group separator
     44                sout | endl;                                                                    // print group separator
    4545        } // for
    4646} // main
  • tests/coroutine/fibonacci.c

    r515a037 rcdc02f2  
    1010// Created On       : Thu Jun  8 07:29:37 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:57:33 2018
    13 // Update Count     : 25
     12// Last Modified On : Sat Aug 18 11:21:58 2018
     13// Update Count     : 24
    1414//
    1515
     
    3939        Fibonacci f1, f2;
    4040        for ( 10 ) {                                                                            // print N Fibonacci values
    41                 sout | next( f1 ) | next( f2 );
     41                sout | next( f1 ) | next( f2 ) | endl;
    4242        } // for
    4343}
  • tests/coroutine/fibonacci_1.c

    r515a037 rcdc02f2  
    1010// Created On       : Thu Apr 26 23:20:08 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:57:54 2018
    13 // Update Count     : 14
     12// Last Modified On : Sat Aug 18 11:21:02 2018
     13// Update Count     : 13
    1414//
    1515
     
    3636        Fibonacci f1, f2;
    3737        for ( 10 ) {                                                                            // print N Fibonacci values
    38                 sout | next( f1 ) | next( f2 );
     38                sout | next( f1 ) | next( f2 ) | endl;
    3939        } // for
    4040}
  • tests/coroutine/fmtLines.c

    r515a037 rcdc02f2  
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:58:49 2018
    13 // Update Count     : 47
     12// Last Modified On : Thu Aug 16 08:20:54 2018
     13// Update Count     : 45
    1414//
    1515
     
    3434                        sout | "  ";                                                            // print block separator
    3535                } // for
    36                 sout | nl;                                                                              // print group separator
     36                sout | endl;                                                                    // print group separator
    3737        } // for
    3838} // main
     
    4343
    4444void ^?{}( Format & fmt ) with( fmt ) {
    45         if ( g != 0 || b != 0 ) sout | nl;
     45        if ( g != 0 || b != 0 ) sout | endl;
    4646}
    4747
     
    5252int main() {
    5353        Format fmt;
    54         sout | nlOff;                                                                           // turn off auto newline
    5554
    5655  eof: for () {                                                                                 // read until end of file
  • tests/coroutine/pingpong.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed Sep 20 11:55:23 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:58:06 2018
    13 // Update Count     : 29
     12// Last Modified On : Sat Aug 18 11:31:11 2018
     13// Update Count     : 28
    1414//
    1515
     
    4040void main( PingPong & pingpong ) {                                              // ping's starter ::main, pong's starter ping
    4141        for ( pingpong.N ) {                                                            // N ping-pongs
    42                 sout | pingpong.name;
     42                sout | pingpong.name | endl;
    4343                cycle( *pingpong.part );
    4444        } // for
  • tests/coroutine/prodcons.c

    r515a037 rcdc02f2  
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:58:25 2018
    13 // Update Count     : 52
     12// Last Modified On : Sat Aug 18 12:55:10 2018
     13// Update Count     : 51
    1414//
    1515
     
    3232                int p1 = random( 100 );
    3333                int p2 = random( 100 );
    34                 sout | p1 | " " | p2;
     34                sout | p1 | " " | p2 | endl;
    3535                int status = delivery( *c, p1, p2 );
    36                 sout | " $" | money;
    37                 sout | status;
     36                sout | " $" | money | endl;
     37                sout | status | endl;
    3838                receipt += 1;
    3939        }
    4040        stop( *c );
    41         sout | "prod stops";
     41        sout | "prod stops" | endl;
    4242}
    4343int payment( Prod & prod, int money ) {
     
    6868        int money = 1, receipt;
    6969        for ( ; ! done; ) {
    70                 sout | p1 | " " | p2;
    71                 sout | " $" | money;
     70                sout | p1 | " " | p2 | endl;
     71                sout | " $" | money | endl;
    7272                status += 1;
    7373                receipt = payment( *p, money );
    74                 sout | " #" | receipt;
     74                sout | " #" | receipt | endl;
    7575                money += 1;
    7676        }
    77         sout | "cons stops";
     77        sout | "cons stops" | endl;
    7878}
    7979int delivery( Cons & cons, int p1, int p2 ) {
     
    9292        srandom( /* getpid() */ 103 );                                          // fixed seed for testing
    9393        start( prod, 5, cons );
    94         sout | "main stops";
     94        sout | "main stops" | endl;
    9595}
    9696
  • tests/coroutine/runningTotal.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed Dec  6 08:05:27 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 21:59:00 2018
    13 // Update Count     : 4
     12// Last Modified On : Thu Aug 16 08:22:29 2018
     13// Update Count     : 3
    1414//
    1515
     
    4242        RunTotal rntl;
    4343        for ( i; 10 ) {
    44                 sout | i | add( rntl, i );
     44                sout | i | add( rntl, i ) | endl;
    4545        } // for
    4646}
  • tests/preempt_longrun/create.c

    r515a037 rcdc02f2  
    33#include <time.hfa>
    44
    5 #include "long_tests.hfa"
     5#include "long_tests.h"
    66
    77#ifndef PREEMPTION_RATE
  • tests/preempt_longrun/enter3.c

    r515a037 rcdc02f2  
    55
    66#define __kick_rate 75000ul
    7 #include "long_tests.hfa"
     7#include "long_tests.h"
    88
    99#ifndef PREEMPTION_RATE
  • tests/preempt_longrun/processor.c

    r515a037 rcdc02f2  
    55#include <unistd.h>
    66
    7 #include "long_tests.hfa"
     7#include "long_tests.h"
    88
    99#ifndef PREEMPTION_RATE
  • tests/preempt_longrun/yield.c

    r515a037 rcdc02f2  
    44
    55#define __kick_rate 550000ul
    6 #include "long_tests.hfa"
     6#include "long_tests.h"
    77
    88#ifndef PREEMPTION_RATE
  • tests/raii/dtor-early-exit.c

    r515a037 rcdc02f2  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 11 22:05:24 2018
    13 // Update Count     : 9
     12// Last Modified On : Sat Aug 11 07:58:39 2018
     13// Update Count     : 8
    1414//
    1515
     
    2525// don't want these called
    2626void ?{}(A & a) { assert( false ); }
    27 void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name; a.x = (int*)malloc(); }
     27void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name | endl; a.x = (int*)malloc(); }
    2828void ?{}(A & a, const char * name, int * ptr) { assert( false ); }
    2929
    3030A ?=?(A & a, A b) {  sout | "assign " | a.name | " " | b.name; return a; }
    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); }
     31void ?{}(A & a, A b) { sout | "copy construct " | b.name | endl; a.x = (int*)malloc(); }
     32void ^?{}(A & a) { sout | "destruct " | a.name | endl; free(a.x); }
    3333
    3434// test returns
    3535void f(int i) {
    36         sout | "f i=" | i;
     36        sout | "f i=" | i | endl;
    3737        A x = { "x" };  // construct x
    3838        {
     
    5555void g() {
    5656        for (int i = 0; i < 10; i++) {
    57                 sout | "g for i=" | i;
     57                sout | "g for i=" | i | endl;
    5858                A x = { "x" };
    5959                // construct x
    6060                // destruct x
    6161        }
    62         sout | nl;
     62        sout | endl;
    6363        {
    6464                int i = 0;
    6565                while (i < 10) {
    66                         sout | "g while i=" | i;
     66                        sout | "g while i=" | i | endl;
    6767                        A x = { "x" };
    6868                        // construct x
     
    7171                }
    7272        }
    73         sout;
     73        sout | endl;
    7474        for (int i = 0; i < 10; i++) {
    7575                switch(10) {
     
    7878                        case 10: {
    7979                                A y = { "y" };
    80                                 sout | "g switch i=" | i;
     80                                sout | "g switch i=" | i | endl;
    8181                                // construct y
    8282                                break; // destruct y
    8383                        }
    8484                        default: {
    85                                 sout | "g switch i=" | i;
     85                                sout | "g switch i=" | i | endl;
    8686                                A x = { "x" };
    8787                                // construct x
     
    9090                }
    9191        }
    92         sout | nl;
     92        sout | endl;
    9393        for (int k = 0; k < 2; k++) {
    94                 sout | "g for k=" | k;
     94                sout | "g for k=" | k | endl;
    9595                L1: for (int i = 0; i < 10; i++) {
    96                         sout | "g for i=" | i;
     96                        sout | "g for i=" | i | endl;
    9797
    9898                        A x = { "x" };
    9999                        if (i == 2) {
    100                                 sout | "continue L1";
     100                                sout | "continue L1" | endl;
    101101                                continue;  // destruct x
    102102                        } else if (i == 3) {
    103                                 sout | "break L1";
     103                                sout | "break L1" | endl;
    104104                                break;  // destruct x
    105105                        }
    106106
    107107                        L2: for (int j = 0; j < 10; j++) {
    108                                 sout | "g for j=" | j;
     108                                sout | "g for j=" | j | endl;
    109109                                A y = { "y" };
    110110                                if (j == 0) {
    111                                         sout | "continue L2";
     111                                        sout | "continue L2" | endl;
    112112                                        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
    113113                                } else if (j == 1) {
    114                                         sout | "break L2";
     114                                        sout | "break L2" | endl;
    115115                                        break;  // destruct y
    116116                                } else if (i == 1) {
    117                                         sout | "continue L1";
     117                                        sout | "continue L1" | endl;
    118118                                        continue L1; // destruct x,y - note: continue takes you to destructors for block, so only generate destructor for y
    119119                                } else if (k == 1) {
    120                                         sout | "break L1";
     120                                        sout | "break L1" | endl;
    121121                                        break L1;  // destruct x,y
    122122                                }
     
    125125        }
    126126
    127         sout | nl;
     127        sout | endl;
    128128        L3: if( 3 ) {
    129129                A w = { "w" };
    130130                if( 4 ) {
    131131                        A v = { "v" };
    132                         sout | "break L3";
     132                        sout | "break L3" | endl;
    133133                        break L3;
    134134                }
     
    144144        // * if S_L-S_G is non-empty, error
    145145        // * emit destructors for all variables in S_G-S_L
    146         sout | "h";
     146        sout | "h" | endl;
    147147        {
    148148                L0: ;
     
    152152                        A y = { "y" };
    153153                        // S_L1 = { y }
    154                 L1: sout | "L1";
     154                L1: sout | "L1" | endl;
    155155                        A x = { "x" };
    156156                        // S_L2 = { y, x }
    157                 L2: sout | "L2";
     157                L2: sout | "L2" | endl;
    158158                        if (i == 0) {
    159159                                ++i;
    160                                 sout | "goto L1";
     160                                sout | "goto L1" | endl;
    161161                                // S_G = { y, x }
    162162                                goto L1;  // jump back, destruct b/c before x definition
     
    165165                        } else if (i == 1) {
    166166                                ++i;
    167                                 sout | "goto L2";
     167                                sout | "goto L2" | endl;
    168168                                // S_G = { y, x }
    169169                                goto L2;  // jump back, do not destruct
     
    172172                        } else if (i == 2) {
    173173                                ++i;
    174                                 sout | "goto L3";
     174                                sout | "goto L3" | endl;
    175175                                // S_G = { y, x }
    176176                                goto L3;  // jump ahead, do not destruct
     
    180180                                ++i;
    181181                                A z = { "z" };
    182                                 sout | "goto L3-2";
     182                                sout | "goto L3-2" | endl;
    183183                                // S_G = { z, y, x }
    184184                                goto L3;
     
    187187                        } else {
    188188                                ++i;
    189                                 sout | "goto L4";
     189                                sout | "goto L4" | endl;
    190190                                // S_G = { y, x }
    191191                                goto L4;  // jump ahead, destruct b/c left block x was defined in
     
    194194                        }
    195195                        // S_L3 = { y, x }
    196                 L3: sout | "L3";
    197                         sout | "goto L2-2";
     196                L3: sout | "L3" | endl;
     197                        sout | "goto L2-2" | endl;
    198198                        // S_G = { y, x }
    199199                        goto L2; // jump back, do not destruct
     
    202202        }
    203203        // S_L4 = {}
    204         L4: sout | "L4";
     204        L4: sout | "L4" | endl;
    205205        if (i == 4) {
    206                 sout | "goto L0";
     206                sout | "goto L0" | endl;
    207207                // S_G = {}
    208208                goto L0;
     
    240240                f(i);
    241241        }
    242         sout | nl;
     242        sout | endl;
    243243        g();
    244         sout | nl;
     244        sout | endl;
    245245        h();
    246246
  • tests/raii/globals.c

    r515a037 rcdc02f2  
    7070
    7171int main() {
    72         sout | "static\t\tinline\t\tautogen\t\tvalue";
     72        sout | "static\t\tinline\t\tautogen\t\tvalue" | endl;
    7373
    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;
     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;
    8282
    8383}
  • tests/tuple/tupleAssign.c

    r515a037 rcdc02f2  
    1010// Created On       : Tue Nov 15 17:24:32 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 22:03:48 2018
    13 // Update Count     : 35
     12// Last Modified On : Mon Mar  6 21:23:58 2017
     13// Update Count     : 34
    1414//
    1515
     
    2424                // swap x, y and store the new [x, y] in [u, v] and in z;
    2525                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 | "]";
     26                sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;
    2727                z = [u, v] = [x, y] = [y, x];
    2828                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 | "]";
     29                sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;
    3030
    3131                // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v
    3232                [v, z, u] = [z, u, v];
    3333                printf( "u=%d v=%d z=[%d, %d]\n", u, v, z );
    34                 sout | "u=" | u | "v=" | v | "z=[" | z | "]";
     34                sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;
    3535
    3636                // multiple assignment with tuple expression on right
     
    3838                [u, v] = [123, 456];
    3939                printf( "u=%d v=%d z=[%d, %d]\n", u, v, z );
    40                 sout | "u=" | u | "v=" | v | "z=[" | z | "]";
     40                sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;
    4141        }
    4242        {
     
    5555                [t, x, d, i, c, x] = (double)94.12;
    5656                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 | "]";
     57                sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;
    5858                [x, c, i, d, x, t] = (double)-94.12;
    5959                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 | "]";
     60                sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;
    6161        }
    6262}
Note: See TracChangeset for help on using the changeset viewer.