Changeset b1e63ac5


Ignore:
Timestamp:
Jul 4, 2017, 9:40:16 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
208e5be
Parents:
9c951e3 (diff), f7cb0bc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

Files:
79 added
12 deleted
159 edited
19 moved

Legend:

Unmodified
Added
Removed
  • .gitignore

    r9c951e3 rb1e63ac5  
    1313libcfa/Makefile
    1414src/Makefile
    15 version
     15/version
    1616
    1717# genereted by premake
     
    3131
    3232src/prelude/builtins.cf
    33 src/prelude/builtins.c
     33src/prelude/gcc-builtins.cf
     34src/prelude/gcc-builtins.c
    3435src/prelude/extras.cf
    3536src/prelude/bootloader.c
    3637src/libcfa/libcfa-prelude.c
    3738
    38 # generated by bison and lex from cfa.yy and lex.ll, respectively
     39# generated by bison and lex from parser.yy and lex.ll
    3940src/Parser/parser.output
    4041src/Parser/lex.cc
     
    4243src/Parser/parser.h
    4344
     45tools/prettyprinter/parser.output
     46tools/prettyprinter/lex.cc
     47tools/prettyprinter/parser.cc
     48tools/prettyprinter/parser.h
     49tools/prettyprinter/pretty
     50tools/pretty
     51
    4452# generated by xfig for user manual
    4553doc/user/Cdecl.tex
  • Jenkins/FullBuild

    r9c951e3 rb1e63ac5  
    161161"""
    162162
    163         def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com, ajbeach@edu.uwaterloo.ca"
     163        def email_to = "cforall@lists.uwaterloo.ca"
    164164
    165165        //send email notification
  • Jenkinsfile

    r9c951e3 rb1e63ac5  
    2828                wrap([$class: 'TimestamperBuildWrapper']) {
    2929
    30                         notify_server()
     30                        notify_server(0)
    3131
    3232                        prepare_build()
     
    3434                        checkout()
    3535
     36                        notify_server(0)
     37
    3638                        build()
    3739
     
    4648                        publish()
    4749
    48                         notify_server()
     50                        notify_server(45)
    4951                }
    5052        }
     
    171173}
    172174
    173 def notify_server() {
    174         sh 'curl --silent -X POST http://plg2:8082/jenkins/notify > /dev/null || true'
     175def notify_server(int wait) {
     176        sh """curl --silent --data "wait=${wait}" -X POST http://plg2:8082/jenkins/notify > /dev/null || true"""
    175177        return
    176178}
     
    374376"""
    375377
    376         def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com, ajbeach@edu.uwaterloo.ca"
     378        def email_to = "cforall@lists.uwaterloo.ca"
    377379
    378380        //send email notification
  • configure

    r9c951e3 rb1e63ac5  
    24962496
    24972497
    2498 if test "x${CXXFLAGS}" = "x"; then
    2499    export CXXFLAGS="-std=c++11 -g ${CXXFLAGS}"  # defaults, no -O2 for debugging and failures
    2500 else
    2501    export CXXFLAGS="-std=c++11 ${CXXFLAGS}"     # flags from configure command
    2502 fi
    2503 
    25042498am__api_version='1.11'
    25052499
     
    62576251
    62586252
    6259 ac_config_files="$ac_config_files Makefile src/driver/Makefile src/Makefile src/benchmark/Makefile src/examples/Makefile src/tests/Makefile src/prelude/Makefile src/libcfa/Makefile"
     6253ac_config_files="$ac_config_files Makefile src/driver/Makefile src/Makefile src/benchmark/Makefile src/examples/Makefile src/tests/Makefile src/tests/preempt_longrun/Makefile src/prelude/Makefile src/libcfa/Makefile tools/prettyprinter/Makefile"
    62606254
    62616255
     
    70257019    "src/examples/Makefile") CONFIG_FILES="$CONFIG_FILES src/examples/Makefile" ;;
    70267020    "src/tests/Makefile") CONFIG_FILES="$CONFIG_FILES src/tests/Makefile" ;;
     7021    "src/tests/preempt_longrun/Makefile") CONFIG_FILES="$CONFIG_FILES src/tests/preempt_longrun/Makefile" ;;
    70277022    "src/prelude/Makefile") CONFIG_FILES="$CONFIG_FILES src/prelude/Makefile" ;;
    70287023    "src/libcfa/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcfa/Makefile" ;;
     7024    "tools/prettyprinter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/prettyprinter/Makefile" ;;
    70297025
    70307026  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
  • configure.ac

    r9c951e3 rb1e63ac5  
    88AC_CONFIG_HEADERS([config.h])
    99AM_SILENT_RULES([no])
    10 
    11 if test "x${CXXFLAGS}" = "x"; then
    12    export CXXFLAGS="-std=c++11 -g ${CXXFLAGS}"  # defaults, no -O2 for debugging and failures
    13 else
    14    export CXXFLAGS="-std=c++11 ${CXXFLAGS}"     # flags from configure command
    15 fi
    1610
    1711AM_INIT_AUTOMAKE
     
    241235        src/examples/Makefile
    242236        src/tests/Makefile
     237        src/tests/preempt_longrun/Makefile
    243238        src/prelude/Makefile
    244239        src/libcfa/Makefile
     240        tools/prettyprinter/Makefile
    245241        ])
    246242
  • doc/LaTeXmacros/common.tex

    r9c951e3 rb1e63ac5  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon May 15 18:03:29 2017
    14 %% Update Count     : 302
     13%% Last Modified On : Sun Jun 18 20:32:32 2017
     14%% Update Count     : 319
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
    38 \newcommand{\CFA}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
     38\newcommand{\CFAIcon}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
     39\newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption
    3940\newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name
    4041\newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name
     
    241242belowskip=3pt,
    242243% replace/adjust listing characters that look bad in sanserif
    243 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
     244literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
    244245        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
    245         {__}{\_\,\_}2 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2
    246         {___}{\_\,\_\,\_}3,
     246        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
    247247moredelim=**[is][\color{red}]{®}{®},                                    % red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
    248248moredelim=**[is][\color{blue}]{ß}{ß},                                   % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
  • doc/LaTeXmacros/lstlang.sty

    r9c951e3 rb1e63ac5  
    88%% Created On       : Sat May 13 16:34:42 2017
    99%% Last Modified By : Peter A. Buhr
    10 %% Last Modified On : Sat May 13 16:49:09 2017
    11 %% Update Count     : 4
     10%% Last Modified On : Fri May 26 12:47:09 2017
     11%% Update Count     : 8
    1212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1313
     
    107107\lstdefinelanguage{CFA}[ANSI]{C}{
    108108        morekeywords={
    109                 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, _Atomic, __attribute,
     109                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute,
    110110                __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__,
    111                 __const, __const__, coroutine, disable, dtype, enable, __extension__, fallthrough, fallthru,
    112                 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, monitor, mutex,
    113                 _Noreturn, one_t, otype, restrict, _Static_assert, thread, _Thread_local, throw, throwResume,
    114                 trait, try, ttype, typeof, __typeof, __typeof__, zero_t},
     111                __const, __const__, disable, dtype, enable, __extension__, fallthrough, fallthru,
     112                finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
     113                otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
     114                __typeof__, zero_t},
     115        morekeywords=[2]{
     116                _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex,
     117                resume, suspend, thread, _Thread_local, yield},
     118}
     119
     120% uC++ programming language, based on ANSI C++
     121\lstdefinelanguage{uC++}[ANSI]{C++}{
     122        morekeywords={
     123                _Accept, _AcceptReturn, _AcceptWait, _Actor, _At, _CatchResume, _Cormonitor, _Coroutine, _Disable,
     124                _Else, _Enable, _Event, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask,
     125                _Resume, _Select, _SporadicTask, _Task, _Timeout, _When, _With, _Throw},
    115126}
    116127
  • doc/bibliography/cfa.bib

    r9c951e3 rb1e63ac5  
    862862}
    863863
    864 @techreport{C11,
    865     type        = {International Standard},
     864@manual{C11,
    866865    keywords    = {ISO/IEC C 11},
    867866    contributer = {pabuhr@plg},
    868     key         = {{ISO/IEC} 9889-2011},
    869     title       = {American National Standard Information technology -- Programming Languages -- {C}},
    870     institution = {International Standard Organization},
    871     address     = {http://www.iso.org},
     867    author      = {C11},
     868    title       = {Programming Languages -- {C} {ISO/IEC} 9889:2011},
     869    edition     = {3rd},
     870    publisher   = {International Standard Organization},
     871    address     = {\href{https://www.iso.org/standard/57853.html}{https://\-www.iso.org/\-standard/\-57853.html}},
    872872    year        = 2012,
    873873}
     
    877877    keywords    = {ISO/IEC TS 19217:2015},
    878878    contributer = {a3moss@uwaterloo.ca},
    879     key         = {{ISO/IEC} {TS} 19217},
    880879    author      = {Concepts},
    881     title       = {Information technology -- Programming languages -- {C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Extensions for concepts},
    882     institution = {International Standard Organization},
    883     address     = {http://www.iso.org},
     880    title       = {Information technology -- Programming languages -- {C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Extensions for concepts {ISO/IEC} {TS} 19217:2015},
     881    publisher   = {International Standard Organization},
     882    address     = {\href{https://www.iso.org/standard/64031.html}{https://\-www.iso.org/\-standard/\-64031.html}},
    884883    year        = 2015
    885884}
     
    10961095    keywords    = {ISO/IEC Cobol 14},
    10971096    contributer = {pabuhr@plg},
    1098     key         = {Cobol14},
    1099     title       = {Programming Languages -- {Cobol}},
     1097    author      = {Cobol14},
     1098    title       = {Programming Languages -- {Cobol} ISO/IEC 1989:2014},
    11001099    edition     = {2nd},
    1101     organization= {International Standard ISO/IEC 1989:2014},
    1102     publisher   = {International Standard Organization},
    1103     address     = {http://www.iso.org},
     1100    institution = {International Standard Organization},
     1101    address     = {\href{https://www.iso.org/standard/51416.html}{https://\-www.iso.org/\-standard/\-51416.html}},
    11041102    year        = 2014,
    11051103}
     
    28362834    keywords    = {ISO/IEC Fortran 08},
    28372835    contributer = {pabuhr@plg},
    2838     key         = {Fortran08},
    2839     title       = {Programming Languages -- {Fortran} Part 1},
    2840     organization= {International Standard ISO/IEC 1989:2014},
     2836    author      = {Fortran08},
     2837    title       = {Programming Languages -- {Fortran} Part 1:Base Language ISO/IEC 1539-1:2010},
     2838    edition     = {3rd},
    28412839    publisher   = {International Standard Organization},
    2842     address     = {http://www.iso.org},
     2840    address     = {\href{https://www.iso.org/standard/50459.html}{https://\-www.iso.org/\-standard/\-50459.html}},
    28432841    year        = 2010,
    28442842}
     
    30373035    year        = 1992,
    30383036    pages       = {T1-53},
     3037}
     3038
     3039@manual{GMP,
     3040    keywords    = {GMP arbitrary-precision library},
     3041    contributer = {pabuhr@plg},
     3042    title       = {{GNU} Multiple Precision Arithmetic Library},
     3043    author      = {GMP},
     3044    organization= {GNU},
     3045    year        = 2016,
     3046    note        = {\href{https://gmplib.org}{https://\-gmplib.org}},
    30393047}
    30403048
     
    44164424    keywords    = {Plan 9},
    44174425    contributer = {pabuhr@plg},
    4418     title       = {A New C Compiler},
     4426    title       = {A New {C} Compiler},
    44194427    author      = {Ken Thompson},
    44204428    booktitle   = {Proceedings of the Summer 1990 UKUUG Conference},
    44214429    year        = 1990,
    44224430    pages       = {41--51},
    4423     url         = {http://doc.cat-v.org/bell_labs/new_c_compilers/new_c_compiler.pdf}
     4431    note        = {\href{http://doc.cat-v.org/bell_labs/new_c_compilers/new_c_compiler.pdf}{http://\-doc.cat-v.org/\-bell\_labs/\-new\_c\_compilers/\-new\_c\_compiler.pdf}},
    44244432}
    44254433
     
    53595367}
    53605368
    5361 @manual{ANSI14:C++,
     5369@manual{C++14,
    53625370    keywords    = {ISO/IEC C++ 14},
    53635371    contributer = {pabuhr@plg},
    5364     key         = {C++14},
    5365     title       = {Programming Languages -- {C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}}},
     5372    author      = {C++14},
     5373    title       = {Programming Languages -- {C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} ISO/IEC 14882:2014},
    53665374    edition     = {4th},
    5367     organization= {International Standard ISO/IEC 14882:2014 (E)},
    53685375    publisher   = {International Standard Organization},
    5369     address     = {http://www.iso.org},
     5376    address     = {\href{https://www.iso.org/standard/64029.html}{https://\-www.iso.org/\-standard/\-64029.html}},
    53705377    year        = 2014,
    53715378}
     
    57065713
    57075714@manual{Ada12,
    5708     keywords    = {Ada},
    5709     contributer = {pabuhr@plg},
    5710     title       = {Programming languages -- {Ada}},
     5715    keywords    = {ISO/IEC Ada},
     5716    contributer = {pabuhr@plg},
     5717    author      = {Ada12},
     5718    title       = {Programming languages -- {Ada} ISO/IEC 8652:2012},
    57115719    edition     = {3rd},
    5712     organization= {International Standard ISO/IEC 1989:2014},
    57135720    publisher   = {International Standard Organization},
    5714     address     = {http://www.iso.org},
     5721    address     = {\href{https://www.iso.org/standard/61507.html}{https://\-www.iso.org/\-standard/\-61507.html}},
    57155722    year        = 2012,
    57165723}
  • doc/proposals/concurrency/.gitignore

    r9c951e3 rb1e63ac5  
    1 concurrency.aux
    2 concurrency.acn
    3 concurrency.acr
    4 concurrency.alg
    5 concurrency.bbl
    6 concurrency.blg
    7 concurrency.brf
    8 concurrency.dvi
    9 concurrency.glg
    10 concurrency.glo
    11 concurrency.gls
    12 concurrency.idx
    13 concurrency.ind
    14 concurrency.ist
    15 concurrency.log
    16 concurrency.out
    17 concurrency.pdf
    18 concurrency.ps
    19 version.aux
    20 monitor.tex
    21 ext_monitor.tex
     1build/*.aux
     2build/*.acn
     3build/*.acr
     4build/*.alg
     5build/*.bbl
     6build/*.blg
     7build/*.brf
     8build/*.dvi
     9build/*.glg
     10build/*.glo
     11build/*.gls
     12build/*.idx
     13build/*.ind
     14build/*.ist
     15build/*.log
     16build/*.out
     17build/*.ps
     18build/*.tex
     19build/*.toc
     20*.pdf
     21
     22examples
  • doc/proposals/concurrency/Makefile

    r9c951e3 rb1e63ac5  
    11## Define the appropriate configuration variables.
    22
    3 TeXLIB = .:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies:
    4 LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error
    5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
     3TeXLIB = .:./style:./text:./annex:./build:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies:
     4LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=build -interaction=nonstopmode
     5BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex -terse
    66
    77## Define the text source files.
    88
    99SOURCES = ${addsuffix .tex, \
    10 concurrency \
    11 style \
    12 cfa-format \
    13 glossary \
     10thesis \
     11style/style \
     12style/cfa-format \
     13annex/glossary \
     14text/intro \
     15text/cforall \
     16text/basics \
     17text/concurrency \
     18text/parallelism \
    1419}
    1520
    16 FIGURES = ${addsuffix .tex, \
     21FIGURES = ${addprefix build/, ${addsuffix .tex, \
    1722        monitor \
    1823        ext_monitor \
    19 }
     24}}
    2025
    2126PICTURES = ${addsuffix .pstex, \
     
    3035## Define the documents that need to be made.
    3136
    32 DOCUMENT = concurrency.pdf
     37DOCUMENT = thesis.pdf
    3338
    3439# Directives #
     
    3742
    3843clean :
    39         rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf *.glg *.glo *.gls *.ist *.acn *.acr *.alg \
    40                 ${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT}
     44        @rm -fv ${DOCUMENT} \
     45        build/*.acn     \
     46        build/*.acr     \
     47        build/*.alg     \
     48        build/*.aux     \
     49        build/*.bbl     \
     50        build/*.blg     \
     51        build/*.brf     \
     52        build/*.cf      \
     53        build/*.dvi     \
     54        build/*.glg     \
     55        build/*.glo     \
     56        build/*.gls     \
     57        build/*.ist     \
     58        build/*.idx     \
     59        build/*.ilg     \
     60        build/*.ind     \
     61        build/*.log     \
     62        build/*.out     \
     63        build/*.ps      \
     64        build/*.pstex_t \
     65        build/*.tex     \
     66        build/*.toc     \
     67
    4168
    4269# File Dependencies #
    4370
    44 ${DOCUMENT} : ${basename ${DOCUMENT}}.ps
     71${DOCUMENT} : build/${basename ${DOCUMENT}}.ps
    4572        ps2pdf $<
    4673
    47 ${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
     74build/${basename ${DOCUMENT}}.ps : build/${basename ${DOCUMENT}}.dvi
    4875        dvips $< -o $@
    4976
    50 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
    51                 ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle
    52         # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
    53         if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
    54         # Must have *.aux file containing citations for bibtex
    55         if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
    56         -${BibTeX} ${basename $@}
    57         # Some citations reference others so run steps again to resolve these citations
    58         ${LaTeX} ${basename $@}.tex
    59         -${BibTeX} ${basename $@}
    60         # Make index from *.aux entries and input index at end of document
    61         makeglossaries ${basename $@}
    62         #${LaTeX} ${basename $@}.tex
    63         # Run again to get index title into table of contents
    64         ${LaTeX} ${basename $@}.tex
    65         -./bump_ver.sh
    66         ${LaTeX} ${basename $@}.tex
     77build/${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle
     78
     79        @ if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi                           # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
     80        @ echo "Citation lookup"                                                                                        # Must have *.aux file containing citations for bibtex
     81        @ if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename ${notdir $@}}.tex ; fi
     82        @ echo "Citation Pass 1"
     83        @ -${BibTeX} ${basename $@}                                                                                     # Some citations reference others so run steps again to resolve these citations
     84        @ echo "Citation Pass 2"
     85        @ ${LaTeX} ${basename ${notdir $@}}.tex
     86        @ -${BibTeX} ${basename $@}
     87        @ echo "Glossary"
     88        makeglossaries -q -s ${basename $@}.ist ${basename $@}                                          # Make index from *.aux entries and input index at end of document
     89        @ echo ".dvi generation"
     90        @ -build/bump_ver.sh
     91        @ ${LaTeX} ${basename ${notdir $@}}.tex                                                                 # Run again to get index title into table of contents
    6792
    6893
     
    7297## Define the default recipes.
    7398
    74 %.tex : %.fig
     99build/%.tex : figures/%.fig
    75100        fig2dev -L eepic $< > $@
    76101
    77 %.ps : %.fig
     102build/%.ps : figures/%.fig
    78103        fig2dev -L ps $< > $@
    79104
    80 %.pstex : %.fig
     105build/%.pstex : figures/%.fig
    81106        fig2dev -L pstex $< > $@
    82107        fig2dev -L pstex_t -p $@ $< > $@_t
  • doc/proposals/concurrency/style/cfa-format.tex

    r9c951e3 rb1e63ac5  
    1 \usepackage{xcolor}
     1\usepackage[usenames,dvipsnames]{xcolor}
    22\usepackage{listings}
    33\usepackage{inconsolata}
     
    144144  % moredelim=** allows cumulative application
    145145}
    146 \lstset{
    147   morekeywords=[2]{nomutex,mutex,thread,wait,wait_release,signal,signal_block,accept,monitor,suspend,resume,coroutine}
    148   language = CFA,
    149   style=defaultStyle
    150 }
     146
     147\lstdefinestyle{cfaStyle}{
     148  escapeinside={@@},
     149  basicstyle=\linespread{0.9}\tt\footnotesize,          % reduce line spacing and use typewriter font
     150  keywordstyle=\bfseries\color{blue},
     151  keywordstyle=[2]\bfseries\color{Plum},
     152  commentstyle=\itshape\color{OliveGreen},                  % green and italic comments
     153  identifierstyle=\color{identifierCol},
     154  stringstyle=\sf\color{Mahogany},                                % use sanserif font
     155  mathescape=true,
     156  columns=fixed,
     157  aboveskip=4pt,                                  % spacing above/below code block
     158  belowskip=3pt,
     159  keepspaces=true,
     160  % frame=lines,
     161  literate=,
     162  showlines=true,                                 % show blank lines at end of code
     163  showspaces=false,
     164  showstringspaces=false,
     165  escapechar=\$,
     166  xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
     167  moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
     168  morekeywords=[2]{accept, signal, signal_block, wait},
     169}
     170
    151171\lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@  % single-character for \lstinline
    152172
    153 \lstnewenvironment{cfacode}[1][]{ %
    154   \lstset{ %
    155     language = CFA, %
    156     style=defaultStyle, %
    157     morekeywords=[2]{nomutex,mutex,thread,wait,signal,signal_block,accept,monitor,suspend,resume,coroutine}, %
    158     #1 %
    159   } %
     173\lstnewenvironment{ccode}[1][]{
     174  \lstset{
     175    language = C,
     176    style=defaultStyle,
     177    #1
     178  }
     179}{}
     180
     181\lstnewenvironment{cfacode}[1][]{
     182  \lstset{
     183    language = CFA,
     184    style=cfaStyle,
     185    #1
     186  }
    160187}{}
    161188
     
    169196
    170197\lstnewenvironment{cppcode}[1][]{
     198  \lstset{
     199    language = c++,
     200    style=defaultStyle,
     201    #1
     202  }
     203}{}
     204
     205\lstnewenvironment{ucppcode}[1][]{
    171206  \lstset{
    172207    language = c++,
     
    219254\newcommand{\one}{\lstinline{one_t}\xspace}
    220255\newcommand{\ateq}{\lstinline{\@=}\xspace}
     256\newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
     257\newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
  • doc/proposals/concurrency/version

    r9c951e3 rb1e63ac5  
    1 0.8.2
     10.9.119
  • doc/refrat/Makefile

    r9c951e3 rb1e63ac5  
    4444
    4545${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
    46                 ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
     46                ../LaTeXmacros/common.tex ../LaTeXmacros/lstlang.sty ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
    4747        # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
    4848        if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
     
    7070        fig2dev -L ps $< > $@
    7171
     72%.pstex : %.fig
     73        fig2dev -L pstex $< > $@
     74        fig2dev -L pstex_t -p $@ $< > $@_t
     75
    7276# Local Variables: #
    7377# compile-command: "make" #
  • doc/refrat/refrat.bib

    r9c951e3 rb1e63ac5  
    22
    33@manual{ANS:C,
    4     keywords = {ANSI C},
    5     contributer = {gjditchfield@msg},
    6     title = {American National Standard for Information Systems --
     4    keywords    = {ANSI C},
     5    contributer = {gjditchfield@msg},
     6    title       = {American National Standard for Information Systems --
    77          Programming Language -- {C}},
    8     organization = {American National Standards Institute},
    9     address = {1430 Broadway, New York, New York  10018},
    10     month = dec, year = 1989,
    11     note = {X3.159-1989}
     8    organization= {American National Standards Institute},
     9    address     = {1430 Broadway, New York, New York  10018},
     10    month       = dec, year     = 1989,
     11    note        = {X3.159-1989}
    1212}
    1313
    1414@manual{ANS:C11,
    15     keywords = {ANS:C11},
    16     contributer = {gjditchfield@acm.org},
    17     title = {American National Standard Information Systems --
     15    keywords    = {ANS:C11},
     16    contributer = {gjditchfield@acm.org},
     17    title       = {American National Standard Information Systems --
    1818          Programming languages -- {C}},
    19     organization = {American National Standards Institute},
    20     address = {25 West 43rd Street, New York, New York 10036},
    21     month = may, year = 2012,
    22     note = {INCITS/ISO/IEC 9899-2011[2012]}
     19    organization= {American National Standards Institute},
     20    address     = {25 West 43rd Street, New York, New York 10036},
     21    month       = may, year     = 2012,
     22    note        = {INCITS/ISO/IEC 9899-2011[2012]}
    2323}
    2424
    2525@book{c++,
    26     keywords = {C++, ANSI},
    27     author = {Margaret A. Ellis and Bjarne Stroustrup},
    28     title = {The Annotated {C}{\tt ++} Reference Manual},
    29     publisher = {Addison Wesley},
    30     year = 1990,
    31     edition = {first}
     26    keywords    = {C++, ANSI},
     27    author      = {Margaret A. Ellis and Bjarne Stroustrup},
     28    title       = {The Annotated {C}{\tt ++} Reference Manual},
     29    publisher   = {Addison Wesley},
     30    year        = 1990,
     31    edition     = {first}
    3232}
    3333
    3434@Unpublished{Ditchfield96:Overview,
    35   author =      "Glen Ditchfield",
    36   title =        "An Overview of Cforall",
    37   note =        "in preparation",
    38   year =        1996
     35    author      = "Glen Ditchfield",
     36    title       = "An Overview of Cforall",
     37    note        = "in preparation",
     38    year        = 1996
    3939}
    4040
    4141@article{Bak:overload,
    42     keywords = {compilation},
    43     contributer = {gjditchfield@msg},
    44     author = {T. P. Baker},
    45     title = {A One-Pass Algorithm for Overload Resolution in {Ada}},
    46     journal = toplas,
    47     year = 1982,
    48     month = oct, volume = 4, number = 4, pages = {601--614},
    49     abstract = {
     42    keywords    = {compilation},
     43    contributer = {gjditchfield@msg},
     44    author      = {T. P. Baker},
     45    title       = {A One-Pass Algorithm for Overload Resolution in {Ada}},
     46    journal     = toplas,
     47    year        = 1982,
     48    month       = oct, volume   = 4, number     = 4, pages      = {601--614},
     49    abstract    = {
    5050        A simple method is presented for detecting ambiguities and finding
    5151        the correct interpretations of expressions in the programming
     
    5656        approach is demonstrated by a brief formal argument.
    5757    },
    58     comment = {
     58    comment     = {
    5959        See also \cite{D:overload}.
    6060        }
     
    7777
    7878@book{clu,
    79     keywords = {CLU},
    80     contributer = {gjditchfield@msg},
    81     author = {Barbara Liskov and Russell Atkinson and Toby Bloom and Eliot
     79    keywords    = {CLU},
     80    contributer = {gjditchfield@msg},
     81    author      = {Barbara Liskov and Russell Atkinson and Toby Bloom and Eliot
    8282    Moss and J. Craig Schaffert and Robert Scheifler and Alan Snyder},
    83     title = {CLU Reference Manual},
    84     publisher = {Springer-Verlag},
    85     year = 1981,
    86     volume = 114,
    87     series = {Lecture Notes in Computer Science}
     83    title       = {CLU Reference Manual},
     84    publisher   = {Springer-Verlag},
     85    year        = 1981,
     86    volume      = 114,
     87    series      = {Lecture Notes in Computer Science}
    8888}
    8989
    9090@manual{SIMULA87,
    91     keywords = {Simula standard},
    92     contributer = {gjditchfield@msg},
    93     title = {Databehandling -- Programspr{\aa}k -- {SIMULA}},
    94     organization = {Standardiseringskommissionen i Sverige},
    95     note = {Svensk Standard SS 63 61 14},
    96     year = 1987,
    97     abstract = {
     91    keywords    = {Simula standard},
     92    contributer = {gjditchfield@msg},
     93    title       = {Databehandling -- Programspr{\aa}k -- {SIMULA}},
     94    organization        = {Standardiseringskommissionen i Sverige},
     95    note        = {Svensk Standard SS 63 61 14},
     96    year        = 1987,
     97    abstract    = {
    9898        Standard for the programming language SIMULA.  Written in English.
    9999    }
     
    112112
    113113@inproceedings{Thompson90new,
    114   title = {A New C Compiler},
    115   author = {Ken Thompson},
    116   booktitle = {Proceedings of the Summer 1990 UKUUG Conference},
    117   year = 1990,
    118   pages = {41--51}
     114    title       = {A New {C} Compiler},
     115    author      = {Ken Thompson},
     116    booktitle   = {Proceedings of the Summer 1990 UKUUG Conference},
     117    year        = 1990,
     118    pages       = {41--51}
    119119}
  • doc/refrat/refrat.tex

    r9c951e3 rb1e63ac5  
    1111%% Created On       : Wed Apr  6 14:52:25 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Wed Apr  5 23:23:28 2017
    14 %% Update Count     : 79
     13%% Last Modified On : Fri Jun  2 10:43:14 2017
     14%% Update Count     : 83
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    2929\usepackage{epic,eepic}
    3030\usepackage{upquote}                                                                    % switch curled `'" to straight
     31\usepackage{calc}
    3132\usepackage{xspace}
    3233\usepackage{varioref}                                                                   % extended references
     
    6263% Names used in the document.
    6364\newcommand{\Version}{\input{../../version}}
    64 
    6565\newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}}
    6666\newcommand{\Emph}[2][red]{{\color{#1}\textbf{\emph{#2}}}}
     
    9797\renewcommand{\chaptermark}[1]{\markboth{\thechapter\quad #1}{\thechapter\quad #1}}
    9898\renewcommand{\sectionmark}[1]{\markboth{\thesection\quad #1}{\thesection\quad #1}}
     99\renewcommand{\subsectionmark}[1]{\markboth{\thesubsection\quad #1}{\thesubsection\quad #1}}
    99100\pagenumbering{roman}
    100101\linenumbers                                            % comment out to turn off line numbering
     
    121122
    122123This document is a reference manual and rationale for \CFA, a polymorphic extension of the C programming language.
    123 It makes frequent reference to the {\c11} standard \cite{C11}, and occasionally compares \CFA to {\CC} \cite{C++}.
    124 
    125 The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering differs).
    126 Unfortunately, this means the manual contains more ``forward references'' than usual, making it harder to follow if the reader does not have a copy of the {\c11} standard.
     124It covers low-level syntactic and semantic details of the language to address complex language issues for programmers, and provide language implementers with a precise language description.
     125It makes frequent reference to the \Celeven standard~\cite{C11}, and occasionally compares \CFA to \CC~\cite{C++}.
     126Changes to the syntax and additional features are expected to be included in later revisions.
     127
     128The manual deliberately imitates the ordering of the \Celeven standard (although the section numbering differs).
     129Unfortunately, this means the manual contains more ``forward references'' than usual, making it harder to follow if the reader does not have a copy of the \Celeven standard.
    127130For a simple introduction to \CFA, see the companion document ``An Overview of \CFA''
    128131\cite{Ditchfield96:Overview}.
     
    139142\chapter{Terms, definitions, and symbols}
    140143
    141 Terms from the {\c11} standard used in this document have the same meaning as in the {\c11} standard.
     144Terms from the \Celeven standard used in this document have the same meaning as in the \Celeven standard.
    142145
    143146% No ``Conformance'' or ``Environment'' chapters yet.
     
    149152
    150153\section{Notation}
    151 The syntax notation used in this document is the same as in the {\c11} standard, with one exception: ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that these rules extend a previous definition, which occurs in this document or in the {\c11} standard.
     154The syntax notation used in this document is the same as in the \Celeven standard, with one exception: ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that these rules extend a previous definition, which occurs in this document or in the \Celeven standard.
    152155
    153156
     
    162165\begin{rationale}
    163166Hence, a \CFA program can declare an ©int v© and a ©float v© in the same scope;
    164 a {\CC} program can not.
     167a \CC program can not.
    165168\end{rationale}
    166169
     
    285288
    286289\begin{rationale}
    287 Note that {\c11} does not include conversion from \Index{real type}s to \Index{complex type}s in the usual arithmetic conversions, and \CFA does not include them as safe conversions.
     290Note that \Celeven does not include conversion from \Index{real type}s to \Index{complex type}s in the usual arithmetic conversions, and \CFA does not include them as safe conversions.
    288291\end{rationale}
    289292
     
    370373\begin{rationale}
    371374As in C, there is an implicit conversion from ©void *© to any pointer type.
    372 This is clearly dangerous, and {\CC} does not have this implicit conversion.
     375This is clearly dangerous, and \CC does not have this implicit conversion.
    373376\CFA\index{deficiencies!void * conversion} keeps it, in the interest of remaining as pure a superset of C as possible, but discourages it by making it unsafe.
    374377\end{rationale}
     
    608611
    609612There are two notable differences between \CFA's overload resolution rules and the rules for
    610 {\CC} defined in \cite{C++}.
     613\CC defined in \cite{C++}.
    611614First, the result type of a function plays a role.
    612 In {\CC}, a function call must be completely resolved based on the arguments to the call in most circumstances.
     615In \CC, a function call must be completely resolved based on the arguments to the call in most circumstances.
    613616In \CFA, a function call may have several interpretations, each with a different result type, and the interpretations of the containing context choose among them.
    614617Second, safe conversions are used to choose among interpretations of all sorts of functions;
    615 in {\CC}, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators.
     618in \CC, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators.
    616619\end{rationale}
    617620
     
    637640
    638641\begin{rationale}
    639 Expression syntax is quoted from the {\c11} standard.
     642Expression syntax is quoted from the \Celeven standard.
    640643The syntax itself defines the precedence and associativity of operators.
    641644The sections are arranged in decreasing order of precedence, with all operators in a section having the same precedence.
     
    665668The \Index{valid interpretation} of an \nonterm{identifier} are given by the visible\index{visible} declarations of the identifier.
    666669
    667 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by {\c11}.
     670A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by \Celeven.
    668671The predefined integer identifiers ``©1©'' and ``©0©'' have the integer values 1 and 0, respectively.
    669672The other two predefined ``©0©'' identifiers are bound to polymorphic pointer values that, when specialized\index{specialization} with a data type or function type respectively, produce a null pointer of that type.
     
    11131116forall( otype T ) T restrict * ?++( T restrict *restrict volatile * );
    11141117\end{lstlisting} with ©T© inferred to be ©float *©.
    1115 This looks odd, because {\c11} contains a constraint that requires restrict-qualified types to be pointer-to-object types, and ©T© is not syntactically a pointer type. \CFA loosens the constraint.
     1118This looks odd, because \Celeven contains a constraint that requires restrict-qualified types to be pointer-to-object types, and ©T© is not syntactically a pointer type. \CFA loosens the constraint.
    11161119\end{enumerate}
    11171120\end{rationale}
     
    14771480
    14781481\begin{rationale}
    1479 {\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
     1482\Celeven does not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
    14801483\end{rationale}
    14811484
     
    15061509
    15071510\begin{rationale}
    1508 {\c11} defines most arithmetic operations to apply an \Index{integer promotion} to any argument that belongs to a type that has an \Index{integer conversion rank} less than that of ©int©.
     1511\Celeven defines most arithmetic operations to apply an \Index{integer promotion} to any argument that belongs to a type that has an \Index{integer conversion rank} less than that of ©int©.
    15091512If ©s© is a ©short int©, ``©s *s©'' does not have type ©short int©;
    15101513it is treated as ``©( (int)s ) * ( (int)s )©'', and has type ©int©. \CFA matches that pattern;
     
    15191522\end{lstlisting}
    15201523Since \CFA does not define a multiplication operator for ©short int©, ©square( s )© is treated as ©square( (int)s )©, and the result has type ©int©.
    1521 This is mildly surprising, but it follows the {\c11} operator pattern.
     1524This is mildly surprising, but it follows the \Celeven operator pattern.
    15221525
    15231526A more troubling example is
     
    16171620©ptrdiff_t© is an implementation-defined identifier defined in ©<stddef.h>© that is synonymous with a signed integral type that is large enough to hold the difference between two pointers.
    16181621It seems reasonable to use it for pointer addition as well. (This is technically a difference between \CFA and C, which only specifies that pointer addition uses an \emph{integral} argument.) Hence it is also used for subscripting, which is defined in terms of pointer addition.
    1619 The {\c11} standard uses ©size_t© in several cases where a library function takes an argument that is used as a subscript, but ©size_t© is unsuitable here because it is an unsigned type.
     1622The \Celeven standard uses ©size_t© in several cases where a library function takes an argument that is used as a subscript, but ©size_t© is unsuitable here because it is an unsigned type.
    16201623\end{rationale}
    16211624
     
    19301933\end{lstlisting}
    19311934The logical expression calls the ©Rational© inequality operator, passing it ©*rp© and the ©Rational 0©, and getting a 1 or 0 as a result.
    1932 In contrast, {\CC} would apply a programmer-defined ©Rational©-to-©int© conversion to ©*rp© in the equivalent situation.
     1935In contrast, \CC would apply a programmer-defined ©Rational©-to-©int© conversion to ©*rp© in the equivalent situation.
    19331936The conversion to ©int© would produce a general integer value, which is unfortunate, and possibly dangerous if the conversion was not written with this situation in mind.
    19341937\end{rationale}
     
    26262629\begin{itemize}
    26272630\item a typedef name may be redefined to denote the same type as it currently does, provided that type is not a variably modified type;
    2628 \item tags may be redeclared as specified in section 6.7.2.3 of the {\c11} standard.
     2631\item tags may be redeclared as specified in section 6.7.2.3 of the \Celeven standard.
    26292632\end{itemize}
    26302633\begin{rationale}
    2631 This constraint adds the phrase ``with compatible types'' to the {\c11} constraint, to allow overloading.
     2634This constraint adds the phrase ``with compatible types'' to the \Celeven constraint, to allow overloading.
    26322635\end{rationale}
    26332636
    26342637An identifier declared by a type declaration shall not be redeclared as a parameter in a function definition whose declarator includes an identifier list.
    26352638\begin{rationale}
    2636 This restriction echos {\c11}'s ban on the redeclaration of typedef names as parameters.
     2639This restriction echos \Celeven's ban on the redeclaration of typedef names as parameters.
    26372640This avoids an ambiguity between old-style function declarations and new-style function prototypes:
    26382641\begin{lstlisting}
     
    26612664
    26622665\semantics
    2663 \CFA extends the {\c11} definition of \define{anonymous structure} to include structure specifiers with tags, and extends the {\c11} definition of \define{anonymous union} to include union specifiers with tags.
     2666\CFA extends the \Celeven definition of \define{anonymous structure} to include structure specifiers with tags, and extends the \Celeven definition of \define{anonymous union} to include union specifiers with tags.
    26642667\begin{rationale}
    26652668This extension imitates an extension in the Plan 9 C compiler \cite{Thompson90new}.
     
    28542857
    28552858\begin{rationale}
    2856 ©lvalue© provides some of the functionality of {\CC}'s ``©T&©'' ( reference to object of type ©T©) type.
    2857 Reference types have four uses in {\CC}.
     2859©lvalue© provides some of the functionality of \CC's ``©T&©'' ( reference to object of type ©T©) type.
     2860Reference types have four uses in \CC.
    28582861\begin{itemize}
    28592862\item
     
    28622865\item
    28632866A reference can be used to define an alias for a complicated lvalue expression, as a way of getting some of the functionality of the Pascal ©with© statement.
    2864 The following {\CC} code gives an example.
     2867The following \CC code gives an example.
    28652868\begin{lstlisting}
    28662869{
     
    28742877A reference parameter can be used to allow a function to modify an argument without forcing the caller to pass the address of the argument.
    28752878This is most useful for user-defined assignment operators.
    2876 In {\CC}, plain assignment is done by a function called ``©operator=©'', and the two expressions
     2879In \CC, plain assignment is done by a function called ``©operator=©'', and the two expressions
    28772880\begin{lstlisting}
    28782881a = b;
     
    28872890\item
    28882891References to \Index{const-qualified} types can be used instead of value parameters.  Given the
    2889 {\CC} function call ``©fiddle( a_thing )©'', where the type of ©a_thing© is
     2892\CC function call ``©fiddle( a_thing )©'', where the type of ©a_thing© is
    28902893©Thing©, the type of ©fiddle© could be either of
    28912894\begin{lstlisting}
     
    32163219The Simula class \cite{SIMULA87} is essentially a record type.
    32173220Since the only operations on a record are member selection and assignment, which can not be overloaded, there is never any ambiguity as to whether the abstraction or the implementation view is being used.
    3218 In {\CC}
     3221In \CC
    32193222\cite{C++}, operations on class instances include assignment and ``©&©'', which can be overloaded.
    32203223A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used.
     
    35483551\subsection{Predefined macro names}
    35493552
    3550 The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the {\c11} standard.
     3553The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the \Celeven standard.
    35513554It shall not define the macro name ©__STDC__©.
    35523555
     
    36343637\subsection{Pointer and array types}
    36353638
    3636 Array types can barely be said to exist in {\c11}, since in most cases an array name is treated as a constant pointer to the first element of the array, and the subscript expression ``©a[i]©'' is equivalent to the dereferencing expression ``©(*( a+( i )))©''.
     3639Array types can barely be said to exist in \Celeven, since in most cases an array name is treated as a constant pointer to the first element of the array, and the subscript expression ``©a[i]©'' is equivalent to the dereferencing expression ``©(*( a+( i )))©''.
    36373640Technically, pointer arithmetic and pointer comparisons other than ``©==©'' and ``©!=©'' are only defined for pointers to array elements, but the type system does not enforce those restrictions.
    36383641Consequently, there is no need for a separate ``array type'' specification.
     
    37123715Different operators often have related meanings;
    37133716for instance, in C, ``©+©'', ``©+=©'', and the two versions of ``©++©'' perform variations of addition.
    3714 Languages like {\CC} and Ada allow programmers to define operators for new types, but do not require that these relationships be preserved, or even that all of the operators be implemented.
     3717Languages like \CC and Ada allow programmers to define operators for new types, but do not require that these relationships be preserved, or even that all of the operators be implemented.
    37153718Completeness and consistency is left to the good taste and discretion of the programmer.
    37163719It is possible to encourage these attributes by providing generic operator functions, or member functions of abstract classes, that are defined in terms of other, related operators.
     
    38233826\end{theindex}
    38243827
     3828
    38253829\end{document}
    38263830
  • doc/rob_thesis/intro.tex

    r9c951e3 rb1e63ac5  
    33%======================================================================
    44
    5 \section{\CFA Background}
     5\section{\protect\CFA Background}
    66\label{s:background}
    77\CFA \footnote{Pronounced ``C-for-all'', and written \CFA or Cforall.} is a modern non-object-oriented extension to the C programming language.
     
    370370    \end{tabular}
    371371  \end{center}
    372   \caption{\label{table:types} The different kinds of type parameters in \CFA}
     372  \caption{\label{table:types} The different kinds of type parameters in \protect\CFA}
    373373\end{table}
    374374
  • doc/rob_thesis/thesis.tex

    r9c951e3 rb1e63ac5  
    6666% ,monochrome % toggle black and white mode
    6767}{xcolor}
     68\PassOptionsToPackage{pdftex}{graphicx}
    6869\documentclass[letterpaper,12pt,titlepage,oneside,final]{book}
    6970
  • doc/user/pointer2.fig

    r9c951e3 rb1e63ac5  
    88-2
    991200 2
     106 1125 2100 3525 2400
    10112 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
    11          1500 1950 1950 1950 1950 2250 1500 2250 1500 1950
     12         1500 2100 1950 2100 1950 2400 1500 2400 1500 2100
     132 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
     14         2700 2100 3150 2100 3150 2400 2700 2400 2700 2100
     154 2 0 100 0 4 10 0.0000 2 120 270 1425 2400 104\001
     164 2 0 100 0 4 10 0.0000 2 120 90 1425 2225 y\001
     174 0 0 100 0 4 10 0.0000 2 120 165 2025 2300 int\001
     184 2 0 100 0 4 10 0.0000 2 120 270 2625 2400 112\001
     194 2 0 100 0 4 10 0.0000 2 150 180 2625 2225 p2\001
     204 1 0 100 0 4 10 0.0000 2 120 90 1725 2300 3\001
     214 0 0 100 0 4 10 0.0000 2 120 270 3225 2300 int *\001
     224 1 0 100 0 4 10 0.0000 2 120 270 2925 2300 100\001
     23-6
    12242 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
    1325         1500 1500 1950 1500 1950 1800 1500 1800 1500 1500
    14262 1 0 1 4 7 100 -1 -1 0.000 0 0 -1 1 0 2
    1527        1 1 1.00 45.00 90.00
    16          2700 1800 1950 1950
     28         2700 1800 1950 2100
    17292 1 0 1 4 7 50 -1 -1 0.000 0 0 -1 1 0 2
    1830        1 1 1.00 45.00 90.00
    19          2700 1950 1950 1800
    20 2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
    21          2700 1950 3150 1950 3150 2250 2700 2250 2700 1950
     31         2700 2100 1950 1800
    22322 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
    2333         2700 1500 3150 1500 3150 1800 2700 1800 2700 1500
    24342 1 0 1 4 7 100 -1 -1 0.000 0 0 -1 1 0 2
    2535        1 1 1.00 45.00 90.00
    26          3900 1800 3150 1950
     36         3900 1800 3150 2100
    27372 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
    2838         3900 1500 4350 1500 4350 1800 3900 1800 3900 1500
    29 4 2 0 100 0 4 10 0.0000 2 120 270 1425 2250 104\001
    30394 2 0 100 0 4 10 0.0000 2 120 270 1425 1800 100\001
    31404 2 0 100 0 4 10 0.0000 2 90 90 1425 1625 x\001
    32 4 2 0 100 0 4 10 0.0000 2 120 90 1425 2075 y\001
    33 4 0 0 100 0 4 10 0.0000 2 120 165 2025 2150 int\001
    34414 0 0 100 0 4 10 0.0000 2 120 165 2025 1700 int\001
    35 4 2 0 100 0 4 10 0.0000 2 120 270 2625 2250 112\001
    36 4 2 0 100 0 4 10 0.0000 2 150 180 2625 2075 p2\001
    37424 2 0 100 0 4 10 0.0000 2 120 270 2625 1800 108\001
    38434 2 0 100 0 4 10 0.0000 2 150 180 2625 1625 p1\001
    39 4 1 0 100 0 4 10 0.0000 2 120 90 1725 2150 3\001
    40444 1 0 100 0 4 10 0.0000 2 120 90 1725 1700 3\001
    41 4 0 0 100 0 4 10 0.0000 2 120 270 3225 2150 int *\001
    42454 0 0 100 0 4 10 0.0000 2 120 270 3225 1700 int *\001
    43464 2 0 100 0 4 10 0.0000 2 120 270 3825 1800 116\001
    44474 2 0 100 0 4 10 0.0000 2 150 180 3825 1625 p3\001
    45 4 1 0 100 0 4 10 0.0000 2 120 270 2925 2150 100\001
    46484 1 0 100 0 4 10 0.0000 2 120 270 2925 1700 104\001
    47494 1 0 100 0 4 10 0.0000 2 120 270 4125 1700 112\001
  • doc/user/user.tex

    r9c951e3 rb1e63ac5  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon May 15 18:29:58 2017
    14 %% Update Count     : 1598
     13%% Last Modified On : Fri Jun 16 12:00:01 2017
     14%% Update Count     : 2433
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    4343\usepackage[pagewise]{lineno}
    4444\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    45 \input{common}                                          % bespoke macros used in the document
     45\input{common}                                          % common CFA document macros
    4646\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    4747\usepackage{breakurl}
     
    9494\author{
    9595\huge \CFA Team \medskip \\
    96 \Large Peter A. Buhr, Richard Bilson, Thierry Delisle, \smallskip \\
     96\Large Andrew Beach, Richard Bilson, Peter A. Buhr, Thierry Delisle, \smallskip \\
    9797\Large Glen Ditchfield, Rodolfo G. Esteves, Aaron Moss, Rob Schluntz
    9898}% author
     
    110110\renewcommand{\subsectionmark}[1]{\markboth{\thesubsection\quad #1}{\thesubsection\quad #1}}
    111111\pagenumbering{roman}
    112 \linenumbers                                            % comment out to turn off line numbering
     112%\linenumbers                                            % comment out to turn off line numbering
    113113
    114114\maketitle
     
    135135
    136136\CFA{}\index{cforall@\CFA}\footnote{Pronounced ``\Index*{C-for-all}'', and written \CFA, CFA, or \CFL.} is a modern general-purpose programming-language, designed as an evolutionary step forward for the C programming language.
    137 The syntax of the \CFA language builds from C, and should look immediately familiar to C/\Index*[C++]{\CC} programmers.
    138 % Any language feature that is not described here can be assumed to be using the standard C11 syntax.
     137The syntax of the \CFA language builds from C, and should look immediately familiar to C/\Index*[C++]{\CC{}} programmers.
     138% Any language feature that is not described here can be assumed to be using the standard \Celeven syntax.
    139139\CFA adds many modern programming-language features that directly lead to increased \emph{\Index{safety}} and \emph{\Index{productivity}}, while maintaining interoperability with existing C programs and achieving C performance.
    140 Like C, \CFA is a statically typed, procedural language with a low-overhead runtime, meaning there is no global \Index{garbage-collection}, but \Index{regional garbage-collection}\index{garbage collection!regional} is possible.
     140Like C, \CFA is a statically typed, procedural language with a low-overhead runtime, meaning there is no global \Index{garbage-collection}, but \Index{regional garbage-collection}\index{garbage-collection!regional} is possible.
    141141The primary new features include parametric-polymorphic routines and types, exceptions, concurrency, and modules.
    142142
     
    147147instead, a programmer evolves an existing C program into \CFA by incrementally incorporating \CFA features.
    148148New programs can be written in \CFA using a combination of C and \CFA features.
    149 \Index*[C++]{\CC} had a similar goal 30 years ago, but currently has the disadvantages of multiple legacy design-choices that cannot be updated and active divergence of the language model from C, requiring significant effort and training to incrementally add \CC to a C-based project.
     149\Index*[C++]{\CC{}} had a similar goal 30 years ago, but currently has the disadvantages of multiple legacy design-choices that cannot be updated and active divergence of the language model from C, requiring significant effort and training to incrementally add \CC to a C-based project.
    150150In contrast, \CFA has 30 years of hindsight and a clean starting point.
    151151
    152 Like \Index*[C++]{\CC}, there may be both an old and new ways to achieve the same effect.
    153 For example, the following programs compare the \CFA and C I/O mechanisms.
     152Like \Index*[C++]{\CC{}}, there may be both an old and new ways to achieve the same effect.
     153For example, the following programs compare the \CFA, C, and \CC I/O mechanisms, where the programs output the same result.
    154154\begin{quote2}
    155155\begin{tabular}{@{}l@{\hspace{1.5em}}l@{\hspace{1.5em}}l@{}}
    156156\multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}}      & \multicolumn{1}{c}{\textbf{C}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
    157157\begin{cfa}
    158 #include <fstream>
     158#include <fstream>§\indexc{fstream}§
    159159
    160160int main( void ) {
     
    165165&
    166166\begin{lstlisting}
    167 #include <stdio.h>
     167#include <stdio.h>§\indexc{stdio.h}§
    168168
    169169int main( void ) {
     
    174174&
    175175\begin{lstlisting}
    176 #include <iostream>
     176#include <iostream>§\indexc{iostream}§
    177177using namespace std;
    178178int main() {
     
    183183\end{tabular}
    184184\end{quote2}
    185 The programs output the same result.
    186 While the \CFA I/O looks similar to the \Index*[C++]{\CC} output style, there are important differences, such as automatic spacing between variables as in \Index*{Python} (see~\VRef{s:IOLibrary}).
    187 
    188 This document is a user manual for the \CFA programming language, targeted at \CFA programmers.
     185While the \CFA I/O looks similar to the \Index*[C++]{\CC{}} output style, there are important differences, such as automatic spacing between variables as in \Index*{Python} (see~\VRef{s:IOLibrary}).
     186
     187This document is a programmer reference-manual for the \CFA programming language.
     188The manual covers the core features of the language and runtime-system, with simple examples illustrating syntax and semantics of each feature.
     189The manual does not teach programming, i.e., how to combine the new constructs to build complex programs.
     190A reader should already have an intermediate knowledge of control flow, data structures, and concurrency issues to understand the ideas presented as well as some experience programming in C/\CC.
    189191Implementers may refer to the \CFA Programming Language Specification for details about the language syntax and semantics.
    190 In its current state, this document covers the intended core features of the language.
    191192Changes to the syntax and additional features are expected to be included in later revisions.
    192193
     
    198199Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction.
    199200For system programming, where direct access to hardware and dealing with real-time issues is a requirement, C is usually the language of choice.
    200 The TIOBE index~\cite{TIOBE} for March 2016 showed the following programming-language popularity: \Index*{Java} 20.5\%, C 14.5\%, \Index*[C++]{\CC} 6.7\%, \Csharp 4.3\%, \Index*{Python} 4.3\%, where the next 50 languages are less than 3\% each with a long tail.
     201The TIOBE index~\cite{TIOBE} for March 2016 showed the following programming-language popularity: \Index*{Java} 20.5\%, C 14.5\%, \Index*[C++]{\CC{}} 6.7\%, \Csharp 4.3\%, \Index*{Python} 4.3\%, where the next 50 languages are less than 3\% each with a long tail.
    201202As well, for 30 years, C has been the number 1 and 2 most popular programming language:
    202203\begin{center}
     
    217218
    218219As stated, the goal of the \CFA project is to engineer modern language features into C in an evolutionary rather than revolutionary way.
    219 \CC~\cite{c++,ANSI14:C++} is an example of a similar project;
     220\CC~\cite{C++14,C++} is an example of a similar project;
    220221however, it largely extended the language, and did not address many existing problems.\footnote{%
    221222Two important existing problems addressed were changing the type of character literals from ©int© to ©char© and enumerator from ©int© to the type of its enumerators.}
     
    226227These costs can be prohibitive for many companies with a large software base in C/\CC, and a significant number of programmers requiring retraining to a new programming language.
    227228
    228 The result of this project is a language that is largely backwards compatible with \Index*{C11}~\cite{C11}, but fixing some of the well known C problems and containing many modern language features.
     229The result of this project is a language that is largely backwards compatible with \Index*[C11]{\Celeven{}}~\cite{C11}, but fixing some of the well known C problems and containing many modern language features.
    229230Without significant extension to the C programming language, it is becoming unable to cope with the needs of modern programming problems and programmers;
    230231as a result, it will fade into disuse.
    231232Considering the large body of existing C code and programmers, there is significant impetus to ensure C is transformed into a modern programming language.
    232 While \Index*{C11} made a few simple extensions to the language, nothing was added to address existing problems in the language or to augment the language with modern language features.
     233While \Index*[C11]{\Celeven{}} made a few simple extensions to the language, nothing was added to address existing problems in the language or to augment the language with modern language features.
    233234While some may argue that modern language features may make C complex and inefficient, it is clear a language without modern capabilities is insufficient for the advanced programming problems existing today.
    234235
     
    244245int forty_two = identity( 42 );                 §\C{// T is bound to int, forty\_two == 42}§
    245246\end{lstlisting}
    246 % extending the C type system with parametric polymorphism and overloading, as opposed to the \Index*[C++]{\CC} approach of object-oriented extensions.
     247% extending the C type system with parametric polymorphism and overloading, as opposed to the \Index*[C++]{\CC{}} approach of object-oriented extensions.
    247248\CFA{}\hspace{1pt}'s polymorphism was originally formalized by Ditchfiled~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}.
    248249However, at that time, there was little interesting in extending C, so work did not continue.
     
    263264A simple example is leveraging the existing type-unsafe (©void *©) C ©bsearch© to binary search a sorted floating-point array:
    264265\begin{lstlisting}
    265 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size,
     266void * bsearch( const void * key, const void * base, size_t dim, size_t size,
    266267                                int (* compar)( const void *, const void * ));
    267268
     
    341342The 1999 C standard plus GNU extensions.
    342343\item
     344{\lstset{deletekeywords={inline}}
    343345\Indexc{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{©-fgnu89-inline©}}
    344346Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files.
     347}%
    345348\end{description}
    346349The following new \CFA options are available:
     
    413416\begin{cfa}
    414417#ifndef __CFORALL__
    415 #include <stdio.h>                                              §\C{// C header file}§
     418#include <stdio.h>§\indexc{stdio.h}§    §\C{// C header file}§
    416419#else
    417 #include <fstream>                                              §\C{// \CFA header file}§
     420#include <fstream>§\indexc{fstream}§    §\C{// \CFA header file}§
    418421#endif
    419422\end{cfa}
     
    451454the type suffixes ©U©, ©L©, etc. may start with an underscore ©1_U©, ©1_ll© or ©1.0E10_f©.
    452455\end{enumerate}
    453 It is significantly easier to read and enter long constants when they are broken up into smaller groupings (most cultures use comma or period among digits for the same purpose).
     456It is significantly easier to read and enter long constants when they are broken up into smaller groupings (many cultures use comma and/or period among digits for the same purpose).
    454457This extension is backwards compatible, matches with the use of underscore in variable names, and appears in \Index*{Ada} and \Index*{Java} 8.
    455458
     
    461464\begin{cfa}
    462465int ®`®otype®`® = 3;                    §\C{// make keyword an identifier}§
    463 double ®`®choose®`® = 3.5;
    464 \end{cfa}
    465 Programs can be converted easily by enclosing keyword identifiers in backquotes, and the backquotes can be removed later when the identifier name is changed to a non-keyword name.
     466double ®`®forall®`® = 3.5;
     467\end{cfa}
     468Existing C programs with keyword clashes can be converted by enclosing keyword identifiers in backquotes, and eventually the identifier name can be changed to a non-keyword name.
    466469\VRef[Figure]{f:InterpositionHeaderFile} shows how clashes in C header files (see~\VRef{s:StandardHeaders}) can be handled using preprocessor \newterm{interposition}: ©#include_next© and ©-I filename©:
    467470
     
    470473// include file uses the CFA keyword "otype".
    471474#if ! defined( otype )                  §\C{// nesting ?}§
    472 #define otype `otype`
     475#define otype ®`®otype®`®               §\C{// make keyword an identifier}§
    473476#define __CFA_BFD_H__
    474477#endif // ! otype
     
    494497\begin{tabular}{@{}ll@{}}
    495498\begin{cfa}
    496 int *x[5]
     499int * x[5]
    497500\end{cfa}
    498501&
     
    505508For example, a routine returning a \Index{pointer} to an array of integers is defined and used in the following way:
    506509\begin{cfa}
    507 int (*f())[5] {...};                    §\C{
    508 ... (*f())[3] += 1;
     510int ®(*®f®())[®5®]® {...};                              §\C{definition
     511 ... ®(*®f®())[®3®]® += 1;                              §\C{usage}§
    509512\end{cfa}
    510513Essentially, the return type is wrapped around the routine name in successive layers (like an \Index{onion}).
     
    513516\CFA provides its own type, variable and routine declarations, using a different syntax.
    514517The new declarations place qualifiers to the left of the base type, while C declarations place qualifiers to the right of the base type.
    515 In the following example, \R{red} is for the base type and \B{blue} is for the qualifiers.
    516 The \CFA declarations move the qualifiers to the left of the base type, i.e., move the blue to the left of the red, while the qualifiers have the same meaning but are ordered left to right to specify a variable's type.
     518In the following example, \R{red} is the base type and \B{blue} is qualifiers.
     519The \CFA declarations move the qualifiers to the left of the base type, \ie move the blue to the left of the red, while the qualifiers have the same meaning but are ordered left to right to specify a variable's type.
    517520\begin{quote2}
    518521\begin{tabular}{@{}l@{\hspace{3em}}l@{}}
     
    531534\end{tabular}
    532535\end{quote2}
    533 The only exception is bit field specification, which always appear to the right of the base type.
     536The only exception is \Index{bit field} specification, which always appear to the right of the base type.
    534537% Specifically, the character ©*© is used to indicate a pointer, square brackets ©[©\,©]© are used to represent an array or function return value, and parentheses ©()© are used to indicate a routine parameter.
    535538However, unlike C, \CFA type declaration tokens are distributed across all variables in the declaration list.
     
    580583\begin{cfa}
    581584int z[ 5 ];
    582 char *w[ 5 ];
    583 double (*v)[ 5 ];
     585char * w[ 5 ];
     586double (* v)[ 5 ];
    584587struct s {
    585588        int f0:3;
    586         int *f1;
    587         int *f2[ 5 ]
     589        int * f1;
     590        int * f2[ 5 ]
    588591};
    589592\end{cfa}
     
    634637\begin{cfa}
    635638int extern x[ 5 ];
    636 const int static *y;
     639const int static * y;
    637640\end{cfa}
    638641&
     
    644647\end{quote2}
    645648
    646 Unsupported are K\&R C declarations where the base type defaults to ©int©, if no type is specified,\footnote{
    647 At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and type name~\cite[\S~6.7.2(2)]{C11}}
    648 \eg:
    649 \begin{cfa}
    650 x;                                                              §\C{// int x}§
    651 *y;                                                             §\C{// int *y}§
    652 f( p1, p2 );                                    §\C{// int f( int p1, int p2 );}§
    653 f( p1, p2 ) {}                                  §\C{// int f( int p1, int p2 ) {}}§
    654 \end{cfa}
     649The new declaration syntax can be used in other contexts where types are required, \eg casts and the pseudo-routine ©sizeof©:
     650\begin{quote2}
     651\begin{tabular}{@{}l@{\hspace{3em}}l@{}}
     652\multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
     653\begin{cfa}
     654y = (®* int®)x;
     655i = sizeof(®[ 5 ] * int®);
     656\end{cfa}
     657&
     658\begin{cfa}
     659y = (®int *®)x;
     660i = sizeof(®int * [ 5 ]®);
     661\end{cfa}
     662\end{tabular}
     663\end{quote2}
    655664
    656665Finally, new \CFA declarations may appear together with C declarations in the same program block, but cannot be mixed within a specific declaration.
     
    659668
    660669
    661 \section{Pointer / Reference}
     670\section{Pointer/Reference}
    662671
    663672C provides a \newterm{pointer type};
    664673\CFA adds a \newterm{reference type}.
    665 Both types contain an \newterm{address}, which is normally a location in memory.
    666 Special addresses are used to denote certain states or access co-processor memory.
    667 By convention, no variable is placed at address 0, so addresses like 0, 1, 2, 3 are often used to denote no-value or other special states.
    668 Often dereferencing a special state causes a \Index{memory fault}, so checking is necessary during execution.
    669 If the programming language assigns addresses, a program's execution is \Index{sound}, i.e., all addresses are to valid memory locations.
    670 C allows programmers to assign addresses, so there is the potential for incorrect addresses, both inside and outside of the computer address-space.
    671 
    672 Program variables are implicit pointers to memory locations generated by the compiler and automatically dereferenced, as in:
     674These types may be derived from an object or routine type, called the \newterm{referenced type}.
     675Objects of these types contain an \newterm{address}, which is normally a location in memory, but may also address memory-mapped registers in hardware devices.
     676An integer constant expression with the value 0, or such an expression cast to type ©void *©, is called a \newterm{null-pointer constant}.\footnote{
     677One way to conceptualize the null pointer is that no variable is placed at this address, so the null-pointer address can be used to denote an uninitialized pointer/reference object;
     678\ie the null pointer is guaranteed to compare unequal to a pointer to any object or routine.}
     679An address is \newterm{sound}, if it points to a valid memory location in scope, \ie within the program's execution-environment and has not been freed.
     680Dereferencing an \newterm{unsound} address, including the null pointer, is \Index{undefined}, often resulting in a \Index{memory fault}.
     681
     682A program \newterm{object} is a region of data storage in the execution environment, the contents of which can represent values.
     683In most cases, objects are located in memory at an address, and the variable name for an object is an implicit address to the object generated by the compiler and automatically dereferenced, as in:
    673684\begin{quote2}
    674 \begin{tabular}{@{}lll@{}}
     685\begin{tabular}{@{}ll@{\hspace{2em}}l@{}}
    675686\begin{cfa}
    676687int x;
     
    691702\end{quote2}
    692703where the right example is how the compiler logically interprets the variables in the left example.
    693 Since a variable name only points to one location during its lifetime, it is an \Index{immutable} \Index{pointer};
    694 hence, variables ©x© and ©y© are constant pointers in the compiler interpretation.
    695 In general, variable addresses are stored in instructions instead of loaded independently, so an instruction fetch implicitly loads a variable's address.
     704Since a variable name only points to one address during its lifetime, it is an \Index{immutable} \Index{pointer};
     705hence, the implicit type of pointer variables ©x© and ©y© are constant pointers in the compiler interpretation.
     706In general, variable addresses are stored in instructions instead of loaded from memory, and hence may not occupy storage.
     707These approaches are contrasted in the following:
    696708\begin{quote2}
    697709\begin{tabular}{@{}l|l@{}}
     710\multicolumn{1}{c|}{explicit variable address} & \multicolumn{1}{c}{implicit variable address} \\
     711\hline
    698712\begin{cfa}
    699713lda             r1,100                  // load address of x
    700 ld              r2,(r1)                   // load value of x
     714ld               r2,(r1)                  // load value of x
    701715lda             r3,104                  // load address of y
    702 st              r2,(r3)                   // store x into y
     716st               r2,(r3)                  // store x into y
    703717\end{cfa}
    704718&
     
    711725\end{tabular}
    712726\end{quote2}
    713 Finally, the immutable nature of a variable's address and the fact that there is no storage for a variable address means pointer assignment\index{pointer!assignment}\index{assignment!pointer} is impossible.
    714 Therefore, the expression ©x = y© only has one meaning, ©*x = *y©, i.e., manipulate values, which is why explicitly writing the dereferences is unnecessary even though it occurs implicitly as part of instruction decoding.
    715 
    716 A \Index{pointer}/\Index{reference} is a generalization of a variable name, i.e., a mutable address that can point to more than one memory location during its lifetime.
    717 (Similarly, an integer variable can contain multiple integer literals during its lifetime versus an integer constant representing a single literal during its lifetime and may not occupy storage as the literal is embedded directly into instructions.)
     727Finally, the immutable nature of a variable's address and the fact that there is no storage for the variable pointer means pointer assignment\index{pointer!assignment}\index{assignment!pointer} is impossible.
     728Therefore, the expression ©x = y© has only one meaning, ©*x = *y©, \ie manipulate values, which is why explicitly writing the dereferences is unnecessary even though it occurs implicitly as part of \Index{instruction decoding}.
     729
     730A \Index{pointer}/\Index{reference} object is a generalization of an object variable-name, \ie a mutable address that can point to more than one memory location during its lifetime.
     731(Similarly, an integer variable can contain multiple integer literals during its lifetime versus an integer constant representing a single literal during its lifetime, and like a variable name, may not occupy storage if the literal is embedded directly into instructions.)
    718732Hence, a pointer occupies memory to store its current address, and the pointer's value is loaded by dereferencing, \eg:
    719733\begin{quote2}
    720 \begin{tabular}{@{}ll@{}}
     734\begin{tabular}{@{}l@{\hspace{2em}}l@{}}
    721735\begin{cfa}
    722736int x, y, ®*® p1, ®*® p2, ®**® p3;
     
    727741\end{cfa}
    728742&
    729 \raisebox{-0.45\totalheight}{\input{pointer2.pstex_t}}
     743\raisebox{-0.5\totalheight}{\input{pointer2.pstex_t}}
    730744\end{tabular}
    731745\end{quote2}
    732746
    733 Notice, an address has a duality\index{address!duality}: a location in memory or the value at that location.
    734 In many cases, a compiler might be able to infer the meaning:
     747Notice, an address has a \Index{duality}\index{address!duality}: a location in memory or the value at that location.
     748In many cases, a compiler might be able to infer the best meaning for these two cases.
     749For example, \Index*{Algol68}~\cite{Algol68} infers pointer dereferencing to select the best meaning for each pointer usage
    735750\begin{cfa}
    736751p2 = p1 + x;                                    §\C{// compiler infers *p2 = *p1 + x;}§
    737752\end{cfa}
    738 because adding the arbitrary integer value in ©x© to the address of ©p1© and storing the resulting address into ©p2© is an unlikely operation.
    739 \Index*{Algol68}~\cite{Algol68} inferences pointer dereferencing to select the best meaning for each pointer usage.
    740 However, in C, the following cases are ambiguous, especially with pointer arithmetic:
    741 \begin{cfa}
    742 p1 = p2;                                                §\C{// p1 = p2\ \ or\ \ *p1 = *p2}§
    743 p1 = p1 + 1;                                    §\C{// p1 = p1 + 1\ \ or\ \ *p1 = *p1 + 1}§
    744 \end{cfa}
    745 
    746 Most languages pick one meaning as the default and the programmer explicitly indicates the other meaning to resolve the address-duality ambiguity\index{address! ambiguity}.
    747 In C, the default meaning for pointers is to manipulate the pointer's address and the pointed-to value is explicitly accessed by the dereference operator ©*©.
     753Algol68 infers the following dereferencing ©*p2 = *p1 + x©, because adding the arbitrary integer value in ©x© to the address of ©p1© and storing the resulting address into ©p2© is an unlikely operation.
     754Unfortunately, automatic dereferencing does not work in all cases, and so some mechanism is necessary to fix incorrect choices.
     755
     756Rather than inferring dereference, most programming languages pick one implicit dereferencing semantics, and the programmer explicitly indicates the other to resolve address-duality.
     757In C, objects of pointer type always manipulate the pointer object's address:
     758\begin{cfa}
     759p1 = p2;                                                §\C{// p1 = p2\ \ rather than\ \ *p1 = *p2}§
     760p2 = p1 + x;                                    §\C{// p2 = p1 + x\ \ rather than\ \ *p2 = *p1 + x}§
     761\end{cfa}
     762even though the assignment to ©p2© is likely incorrect, and the programmer probably meant:
    748763\begin{cfa}
    749764p1 = p2;                                                §\C{// pointer address assignment}§
    750 *p1 = *p1 + 1;                                  §\C{// pointed-to value assignment / operation}§
    751 \end{cfa}
    752 which works well for situations where manipulation of addresses is the primary meaning and data is rarely accessed, such as storage management (©malloc©/©free©).
     765®*®p2 = ®*®p1 + x;                              §\C{// pointed-to value assignment / operation}§
     766\end{cfa}
     767The C semantics work well for situations where manipulation of addresses is the primary meaning and data is rarely accessed, such as storage management (©malloc©/©free©).
    753768
    754769However, in most other situations, the pointed-to value is requested more often than the pointer address.
     
    762777\end{cfa}
    763778
    764 To switch the default meaning for an address requires a new kind of pointer, called a \newterm{reference} denoted by ©&©.
     779To support this common case, a reference type is introduced in \CFA, denoted by ©&©, which is the opposite dereference semantics to a pointer type, making the value at the pointed-to location the implicit semantics for dereferencing (similar but not the same as \CC \Index{reference type}s).
    765780\begin{cfa}
    766781int x, y, ®&® r1, ®&® r2, ®&&® r3;
     
    773788Except for auto-dereferencing by the compiler, this reference example is the same as the previous pointer example.
    774789Hence, a reference behaves like the variable name for the current variable it is pointing-to.
    775 The simplest way to understand a reference is to imagine the compiler inserting a dereference operator before the reference variable for each reference qualifier in a declaration, \eg:
    776 \begin{cfa}
    777 r2 = ((r1 + r2) * (r3 - r1)) / (r3 - 15);
    778 \end{cfa}
    779 is rewritten as:
     790One way to conceptualize a reference is via a rewrite rule, where the compiler inserts a dereference operator before the reference variable for each reference qualifier in a declaration, so the previous example becomes:
    780791\begin{cfa}
    781792®*®r2 = ((®*®r1 + ®*®r2) ®*® (®**®r3 - ®*®r1)) / (®**®r3 - 15);
    782793\end{cfa}
    783 When a reference operation appears beside a dereference operation, \eg ©&*©, they cancel out.\footnote{
     794When a reference operation appears beside a dereference operation, \eg ©&*©, they cancel out.
     795However, in C, the cancellation always yields a value (\Index{rvalue}).\footnote{
    784796The unary ©&© operator yields the address of its operand.
    785797If the operand has type ``type'', the result has type ``pointer to type''.
    786798If the operand is the result of a unary ©*© operator, neither that operator nor the ©&© operator is evaluated and the result is as if both were omitted, except that the constraints on the operators still apply and the result is not an lvalue.~\cite[\S~6.5.3.2--3]{C11}}
    787 Hence, assigning to a reference requires the address of the reference variable (\Index{lvalue}):
    788 \begin{cfa}
    789 (&®*®)r1 = &x;                                  §\C{// (\&*) cancel giving variable r1 not variable pointed-to by r1}§
     799For a \CFA reference type, the cancellation on the left-hand side of assignment leaves the reference as an address (\Index{lvalue}):
     800\begin{cfa}
     801(&®*®)r1 = &x;                                  §\C{// (\&*) cancel giving address in r1 not variable pointed-to by r1}§
    790802\end{cfa}
    791803Similarly, the address of a reference can be obtained for assignment or computation (\Index{rvalue}):
    792804\begin{cfa}
    793 (&(&®*®)®*®)r3 = &(&®*®)r2;             §\C{// (\&*) cancel giving address of r2, (\&(\&*)*) cancel giving variable r3}§
    794 \end{cfa}
    795 Cancellation\index{cancellation!pointer/reference}\index{pointer!cancellation} works to arbitrary depth, and pointer and reference values are interchangeable because both contain addresses.
     805(&(&®*®)®*®)r3 = &(&®*®)r2;             §\C{// (\&*) cancel giving address in r2, (\&(\&*)*) cancel giving address in r3}§
     806\end{cfa}
     807Cancellation\index{cancellation!pointer/reference}\index{pointer!cancellation} works to arbitrary depth.
     808
     809Fundamentally, pointer and reference objects are functionally interchangeable because both contain addresses.
    796810\begin{cfa}
    797811int x, *p1 = &x, **p2 = &p1, ***p3 = &p2,
     
    805819&&&r3 = p3;                                             §\C{// change r3 to p3, (\&(\&(\&*)*)*)r3, 3 cancellations}§
    806820\end{cfa}
    807 Finally, implicit dereferencing and cancellation are a static (compilation) phenomenon not a dynamic one.
    808 That is, all implicit dereferencing and any cancellation is carried out prior to the start of the program, so reference performance is equivalent to pointer performance.
    809 A programmer selects a pointer or reference type solely on whether the address is dereferenced frequently or infrequently, which dictates the amount of direct aid from the compiler;
    810 otherwise, everything else is equal.
    811 
    812 Interestingly, \Index*[C++]{\CC} deals with the address duality by making the pointed-to value the default, and prevent\-ing changes to the reference address, which eliminates half of the duality.
    813 \Index*{Java} deals with the address duality by making address assignment the default and requiring field assignment (direct or indirect via methods), i.e., there is no builtin bit-wise or method-wise assignment, which eliminates half of the duality.
    814 
    815 As for a pointer, a reference may have qualifiers:
    816 \begin{cfa}
    817 const int cx = 5;                               §\C{// cannot change cx;}§
    818 const int & cr = cx;                    §\C{// cannot change what cr points to}§
    819 ®&®cr = &cx;                                    §\C{// can change cr}§
    820 cr = 7;                                                 §\C{// error, cannot change cx}§
    821 int & const rc = x;                             §\C{// must be initialized, \CC reference}§
    822 ®&®rc = &x;                                             §\C{// error, cannot change rc}§
    823 const int & const crc = cx;             §\C{// must be initialized, \CC reference}§
    824 crc = 7;                                                §\C{// error, cannot change cx}§
    825 ®&®crc = &cx;                                   §\C{// error, cannot change crc}§
    826 \end{cfa}
    827 Hence, for type ©& const©, there is no pointer assignment, so ©&rc = &x© is disallowed, and \emph{the address value cannot be ©0© unless an arbitrary pointer is assigned to the reference}, \eg:
    828 \begin{cfa}
    829 int & const r = *0;                             §\C{// where 0 is the int * zero}§
    830 \end{cfa}
    831 Otherwise, the compiler is managing the addresses for type ©& const© not the programmer, and by a programming discipline of only using references with references, address errors can be prevented.
    832 Finally, the position of the ©const© qualifier \emph{after} the pointer/reference qualifier causes confuse for C programmers.
     821Furthermore, both types are equally performant, as the same amount of dereferencing occurs for both types.
     822Therefore, the choice between them is based solely on whether the address is dereferenced frequently or infrequently, which dictates the amount of implicit dereferencing aid from the compiler.
     823
     824As for a pointer type, a reference type may have qualifiers:
     825\begin{cfa}
     826const int cx = 5;                                       §\C{// cannot change cx;}§
     827const int & cr = cx;                            §\C{// cannot change what cr points to}§
     828®&®cr = &cx;                                            §\C{// can change cr}§
     829cr = 7;                                                         §\C{// error, cannot change cx}§
     830int & const rc = x;                                     §\C{// must be initialized}§
     831®&®rc = &x;                                                     §\C{// error, cannot change rc}§
     832const int & const crc = cx;                     §\C{// must be initialized}§
     833crc = 7;                                                        §\C{// error, cannot change cx}§
     834®&®crc = &cx;                                           §\C{// error, cannot change crc}§
     835\end{cfa}
     836Hence, for type ©& const©, there is no pointer assignment, so ©&rc = &x© is disallowed, and \emph{the address value cannot be the null pointer unless an arbitrary pointer is coerced\index{coercion} into the reference}:
     837\begin{cfa}
     838int & const cr = *0;                            §\C{// where 0 is the int * zero}§
     839\end{cfa}
     840Note, constant reference-types do not prevent \Index{addressing errors} because of explicit storage-management:
     841\begin{cfa}
     842int & const cr = *malloc();
     843cr = 5;
     844free( &cr );
     845cr = 7;                                                         §\C{// unsound pointer dereference}§
     846\end{cfa}
     847
     848The position of the ©const© qualifier \emph{after} the pointer/reference qualifier causes confuse for C programmers.
    833849The ©const© qualifier cannot be moved before the pointer/reference qualifier for C style-declarations;
    834 \CFA-style declarations attempt to address this issue:
     850\CFA-style declarations (see \VRef{s:Declarations}) attempt to address this issue:
    835851\begin{quote2}
    836852\begin{tabular}{@{}l@{\hspace{3em}}l@{}}
     
    847863\end{tabular}
    848864\end{quote2}
    849 where the \CFA declaration is read left-to-right (see \VRef{s:Declarations}).
     865where the \CFA declaration is read left-to-right.
     866
     867Finally, like pointers, references are usable and composable with other type operators and generators.
     868\begin{cfa}
     869int w, x, y, z, & ar[3] = { x, y, z }; §\C{// initialize array of references}§
     870&ar[1] = &w;                                            §\C{// change reference array element}§
     871typeof( ar[1] ) p;                                      §\C{// (gcc) is int, i.e., the type of referenced object}§
     872typeof( &ar[1] ) q;                                     §\C{// (gcc) is int \&, i.e., the type of reference}§
     873sizeof( ar[1] ) == sizeof( int );       §\C{// is true, i.e., the size of referenced object}§
     874sizeof( &ar[1] ) == sizeof( int *)      §\C{// is true, i.e., the size of a reference}§
     875\end{cfa}
     876
     877In contrast to \CFA reference types, \Index*[C++]{\CC{}}'s reference types are all ©const© references, preventing changes to the reference address, so only value assignment is possible, which eliminates half of the \Index{address duality}.
     878Also, \CC does not allow \Index{array}s\index{array!reference} of reference\footnote{
     879The reason for disallowing arrays of reference is unknown, but possibly comes from references being ethereal (like a textual macro), and hence, replaceable by the referant object.}
     880\Index*{Java}'s reference types to objects (all Java objects are on the heap) are like C pointers, which always manipulate the address, and there is no (bit-wise) object assignment, so objects are explicitly cloned by shallow or deep copying, which eliminates half of the address duality.
     881
     882
     883\subsection{Initialization}
    850884
    851885\Index{Initialization} is different than \Index{assignment} because initialization occurs on the empty (uninitialized) storage on an object, while assignment occurs on possibly initialized storage of an object.
    852886There are three initialization contexts in \CFA: declaration initialization, argument/parameter binding, return/temporary binding.
    853 For reference initialization (like pointer), the initializing value must be an address (\Index{lvalue}) not a value (\Index{rvalue}).
    854 \begin{cfa}
    855 int * p = &x;                                   §\C{// both \&x and x are possible interpretations}§
    856 int & r = x;                                    §\C{// x unlikely interpretation, because of auto-dereferencing}§
    857 \end{cfa}
    858 Hence, the compiler implicitly inserts a reference operator, ©&©, before the initialization expression.
    859 Similarly, when a reference is used for a parameter/return type, the call-site argument does not require a reference operator.
    860 \begin{cfa}
    861 int & f( int & rp );                    §\C{// reference parameter and return}§
    862 z = f( x ) + f( y );                    §\C{// reference operator added, temporaries needed for call results}§
    863 \end{cfa}
    864 Within routine ©f©, it is possible to change the argument by changing the corresponding parameter, and parameter ©rp© can be locally reassigned within ©f©.
    865 Since ©?+?© takes its arguments by value, the references returned from ©f© are used to initialize compiler generated temporaries with value semantics that copy from the references.
     887Because the object being initialized has no value, there is only one meaningful semantics with respect to address duality: it must mean address as there is no pointed-to value.
     888In contrast, the left-hand side of assignment has an address that has a duality.
     889Therefore, for pointer/reference initialization, the initializing value must be an address not a value.
     890\begin{cfa}
     891int * p = &x;                                           §\C{// assign address of x}§
     892®int * p = x;®                                          §\C{// assign value of x}§
     893int & r = x;                                            §\C{// must have address of x}§
     894\end{cfa}
     895Like the previous example with C pointer-arithmetic, it is unlikely assigning the value of ©x© into a pointer is meaningful (again, a warning is usually given).
     896Therefore, for safety, this context requires an address, so it is superfluous to require explicitly taking the address of the initialization object, even though the type is incorrect.
     897Note, this is strictly a convenience and safety feature for a programmer.
     898Hence, \CFA allows ©r© to be assigned ©x© because it infers a reference for ©x©, by implicitly inserting a address-of operator, ©&©, and it is an error to put an ©&© because the types no longer match due to the implicit dereference.
     899Unfortunately, C allows ©p© to be assigned with ©&x© (address) or ©x© (value), but most compilers warn about the latter assignment as being potentially incorrect.
     900Similarly, when a reference type is used for a parameter/return type, the call-site argument does not require a reference operator for the same reason.
     901\begin{cfa}
     902int & f( int & r );                                     §\C{// reference parameter and return}§
     903z = f( x ) + f( y );                            §\C{// reference operator added, temporaries needed for call results}§
     904\end{cfa}
     905Within routine ©f©, it is possible to change the argument by changing the corresponding parameter, and parameter ©r© can be locally reassigned within ©f©.
     906Since operator routine ©?+?© takes its arguments by value, the references returned from ©f© are used to initialize compiler generated temporaries with value semantics that copy from the references.
     907\begin{cfa}
     908int temp1 = f( x ), temp2 = f( y );
     909z = temp1 + temp2;
     910\end{cfa}
     911This \Index{implicit referencing} is crucial for reducing the syntactic burden for programmers when using references;
     912otherwise references have the same syntactic  burden as pointers in these contexts.
    866913
    867914When a pointer/reference parameter has a ©const© value (immutable), it is possible to pass literals and expressions.
    868915\begin{cfa}
    869 void f( ®const® int & crp );
    870 void g( ®const® int * cpp );
    871 f( 3 );                   g( &3 );
    872 f( x + y );             g( &(x + y) );
     916void f( ®const® int & cr );
     917void g( ®const® int * cp );
     918f( 3 );                   g( ®&®3 );
     919f( x + y );             g( ®&®(x + y) );
    873920\end{cfa}
    874921Here, the compiler passes the address to the literal 3 or the temporary for the expression ©x + y©, knowing the argument cannot be changed through the parameter.
    875 (The ©&© is necessary for the pointer parameter to make the types match, and is a common requirement for a C programmer.)
    876 \CFA \emph{extends} this semantics to a mutable pointer/reference parameter, and the compiler implicitly creates the necessary temporary (copying the argument), which is subsequently pointed-to by the reference parameter and can be changed.
    877 \begin{cfa}
    878 void f( int & rp );
    879 void g( int * pp );
    880 f( 3 );                   g( &3 );              §\C{// compiler implicit generates temporaries}§
    881 f( x + y );             g( &(x + y) );  §\C{// compiler implicit generates temporaries}§
     922The ©&© before the constant/expression for the pointer-type parameter (©g©) is a \CFA extension necessary to type match and is a common requirement before a variable in C (\eg ©scanf©).
     923Importantly, ©&3© may not be equal to ©&3©, where the references occur across calls because the temporaries maybe different on each call.
     924
     925\CFA \emph{extends} this semantics to a mutable pointer/reference parameter, and the compiler implicitly creates the necessary temporary (copying the argument), which is subsequently pointed-to by the reference parameter and can be changed.\footnote{
     926If whole program analysis is possible, and shows the parameter is not assigned, \ie it is ©const©, the temporary is unnecessary.}
     927\begin{cfa}
     928void f( int & r );
     929void g( int * p );
     930f( 3 );                   g( ®&®3 );            §\C{// compiler implicit generates temporaries}§
     931f( x + y );             g( ®&®(x + y) );        §\C{// compiler implicit generates temporaries}§
    882932\end{cfa}
    883933Essentially, there is an implicit \Index{rvalue} to \Index{lvalue} conversion in this case.\footnote{
     
    885935The implicit conversion allows seamless calls to any routine without having to explicitly name/copy the literal/expression to allow the call.
    886936
    887 While \CFA attempts to handle pointers and references in a uniform, symmetric manner, C handles routine variables in an inconsistent way: a routine variable is both a pointer and a reference (particle and wave).
    888 \begin{cfa}
    889 void f( int p ) {...}
    890 void (*fp)( int ) = &f;                 §\C{// pointer initialization}§
    891 void (*fp)( int ) = f;                  §\C{// reference initialization}§
    892 (*fp)(3);                                               §\C{// pointer invocation}§
    893 fp(3);                                                  §\C{// reference invocation}§
    894 \end{cfa}
    895 A routine variable is best described by a ©const© reference:
    896 \begin{cfa}
    897 const void (&fp)( int ) = f;
    898 fp( 3 );
    899 fp = ...                                                §\C{// error, cannot change code}§
    900 &fp = ...;                                              §\C{// changing routine reference}§
    901 \end{cfa}
    902 because the value of the routine variable is a routine literal, i.e., the routine code is normally immutable during execution.\footnote{
     937%\CFA attempts to handle pointers and references in a uniform, symmetric manner.
     938Finally, C handles \Index{routine object}s in an inconsistent way.
     939A routine object is both a pointer and a reference (\Index{particle and wave}).
     940\begin{cfa}
     941void f( int i );
     942void (*fp)( int );                                      §\C{// routine pointer}§
     943fp = f;                                                         §\C{// reference initialization}§
     944fp = &f;                                                        §\C{// pointer initialization}§
     945fp = *f;                                                        §\C{// reference initialization}§
     946fp(3);                                                          §\C{// reference invocation}§
     947(*fp)(3);                                                       §\C{// pointer invocation}§
     948\end{cfa}
     949While C's treatment of routine objects has similarity to inferring a reference type in initialization contexts, the examples are assignment not initialization, and all possible forms of assignment are possible (©f©, ©&f©, ©*f©) without regard for type.
     950Instead, a routine object should be referenced by a ©const© reference:
     951\begin{cfa}
     952®const® void (®&® fr)( int ) = f;       §\C{// routine reference}§
     953fr = ...                                                        §\C{// error, cannot change code}§
     954&fr = ...;                                                      §\C{// changing routine reference}§
     955fr( 3 );                                                        §\C{// reference call to f}§
     956(*fr)(3);                                                       §\C{// error, incorrect type}§
     957\end{cfa}
     958because the value of the routine object is a routine literal, \ie the routine code is normally immutable during execution.\footnote{
    903959Dynamic code rewriting is possible but only in special circumstances.}
    904 \CFA allows this additional use of references for routine variables in an attempt to give a more consistent meaning for them.
    905 
    906 
    907 \section{Type Operators}
    908 
    909 The new declaration syntax can be used in other contexts where types are required, \eg casts and the pseudo-routine ©sizeof©:
    910 \begin{quote2}
    911 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    912 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    913 \begin{cfa}
    914 y = (®* int®)x;
    915 i = sizeof(®[ 5 ] * int®);
    916 \end{cfa}
    917 &
    918 \begin{cfa}
    919 y = (®int *®)x;
    920 i = sizeof(®int *[ 5 ]®);
    921 \end{cfa}
    922 \end{tabular}
    923 \end{quote2}
     960\CFA allows this additional use of references for routine objects in an attempt to give a more consistent meaning for them.
     961
     962
     963\subsection{Address-of Semantics}
     964
     965In C, ©&E© is an rvalue for any expression ©E©.
     966\CFA extends the ©&© (address-of) operator as follows:
     967\begin{itemize}
     968\item
     969if ©R© is an \Index{rvalue} of type ©T &$_1$...&$_r$© where $r \ge 1$ references (©&© symbols) than ©&R© has type ©T ®*®&$_{\color{red}2}$...&$_{\color{red}r}$©, \ie ©T© pointer with $r-1$ references (©&© symbols).
     970
     971\item
     972if ©L© is an \Index{lvalue} of type ©T &$_1$...&$_l$© where $l \ge 0$ references (©&© symbols) then ©&L© has type ©T ®*®&$_{\color{red}1}$...&$_{\color{red}l}$©, \ie ©T© pointer with $l$ references (©&© symbols).
     973\end{itemize}
     974The following example shows the first rule applied to different \Index{rvalue} contexts:
     975\begin{cfa}
     976int x, * px, ** ppx, *** pppx, **** ppppx;
     977int & rx = x, && rrx = rx, &&& rrrx = rrx ;
     978x = rrrx;               // rrrx is an lvalue with type int &&& (equivalent to x)
     979px = &rrrx;             // starting from rrrx, &rrrx is an rvalue with type int *&&& (&x)
     980ppx = &&rrrx;   // starting from &rrrx, &&rrrx is an rvalue with type int **&& (&rx)
     981pppx = &&&rrrx; // starting from &&rrrx, &&&rrrx is an rvalue with type int ***& (&rrx)
     982ppppx = &&&&rrrx; // starting from &&&rrrx, &&&&rrrx is an rvalue with type int **** (&rrrx)
     983\end{cfa}
     984The following example shows the second rule applied to different \Index{lvalue} contexts:
     985\begin{cfa}
     986int x, * px, ** ppx, *** pppx;
     987int & rx = x, && rrx = rx, &&& rrrx = rrx ;
     988rrrx = 2;               // rrrx is an lvalue with type int &&& (equivalent to x)
     989&rrrx = px;             // starting from rrrx, &rrrx is an rvalue with type int *&&& (rx)
     990&&rrrx = ppx;   // starting from &rrrx, &&rrrx is an rvalue with type int **&& (rrx)
     991&&&rrrx = pppx; // starting from &&rrrx, &&&rrrx is an rvalue with type int ***& (rrrx)
     992\end{cfa}
     993
     994
     995\subsection{Conversions}
     996
     997C provides a basic implicit conversion to simplify variable usage:
     998\begin{enumerate}
     999\setcounter{enumi}{-1}
     1000\item
     1001lvalue to rvalue conversion: ©cv T© converts to ©T©, which allows implicit variable dereferencing.
     1002\begin{cfa}
     1003int x;
     1004x + 1;                  // lvalue variable (int) converts to rvalue for expression
     1005\end{cfa}
     1006An rvalue has no type qualifiers (©cv©), so the lvalue qualifiers are dropped.
     1007\end{enumerate}
     1008\CFA provides three new implicit conversion for reference types to simplify reference usage.
     1009\begin{enumerate}
     1010\item
     1011reference to rvalue conversion: ©cv T &© converts to ©T©, which allows implicit reference dereferencing.
     1012\begin{cfa}
     1013int x, &r = x, f( int p );
     1014x = ®r® + f( ®r® );  // lvalue reference converts to rvalue
     1015\end{cfa}
     1016An rvalue has no type qualifiers (©cv©), so the reference qualifiers are dropped.
     1017
     1018\item
     1019lvalue to reference conversion: \lstinline[deletekeywords={lvalue}]@lvalue-type cv1 T@ converts to ©cv2 T &©, which allows implicitly converting variables to references.
     1020\begin{cfa}
     1021int x, &r = ®x®, f( int & p ); // lvalue variable (int) convert to reference (int &)
     1022f( ®x® );               // lvalue variable (int) convert to reference (int &)
     1023\end{cfa}
     1024Conversion can restrict a type, where ©cv1© $\le$ ©cv2©, \eg passing an ©int© to a ©const volatile int &©, which has low cost.
     1025Conversion can expand a type, where ©cv1© $>$ ©cv2©, \eg passing a ©const volatile int© to an ©int &©, which has high cost (\Index{warning});
     1026furthermore, if ©cv1© has ©const© but not ©cv2©, a temporary variable is created to preserve the immutable lvalue.
     1027
     1028\item
     1029rvalue to reference conversion: ©T© converts to ©cv T &©, which allows binding references to temporaries.
     1030\begin{cfa}
     1031int x, & f( int & p );
     1032f( ®x + 3® );   // rvalue parameter (int) implicitly converts to lvalue temporary reference (int &)
     1033®&f®(...) = &x; // rvalue result (int &) implicitly converts to lvalue temporary reference (int &)
     1034\end{cfa}
     1035In both case, modifications to the temporary are inaccessible (\Index{warning}).
     1036Conversion expands the temporary-type with ©cv©, which is low cost since the temporary is inaccessible.
     1037\end{enumerate}
     1038
     1039
     1040\begin{comment}
     1041From: Richard Bilson <rcbilson@gmail.com>
     1042Date: Wed, 13 Jul 2016 01:58:58 +0000
     1043Subject: Re: pointers / references
     1044To: "Peter A. Buhr" <pabuhr@plg2.cs.uwaterloo.ca>
     1045
     1046As a general comment I would say that I found the section confusing, as you move back and forth
     1047between various real and imagined programming languages. If it were me I would rewrite into two
     1048subsections, one that specifies precisely the syntax and semantics of reference variables and
     1049another that provides the rationale.
     1050
     1051I don't see any obvious problems with the syntax or semantics so far as I understand them. It's not
     1052obvious that the description you're giving is complete, but I'm sure you'll find the special cases
     1053as you do the implementation.
     1054
     1055My big gripes are mostly that you're not being as precise as you need to be in your terminology, and
     1056that you say a few things that aren't actually true even though I generally know what you mean.
     1057
     105820 C provides a pointer type; CFA adds a reference type. Both types contain an address, which is normally a
     105921 location in memory.
     1060
     1061An address is not a location in memory; an address refers to a location in memory. Furthermore it
     1062seems weird to me to say that a type "contains" an address; rather, objects of that type do.
     1063
     106421 Special addresses are used to denote certain states or access co-processor memory. By
     106522 convention, no variable is placed at address 0, so addresses like 0, 1, 2, 3 are often used to denote no-value
     106623 or other special states.
     1067
     1068This isn't standard C at all. There has to be one null pointer representation, but it doesn't have
     1069to be a literal zero representation and there doesn't have to be more than one such representation.
     1070
     107123 Often dereferencing a special state causes a memory fault, so checking is necessary
     107224 during execution.
     1073
     1074I don't see the connection between the two clauses here. I feel like if a bad pointer will not cause
     1075a memory fault then I need to do more checking, not less.
     1076
     107724 If the programming language assigns addresses, a program's execution is sound, \ie all
     107825 addresses are to valid memory locations.
     1079
     1080You haven't said what it means to "assign" an address, but if I use my intuitive understanding of
     1081the term I don't see how this can be true unless you're assuming automatic storage management.
     1082
     10831 Program variables are implicit pointers to memory locations generated by the compiler and automatically
     10842 dereferenced, as in:
     1085
     1086There is no reason why a variable needs to have a location in memory, and indeed in a typical
     1087program many variables will not. In standard terminology an object identifier refers to data in the
     1088execution environment, but not necessarily in memory.
     1089
     109013 A pointer/reference is a generalization of a variable name, \ie a mutable address that can point to more
     109114 than one memory location during its lifetime.
     1092
     1093I feel like you're off the reservation here. In my world there are objects of pointer type, which
     1094seem to be what you're describing here, but also pointer values, which can be stored in an object of
     1095pointer type but don't necessarily have to be. For example, how would you describe the value denoted
     1096by "&main" in a C program? I would call it a (function) pointer, but that doesn't satisfy your
     1097definition.
     1098
     109916 not occupy storage as the literal is embedded directly into instructions.) Hence, a pointer occupies memory
     110017 to store its current address, and the pointer's value is loaded by dereferencing, e.g.:
     1101
     1102As with my general objection regarding your definition of variables, there is no reason why a
     1103pointer variable (object of pointer type) needs to occupy memory.
     1104
     110521 p2 = p1 + x; // compiler infers *p2 = *p1 + x;
     1106
     1107What language are we in now?
     1108
     110924 pointer usage. However, in C, the following cases are ambiguous, especially with pointer arithmetic:
     111025 p1 = p2; // p1 = p2 or *p1 = *p2
     1111
     1112This isn't ambiguous. it's defined to be the first option.
     1113
     111426 p1 = p1 + 1; // p1 = p1 + 1 or *p1 = *p1 + 1
     1115
     1116Again, this statement is not ambiguous.
     1117
     111813 example. Hence, a reference behaves like the variable name for the current variable it is pointing-to. The
     111914 simplest way to understand a reference is to imagine the compiler inserting a dereference operator before
     112015 the reference variable for each reference qualifier in a declaration, e.g.:
     1121
     1122It's hard for me to understand who the audience for this part is. I think a practical programmer is
     1123likely to be satisfied with "a reference behaves like the variable name for the current variable it
     1124is pointing-to," maybe with some examples. Your "simplest way" doesn't strike me as simpler than
     1125that. It feels like you're trying to provide a more precise definition for the semantics of
     1126references, but it isn't actually precise enough to be a formal specification. If you want to
     1127express the semantics of references using rewrite rules that's a great way to do it, but lay the
     1128rules out clearly, and when you're showing an example of rewriting keep your
     1129references/pointers/values separate (right now, you use \eg "r3" to mean a reference, a pointer,
     1130and a value).
     1131
     113224 Cancellation works to arbitrary depth, and pointer and reference values are interchangeable because both
     113325 contain addresses.
     1134
     1135Except they're not interchangeable, because they have different and incompatible types.
     1136
     113740 Interestingly, C++ deals with the address duality by making the pointed-to value the default, and prevent-
     113841 ing changes to the reference address, which eliminates half of the duality. Java deals with the address duality
     113942 by making address assignment the default and requiring field assignment (direct or indirect via methods),
     114043 \ie there is no builtin bit-wise or method-wise assignment, which eliminates half of the duality.
     1141
     1142I can follow this but I think that's mostly because I already understand what you're trying to
     1143say. I don't think I've ever heard the term "method-wise assignment" and I don't see you defining
     1144it. Furthermore Java does have value assignment of basic (non-class) types, so your summary here
     1145feels incomplete. (If it were me I'd drop this paragraph rather than try to save it.)
     1146
     114711 Hence, for type & const, there is no pointer assignment, so &rc = &x is disallowed, and the address value
     114812 cannot be 0 unless an arbitrary pointer is assigned to the reference.
     1149
     1150Given the pains you've taken to motivate every little bit of the semantics up until now, this last
     1151clause ("the address value cannot be 0") comes out of the blue. It seems like you could have
     1152perfectly reasonable semantics that allowed the initialization of null references.
     1153
     115412 In effect, the compiler is managing the
     115513 addresses for type & const not the programmer, and by a programming discipline of only using references
     115614 with references, address errors can be prevented.
     1157
     1158Again, is this assuming automatic storage management?
     1159
     116018 rary binding. For reference initialization (like pointer), the initializing value must be an address (lvalue) not
     116119 a value (rvalue).
     1162
     1163This sentence appears to suggest that an address and an lvalue are the same thing.
     1164
     116520 int * p = &x; // both &x and x are possible interpretations
     1166
     1167Are you saying that we should be considering "x" as a possible interpretation of the initializer
     1168"&x"? It seems to me that this expression has only one legitimate interpretation in context.
     1169
     117021 int & r = x; // x unlikely interpretation, because of auto-dereferencing
     1171
     1172You mean, we can initialize a reference using an integer value? Surely we would need some sort of
     1173cast to induce that interpretation, no?
     1174
     117522 Hence, the compiler implicitly inserts a reference operator, &, before the initialization expression.
     1176
     1177But then the expression would have pointer type, which wouldn't be compatible with the type of r.
     1178
     117922 Similarly,
     118023 when a reference is used for a parameter/return type, the call-site argument does not require a reference
     118124 operator.
     1182
     1183Furthermore, it would not be correct to use a reference operator.
     1184
     118545 The implicit conversion allows
     11861 seamless calls to any routine without having to explicitly name/copy the literal/expression to allow the call.
     11872 While C' attempts to handle pointers and references in a uniform, symmetric manner, C handles routine
     11883 variables in an inconsistent way: a routine variable is both a pointer and a reference (particle and wave).
     1189
     1190After all this talk of how expressions can have both pointer and value interpretations, you're
     1191disparaging C because it has expressions that have both pointer and value interpretations?
     1192
     1193On Sat, Jul 9, 2016 at 4:18 PM Peter A. Buhr <pabuhr@plg.uwaterloo.ca> wrote:
     1194> Aaron discovered a few places where "&"s are missing and where there are too many "&", which are
     1195> corrected in the attached updated. None of the text has changed, if you have started reading
     1196> already.
     1197\end{comment}
    9241198
    9251199
    9261200\section{Routine Definition}
    9271201
    928 \CFA also supports a new syntax for routine definition, as well as ISO C and K\&R routine syntax.
     1202\CFA also supports a new syntax for routine definition, as well as \Celeven and K\&R routine syntax.
    9291203The point of the new syntax is to allow returning multiple values from a routine~\cite{Galletly96,CLU}, \eg:
    9301204\begin{cfa}
     
    9461220in both cases the type is assumed to be void as opposed to old style C defaults of int return type and unknown parameter types, respectively, as in:
    9471221\begin{cfa}
    948 [§\,§] g();                                             §\C{// no input or output parameters}§
    949 [ void ] g( void );                             §\C{// no input or output parameters}§
     1222[§\,§] g();                                                     §\C{// no input or output parameters}§
     1223[ void ] g( void );                                     §\C{// no input or output parameters}§
    9501224\end{cfa}
    9511225
     
    9651239\begin{cfa}
    9661240typedef int foo;
    967 int f( int (* foo) );                   §\C{// foo is redefined as a parameter name}§
     1241int f( int (* foo) );                           §\C{// foo is redefined as a parameter name}§
    9681242\end{cfa}
    9691243The string ``©int (* foo)©'' declares a C-style named-parameter of type pointer to an integer (the parenthesis are superfluous), while the same string declares a \CFA style unnamed parameter of type routine returning integer with unnamed parameter of type pointer to foo.
     
    9731247C-style declarations can be used to declare parameters for \CFA style routine definitions, \eg:
    9741248\begin{cfa}
    975 [ int ] f( * int, int * );              §\C{// returns an integer, accepts 2 pointers to integers}§
    976 [ * int, int * ] f( int );              §\C{// returns 2 pointers to integers, accepts an integer}§
     1249[ int ] f( * int, int * );                      §\C{// returns an integer, accepts 2 pointers to integers}§
     1250[ * int, int * ] f( int );                      §\C{// returns 2 pointers to integers, accepts an integer}§
    9771251\end{cfa}
    9781252The reason for allowing both declaration styles in the new context is for backwards compatibility with existing preprocessor macros that generate C-style declaration-syntax, as in:
    9791253\begin{cfa}
    9801254#define ptoa( n, d ) int (*n)[ d ]
    981 int f( ptoa( p, 5 ) ) ...               §\C{// expands to int f( int (*p)[ 5 ] )}§
    982 [ int ] f( ptoa( p, 5 ) ) ...   §\C{// expands to [ int ] f( int (*p)[ 5 ] )}§
     1255int f( ptoa( p, 5 ) ) ...                       §\C{// expands to int f( int (*p)[ 5 ] )}§
     1256[ int ] f( ptoa( p, 5 ) ) ...           §\C{// expands to [ int ] f( int (*p)[ 5 ] )}§
    9831257\end{cfa}
    9841258Again, programmers are highly encouraged to use one declaration form or the other, rather than mixing the forms.
     
    10021276        int z;
    10031277        ... x = 0; ... y = z; ...
    1004         ®return;® §\C{// implicitly return x, y}§
     1278        ®return;®                                                       §\C{// implicitly return x, y}§
    10051279}
    10061280\end{cfa}
     
    10121286[ int x, int y ] f() {
    10131287        ...
    1014 } §\C{// implicitly return x, y}§
     1288}                                                                               §\C{// implicitly return x, y}§
    10151289\end{cfa}
    10161290In this case, the current values of ©x© and ©y© are returned to the calling routine just as if a ©return© had been encountered.
     1291
     1292Named return values may be used in conjunction with named parameter values;
     1293specifically, a return and parameter can have the same name.
     1294\begin{cfa}
     1295[ int x, int y ] f( int, x, int y ) {
     1296        ...
     1297}                                                                               §\C{// implicitly return x, y}§
     1298\end{cfa}
     1299This notation allows the compiler to eliminate temporary variables in nested routine calls.
     1300\begin{cfa}
     1301[ int x, int y ] f( int, x, int y );    §\C{// prototype declaration}§
     1302int a, b;
     1303[a, b] = f( f( f( a, b ) ) );
     1304\end{cfa}
     1305While the compiler normally ignores parameters names in prototype declarations, here they are used to eliminate temporary return-values by inferring that the results of each call are the inputs of the next call, and ultimately, the left-hand side of the assignment.
     1306Hence, even without the body of routine ©f© (separate compilation), it is possible to perform a global optimization across routine calls.
     1307The compiler warns about naming inconsistencies between routine prototype and definition in this case, and behaviour is \Index{undefined} if the programmer is inconsistent.
    10171308
    10181309
     
    10221313as well, parameter names are optional, \eg:
    10231314\begin{cfa}
    1024 [ int x ] f ();                                 §\C{// returning int with no parameters}§
    1025 [ * int ] g (int y);                    §\C{// returning pointer to int with int parameter}§
    1026 [ ] h (int,char);                               §\C{// returning no result with int and char parameters}§
    1027 [ * int,int ] j (int);                  §\C{// returning pointer to int and int, with int parameter}§
     1315[ int x ] f ();                                                 §\C{// returning int with no parameters}§
     1316[ * int ] g (int y);                                    §\C{// returning pointer to int with int parameter}§
     1317[ ] h ( int, char );                                    §\C{// returning no result with int and char parameters}§
     1318[ * int, int ] j ( int );                               §\C{// returning pointer to int and int, with int parameter}§
    10281319\end{cfa}
    10291320This syntax allows a prototype declaration to be created by cutting and pasting source text from the routine definition header (or vice versa).
     
    10331324\multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    10341325\begin{cfa}
    1035 [ int ] f(int), g;
     1326[ int ] f( int ), g;
    10361327\end{cfa}
    10371328&
    10381329\begin{cfa}
    1039 int f(int), g(int);
     1330int f( int ), g( int );
    10401331\end{cfa}
    10411332\end{tabular}
     
    10431334Declaration qualifiers can only appear at the start of a \CFA routine declaration,\footref{StorageClassSpecifier} \eg:
    10441335\begin{cfa}
    1045 extern [ int ] f (int);
    1046 static [ int ] g (int);
     1336extern [ int ] f ( int );
     1337static [ int ] g ( int );
    10471338\end{cfa}
    10481339
     
    10521343The syntax for pointers to \CFA routines specifies the pointer name on the right, \eg:
    10531344\begin{cfa}
    1054 * [ int x ] () fp;                      §\C{// pointer to routine returning int with no parameters}§
    1055 * [ * int ] (int y) gp;         §\C{// pointer to routine returning pointer to int with int parameter}§
    1056 * [ ] (int,char) hp;            §\C{// pointer to routine returning no result with int and char parameters}§
    1057 * [ * int,int ] (int) jp;       §\C{// pointer to routine returning pointer to int and int, with int parameter}§
     1345* [ int x ] () fp;                                              §\C{// pointer to routine returning int with no parameters}§
     1346* [ * int ] (int y) gp;                                 §\C{// pointer to routine returning pointer to int with int parameter}§
     1347* [ ] (int,char) hp;                                    §\C{// pointer to routine returning no result with int and char parameters}§
     1348* [ * int,int ] ( int ) jp;                             §\C{// pointer to routine returning pointer to int and int, with int parameter}§
    10581349\end{cfa}
    10591350While parameter names are optional, \emph{a routine name cannot be specified};
    10601351for example, the following is incorrect:
    10611352\begin{cfa}
    1062 * [ int x ] f () fp;            §\C{// routine name "f" is not allowed}§
     1353* [ int x ] f () fp;                                    §\C{// routine name "f" is not allowed}§
    10631354\end{cfa}
    10641355
     
    10661357\section{Named and Default Arguments}
    10671358
    1068 Named and default arguments~\cite{Hardgrave76}\footnote{
     1359Named\index{named arguments}\index{arguments!named} and default\index{default arguments}\index{arguments!default} arguments~\cite{Hardgrave76}\footnote{
    10691360Francez~\cite{Francez77} proposed a further extension to the named-parameter passing style, which specifies what type of communication (by value, by reference, by name) the argument is passed to the routine.}
    10701361are two mechanisms to simplify routine call.
     
    12331524
    12341525Given the \CFA restrictions above, both named and default arguments are backwards compatible.
    1235 \Index*[C++]{\CC} only supports default arguments;
     1526\Index*[C++]{\CC{}} only supports default arguments;
    12361527\Index*{Ada} supports both named and default arguments.
    12371528
    12381529
    1239 \section{Type/Routine Nesting}
     1530\section{Unnamed Structure Fields}
     1531
     1532C requires each field of a structure to have a name, except for a bit field associated with a basic type, \eg:
     1533\begin{cfa}
     1534struct {
     1535        int f1;                                 §\C{// named field}§
     1536        int f2 : 4;                             §\C{// named field with bit field size}§
     1537        int : 3;                                §\C{// unnamed field for basic type with bit field size}§
     1538        int ;                                   §\C{// disallowed, unnamed field}§
     1539        int *;                                  §\C{// disallowed, unnamed field}§
     1540        int (*)( int );                 §\C{// disallowed, unnamed field}§
     1541};
     1542\end{cfa}
     1543This requirement is relaxed by making the field name optional for all field declarations; therefore, all the field declarations in the example are allowed.
     1544As for unnamed bit fields, an unnamed field is used for padding a structure to a particular size.
     1545A list of unnamed fields is also supported, \eg:
     1546\begin{cfa}
     1547struct {
     1548        int , , ;                               §\C{// 3 unnamed fields}§
     1549}
     1550\end{cfa}
     1551
     1552
     1553\section{Nesting}
    12401554
    12411555Nesting of types and routines is useful for controlling name visibility (\newterm{name hiding}).
     
    12441558\subsection{Type Nesting}
    12451559
    1246 \CFA allows \Index{type nesting}, and type qualification of the nested typres (see \VRef[Figure]{f:TypeNestingQualification}), where as C hoists\index{type hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
     1560\CFA allows \Index{type nesting}, and type qualification of the nested types (see \VRef[Figure]{f:TypeNestingQualification}), where as C hoists\index{type hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
    12471561\begin{figure}
    12481562\centering
     
    13471661}
    13481662int main() {
    1349         * [int](int) fp = foo();        §\C{// int (*fp)(int)}§
    1350     sout | fp( 3 ) | endl;
     1663        * [int]( int ) fp = foo();      §\C{// int (*fp)( int )}§
     1664        sout | fp( 3 ) | endl;
    13511665}
    13521666\end{cfa}
    13531667because
    13541668
    1355 Currently, there are no \Index{lambda} expressions, i.e., unnamed routines because routine names are very important to properly select the correct routine.
    1356 
    1357 
    1358 \section{Lexical List}
     1669Currently, there are no \Index{lambda} expressions, \ie unnamed routines because routine names are very important to properly select the correct routine.
     1670
     1671
     1672\section{Tuples}
    13591673
    13601674In C and \CFA, lists of elements appear in several contexts, such as the parameter list for a routine call.
     
    13731687[ v+w, x*y, 3.14159, f() ]
    13741688\end{cfa}
    1375 Tuples are permitted to contain sub-tuples (i.e., nesting), such as ©[ [ 14, 21 ], 9 ]©, which is a 2-element tuple whose first element is itself a tuple.
     1689Tuples are permitted to contain sub-tuples (\ie nesting), such as ©[ [ 14, 21 ], 9 ]©, which is a 2-element tuple whose first element is itself a tuple.
    13761690Note, a tuple is not a record (structure);
    13771691a record denotes a single value with substructure, whereas a tuple is multiple values with no substructure (see flattening coercion in Section 12.1).
     
    14291743tuple does not have structure like a record; a tuple is simply converted into a list of components.
    14301744\begin{rationale}
    1431 The present implementation of \CFA does not support nested routine calls when the inner routine returns multiple values; i.e., a statement such as ©g( f() )© is not supported.
     1745The present implementation of \CFA does not support nested routine calls when the inner routine returns multiple values; \ie a statement such as ©g( f() )© is not supported.
    14321746Using a temporary variable to store the  results of the inner routine and then passing this variable to the outer routine works, however.
    14331747\end{rationale}
     
    14421756This requirement is the same as for comma expressions in argument lists.
    14431757
    1444 Type qualifiers, i.e., const and volatile, may modify a tuple type.
    1445 The meaning is the same as for a type qualifier modifying an aggregate type [Int99, x 6.5.2.3(7),x 6.7.3(11)], i.e., the qualifier is distributed across all of the types in the tuple, \eg:
     1758Type qualifiers, \ie const and volatile, may modify a tuple type.
     1759The meaning is the same as for a type qualifier modifying an aggregate type [Int99, x 6.5.2.3(7),x 6.7.3(11)], \ie the qualifier is distributed across all of the types in the tuple, \eg:
    14461760\begin{cfa}
    14471761const volatile [ int, float, const int ] x;
     
    14811795©w© is implicitly opened to yield a tuple of four values, which are then assigned individually.
    14821796
    1483 A \newterm{flattening coercion} coerces a nested tuple, i.e., a tuple with one or more components, which are themselves tuples, into a flattened tuple, which is a tuple whose components are not tuples, as in:
     1797A \newterm{flattening coercion} coerces a nested tuple, \ie a tuple with one or more components, which are themselves tuples, into a flattened tuple, which is a tuple whose components are not tuples, as in:
    14841798\begin{cfa}
    14851799[ a, b, c, d ] = [ 1, [ 2, 3 ], 4 ];
     
    15161830\end{cfa}
    15171831\index{lvalue}
    1518 The left-hand side is a tuple of \emph{lvalues}, which is a list of expressions each yielding an address, i.e., any data object that can appear on the left-hand side of a conventional assignment statement.
     1832The left-hand side is a tuple of \emph{lvalues}, which is a list of expressions each yielding an address, \ie any data object that can appear on the left-hand side of a conventional assignment statement.
    15191833©$\emph{expr}$© is any standard arithmetic expression.
    15201834Clearly, the types of the entities being assigned must be type compatible with the value of the expression.
     
    15571871\index{lvalue}
    15581872The left-hand side is a tuple of \emph{lvalues}, and the right-hand side is a tuple of \emph{expr}s.
    1559 Each \emph{expr} appearing on the righthand side of a multiple assignment statement is assigned to the corresponding \emph{lvalues} on the left-hand side of the statement using parallel semantics for each assignment.
     1873Each \emph{expr} appearing on the right-hand side of a multiple assignment statement is assigned to the corresponding \emph{lvalues} on the left-hand side of the statement using parallel semantics for each assignment.
    15601874An example of multiple assignment is:
    15611875\begin{cfa}
     
    16041918[ x1, y1 ] = z = 0;
    16051919\end{cfa}
    1606 As in C, the rightmost assignment is performed first, i.e., assignment parses right to left.
    1607 
    1608 
    1609 \section{Unnamed Structure Fields}
    1610 
    1611 C requires each field of a structure to have a name, except for a bit field associated with a basic type, \eg:
    1612 \begin{cfa}
    1613 struct {
    1614         int f1;                                 §\C{// named field}§
    1615         int f2 : 4;                             §\C{// named field with bit field size}§
    1616         int : 3;                                §\C{// unnamed field for basic type with bit field size}§
    1617         int ;                                   §\C{// disallowed, unnamed field}§
    1618         int *;                                  §\C{// disallowed, unnamed field}§
    1619         int (*)(int);                   §\C{// disallowed, unnamed field}§
    1620 };
    1621 \end{cfa}
    1622 This requirement is relaxed by making the field name optional for all field declarations; therefore, all the field declarations in the example are allowed.
    1623 As for unnamed bit fields, an unnamed field is used for padding a structure to a particular size.
    1624 A list of unnamed fields is also supported, \eg:
    1625 \begin{cfa}
    1626 struct {
    1627         int , , ;                               §\C{// 3 unnamed fields}§
    1628 }
    1629 \end{cfa}
     1920As in C, the rightmost assignment is performed first, \ie assignment parses right to left.
    16301921
    16311922
     
    16691960
    16701961
    1671 \section{Labelled Continue / Break}
     1962\section{Labelled Continue/Break}
    16721963
    16731964While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    1674 Unfortunately, this restriction forces programmers to use ©goto© to achieve the equivalent control-flow for more than one level of nesting.
    1675 To prevent having to switch to the ©goto©, \CFA extends the ©continue©\index{continue@©continue©}\index{continue@©continue©!labelled}\index{labelled!continue@©continue©} and ©break©\index{break@©break©}\index{break@©break©!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85,Java}.
     1965Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
     1966To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline $continue$!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline $break$!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85,Java}.
    16761967For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    16771968for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
    1678 
    1679 The following example shows the labelled ©continue© specifying which control structure is the target for the next loop iteration:
    1680 \begin{quote2}
    1681 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    1682 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    1683 \begin{cfa}
    1684 ®L1:® do {
    1685         ®L2:® while ( ... ) {
    1686                 ®L3:® for ( ... ) {
    1687                         ... continue ®L1®; ...  // continue do
    1688                         ... continue ®L2®; ...  // continue while
    1689                         ... continue ®L3®; ...  // continue for
    1690                 } // for
    1691         } // while
    1692 } while ( ... );
    1693 \end{cfa}
    1694 &
    1695 \begin{cfa}
    1696 do {
    1697         while ( ... ) {
    1698                 for ( ... ) {
    1699                         ... goto L1; ...
    1700                         ... goto L2; ...
    1701                         ... goto L3; ...
    1702                 L3: ; }
    1703         L2: ; }
    1704 L1: ; } while ( ... );
    1705 \end{cfa}
    1706 \end{tabular}
    1707 \end{quote2}
    1708 The innermost loop has three restart points, which cause the next loop iteration to begin.
    1709 
    1710 The following example shows the labelled ©break© specifying which control structure is the target for exit:
    1711 \begin{quote2}
    1712 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    1713 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    1714 \begin{cfa}
    1715 ®L1:® {
     1969\VRef[Figure]{f:MultiLevelResumeTermination} shows the labelled ©continue© and ©break©, specifying which control structure is the target for exit, and the corresponding C program using only ©goto©.
     1970The innermost loop has 7 exit points, which cause resumption or termination of one or more of the 7 \Index{nested control-structure}s.
     1971
     1972\begin{figure}
     1973\begin{tabular}{@{\hspace{\parindentlnth}}l@{\hspace{1.5em}}l@{}}
     1974\multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}}      & \multicolumn{1}{c}{\textbf{C}}        \\
     1975\begin{cfa}
     1976®LC:® {
    17161977        ... §declarations§ ...
    1717         ®L2:® switch ( ... ) {
     1978        ®LS:® switch ( ... ) {
    17181979          case 3:
    1719             ®L3:® if ( ... ) {
    1720                         ®L4:® for ( ... ) {
    1721                                 ... break ®L1®; ...     // exit compound statement
    1722                                 ... break ®L2®; ...     // exit switch
    1723                                 ... break ®L3®; ...     // exit if
    1724                                 ... break ®L4®; ...     // exit loop
     1980                ®LIF:® if ( ... ) {
     1981                        ®LF:® for ( ... ) {
     1982                                ®LW:® while ( ... ) {
     1983                                        ... break ®LC®; ...                     // terminate compound
     1984                                        ... break ®LS®; ...                     // terminate switch
     1985                                        ... break ®LIF®; ...                    // terminate if
     1986                                        ... continue ®LF;® ...   // resume loop
     1987                                        ... break ®LF®; ...                     // terminate loop
     1988                                        ... continue ®LW®; ...   // resume loop
     1989                                        ... break ®LW®; ...               // terminate loop
     1990                                } // while
    17251991                        } // for
    17261992                } else {
    1727                         ... break ®L3®; ...             // exit if
     1993                        ... break ®LIF®; ...                                     // terminate if
    17281994                } // if
    17291995        } // switch
     
    17362002        switch ( ... ) {
    17372003          case 3:
    1738             if ( ... ) {
     2004                if ( ... ) {
    17392005                        for ( ... ) {
    1740                                 ... goto L1; ...
    1741                                 ... goto L2; ...
    1742                                 ... goto L3; ...
    1743                                 ... goto L4; ...
    1744                         } L4: ;
     2006                                while ( ... ) {
     2007                                        ... goto ®LC®; ...
     2008                                        ... goto ®LS®; ...
     2009                                        ... goto ®LIF®; ...
     2010                                        ... goto ®LFC®; ...
     2011                                        ... goto ®LFB®; ...
     2012                                        ... goto ®LWC®; ...
     2013                                        ... goto ®LWB®; ...
     2014                                  ®LWC®: ; } ®LWB:® ;
     2015                          ®LFC:® ; } ®LFB:® ;
    17452016                } else {
    1746                         ... goto L3; ...
    1747                 } L3: ;
    1748         } L2: ;
    1749 } L1: ;
     2017                        ... goto ®LIF®; ...
     2018                } ®L3:® ;
     2019        } ®LS:® ;
     2020} ®LC:® ;
    17502021\end{cfa}
    17512022\end{tabular}
    1752 \end{quote2}
    1753 The innermost loop has four exit points, which cause termination of one or more of the four \Index{nested control structure}s.
    1754 
    1755 Both ©continue© and ©break© with target labels are simply a ©goto©\index{goto@©goto©!restricted} restricted in the following ways:
     2023\caption{Multi-level Resume/Termination}
     2024\label{f:MultiLevelResumeTermination}
     2025\end{figure}
     2026
     2027\begin{comment}
     2028int main() {
     2029  LC: {
     2030          LS: switch ( 1 ) {
     2031                  case 3:
     2032                  LIF: if ( 1 ) {
     2033                          LF: for ( ;; ) {
     2034                                  LW: while ( 1 ) {
     2035                                                break LC;                       // terminate compound
     2036                                                break LS;                       // terminate switch
     2037                                                break LIF;                      // terminate if
     2038                                                continue LF;     // resume loop
     2039                                                break LF;                       // terminate loop
     2040                                                continue LW;     // resume loop
     2041                                                break LW;                 // terminate loop
     2042                                        } // while
     2043                                } // for
     2044                        } else {
     2045                                break LIF;                                       // terminate if
     2046                        } // if
     2047                } // switch
     2048        } // compound
     2049        {
     2050                switch ( 1 ) {
     2051                  case 3:
     2052                        if ( 1 ) {
     2053                                for ( ;; ) {
     2054                                        while ( 1 ) {
     2055                                                goto LCx;
     2056                                                goto LSx;
     2057                                                goto LIF;
     2058                                                goto LFC;
     2059                                                goto LFB;
     2060                                                goto LWC;
     2061                                                goto LWB;
     2062                                          LWC: ; } LWB: ;
     2063                                  LFC: ; } LFB: ;
     2064                        } else {
     2065                                goto LIF;
     2066                        } L3: ;
     2067                } LSx: ;
     2068        } LCx: ;
     2069}
     2070
     2071// Local Variables: //
     2072// tab-width: 4 //
     2073// End: //
     2074\end{comment}
     2075
     2076
     2077Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline $goto$!restricted} restricted in the following ways:
    17562078\begin{itemize}
    17572079\item
    1758 They cannot be used to create a loop.
    1759 This means that only the looping construct can be used to create a loop.
    1760 This restriction is important since all situations that can result in repeated execution of statements in a program are clearly delineated.
    1761 \item
    1762 Since they always transfer out of containing control structures, they cannot be used to branch into a control structure.
     2080They cannot create a loop, which means only the looping constructs cause looping.
     2081This restriction means all situations resulting in repeated execution are clearly delineated.
     2082\item
     2083They cannot branch into a control structure.
     2084This restriction prevents missing initialization at the start of a control structure resulting in undefined behaviour.
    17632085\end{itemize}
    1764 The advantage of the labelled ©continue©/©break© is allowing static multi-level exits without having to use the ©goto© statement and tying control flow to the target control structure rather than an arbitrary point in a program.
     2086The advantage of the labelled ©continue©/©break© is allowing static multi-level exits without having to use the ©goto© statement, and tying control flow to the target control structure rather than an arbitrary point in a program.
    17652087Furthermore, the location of the label at the \emph{beginning} of the target control structure informs the reader that complex control-flow is occurring in the body of the control structure.
    17662088With ©goto©, the label is at the end of the control structure, which fails to convey this important clue early enough to the reader.
    17672089Finally, using an explicit target for the transfer instead of an implicit target allows new constructs to be added or removed without affecting existing constructs.
    1768 The implicit targets of the current ©continue© and ©break©, i.e., the closest enclosing loop or ©switch©, change as certain constructs are added or removed.
     2090The implicit targets of the current ©continue© and ©break©, \ie the closest enclosing loop or ©switch©, change as certain constructs are added or removed.
    17692091
    17702092
     
    19032225Furthermore, any statements before the first ©case© clause can only be executed if labelled and transferred to using a ©goto©, either from outside or inside of the ©switch©, both of which are problematic.
    19042226As well, the declaration of ©z© cannot occur after the ©case© because a label can only be attached to a statement, and without a fall through to case 3, ©z© is uninitialized.
    1905 The key observation is that the ©switch© statement branches into control structure, i.e., there are multiple entry points into its statement body.
     2227The key observation is that the ©switch© statement branches into control structure, \ie there are multiple entry points into its statement body.
    19062228\end{enumerate}
    19072229
     
    19112233the number of ©switch© statements is small,
    19122234\item
    1913 most ©switch© statements are well formed (i.e., no \Index*{Duff's device}),
     2235most ©switch© statements are well formed (\ie no \Index*{Duff's device}),
    19142236\item
    19152237the ©default© clause is usually written as the last case-clause,
     
    19212243\item
    19222244Eliminating default fall-through has the greatest potential for affecting existing code.
    1923 However, even if fall-through is removed, most ©switch© statements would continue to work because of the explicit transfers already present at the end of each ©case© clause, the common placement of the ©default© clause at the end of the case list, and the most common use of fall-through, i.e., a list of ©case© clauses executing common code, \eg:
     2245However, even if fall-through is removed, most ©switch© statements would continue to work because of the explicit transfers already present at the end of each ©case© clause, the common placement of the ©default© clause at the end of the case list, and the most common use of fall-through, \ie a list of ©case© clauses executing common code, \eg:
    19242246\begin{cfa}
    19252247case 1:  case 2:  case 3: ...
     
    19642286        ®int j = 0;®                            §\C{// disallowed}§
    19652287  case 1:
    1966     {
     2288        {
    19672289                ®int k = 0;®                    §\C{// allowed at different nesting levels}§
    19682290                ...
     
    20792401\index{input/output library}
    20802402
    2081 The goal for the \CFA I/O is to make I/O as simple as possible in the common cases, while fully supporting polymorphism and user defined types in a consistent way.
     2403The goal of \CFA I/O is to simplify the common cases\index{I/O!common case}, while fully supporting polymorphism and user defined types in a consistent way.
     2404The \CFA header file for the I/O library is \Indexc{fstream}.
     2405
    20822406The common case is printing out a sequence of variables separated by whitespace.
    20832407\begin{quote2}
     
    20852409\multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
    20862410\begin{cfa}
    2087 int x = 0, y = 1, z = 2;
     2411int x = 1, y = 2, z = 3;
    20882412sout | x ®|® y ®|® z | endl;
    20892413\end{cfa}
     
    20922416
    20932417cout << x ®<< " "® << y ®<< " "® << z << endl;
     2418\end{cfa}
     2419\\
     2420\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     24211 2 3
     2422\end{cfa}
     2423&
     2424\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     24251 2 3
    20942426\end{cfa}
    20952427\end{tabular}
    20962428\end{quote2}
    20972429The \CFA form has half as many characters as the \CC form, and is similar to \Index*{Python} I/O with respect to implicit separators.
    2098 
    2099 The logical-or operator is used because it is the lowest-priority overloadable operator, other than assignment.
     2430A tuple prints all the tuple's values, each separated by ©", "©.
     2431\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2432[int, int] t1 = [1, 2], t2 = [3, 4];
     2433sout | t1 | t2 | endl;                                  §\C{// print tuples}§
     2434\end{cfa}
     2435\begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt]
     24361, 2, 3, 4
     2437\end{cfa}
     2438\CFA uses the logical-or operator for I/O because it is the lowest-priority overloadable operator, other than assignment.
    21002439Therefore, fewer output expressions require parenthesis.
    21012440\begin{quote2}
     
    21102449&
    21112450\begin{cfa}
    2112 cout << x * 3 << y + 1 << (z << 2) << (x == y) << (x | y) << (x || y) << (x > z ? 1 : 2) << endl;
     2451cout << x * 3 << y + 1 << ®(®z << 2®)® << ®(®x == y®)® << (x | y) << (x || y) << (x > z ? 1 : 2) << endl;
     2452\end{cfa}
     2453\\
     2454&
     2455\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     24563 3 12 0 3 1 2
    21132457\end{cfa}
    21142458\end{tabular}
     
    21162460Finally, the logical-or operator has a link with the Shell pipe-operator for moving data, where data flows in the correct direction for input but the opposite direction for output.
    21172461
    2118 The implicit separator\index{I/O separator} character (space/blank) is a separator not a terminator.
     2462
     2463The implicit separator\index{I/O!separator} character (space/blank) is a separator not a terminator.
    21192464The rules for implicitly adding the separator are:
    21202465\begin{enumerate}
     
    212724721 2 3
    21282473\end{cfa}
     2474
    21292475\item
    21302476A separator does not appear before or after a character literal or variable.
     
    21332479123
    21342480\end{cfa}
    2135 \item
    2136 A separator does not appear before or after a null (empty) C string
     2481
     2482\item
     2483A separator does not appear before or after a null (empty) C string.
    21372484\begin{cfa}
    21382485sout | 1 | "" | 2 | "" | 3 | endl;
     
    21402487\end{cfa}
    21412488which is a local mechanism to disable insertion of the separator character.
    2142 \item
    2143 A separator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{=$£¥¡¿«@
     2489
     2490\item
     2491A separator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$£¥¡¿«@
    21442492%$
    21452493\begin{cfa}[mathescape=off]
     
    21482496\end{cfa}
    21492497%$
    2150 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2151 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
     2498\begin{cfa}[mathescape=off,basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2499x ®(®1 x ®[®2 x ®{®3 x ®=®4 x ®$®5 x ®£®6 x ®¥®7 x ®¡®8 x ®¿®9 x ®«®10
    21522500\end{cfa}
    21532501%$
     2502where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark.
     2503
    21542504\item
    21552505{\lstset{language=CFA,deletedelim=**[is][]{¢}{¢}}
    2156 A seperator does not appear after a C string ending with the (extended) \Index{ASCII}\index{ASCII!extended} characters: ©,.;!?)]}%¢»©
     2506A seperator does not appear after a C string ending with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@
    21572507\begin{cfa}[belowskip=0pt]
    21582508sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x"
    21592509                | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;
    21602510\end{cfa}
    2161 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2162 1, x 2. x 3; x 4! x 5? x 6% x 7§\textcent§ x 8» x 9) x 10] x 11} x
     2511\begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt]
     25121®,® x 2®.® x 3®;® x 4®!® x 5®?® x 6®%® x 7§\color{red}\textcent§ x 8®»® x 9®)® x 10®]® x 11®}® x
    21632513\end{cfa}}%
    2164 \item
    2165 A seperator does not appear before or after a C string begining/ending with the \Index{ASCII} quote or whitespace characters: \lstinline[showspaces=true]@`'": \t\v\f\r\n@
     2514where \lstinline[basicstyle=\tt]@»@ is a closing citation mark.
     2515
     2516\item
     2517A 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@
    21662518\begin{cfa}[belowskip=0pt]
    21672519sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;
    21682520\end{cfa}
    2169 \begin{cfa}[mathescape=off,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
    2170 x`1`x'2'x"3"x:4:x 5 x   6       x
     2521\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     2522x®`®1®`®x§\color{red}\texttt{'}§2§\color{red}\texttt{'}§x§\color{red}\texttt{"}§3§\color{red}\texttt{"}§x®:®4®:®x® ®5® ®x®      ®6®     ®x
     2523\end{cfa}
     2524
     2525\item
     2526If a space is desired before or after one of the special string start/end characters, simply insert a space.
     2527\begin{cfa}[belowskip=0pt]
     2528sout | "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;
     2529\end{cfa}
     2530\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     2531x (® ®1® ®) x 2® ®, x 3® ®:x:® ®4
    21712532\end{cfa}
    21722533\end{enumerate}
    21732534
    2174 The following \CC-style \Index{manipulator}s allow control over implicit seperation.
    2175 Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, i.e., the seperator is adjusted only with respect to the next printed item.
     2535The following routines and \CC-style \Index{manipulator}s control implicit seperation.
     2536\begin{enumerate}
     2537\item
     2538Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
     2539The separator string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
     2540\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2541sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
     2542sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
     2543\end{cfa}
     2544%$
     2545\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     25461, $2, $3 ®", $"®
     2547\end{cfa}
     2548%$
     2549\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2550sepSet( sout, " " );                                            §\C{// reset separator to " "}§
     2551sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
     2552\end{cfa}
     2553\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     25541 2 3 ®" "®
     2555\end{cfa}
     2556
     2557\item
     2558Manipulators \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.
    21762559\begin{cfa}[mathescape=off,belowskip=0pt]
    21772560sout | sepOn | 1 | 2 | 3 | sepOn | endl;        §\C{// separator at start of line}§
     
    2186256912 3
    21872570\end{cfa}
    2188 Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, i.e., the seperator is adjusted with respect to all subsequent printed items, unless locally adjusted.
     2571
     2572\item
     2573Manipulators \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, unless locally adjusted.
    21892574\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    21902575sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separation}§
     
    220525901 2 3
    22062591\end{cfa}
    2207 Printing a tuple outputs all the tuple's values separated by ©", "©:
     2592
     2593\item
     2594Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
     2595The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    22082596\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2209 sout | [2, 3] | [4, 5] | endl;                          §\C{// print tuple}§
     2597sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
     2598sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2599\end{cfa}
     2600\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26011 2 3 4 ®" "®
     2602\end{cfa}
     2603\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2604sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
     2605sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2606\end{cfa}
     2607\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26081, 2, 3, 4 ®", "®
     2609\end{cfa}
     2610
     2611\item
     2612The tuple separator can also be turned on and off.
     2613\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2614sout | sepOn | t1 | sepOff | t2 | endl;         §\C{// locally turn on/off implicit separation}§
    22102615\end{cfa}
    22112616\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2212 2, 3, 4, 5
    2213 \end{cfa}
    2214 The tuple separator can also be turned on and off:
    2215 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2216 sout | sepOn | [2, 3] | sepOff | [4, 5] | endl; §\C{// locally turn on/off implicit separation}§
    2217 \end{cfa}
    2218 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2219 , 2, 34, 5
     2617, 1, 23, 4
    22202618\end{cfa}
    22212619Notice a tuple seperator starts the line because the next item is a tuple.
    2222 Finally, the stream routines \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} and \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} get and set the basic separator-string.
    2223 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2224 sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    2225 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    2226 \end{cfa}
    2227 %$
    2228 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2229 1, $2, $3 ", $"
    2230 \end{cfa}
    2231 %$
    2232 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2233 sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    2234 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    2235 \end{cfa}
    2236 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2237 1 2 3 " "
    2238 \end{cfa}
    2239 and the stream routines \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} and \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} get and set the tuple separator-string.
    2240 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2241 sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    2242 sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
    2243 \end{cfa}
    2244 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2245 2 3 4 5 " "
    2246 \end{cfa}
    2247 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2248 sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    2249 sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
    2250 \end{cfa}
    2251 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2252 2, 3, 4, 5 ", "
    2253 \end{cfa}
     2620\end{enumerate}
    22542621
    22552622\begin{comment}
     
    22572624
    22582625int main( void ) {
    2259         int x = 0, y = 1, z = 2;
    2260         sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl | endl;
     2626        int x = 1, y = 2, z = 3;
     2627        sout | x | y | z | endl;
     2628        [int, int] t1 = [1, 2], t2 = [3, 4];
     2629        sout | t1 | t2 | endl;                                          // print tuple
     2630        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
    22612631        sout | 1 | 2 | 3 | endl;
    22622632        sout | '1' | '2' | '3' | endl;
     
    22672637                | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;
    22682638        sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;
    2269 
    2270         sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
    2271         sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
    2272         sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
    2273         sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
    2274         sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
    2275 
    2276         sout | [2, 3] | [4, 5] | endl;                          // print tuple
    2277         sout | sepOn | [2, 3] | sepOff | [4, 5] | endl; // locally turn on/off implicit separation
     2639        sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;
    22782640
    22792641        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
     
    22822644        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    22832645
     2646        sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
     2647        sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
     2648
     2649        sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
     2650        sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
     2651        sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
     2652
    22842653        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    2285         sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2654        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    22862655        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    2287         sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2656        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2657
     2658        sout | t1 | t2 | endl;                                          // print tuple
     2659        sout | sepOn | t1 | sepOff | t2 | endl;         // locally turn on/off implicit separation
    22882660}
    22892661
    22902662// Local Variables: //
    22912663// tab-width: 4 //
     2664// fill-column: 100 //
    22922665// End: //
    22932666\end{comment}
     
    24092782
    24102783
    2411 \subsection{Constructors and Destructors}
     2784\section{Constructors and Destructors}
    24122785
    24132786\CFA supports C initialization of structures, but it also adds constructors for more advanced initialization.
    2414 Additionally, \CFA adds destructors that are called when a variable is de-allocated (variable goes out of scope or object is deleted).
     2787Additionally, \CFA adds destructors that are called when a variable is deallocated (variable goes out of scope or object is deleted).
    24152788These functions take a reference to the structure as a parameter (see References for more information).
    24162789
     
    24612834\caption{Constructors and Destructors}
    24622835\end{figure}
    2463 
    2464 
    2465 \begin{comment}
    2466 \section{References}
    2467 
    2468 
    2469 By introducing references in parameter types, users are given an easy way to pass a value by reference, without the need for NULL pointer checks.
    2470 In structures, a reference can replace a pointer to an object that should always have a valid value.
    2471 When a structure contains a reference, all of its constructors must initialize the reference and all instances of this structure must initialize it upon definition.
    2472 
    2473 The syntax for using references in \CFA is the same as \CC with the exception of reference initialization.
    2474 Use ©&© to specify a reference, and access references just like regular objects, not like pointers (use dot notation to access fields).
    2475 When initializing a reference, \CFA uses a different syntax which differentiates reference initialization from assignment to a reference.
    2476 The ©&© is used on both sides of the expression to clarify that the address of the reference is being set to the address of the variable to which it refers.
    2477 \end{comment}
    24782836
    24792837
     
    27553113
    27563114
     3115\begin{comment}
    27573116\section{Generics}
    27583117
     
    27603119Generics allow programmers to use type variables in place of concrete types so that the code can be reused with multiple types.
    27613120The type parameters can be restricted to satisfy a set of constraints.
    2762 This enables \CFA to build fully compiled generic functions and types, unlike other languages like \Index*[C++]{\CC} where templates are expanded or must be explicitly instantiated.
     3121This enables \CFA to build fully compiled generic functions and types, unlike other languages like \Index*[C++]{\CC{}} where templates are expanded or must be explicitly instantiated.
    27633122
    27643123
    27653124\subsection{Generic Functions}
    27663125
    2767 Generic functions in \CFA are similar to template functions in \Index*[C++]{\CC}, and will sometimes be expanded into specialized versions, just like in \CC.
     3126Generic functions in \CFA are similar to template functions in \Index*[C++]{\CC{}}, and will sometimes be expanded into specialized versions, just like in \CC.
    27683127The difference, however, is that generic functions in \CFA can also be separately compiled, using function pointers for callers to pass in all needed functionality for the given type.
    27693128This means that compiled libraries can contain generic functions that can be used by programs linked with them (statically or dynamically).
     
    27983157generic (type T | bool ?<?(T, T) )
    27993158
    2800 T min(T a, T b) {
     3159T min( T a, T b ) {
    28013160        return a < b ? a : b;
    28023161}
     
    28373196
    28383197generic (type T | Orderable(T))
    2839 T min(T a, T b) {
     3198T min( T a, T b ) {
    28403199        return a < b ? a : b;
    28413200}
     
    28843243
    28853244Generic types are defined using the same mechanisms as those described above for generic functions.
    2886 This feature allows users to create types that have one or more fields that use generic parameters as types, similar to a template classes in \Index*[C++]{\CC}.
     3245This feature allows users to create types that have one or more fields that use generic parameters as types, similar to a template classes in \Index*[C++]{\CC{}}.
    28873246For example, to make a generic linked list, a placeholder is created for the type of the elements, so that the specific type of the elements in the list need not be specified when defining the list.
    28883247In C, something like this would have to be done using void pointers and unsafe casting.
     
    29363295Throwing an exception terminates execution of the current block, invokes the destructors of variables that are local to the block, and propagates the exception to the parent block.
    29373296The exception is immediately re-thrown from the parent block unless it is caught as described below.
    2938 \CFA uses keywords similar to \Index*[C++]{\CC} for exception handling.
     3297\CFA uses keywords similar to \Index*[C++]{\CC{}} for exception handling.
    29393298An exception is thrown using a throw statement, which accepts one argument.
    29403299
     
    29613320        }
    29623321\end{cfa}
     3322\end{comment}
    29633323
    29643324
     
    30203380        Complex *p3 = new(0.5, 1.0); // allocate + 2 param constructor
    30213381}
    3022 
    30233382\end{cfa}
    30243383
     
    30323391
    30333392
     3393\begin{comment}
    30343394\subsection{Unsafe C Constructs}
    30353395
     
    30423402The exact set of unsafe C constructs that will be disallowed in \CFA has not yet been decided, but is sure to include pointer arithmetic, pointer casting, etc.
    30433403Once the full set is decided, the rules will be listed here.
     3404\end{comment}
    30443405
    30453406
    30463407\section{Concurrency}
    3047 
    3048 Today's processors for nearly all use cases, ranging from embedded systems to large cloud computing servers, are composed of multiple cores, often heterogeneous.
    3049 As machines grow in complexity, it becomes more difficult for a program to make the most use of the hardware available.
    3050 \CFA includes built-in concurrency features to enable high performance and improve programmer productivity on these multi-/many-core machines.
    30513408
    30523409Concurrency support in \CFA is implemented on top of a highly efficient runtime system of light-weight, M:N, user level threads.
     
    30553412This enables a very familiar interface to all programmers, even those with no parallel programming experience.
    30563413It also allows the compiler to do static type checking of all communication, a very important safety feature.
    3057 This controlled communication with type safety has some similarities with channels in \Index*{Go}, and can actually implement
    3058 channels exactly, as well as create additional communication patterns that channels cannot.
     3414This controlled communication with type safety has some similarities with channels in \Index*{Go}, and can actually implement channels exactly, as well as create additional communication patterns that channels cannot.
    30593415Mutex objects, monitors, are used to contain mutual exclusion within an object and synchronization across concurrent threads.
    30603416
    3061 Three new keywords are added to support these features:
    3062 
    3063 monitor creates a structure with implicit locking when accessing fields
    3064 
    3065 mutex implies use of a monitor requiring the implicit locking
    3066 
    3067 task creates a type with implicit locking, separate stack, and a thread
     3417\begin{figure}
     3418\begin{cfa}
     3419#include <fstream>
     3420#include <coroutine>
     3421
     3422coroutine Fibonacci {
     3423        int fn;                                                         §\C{// used for communication}§
     3424};
     3425void ?{}( Fibonacci * this ) {
     3426        this->fn = 0;
     3427}
     3428void main( Fibonacci * this ) {
     3429        int fn1, fn2;                                           §\C{// retained between resumes}§
     3430        this->fn = 0;                                           §\C{// case 0}§
     3431        fn1 = this->fn;
     3432        suspend();                                                      §\C{// return to last resume}§
     3433
     3434        this->fn = 1;                                           §\C{// case 1}§
     3435        fn2 = fn1;
     3436        fn1 = this->fn;
     3437        suspend();                                                      §\C{// return to last resume}§
     3438
     3439        for ( ;; ) {                                            §\C{// general case}§
     3440                this->fn = fn1 + fn2;
     3441                fn2 = fn1;
     3442                fn1 = this->fn;
     3443                suspend();                                              §\C{// return to last resume}§
     3444        } // for
     3445}
     3446int next( Fibonacci * this ) {
     3447        resume( this );                                         §\C{// transfer to last suspend}§
     3448        return this->fn;
     3449}
     3450int main() {
     3451        Fibonacci f1, f2;
     3452        for ( int i = 1; i <= 10; i += 1 ) {
     3453                sout | next( &f1 ) | ' ' | next( &f2 ) | endl;
     3454        } // for
     3455}
     3456\end{cfa}
     3457\caption{Fibonacci Coroutine}
     3458\label{f:FibonacciCoroutine}
     3459\end{figure}
     3460
     3461
     3462\subsection{Coroutine}
     3463
     3464\Index{Coroutines} are the precursor to tasks.
     3465\VRef[Figure]{f:FibonacciCoroutine} shows a coroutine that computes the \Index*{Fibonacci} numbers.
    30683466
    30693467
     
    30803478\end{cfa}
    30813479
     3480\begin{figure}
     3481\begin{cfa}
     3482#include <fstream>
     3483#include <kernel>
     3484#include <monitor>
     3485#include <thread>
     3486
     3487monitor global_t {
     3488        int value;
     3489};
     3490
     3491void ?{}(global_t * this) {
     3492        this->value = 0;
     3493}
     3494
     3495static global_t global;
     3496
     3497void increment3( global_t * mutex this ) {
     3498        this->value += 1;
     3499}
     3500void increment2( global_t * mutex this ) {
     3501        increment3( this );
     3502}
     3503void increment( global_t * mutex this ) {
     3504        increment2( this );
     3505}
     3506
     3507thread MyThread {};
     3508
     3509void main( MyThread* this ) {
     3510        for(int i = 0; i < 1_000_000; i++) {
     3511                increment( &global );
     3512        }
     3513}
     3514int main(int argc, char* argv[]) {
     3515        processor p;
     3516        {
     3517                MyThread f[4];
     3518        }
     3519        sout | global.value | endl;
     3520}
     3521\end{cfa}
     3522\caption{Atomic-Counter Monitor}
     3523\caption{f:AtomicCounterMonitor}
     3524\end{figure}
     3525
     3526\begin{comment}
    30823527Since a monitor structure includes an implicit locking mechanism, it does not make sense to copy a monitor;
    30833528it is always passed by reference.
     
    31263571}
    31273572\end{cfa}
     3573\end{comment}
    31283574
    31293575
     
    31333579A task provides mutual exclusion like a monitor, and also has its own execution state and a thread of control.
    31343580Similar to a monitor, a task is defined like a structure:
     3581
     3582\begin{figure}
     3583\begin{cfa}
     3584#include <fstream>
     3585#include <kernel>
     3586#include <stdlib>
     3587#include <thread>
     3588
     3589thread First  { signal_once * lock; };
     3590thread Second { signal_once * lock; };
     3591
     3592void ?{}( First * this, signal_once* lock ) { this->lock = lock; }
     3593void ?{}( Second * this, signal_once* lock ) { this->lock = lock; }
     3594
     3595void main( First * this ) {
     3596        for ( int i = 0; i < 10; i += 1 ) {
     3597                sout | "First : Suspend No." | i + 1 | endl;
     3598                yield();
     3599        }
     3600        signal( this->lock );
     3601}
     3602
     3603void main( Second * this ) {
     3604        wait( this->lock );
     3605        for ( int i = 0; i < 10; i += 1 ) {
     3606                sout | "Second : Suspend No." | i + 1 | endl;
     3607                yield();
     3608        }
     3609}
     3610
     3611int main( void ) {
     3612        signal_once lock;
     3613        sout | "User main begin" | endl;
     3614        {
     3615                processor p;
     3616                {
     3617                        First  f = { &lock };
     3618                        Second s = { &lock };
     3619                }
     3620        }
     3621        sout | "User main end" | endl;
     3622}
     3623\end{cfa}
     3624\caption{Simple Tasks}
     3625\label{f:SimpleTasks}
     3626\end{figure}
     3627
     3628
     3629\begin{comment}
    31353630\begin{cfa}
    31363631type Adder = task {
     
    31423637
    31433638A task may define a constructor, which will be called upon allocation and run on the caller.s thread.
    3144 A destructor may also be defined, which is called at de-allocation (when a dynamic object is deleted or when a local object goes out of scope).
     3639A destructor may also be defined, which is called at deallocation (when a dynamic object is deleted or when a local object goes out of scope).
    31453640After a task is allocated and initialized, its thread is spawned implicitly and begins executing in its function call method.
    31463641All tasks must define this function call method, with a void return value and no additional parameters, or the compiler will report an error.
     
    31863681\end{cfa}
    31873682
    3188 
    31893683\subsection{Cooperative Scheduling}
    31903684
     
    32993793}
    33003794\end{cfa}
    3301 
    3302 
     3795\end{comment}
     3796
     3797
     3798\begin{comment}
    33033799\section{Modules and Packages }
    33043800
    3305 \begin{comment}
    33063801High-level encapsulation is useful for organizing code into reusable units, and accelerating compilation speed.
    33073802\CFA provides a convenient mechanism for creating, building and sharing groups of functionality that enhances productivity and improves compile time.
     
    33193814\subsection{No Declarations, No Header Files}
    33203815
    3321 In C and \Index*[C++]{\CC}, it is necessary to declare or define every global variable, global function, and type before it is used in each file.
     3816In C and \Index*[C++]{\CC{}}, it is necessary to declare or define every global variable, global function, and type before it is used in each file.
    33223817Header files and a preprocessor are normally used to avoid repeating code.
    33233818Thus, many variables, functions, and types are described twice, which exposes an opportunity for errors and causes additional maintenance work.
     
    39644459In developing \CFA, many other languages were consulted for ideas, constructs, and syntax.
    39654460Therefore, it is important to show how these languages each compare with Do.
    3966 In this section, \CFA is compared with what the writers of this document consider to be the closest competitors of Do: \Index*[C++]{\CC}, \Index*{Go}, \Index*{Rust}, and \Index*{D}.
    3967 
    3968 
     4461In this section, \CFA is compared with what the writers of this document consider to be the closest competitors of Do: \Index*[C++]{\CC{}}, \Index*{Go}, \Index*{Rust}, and \Index*{D}.
     4462
     4463
     4464\begin{comment}
    39694465\subsection[Comparing Key Features of CFA]{Comparing Key Features of \CFA}
    39704466
     
    43444840
    43454841
    4346 \begin{comment}
    43474842\subsubsection{Modules / Packages}
    43484843
     
    44244919}
    44254920\end{cfa}
    4426 \end{comment}
    44274921
    44284922
     
    45855079
    45865080\subsection{Summary of Language Comparison}
    4587 
    4588 
    4589 \subsubsection[C++]{\CC}
    4590 
    4591 \Index*[C++]{\CC} is a general-purpose programming language.
     5081\end{comment}
     5082
     5083
     5084\subsection[C++]{\CC}
     5085
     5086\Index*[C++]{\CC{}} is a general-purpose programming language.
    45925087It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation. (Wikipedia)
    45935088
     
    46085103
    46095104
    4610 \subsubsection{Go}
     5105\subsection{Go}
    46115106
    46125107\Index*{Go}, also commonly referred to as golang, is a programming language developed at Google in 2007 [.].
     
    46245119
    46255120
    4626 \subsubsection{Rust}
     5121\subsection{Rust}
    46275122
    46285123\Index*{Rust} is a general-purpose, multi-paradigm, compiled programming language developed by Mozilla Research.
     
    46385133
    46395134
    4640 \subsubsection{D}
     5135\subsection{D}
    46415136
    46425137The \Index*{D} programming language is an object-oriented, imperative, multi-paradigm system programming
     
    46555150
    46565151
    4657 \section{Syntactic Anomalies}
    4658 
    4659 There are several ambiguous cases with operator identifiers, \eg ©int *?*?()©, where the string ©*?*?© can be lexed as ©*©~\R{/}~©?*?© or ©*?©~\R{/}~©*?©.
    4660 Since it is common practise to put a unary operator juxtaposed to an identifier, \eg ©*i©, users will be annoyed if they cannot do this with respect to operator identifiers.
    4661 Even with this special hack, there are 5 general cases that cannot be handled.
    4662 The first case is for the function-call identifier ©?()©:
    4663 \begin{cfa}
    4664 int *§\textvisiblespace§?()();  // declaration: space required after '*'
    4665 *§\textvisiblespace§?()();              // expression: space required after '*'
    4666 \end{cfa}
    4667 Without the space, the string ©*?()© is ambiguous without N character look ahead;
    4668 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument/parameter list.
    4669 
    4670 The 4 remaining cases occur in expressions:
    4671 \begin{cfa}
    4672 i++§\textvisiblespace§?i:0;             // space required before '?'
    4673 i--§\textvisiblespace§?i:0;             // space required before '?'
    4674 i§\textvisiblespace§?++i:0;             // space required after '?'
    4675 i§\textvisiblespace§?--i:0;             // space required after '?'
    4676 \end{cfa}
    4677 In the first two cases, the string ©i++?© is ambiguous, where this string can be lexed as ©i© / ©++?© or ©i++© / ©?©;
    4678 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument list.
    4679 In the second two cases, the string ©?++x© is ambiguous, where this string can be lexed as ©?++© / ©x© or ©?© / y©++x©;
    4680 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument list.
    4681 
    4682 
    4683 \section{Incompatible}
    4684 
    4685 The following incompatibles exist between \CFA and C, and are similar to Annex C for \CC~\cite{ANSI14:C++}.
    4686 
    4687 \begin{enumerate}
    4688 \item
    4689 \begin{description}
    4690 \item[Change:] add new keywords \\
    4691 New keywords are added to \CFA (see~\VRef{s:NewKeywords}).
    4692 \item[Rationale:] keywords added to implement new semantics of \CFA.
    4693 \item[Effect on original feature:] change to semantics of well-defined feature. \\
    4694 Any ISO C programs using these keywords as identifiers are invalid \CFA programs.
    4695 \item[Difficulty of converting:] keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism (see~\VRef{s:BackquoteIdentifiers}):
    4696 \item[How widely used:] clashes among new \CFA keywords and existing identifiers are rare.
    4697 \end{description}
    4698 
    4699 \item
    4700 \begin{description}
    4701 \item[Change:] type of character literal ©int© to ©char© to allow more intuitive overloading:
    4702 \begin{cfa}
    4703 int rtn( int i );
    4704 int rtn( char c );
    4705 rtn( 'x' );                                             §\C{// programmer expects 2nd rtn to be called}§
    4706 \end{cfa}
    4707 \item[Rationale:] it is more intuitive for the call to ©rtn© to match the second version of definition of ©rtn© rather than the first.
    4708 In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character.
    4709 \begin{cfa}
    4710 sout | 'x' | " " | (int)'x' | endl;
    4711 x 120
    4712 \end{cfa}
    4713 Having to cast ©'x'© to ©char© is non-intuitive.
    4714 \item[Effect on original feature:] change to semantics of well-defined feature that depend on:
    4715 \begin{cfa}
    4716 sizeof( 'x' ) == sizeof( int )
    4717 \end{cfa}
    4718 no long work the same in \CFA programs.
    4719 \item[Difficulty of converting:] simple
    4720 \item[How widely used:] programs that depend upon ©sizeof( 'x' )© are rare and can be changed to ©sizeof(char)©.
    4721 \end{description}
    4722 
    4723 \item
    4724 \begin{description}
    4725 \item[Change:] make string literals ©const©:
    4726 \begin{cfa}
    4727 char * p = "abc";                               §\C{// valid in C, deprecated in \CFA}§
    4728 char * q = expr ? "abc" : "de"; §\C{// valid in C, invalid in \CFA}§
    4729 \end{cfa}
    4730 The type of a string literal is changed from ©[] char© to ©const [] char©.
    4731 Similarly, the type of a wide string literal is changed from ©[] wchar_t© to ©const [] wchar_t©.
    4732 \item[Rationale:] This change is a safety issue:
    4733 \begin{cfa}
    4734 char * p = "abc";
    4735 p[0] = 'w';                                             §\C{// segment fault or change constant literal}§
    4736 \end{cfa}
    4737 The same problem occurs when passing a string literal to a routine that changes its argument.
    4738 \item[Effect on original feature:] change to semantics of well-defined feature.
    4739 \item[Difficulty of converting:] simple syntactic transformation, because string literals can be converted to ©char *©.
    4740 \item[How widely used:] programs that have a legitimate reason to treat string literals as pointers to potentially modifiable memory are rare.
    4741 \end{description}
    4742 
    4743 \item
    4744 \begin{description}
    4745 \item[Change:] remove \newterm{tentative definitions}, which only occurs at file scope:
    4746 \begin{cfa}
    4747 int i;                                                  §\C{// forward definition}§
    4748 int *j = ®&i®;                                  §\C{// forward reference, valid in C, invalid in \CFA}§
    4749 int i = 0;                                              §\C{// definition}§
    4750 \end{cfa}
    4751 is valid in C, and invalid in \CFA because duplicate overloaded object definitions at the same scope level are disallowed.
    4752 This change makes it impossible to define mutually referential file-local static objects, if initializers are restricted to the syntactic forms of C. For example,
    4753 \begin{cfa}
    4754 struct X { int i; struct X *next; };
    4755 static struct X a;                              §\C{// forward definition}§
    4756 static struct X b = { 0, ®&a® };        §\C{// forward reference, valid in C, invalid in \CFA}§
    4757 static struct X a = { 1, &b };  §\C{// definition}§
    4758 \end{cfa}
    4759 \item[Rationale:] avoids having different initialization rules for builtin types and userdefined types.
    4760 \item[Effect on original feature:] change to semantics of well-defined feature.
    4761 \item[Difficulty of converting:] the initializer for one of a set of mutually-referential file-local static objects must invoke a routine call to achieve the initialization.
    4762 \item[How widely used:] seldom
    4763 \end{description}
    4764 
    4765 \item
    4766 \begin{description}
    4767 \item[Change:] have ©struct© introduce a scope for nested types:
    4768 \begin{cfa}
    4769 enum ®Colour® { R, G, B, Y, C, M };
    4770 struct Person {
    4771         enum ®Colour® { R, G, B };      §\C{// nested type}§
    4772         struct Face {                           §\C{// nested type}§
    4773                 ®Colour® Eyes, Hair;    §\C{// type defined outside (1 level)}§
    4774         };
    4775         ß.ß®Colour® shirt;                      §\C{// type defined outside (top level)}§
    4776         ®Colour® pants;                         §\C{// type defined same level}§
    4777         Face looks[10];                         §\C{// type defined same level}§
    4778 };
    4779 ®Colour® c = R;                                 §\C{// type/enum defined same level}§
    4780 Personß.ß®Colour® pc = Personß.ßR;      §\C{// type/enum defined inside}§
    4781 Personß.ßFace pretty;                   §\C{// type defined inside}§
    4782 \end{cfa}
    4783 In C, the name of the nested types belongs to the same scope as the name of the outermost enclosing structure, i.e., the nested types are hoisted to the scope of the outer-most type, which is not useful and confusing.
    4784 \CFA is C \emph{incompatible} on this issue, and provides semantics similar to \Index*[C++]{\CC}.
    4785 Nested types are not hoisted and can be referenced using the field selection operator ``©.©'', unlike the \CC scope-resolution operator ``©::©''.
    4786 \item[Rationale:] ©struct© scope is crucial to \CFA as an information structuring and hiding mechanism.
    4787 \item[Effect on original feature:] change to semantics of well-defined feature.
    4788 \item[Difficulty of converting:] Semantic transformation.
    4789 \item[How widely used:] C programs rarely have nest types because they are equivalent to the hoisted version.
    4790 \end{description}
    4791 
    4792 \item
    4793 \begin{description}
    4794 \item[Change:] In C++, the name of a nested class is local to its enclosing class.
    4795 \item[Rationale:] C++ classes have member functions which require that classes establish scopes.
    4796 \item[Difficulty of converting:] Semantic transformation. To make the struct type name visible in the scope of the enclosing struct, the struct tag could be declared in the scope of the enclosing struct, before the enclosing struct is defined. Example:
    4797 \begin{cfa}
    4798 struct Y;                                               §\C{// struct Y and struct X are at the same scope}§
    4799 struct X {
    4800 struct Y { /* ... */ } y;
    4801 };
    4802 \end{cfa}
    4803 All the definitions of C struct types enclosed in other struct definitions and accessed outside the scope of the enclosing struct could be exported to the scope of the enclosing struct.
    4804 Note: this is a consequence of the difference in scope rules, which is documented in 3.3.
    4805 \item[How widely used:] Seldom.
    4806 \end{description}
    4807 
    4808 \item
    4809 \begin{description}
    4810 \item[Change:] comma expression is disallowed as subscript
    4811 \item[Rationale:] safety issue to prevent subscripting error for multidimensional arrays: ©x[i,j]© instead of ©x[i][j]©, and this syntactic form then taken by \CFA for new style arrays.
    4812 \item[Effect on original feature:] change to semantics of well-defined feature.
    4813 \item[Difficulty of converting:] semantic transformation of ©x[i,j]© to ©x[(i,j)]©
    4814 \item[How widely used:] seldom.
    4815 \end{description}
    4816 \end{enumerate}
     5152\section{Syntax Ambiguities}
     5153
     5154C has a number of syntax ambiguities, which are resolved by taking the longest sequence of overlapping characters that constitute a token.
     5155For example, the program fragment ©x+++++y© is parsed as \lstinline[showspaces=true]@x ++ ++ + y@ because operator tokens ©++© and ©+© overlap.
     5156Unfortunately, the longest sequence violates a constraint on increment operators, even though the parse \lstinline[showspaces=true]@x ++ + ++ y@ might yield a correct expression.
     5157Hence, C programmers are aware that spaces have to added to disambiguate certain syntactic cases.
     5158
     5159In \CFA, there are ambiguous cases with dereference and operator identifiers, \eg ©int *?*?()©, where the string ©*?*?© can be interpreted as:
     5160\begin{cfa}
     5161*?§\color{red}\textvisiblespace§*?              §\C{// dereference operator, dereference operator}§
     5162*§\color{red}\textvisiblespace§?*?              §\C{// dereference, multiplication operator}§
     5163\end{cfa}
     5164By default, the first interpretation is selected, which does not yield a meaningful parse.
     5165Therefore, \CFA does a lexical look-ahead for the second case, and backtracks to return the leading unary operator and reparses the trailing operator identifier.
     5166Otherwise a space is needed between the unary operator and operator identifier to disambiguate this common case.
     5167
     5168A similar issue occurs with the dereference, ©*?(...)©, and routine-call, ©?()(...)© identifiers.
     5169The ambiguity occurs when the deference operator has no parameters:
     5170\begin{cfa}
     5171*?()§\color{red}\textvisiblespace...§ ;
     5172*?()§\color{red}\textvisiblespace...§(...) ;
     5173\end{cfa}
     5174requiring arbitrary whitespace look-ahead for the routine-call parameter-list to disambiguate.
     5175However, the dereference operator \emph{must} have a parameter/argument to dereference ©*?(...)©.
     5176Hence, always interpreting the string ©*?()© as \lstinline[showspaces=true]@* ?()@ does not preclude any meaningful program.
     5177
     5178The remaining cases are with the increment/decrement operators and conditional expression, \eg:
     5179\begin{cfa}
     5180i++?§\color{red}\textvisiblespace...§(...);
     5181i?++§\color{red}\textvisiblespace...§(...);
     5182\end{cfa}
     5183requiring arbitrary whitespace look-ahead for the operator parameter-list, even though that interpretation is an incorrect expression (juxtaposed identifiers).
     5184Therefore, it is necessary to disambiguate these cases with a space:
     5185\begin{cfa}
     5186i++§\color{red}\textvisiblespace§? i : 0;
     5187i?§\color{red}\textvisiblespace§++i : 0;
     5188\end{cfa}
    48175189
    48185190
     
    48215193
    48225194\begin{quote2}
    4823 \begin{tabular}{lll}
     5195\begin{tabular}{llll}
    48245196\begin{tabular}{@{}l@{}}
    48255197©_AT©                   \\
     
    48295201©coroutine©             \\
    48305202©disable©               \\
    4831 ©dtype©                 \\
    4832 ©enable©                \\
    48335203\end{tabular}
    48345204&
    48355205\begin{tabular}{@{}l@{}}
     5206©dtype©                 \\
     5207©enable©                \\
    48365208©fallthrough©   \\
    48375209©fallthru©              \\
    48385210©finally©               \\
    48395211©forall©                \\
     5212\end{tabular}
     5213&
     5214\begin{tabular}{@{}l@{}}
    48405215©ftype©                 \\
    48415216©lvalue©                \\
    48425217©monitor©               \\
    48435218©mutex©                 \\
     5219©one_t©                 \\
     5220©otype©                 \\
    48445221\end{tabular}
    48455222&
    48465223\begin{tabular}{@{}l@{}}
    4847 ©one_t©                 \\
    4848 ©otype©                 \\
    48495224©throw©                 \\
    48505225©throwResume©   \\
     
    48585233
    48595234
     5235\section{Incompatible}
     5236
     5237The following incompatibles exist between \CFA and C, and are similar to Annex C for \CC~\cite{C++14}.
     5238
     5239
     5240\begin{enumerate}
     5241\item
     5242\begin{description}
     5243\item[Change:] add new keywords \\
     5244New keywords are added to \CFA (see~\VRef{s:CFAKeywords}).
     5245\item[Rationale:] keywords added to implement new semantics of \CFA.
     5246\item[Effect on original feature:] change to semantics of well-defined feature. \\
     5247Any \Celeven programs using these keywords as identifiers are invalid \CFA programs.
     5248\item[Difficulty of converting:] keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism (see~\VRef{s:BackquoteIdentifiers}).
     5249\item[How widely used:] clashes among new \CFA keywords and existing identifiers are rare.
     5250\end{description}
     5251
     5252\item
     5253\begin{description}
     5254\item[Change:] drop K\&R C declarations \\
     5255K\&R declarations allow an implicit base-type of ©int©, if no type is specified, plus an alternate syntax for declaring parameters.
     5256\eg:
     5257\begin{cfa}
     5258x;                                                              §\C{// int x}§
     5259*y;                                                             §\C{// int *y}§
     5260f( p1, p2 );                                    §\C{// int f( int p1, int p2 );}§
     5261g( p1, p2 ) int p1, p2;                 §\C{// int g( int p1, int p2 );}§
     5262\end{cfa}
     5263\CFA supports K\&R routine definitions:
     5264\begin{cfa}
     5265f( a, b, c )                                    §\C{// default int return}§
     5266        int a, b; char c                        §\C{// K\&R parameter declarations}§
     5267{
     5268        ...
     5269}
     5270\end{cfa}
     5271\item[Rationale:] dropped from \Celeven standard.\footnote{
     5272At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and type name~\cite[\S~6.7.2(2)]{C11}}
     5273\item[Effect on original feature:] original feature is deprecated. \\
     5274Any old C programs using these K\&R declarations are invalid \CFA programs.
     5275\item[Difficulty of converting:] trivial to convert to \CFA.
     5276\item[How widely used:] existing usages are rare.
     5277\end{description}
     5278
     5279\item
     5280\begin{description}
     5281\item[Change:] type of character literal ©int© to ©char© to allow more intuitive overloading:
     5282\begin{cfa}
     5283int rtn( int i );
     5284int rtn( char c );
     5285rtn( 'x' );                                             §\C{// programmer expects 2nd rtn to be called}§
     5286\end{cfa}
     5287\item[Rationale:] it is more intuitive for the call to ©rtn© to match the second version of definition of ©rtn© rather than the first.
     5288In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character.
     5289\begin{cfa}
     5290sout | 'x' | " " | (int)'x' | endl;
     5291x 120
     5292\end{cfa}
     5293Having to cast ©'x'© to ©char© is non-intuitive.
     5294\item[Effect on original feature:] change to semantics of well-defined feature that depend on:
     5295\begin{cfa}
     5296sizeof( 'x' ) == sizeof( int )
     5297\end{cfa}
     5298no long work the same in \CFA programs.
     5299\item[Difficulty of converting:] simple
     5300\item[How widely used:] programs that depend upon ©sizeof( 'x' )© are rare and can be changed to ©sizeof(char)©.
     5301\end{description}
     5302
     5303\item
     5304\begin{description}
     5305\item[Change:] make string literals ©const©:
     5306\begin{cfa}
     5307char * p = "abc";                               §\C{// valid in C, deprecated in \CFA}§
     5308char * q = expr ? "abc" : "de"; §\C{// valid in C, invalid in \CFA}§
     5309\end{cfa}
     5310The type of a string literal is changed from ©[] char© to ©const [] char©.
     5311Similarly, the type of a wide string literal is changed from ©[] wchar_t© to ©const [] wchar_t©.
     5312\item[Rationale:] This change is a safety issue:
     5313\begin{cfa}
     5314char * p = "abc";
     5315p[0] = 'w';                                             §\C{// segment fault or change constant literal}§
     5316\end{cfa}
     5317The same problem occurs when passing a string literal to a routine that changes its argument.
     5318\item[Effect on original feature:] change to semantics of well-defined feature.
     5319\item[Difficulty of converting:] simple syntactic transformation, because string literals can be converted to ©char *©.
     5320\item[How widely used:] programs that have a legitimate reason to treat string literals as pointers to potentially modifiable memory are rare.
     5321\end{description}
     5322
     5323\item
     5324\begin{description}
     5325\item[Change:] remove \newterm{tentative definitions}, which only occurs at file scope:
     5326\begin{cfa}
     5327int i;                                                  §\C{// forward definition}§
     5328int *j = ®&i®;                                  §\C{// forward reference, valid in C, invalid in \CFA}§
     5329int i = 0;                                              §\C{// definition}§
     5330\end{cfa}
     5331is valid in C, and invalid in \CFA because duplicate overloaded object definitions at the same scope level are disallowed.
     5332This change makes it impossible to define mutually referential file-local static objects, if initializers are restricted to the syntactic forms of C. For example,
     5333\begin{cfa}
     5334struct X { int i; struct X *next; };
     5335static struct X a;                              §\C{// forward definition}§
     5336static struct X b = { 0, ®&a® };        §\C{// forward reference, valid in C, invalid in \CFA}§
     5337static struct X a = { 1, &b };  §\C{// definition}§
     5338\end{cfa}
     5339\item[Rationale:] avoids having different initialization rules for builtin types and user-defined types.
     5340\item[Effect on original feature:] change to semantics of well-defined feature.
     5341\item[Difficulty of converting:] the initializer for one of a set of mutually-referential file-local static objects must invoke a routine call to achieve the initialization.
     5342\item[How widely used:] seldom
     5343\end{description}
     5344
     5345\item
     5346\begin{description}
     5347\item[Change:] have ©struct© introduce a scope for nested types:
     5348\begin{cfa}
     5349enum ®Colour® { R, G, B, Y, C, M };
     5350struct Person {
     5351        enum ®Colour® { R, G, B };      §\C{// nested type}§
     5352        struct Face {                           §\C{// nested type}§
     5353                ®Colour® Eyes, Hair;    §\C{// type defined outside (1 level)}§
     5354        };
     5355        ®.Colour® shirt;                        §\C{// type defined outside (top level)}§
     5356        ®Colour® pants;                         §\C{// type defined same level}§
     5357        Face looks[10];                         §\C{// type defined same level}§
     5358};
     5359®Colour® c = R;                                 §\C{// type/enum defined same level}§
     5360Person®.Colour® pc = Person®.®R;        §\C{// type/enum defined inside}§
     5361Person®.®Face pretty;                   §\C{// type defined inside}§
     5362\end{cfa}
     5363In C, the name of the nested types belongs to the same scope as the name of the outermost enclosing structure, \ie the nested types are hoisted to the scope of the outer-most type, which is not useful and confusing.
     5364\CFA is C \emph{incompatible} on this issue, and provides semantics similar to \Index*[C++]{\CC{}}.
     5365Nested types are not hoisted and can be referenced using the field selection operator ``©.©'', unlike the \CC scope-resolution operator ``©::©''.
     5366\item[Rationale:] ©struct© scope is crucial to \CFA as an information structuring and hiding mechanism.
     5367\item[Effect on original feature:] change to semantics of well-defined feature.
     5368\item[Difficulty of converting:] Semantic transformation.
     5369\item[How widely used:] C programs rarely have nest types because they are equivalent to the hoisted version.
     5370\end{description}
     5371
     5372\item
     5373\begin{description}
     5374\item[Change:] In C++, the name of a nested class is local to its enclosing class.
     5375\item[Rationale:] C++ classes have member functions which require that classes establish scopes.
     5376\item[Difficulty of converting:] Semantic transformation. To make the struct type name visible in the scope of the enclosing struct, the struct tag could be declared in the scope of the enclosing struct, before the enclosing struct is defined. Example:
     5377\begin{cfa}
     5378struct Y;                                               §\C{// struct Y and struct X are at the same scope}§
     5379struct X {
     5380        struct Y { /* ... */ } y;
     5381};
     5382\end{cfa}
     5383All the definitions of C struct types enclosed in other struct definitions and accessed outside the scope of the enclosing struct could be exported to the scope of the enclosing struct.
     5384Note: this is a consequence of the difference in scope rules, which is documented in 3.3.
     5385\item[How widely used:] Seldom.
     5386\end{description}
     5387
     5388\item
     5389\begin{description}
     5390\item[Change:] comma expression is disallowed as subscript
     5391\item[Rationale:] safety issue to prevent subscripting error for multidimensional arrays: ©x[i,j]© instead of ©x[i][j]©, and this syntactic form then taken by \CFA for new style arrays.
     5392\item[Effect on original feature:] change to semantics of well-defined feature.
     5393\item[Difficulty of converting:] semantic transformation of ©x[i,j]© to ©x[(i,j)]©
     5394\item[How widely used:] seldom.
     5395\end{description}
     5396\end{enumerate}
     5397
     5398
    48605399\section{Standard Headers}
    48615400\label{s:StandardHeaders}
    48625401
    4863 C11 prescribes the following standard header-files~\cite[\S~7.1.2]{C11} and \CFA adds to this list:
     5402\Celeven prescribes the following standard header-files~\cite[\S~7.1.2]{C11} and \CFA adds to this list:
    48645403\begin{quote2}
    4865 \begin{tabular}{lll|l}
    4866 \multicolumn{3}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
     5404\lstset{deletekeywords={float}}
     5405\begin{tabular}{@{}llll|l@{}}
     5406\multicolumn{4}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
    48675407\hline
    4868 assert.h        & math.h                & stdlib.h              & unistd.h      \\
    4869 complex.h       & setjmp.h              & stdnoreturn.h & gmp.h         \\
    4870 ctype.h         & signal.h              & string.h              \\
    4871 errno.h         & stdalign.h    & tgmath.h              \\
    4872 fenv.h          & stdarg.h              & threads.h             \\
    4873 float.h         & stdatomic.h   & time.h                \\
    4874 inttypes.h      & stdbool.h             & uchar.h               \\
    4875 iso646.h        & stddef.h              & wchar.h               \\
    4876 limits.h        & stdint.h              & wctype.h              \\
    4877 locale.h        & stdio.h               &                               \\
     5408\begin{tabular}{@{}l@{}}
     5409\Indexc{assert.h}               \\
     5410\Indexc{complex.h}              \\
     5411\Indexc{ctype.h}                \\
     5412\Indexc{errno.h}                \\
     5413\Indexc{fenv.h}                 \\
     5414\Indexc{float.h}                \\
     5415\Indexc{inttypes.h}             \\
     5416\Indexc{iso646.h}               \\
     5417\end{tabular}
     5418&
     5419\begin{tabular}{@{}l@{}}
     5420\Indexc{limits.h}               \\
     5421\Indexc{locale.h}               \\
     5422\Indexc{math.h}                 \\
     5423\Indexc{setjmp.h}               \\
     5424\Indexc{signal.h}               \\
     5425\Indexc{stdalign.h}             \\
     5426\Indexc{stdarg.h}               \\
     5427\Indexc{stdatomic.h}    \\
     5428\end{tabular}
     5429&
     5430\begin{tabular}{@{}l@{}}
     5431\Indexc{stdbool.h}              \\
     5432\Indexc{stddef.h}               \\
     5433\Indexc{stdint.h}               \\
     5434\Indexc{stdio.h}                \\
     5435\Indexc{stdlib.h}               \\
     5436\Indexc{stdnoreturn.h}  \\
     5437\Indexc{string.h}               \\
     5438\Indexc{tgmath.h}               \\
     5439\end{tabular}
     5440&
     5441\begin{tabular}{@{}l@{}}
     5442\Indexc{threads.h}              \\
     5443\Indexc{time.h}                 \\
     5444\Indexc{uchar.h}                \\
     5445\Indexc{wchar.h}                \\
     5446\Indexc{wctype.h}               \\
     5447                                                \\
     5448                                                \\
     5449                                                \\
     5450\end{tabular}
     5451&
     5452\begin{tabular}{@{}l@{}}
     5453\Indexc{unistd.h}               \\
     5454\Indexc{gmp.h}                  \\
     5455                                                \\
     5456                                                \\
     5457                                                \\
     5458                                                \\
     5459                                                \\
     5460                                                \\
     5461\end{tabular}
    48785462\end{tabular}
    48795463\end{quote2}
    4880 For the prescribed head-files, \CFA implicitly wraps their includes in an ©extern "C"©;
     5464For the prescribed head-files, \CFA uses header interposition to wraps these includes in an ©extern "C"©;
    48815465hence, names in these include files are not mangled\index{mangling!name} (see~\VRef{s:Interoperability}).
    48825466All other C header files must be explicitly wrapped in ©extern "C"© to prevent name mangling.
     5467For \Index*[C++]{\CC{}}, the name-mangling issue is handled implicitly because most C header-files are augmented with checks for preprocessor variable ©__cplusplus©, which adds appropriate ©extern "C"© qualifiers.
    48835468
    48845469
     
    48865471\label{s:StandardLibrary}
    48875472
    4888 The goal of the \CFA standard-library is to wrap many of the existing C library-routines that are explicitly polymorphic into implicitly polymorphic versions.
    4889 
    4890 
    4891 \subsection{malloc}
     5473The \CFA standard-library wraps explicitly-polymorphic C routines into implicitly-polymorphic versions.
     5474
     5475
     5476\subsection{Storage Management}
     5477
     5478The storage-management routines extend their C equivalents by overloading, alternate names, providing shallow type-safety, and removing the need to specify the allocation size for non-array types.
     5479
     5480Storage management provides the following capabilities:
     5481\begin{description}
     5482\item[fill]
     5483after allocation the storage is filled with a specified character.
     5484\item[resize]
     5485an existing allocation is decreased or increased in size.
     5486In either case, new storage may or may not be allocated and, if there is a new allocation, as much data from the existing allocation is copied.
     5487For an increase in storage size, new storage after the copied data may be filled.
     5488\item[alignment]
     5489an allocation starts on a specified memory boundary, e.g., an address multiple of 64 or 128 for cache-line purposes.
     5490\item[array]
     5491the allocation size is scaled to the specified number of array elements.
     5492An array may be filled, resized, or aligned.
     5493\end{description}
     5494The table shows allocation routines supporting different combinations of storage-management capabilities:
     5495\begin{center}
     5496\begin{tabular}{@{}lr|l|l|l|l@{}}
     5497                &                                       & \multicolumn{1}{c|}{fill}     & resize        & alignment     & array \\
     5498\hline
     5499C               & ©malloc©                      & no                    & no            & no            & no    \\
     5500                & ©calloc©                      & yes (0 only)  & no            & no            & yes   \\
     5501                & ©realloc©                     & no/copy               & yes           & no            & no    \\
     5502                & ©memalign©            & no                    & no            & yes           & no    \\
     5503                & ©posix_memalign©      & no                    & no            & yes           & no    \\
     5504C11             & ©aligned_alloc©       & no                    & no            & yes           & no    \\
     5505\CFA    & ©alloc©                       & no/copy/yes   & no/yes        & no            & yes   \\
     5506                & ©align_alloc©         & no/yes                & no            & yes           & yes   \\
     5507\end{tabular}
     5508\end{center}
     5509It is impossible to resize with alignment because the underlying ©realloc© allocates storage if more space is needed, and it does not honour alignment from the original allocation.
    48925510
    48935511\leavevmode
    48945512\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    4895 forall( otype T ) T * malloc( void );§\indexc{malloc}§
    4896 forall( otype T ) T * malloc( char fill );
    4897 forall( otype T ) T * malloc( T * ptr, size_t size );
    4898 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill );
    4899 forall( otype T ) T * calloc( size_t nmemb );§\indexc{calloc}§
    4900 forall( otype T ) T * realloc( T * ptr, size_t size );§\indexc{ato}§
    4901 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill );
    4902 
    4903 forall( otype T ) T * aligned_alloc( size_t alignment );§\indexc{ato}§
    4904 forall( otype T ) T * memalign( size_t alignment );             // deprecated
    4905 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment );
    4906 
    4907 forall( otype T ) T * memset( T * ptr, unsigned char fill ); // use default value '\0' for fill
    4908 forall( otype T ) T * memset( T * ptr );                                // remove when default value available
    4909 \end{cfa}
    4910 
    4911 
    4912 \subsection{ato / strto}
     5513// C unsafe allocation
     5514extern "C" {
     5515void * mallac( size_t size );§\indexc{memset}§
     5516void * calloc( size_t dim, size_t size );§\indexc{calloc}§
     5517void * realloc( void * ptr, size_t size );§\indexc{realloc}§
     5518void * memalign( size_t align, size_t size );§\indexc{memalign}§
     5519int posix_memalign( void ** ptr, size_t align, size_t size );§\indexc{posix_memalign}§
     5520}
     5521
     5522// §\CFA§ safe equivalents, i.e., implicit size specification
     5523forall( dtype T | sized(T) ) T * malloc( void );
     5524forall( dtype T | sized(T) ) T * calloc( size_t dim );
     5525forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size );
     5526forall( dtype T | sized(T) ) T * memalign( size_t align );
     5527forall( dtype T | sized(T) ) T * aligned_alloc( size_t align );
     5528forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t align );
     5529
     5530// §\CFA§ safe general allocation, fill, resize, array
     5531forall( dtype T | sized(T) ) T * alloc( void );§\indexc{alloc}§
     5532forall( dtype T | sized(T) ) T * alloc( char fill );
     5533forall( dtype T | sized(T) ) T * alloc( size_t dim );
     5534forall( dtype T | sized(T) ) T * alloc( size_t dim, char fill );
     5535forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim );
     5536forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
     5537
     5538// §\CFA§ safe general allocation, align, fill, array
     5539forall( dtype T | sized(T) ) T * align_alloc( size_t align );
     5540forall( dtype T | sized(T) ) T * align_alloc( size_t align, char fill );
     5541forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim );
     5542forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim, char fill );
     5543
     5544// C unsafe initialization/copy
     5545extern "C" {
     5546void * memset( void * dest, int c, size_t size );
     5547void * memcpy( void * dest, const void * src, size_t size );
     5548}
     5549
     5550// §\CFA§ safe initialization/copy, i.e., implicit size specification
     5551forall( dtype T | sized(T) ) T * memset( T * dest, char c );§\indexc{memset}§
     5552forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src );§\indexc{memcpy}§
     5553
     5554// §\CFA§ safe initialization/copy array
     5555forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c );
     5556forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim );
     5557
     5558// §\CFA§ allocation/deallocation and constructor/destructor
     5559forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p );§\indexc{new}§
     5560forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr );§\indexc{delete}§
     5561forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } )
     5562  void delete( T * ptr, Params rest );
     5563
     5564// §\CFA§ allocation/deallocation and constructor/destructor, array
     5565forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p );§\indexc{anew}§
     5566forall( dtype T | sized(T) | { void ^?{}( T * ); } ) void adelete( size_t dim, T arr[] );§\indexc{adelete}§
     5567forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } )
     5568  void adelete( size_t dim, T arr[], Params rest );
     5569\end{cfa}
     5570
     5571
     5572\subsection{Conversion}
    49135573
    49145574\leavevmode
     
    49425602
    49435603
    4944 \subsection{bsearch / qsort}
     5604\subsection{Search / Sort}
    49455605
    49465606\leavevmode
    49475607\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     5608forall( otype T | { int ?<?( T, T ); } )        §\C{// location}§
     5609T * bsearch( T key, const T * arr, size_t dim );§\indexc{bsearch}§
     5610
     5611forall( otype T | { int ?<?( T, T ); } )        §\C{// position}§
     5612unsigned int bsearch( T key, const T * arr, size_t dim );
     5613
    49485614forall( otype T | { int ?<?( T, T ); } )
    4949 T * bsearch( const T key, const T * arr, size_t dimension );§\indexc{bsearch}§
    4950 
    4951 forall( otype T | { int ?<?( T, T ); } )
    4952 void qsort( const T * arr, size_t dimension );§\indexc{qsort}§
    4953 \end{cfa}
    4954 
    4955 
    4956 \subsection{abs}
     5615void qsort( const T * arr, size_t dim );§\indexc{qsort}§
     5616\end{cfa}
     5617
     5618
     5619\subsection{Absolute Value}
    49575620
    49585621\leavevmode
    49595622\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    4960 char abs( char );§\indexc{abs}§
     5623unsigned char abs( signed char );§\indexc{abs}§
    49615624int abs( int );
    4962 long int abs( long int );
    4963 long long int abs( long long int );
     5625unsigned long int abs( long int );
     5626unsigned long long int abs( long long int );
    49645627float abs( float );
    49655628double abs( double );
     
    49685631double abs( double _Complex );
    49695632long double abs( long double _Complex );
    4970 \end{cfa}
    4971 
    4972 
    4973 \subsection{random}
     5633forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
     5634T abs( T );
     5635\end{cfa}
     5636
     5637
     5638\subsection{Random Numbers}
    49745639
    49755640\leavevmode
     
    49895654
    49905655
    4991 \subsection{min / max / clamp / swap}
     5656\subsection{Algorithms}
    49925657
    49935658\leavevmode
    49945659\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    4995 forall( otype T | { int ?<?( T, T ); } )
    4996 T min( const T t1, const T t2 );§\indexc{min}§
    4997 
    4998 forall( otype T | { int ?>?( T, T ); } )
    4999 T max( const T t1, const T t2 );§\indexc{max}§
    5000 
    5001 forall( otype T | { T min( T, T ); T max( T, T ); } )
    5002 T clamp( T value, T min_val, T max_val );§\indexc{clamp}§
    5003 
    5004 forall( otype T )
    5005 void swap( T * t1, T * t2 );§\indexc{swap}§
     5660forall( otype T | { int ?<?( T, T ); } ) T min( T t1, T t2 );§\indexc{min}§
     5661forall( otype T | { int ?>?( T, T ); } ) T max( T t1, T t2 );§\indexc{max}§
     5662forall( otype T | { T min( T, T ); T max( T, T ); } ) T clamp( T value, T min_val, T max_val );§\indexc{clamp}§
     5663forall( otype T ) void swap( T * t1, T * t2 );§\indexc{swap}§
    50065664\end{cfa}
    50075665
     
    50105668\label{s:Math Library}
    50115669
    5012 The goal of the \CFA math-library is to wrap many of the existing C math library-routines that are explicitly polymorphic into implicitly polymorphic versions.
     5670The \CFA math-library wraps explicitly-polymorphic C math-routines into implicitly-polymorphic versions.
    50135671
    50145672
     
    50175675\leavevmode
    50185676\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    5019 float fabs( float );§\indexc{fabs}§
    5020 double fabs( double );
    5021 long double fabs( long double );
    5022 float cabs( float _Complex );
    5023 double cabs( double _Complex );
    5024 long double cabs( long double _Complex );
    5025 
    50265677float ?%?( float, float );§\indexc{fmod}§
    50275678float fmod( float, float );
     
    53786029
    53796030
     6031\section{Multi-precision Integers}
     6032\label{s:MultiPrecisionIntegers}
     6033
     6034\CFA has an interface to the GMP \Index{multi-precision} signed-integers~\cite{GMP}, similar to the \CC interface provided by GMP.
     6035The \CFA interface wraps GMP routines into operator routines to make programming with multi-precision integers identical to using fixed-sized integers.
     6036The \CFA type name for multi-precision signed-integers is \Indexc{Int} and the header file is \Indexc{gmp}.
     6037
     6038\begin{cfa}
     6039void ?{}( Int * this );                                 §\C{// constructor}§
     6040void ?{}( Int * this, Int init );
     6041void ?{}( Int * this, zero_t );
     6042void ?{}( Int * this, one_t );
     6043void ?{}( Int * this, signed long int init );
     6044void ?{}( Int * this, unsigned long int init );
     6045void ?{}( Int * this, const char * val );
     6046void ^?{}( Int * this );
     6047
     6048Int ?=?( Int * lhs, Int rhs );                  §\C{// assignment}§
     6049Int ?=?( Int * lhs, long int rhs );
     6050Int ?=?( Int * lhs, unsigned long int rhs );
     6051Int ?=?( Int * lhs, const char * rhs );
     6052
     6053char ?=?( char * lhs, Int rhs );
     6054short int ?=?( short int * lhs, Int rhs );
     6055int ?=?( int * lhs, Int rhs );
     6056long int ?=?( long int * lhs, Int rhs );
     6057unsigned char ?=?( unsigned char * lhs, Int rhs );
     6058unsigned short int ?=?( unsigned short int * lhs, Int rhs );
     6059unsigned int ?=?( unsigned int * lhs, Int rhs );
     6060unsigned long int ?=?( unsigned long int * lhs, Int rhs );
     6061
     6062long int narrow( Int val );
     6063unsigned long int narrow( Int val );
     6064
     6065int ?==?( Int oper1, Int oper2 );               §\C{// comparison}§
     6066int ?==?( Int oper1, long int oper2 );
     6067int ?==?( long int oper2, Int oper1 );
     6068int ?==?( Int oper1, unsigned long int oper2 );
     6069int ?==?( unsigned long int oper2, Int oper1 );
     6070
     6071int ?!=?( Int oper1, Int oper2 );
     6072int ?!=?( Int oper1, long int oper2 );
     6073int ?!=?( long int oper1, Int oper2 );
     6074int ?!=?( Int oper1, unsigned long int oper2 );
     6075int ?!=?( unsigned long int oper1, Int oper2 );
     6076
     6077int ?<?( Int oper1, Int oper2 );
     6078int ?<?( Int oper1, long int oper2 );
     6079int ?<?( long int oper2, Int oper1 );
     6080int ?<?( Int oper1, unsigned long int oper2 );
     6081int ?<?( unsigned long int oper2, Int oper1 );
     6082
     6083int ?<=?( Int oper1, Int oper2 );
     6084int ?<=?( Int oper1, long int oper2 );
     6085int ?<=?( long int oper2, Int oper1 );
     6086int ?<=?( Int oper1, unsigned long int oper2 );
     6087int ?<=?( unsigned long int oper2, Int oper1 );
     6088
     6089int ?>?( Int oper1, Int oper2 );
     6090int ?>?( Int oper1, long int oper2 );
     6091int ?>?( long int oper1, Int oper2 );
     6092int ?>?( Int oper1, unsigned long int oper2 );
     6093int ?>?( unsigned long int oper1, Int oper2 );
     6094
     6095int ?>=?( Int oper1, Int oper2 );
     6096int ?>=?( Int oper1, long int oper2 );
     6097int ?>=?( long int oper1, Int oper2 );
     6098int ?>=?( Int oper1, unsigned long int oper2 );
     6099int ?>=?( unsigned long int oper1, Int oper2 );
     6100
     6101Int +?( Int oper );                                             §\C{// arithmetic}§
     6102Int -?( Int oper );
     6103Int ~?( Int oper );
     6104
     6105Int ?&?( Int oper1, Int oper2 );
     6106Int ?&?( Int oper1, long int oper2 );
     6107Int ?&?( long int oper1, Int oper2 );
     6108Int ?&?( Int oper1, unsigned long int oper2 );
     6109Int ?&?( unsigned long int oper1, Int oper2 );
     6110Int ?&=?( Int * lhs, Int rhs );
     6111
     6112Int ?|?( Int oper1, Int oper2 );
     6113Int ?|?( Int oper1, long int oper2 );
     6114Int ?|?( long int oper1, Int oper2 );
     6115Int ?|?( Int oper1, unsigned long int oper2 );
     6116Int ?|?( unsigned long int oper1, Int oper2 );
     6117Int ?|=?( Int * lhs, Int rhs );
     6118
     6119Int ?^?( Int oper1, Int oper2 );
     6120Int ?^?( Int oper1, long int oper2 );
     6121Int ?^?( long int oper1, Int oper2 );
     6122Int ?^?( Int oper1, unsigned long int oper2 );
     6123Int ?^?( unsigned long int oper1, Int oper2 );
     6124Int ?^=?( Int * lhs, Int rhs );
     6125
     6126Int ?+?( Int addend1, Int addend2 );
     6127Int ?+?( Int addend1, long int addend2 );
     6128Int ?+?( long int addend2, Int addend1 );
     6129Int ?+?( Int addend1, unsigned long int addend2 );
     6130Int ?+?( unsigned long int addend2, Int addend1 );
     6131Int ?+=?( Int * lhs, Int rhs );
     6132Int ?+=?( Int * lhs, long int rhs );
     6133Int ?+=?( Int * lhs, unsigned long int rhs );
     6134Int ++?( Int * lhs );
     6135Int ?++( Int * lhs );
     6136
     6137Int ?-?( Int minuend, Int subtrahend );
     6138Int ?-?( Int minuend, long int subtrahend );
     6139Int ?-?( long int minuend, Int subtrahend );
     6140Int ?-?( Int minuend, unsigned long int subtrahend );
     6141Int ?-?( unsigned long int minuend, Int subtrahend );
     6142Int ?-=?( Int * lhs, Int rhs );
     6143Int ?-=?( Int * lhs, long int rhs );
     6144Int ?-=?( Int * lhs, unsigned long int rhs );
     6145Int --?( Int * lhs );
     6146Int ?--( Int * lhs );
     6147
     6148Int ?*?( Int multiplicator, Int multiplicand );
     6149Int ?*?( Int multiplicator, long int multiplicand );
     6150Int ?*?( long int multiplicand, Int multiplicator );
     6151Int ?*?( Int multiplicator, unsigned long int multiplicand );
     6152Int ?*?( unsigned long int multiplicand, Int multiplicator );
     6153Int ?*=?( Int * lhs, Int rhs );
     6154Int ?*=?( Int * lhs, long int rhs );
     6155Int ?*=?( Int * lhs, unsigned long int rhs );
     6156
     6157Int ?/?( Int dividend, Int divisor );
     6158Int ?/?( Int dividend, unsigned long int divisor );
     6159Int ?/?( unsigned long int dividend, Int divisor );
     6160Int ?/?( Int dividend, long int divisor );
     6161Int ?/?( long int dividend, Int divisor );
     6162Int ?/=?( Int * lhs, Int rhs );
     6163Int ?/=?( Int * lhs, long int rhs );
     6164Int ?/=?( Int * lhs, unsigned long int rhs );
     6165
     6166[ Int, Int ] div( Int dividend, Int divisor );
     6167[ Int, Int ] div( Int dividend, unsigned long int divisor );
     6168
     6169Int ?%?( Int dividend, Int divisor );
     6170Int ?%?( Int dividend, unsigned long int divisor );
     6171Int ?%?( unsigned long int dividend, Int divisor );
     6172Int ?%?( Int dividend, long int divisor );
     6173Int ?%?( long int dividend, Int divisor );
     6174Int ?%=?( Int * lhs, Int rhs );
     6175Int ?%=?( Int * lhs, long int rhs );
     6176Int ?%=?( Int * lhs, unsigned long int rhs );
     6177
     6178Int ?<<?( Int shiften, mp_bitcnt_t shift );
     6179Int ?<<=?( Int * lhs, mp_bitcnt_t shift );
     6180Int ?>>?( Int shiften, mp_bitcnt_t shift );
     6181Int ?>>=?( Int * lhs, mp_bitcnt_t shift );
     6182
     6183Int abs( Int oper );                                    §\C{// number functions}§
     6184Int fact( unsigned long int N );
     6185Int gcd( Int oper1, Int oper2 );
     6186Int pow( Int base, unsigned long int exponent );
     6187Int pow( unsigned long int base, unsigned long int exponent );
     6188void srandom( gmp_randstate_t state );
     6189Int random( gmp_randstate_t state, mp_bitcnt_t n );
     6190Int random( gmp_randstate_t state, Int n );
     6191Int random( gmp_randstate_t state, mp_size_t max_size );
     6192int sgn( Int oper );
     6193Int sqrt( Int oper );
     6194
     6195forall( dtype istype | istream( istype ) ) istype * ?|?( istype * is, Int * mp );  §\C{// I/O}§
     6196forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype * os, Int mp );
     6197\end{cfa}
     6198
     6199The following factorial programs contrast using GMP with the \CFA and C interfaces, where the output from these programs appears in \VRef[Figure]{f:MultiPrecisionFactorials}.
     6200(Compile with flag \Indexc{-lgmp} to link with the GMP library.)
     6201\begin{quote2}
     6202\begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}}
     6203\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}}      \\
     6204\hline
     6205\begin{cfa}
     6206#include <gmp>§\indexc{gmp}§
     6207int main( void ) {
     6208        sout | "Factorial Numbers" | endl;
     6209        Int fact = 1;
     6210
     6211        sout | 0 | fact | endl;
     6212        for ( unsigned int i = 1; i <= 40; i += 1 ) {
     6213                fact *= i;
     6214                sout | i | fact | endl;
     6215        }
     6216}
     6217\end{cfa}
     6218&
     6219\begin{cfa}
     6220#include <gmp.h>§\indexc{gmp.h}§
     6221int main( void ) {
     6222        ®gmp_printf®( "Factorial Numbers\n" );
     6223        ®mpz_t® fact;
     6224        ®mpz_init_set_ui®( fact, 1 );
     6225        ®gmp_printf®( "%d %Zd\n", 0, fact );
     6226        for ( unsigned int i = 1; i <= 40; i += 1 ) {
     6227                ®mpz_mul_ui®( fact, fact, i );
     6228                ®gmp_printf®( "%d %Zd\n", i, fact );
     6229        }
     6230}
     6231\end{cfa}
     6232\end{tabular}
     6233\end{quote2}
     6234
     6235\begin{figure}
     6236\begin{cfa}
     6237Factorial Numbers
     62380 1
     62391 1
     62402 2
     62413 6
     62424 24
     62435 120
     62446 720
     62457 5040
     62468 40320
     62479 362880
     624810 3628800
     624911 39916800
     625012 479001600
     625113 6227020800
     625214 87178291200
     625315 1307674368000
     625416 20922789888000
     625517 355687428096000
     625618 6402373705728000
     625719 121645100408832000
     625820 2432902008176640000
     625921 51090942171709440000
     626022 1124000727777607680000
     626123 25852016738884976640000
     626224 620448401733239439360000
     626325 15511210043330985984000000
     626426 403291461126605635584000000
     626527 10888869450418352160768000000
     626628 304888344611713860501504000000
     626729 8841761993739701954543616000000
     626830 265252859812191058636308480000000
     626931 8222838654177922817725562880000000
     627032 263130836933693530167218012160000000
     627133 8683317618811886495518194401280000000
     627234 295232799039604140847618609643520000000
     627335 10333147966386144929666651337523200000000
     627436 371993326789901217467999448150835200000000
     627537 13763753091226345046315979581580902400000000
     627638 523022617466601111760007224100074291200000000
     627739 20397882081197443358640281739902897356800000000
     627840 815915283247897734345611269596115894272000000000
     6279\end{cfa}
     6280\caption{Multi-precision Factorials}
     6281\label{f:MultiPrecisionFactorials}
     6282\end{figure}
     6283
     6284
    53806285\section{Rational Numbers}
    53816286\label{s:RationalNumbers}
     
    53906295}; // Rational
    53916296
    5392 // constants
    5393 extern struct Rational 0;
    5394 extern struct Rational 1;
    5395 
    5396 // constructors
    5397 Rational rational();
     6297Rational rational();                                    §\C{// constructors}§
    53986298Rational rational( long int n );
    53996299Rational rational( long int n, long int d );
    5400 
    5401 // getter/setter for numerator/denominator
    5402 long int numerator( Rational r );
     6300void ?{}( Rational * r, zero_t );
     6301void ?{}( Rational * r, one_t );
     6302
     6303long int numerator( Rational r );               §\C{// numerator/denominator getter/setter}§
    54036304long int numerator( Rational r, long int n );
    54046305long int denominator( Rational r );
    54056306long int denominator( Rational r, long int d );
    54066307
    5407 // comparison
    5408 int ?==?( Rational l, Rational r );
     6308int ?==?( Rational l, Rational r );             §\C{// comparison}§
    54096309int ?!=?( Rational l, Rational r );
    54106310int ?<?( Rational l, Rational r );
     
    54136313int ?>=?( Rational l, Rational r );
    54146314
    5415 // arithmetic
    5416 Rational -?( Rational r );
     6315Rational -?( Rational r );                              §\C{// arithmetic}§
    54176316Rational ?+?( Rational l, Rational r );
    54186317Rational ?-?( Rational l, Rational r );
     
    54206319Rational ?/?( Rational l, Rational r );
    54216320
    5422 // conversion
    5423 double widen( Rational r );
     6321double widen( Rational r );                             §\C{// conversion}§
    54246322Rational narrow( double f, long int md );
    54256323
    5426 // I/O
    5427 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * );
     6324forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); // I/O
    54286325forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational );
    54296326\end{cfa}
  • doc/working/resolver_design.md

    r9c951e3 rb1e63ac5  
    4141ensure that they are two-arg functions (this restriction may be valuable
    4242regardless).
     43
     44Regardless of syntax, there should be a type assertion that expresses `From`
     45is convertable to `To`.
     46If user-defined conversions are not added to the language,
     47`void ?{} ( To*, From )` may be a suitable representation, relying on
     48conversions on the argument types to account for transitivity.
     49On the other hand, `To*` should perhaps match its target type exactly, so
     50another assertion syntax specific to conversions may be required, e.g.
     51`From -> To`.
    4352
    4453### Constructor Idiom ###
  • src/CodeGen/CodeGenerator.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 10 14:45:00 2017
    13 // Update Count     : 484
     12// Last Modified On : Thu Jun  8 16:00:00 2017
     13// Update Count     : 485
    1414//
    1515
     
    6565                } // if
    6666        } // extension
    67 
    68         ostream & CodeGenerator::Indenter::operator()( ostream & output ) const {
    69           return output << string( cg.cur_indent, ' ' );
    70         }
    71 
    72         ostream & operator<<( ostream & output, const CodeGenerator::Indenter &indent ) {
    73                 return indent( output );
    74         }
    7567
    7668        CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) {
     
    111103        }
    112104
    113         CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {}
    114 
    115         CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )
    116                         : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {
    117                 //output << std::string( init );
    118         }
    119 
    120         CodeGenerator::CodeGenerator( std::ostream & os, char * init, int indentation, bool infunp )
    121                         : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {
    122                 //output << std::string( init );
    123         }
     105        CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {}
    124106
    125107        string CodeGenerator::mangleName( DeclarationWithType * decl ) {
     
    212194                        output << " {" << endl;
    213195
    214                         cur_indent += CodeGenerator::tabsize;
     196                        ++indent;
    215197                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) {
    216198                                output << lineDirective( *i ) << indent;
     
    219201                        } // for
    220202
    221                         cur_indent -= CodeGenerator::tabsize;
     203                        --indent;
    222204
    223205                        output << indent << "}";
     
    249231                        output << " {" << endl;
    250232
    251                         cur_indent += CodeGenerator::tabsize;
     233                        ++indent;
    252234                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    253235                                ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
     
    261243                        } // for
    262244
    263                         cur_indent -= CodeGenerator::tabsize;
     245                        --indent;
    264246
    265247                        output << indent << "}";
     
    267249        }
    268250
    269         void CodeGenerator::visit( TraitDecl * traitDecl ) {}
     251        void CodeGenerator::visit( __attribute__((unused)) TraitDecl * traitDecl ) {}
    270252
    271253        void CodeGenerator::visit( TypedefDecl * typeDecl ) {
     
    298280        }
    299281
    300         void CodeGenerator::printDesignators( std::list< Expression * > & designators ) {
    301                 typedef std::list< Expression * > DesignatorList;
     282        void CodeGenerator::visit( Designation * designation ) {
     283                std::list< Expression * > designators = designation->get_designators();
    302284                if ( designators.size() == 0 ) return;
    303                 for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) {
    304                         if ( dynamic_cast< NameExpr * >( *iter ) ) {
    305                                 // if expression is a name, then initializing aggregate member
     285                for ( Expression * des : designators ) {
     286                        if ( dynamic_cast< NameExpr * >( des ) || dynamic_cast< VariableExpr * >( des ) ) {
     287                                // if expression is a NameExpr or VariableExpr, then initializing aggregate member
    306288                                output << ".";
    307                                 (*iter)->accept( *this );
     289                                des->accept( *this );
    308290                        } else {
    309                                 // if not a simple name, it has to be a constant expression, i.e. an array designator
     291                                // otherwise, it has to be a ConstantExpr or CastExpr, initializing array eleemnt
    310292                                output << "[";
    311                                 (*iter)->accept( *this );
     293                                des->accept( *this );
    312294                                output << "]";
    313295                        } // if
     
    317299
    318300        void CodeGenerator::visit( SingleInit * init ) {
    319                 printDesignators( init->get_designators() );
    320301                init->get_value()->accept( *this );
    321302        }
    322303
    323304        void CodeGenerator::visit( ListInit * init ) {
    324                 printDesignators( init->get_designators() );
     305                auto initBegin = init->begin();
     306                auto initEnd = init->end();
     307                auto desigBegin = init->get_designations().begin();
     308                auto desigEnd = init->get_designations().end();
     309
    325310                output << "{ ";
    326                 if ( init->begin() == init->end() ) {
    327                         // illegal to leave initializer list empty for scalar initializers, but always legal to have 0
    328                         output << "0";
    329                 } else {
    330                         genCommaList( init->begin(), init->end() );
    331                 } // if
     311                for ( ; initBegin != initEnd && desigBegin != desigEnd; ) {
     312                        (*desigBegin)->accept( *this );
     313                        (*initBegin)->accept( *this );
     314                        ++initBegin, ++desigBegin;
     315                        if ( initBegin != initEnd ) {
     316                                output << ", ";
     317                        }
     318                }
    332319                output << " }";
    333         }
    334 
    335         void CodeGenerator::visit( ConstructorInit * init ){
     320                assertf( initBegin == initEnd && desigBegin == desigEnd, "Initializers and designators not the same length. %s", toString( init ).c_str() );
     321        }
     322
     323        void CodeGenerator::visit( __attribute__((unused)) ConstructorInit * init ){
    336324                assertf( ! genC, "ConstructorInit nodes should not reach code generation." );
    337325                // xxx - generate something reasonable for constructor/destructor pairs
     
    731719
    732720        void CodeGenerator::visit( TypeExpr * typeExpr ) {
    733                 assertf( ! genC, "TypeExpr should not reach code generation." );
    734                 output<< genType( typeExpr->get_type(), "", pretty, genC );
     721                // if ( genC ) std::cerr << "typeexpr still exists: " << typeExpr << std::endl;
     722                // assertf( ! genC, "TypeExpr should not reach code generation." );
     723                if ( ! genC ) {
     724                        output<< genType( typeExpr->get_type(), "", pretty, genC );
     725                }
    735726        }
    736727
     
    756747                std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
    757748                output << lineDirective( stmtExpr) << "({" << std::endl;
    758                 cur_indent += CodeGenerator::tabsize;
     749                ++indent;
    759750                unsigned int numStmts = stmts.size();
    760751                unsigned int i = 0;
     
    779770                        ++i;
    780771                }
    781                 cur_indent -= CodeGenerator::tabsize;
     772                --indent;
    782773                output << indent << "})";
    783774        }
     
    788779                output << "{" << endl;
    789780
    790                 cur_indent += CodeGenerator::tabsize;
     781                ++indent;
    791782
    792783                for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end();  i++ ) {
     
    799790                        } // if
    800791                } // for
    801                 cur_indent -= CodeGenerator::tabsize;
     792                --indent;
    802793
    803794                output << indent << "}";
     
    867858
    868859                output << "{" << std::endl;
    869                 cur_indent += CodeGenerator::tabsize;
     860                ++indent;
    870861                acceptAll( switchStmt->get_statements(), *this );
    871                 cur_indent -= CodeGenerator::tabsize;
     862                --indent;
    872863                output << indent << "}";
    873864        }
     
    886877                std::list<Statement *> sts = caseStmt->get_statements();
    887878
    888                 cur_indent += CodeGenerator::tabsize;
     879                ++indent;
    889880                for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end();  i++) {
    890881                        output << indent << printLabels( (*i)->get_labels() )  ;
     
    892883                        output << endl;
    893884                } // for
    894                 cur_indent -= CodeGenerator::tabsize;
     885                --indent;
    895886        }
    896887
     
    923914        }
    924915
     916        void CodeGenerator::visit( ThrowStmt * throwStmt ) {
     917                assertf( ! genC, "Throw statements should not reach code generation." );
     918
     919                output << ((throwStmt->get_kind() == ThrowStmt::Terminate) ?
     920                           "throw" : "throwResume");
     921                if (throwStmt->get_expr()) {
     922                        output << " ";
     923                        throwStmt->get_expr()->accept( *this );
     924                }
     925                if (throwStmt->get_target()) {
     926                        output << " _At ";
     927                        throwStmt->get_target()->accept( *this );
     928                }
     929                output << ";";
     930        }
     931
    925932        void CodeGenerator::visit( WhileStmt * whileStmt ) {
    926933                if ( whileStmt->get_isDoWhile() ) {
     
    967974        }
    968975
    969         void CodeGenerator::visit( NullStmt * nullStmt ) {
     976        void CodeGenerator::visit( __attribute__((unused)) NullStmt * nullStmt ) {
    970977                //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
    971978                output << "/* null statement */ ;";
  • src/CodeGen/CodeGenerator.h

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 10 10:57:00 2017
    13 // Update Count     : 51
     12// Last Modified On : Thu Jun  8 15:48:00 2017
     13// Update Count     : 52
    1414//
    1515
     
    2525#include "SymTab/Indexer.h"
    2626
     27#include "Common/Indenter.h"
    2728#include "Common/utility.h"
    2829
     
    4748
    4849                //*** Initializer
     50                virtual void visit( Designation * );
    4951                virtual void visit( SingleInit * );
    5052                virtual void visit( ListInit * );
     
    9193                virtual void visit( BranchStmt * );
    9294                virtual void visit( ReturnStmt * );
     95                virtual void visit( ThrowStmt * );
    9396                virtual void visit( WhileStmt * );
    9497                virtual void visit( ForStmt * );
     
    99102
    100103                template< class Iterator > void genCommaList( Iterator begin, Iterator end );
    101 
    102                 struct Indenter {
    103                         Indenter(CodeGenerator &cg) : cg(cg) {}
    104                         CodeGenerator & cg;
    105                         std::ostream& operator()(std::ostream & os) const;
    106                 };
    107104
    108105                struct LabelPrinter {
     
    128125          private:
    129126                Indenter indent;
    130                 int cur_indent;
    131127                bool insideFunction;
    132128                std::ostream &output;
     
    136132                bool lineMarks = false;
    137133
    138                 void printDesignators( std::list< Expression * > & );
    139134                void handleStorageClass( DeclarationWithType *decl );
    140135                void handleAggregate( AggregateDecl *aggDecl, const std::string & kind );
  • src/CodeGen/FixNames.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:50:30 2017
    13 // Update Count     : 16
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:26:00 2017
     13// Update Count     : 20
    1414//
    1515
     
    9393        void FixNames::fixDWT( DeclarationWithType *dwt ) {
    9494                if ( dwt->get_name() != "" ) {
    95                         if ( LinkageSpec::isDecoratable( dwt->get_linkage() ) ) {
     95                        if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) {
    9696                                dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) );
    9797                                dwt->set_scopeLevel( scopeLevel );
     
    114114                                throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
    115115                        }
    116                         functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), "0") ) ) );
     116                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
    117117                        CodeGen::FixMain::registerMain( functionDecl );
    118118                }
  • src/CodeTools/TrackLoc.cc

    r9c951e3 rb1e63ac5  
    1616#include "TrackLoc.h"
    1717
     18#include <cstdlib>
     19
    1820#include <iostream>
    1921#include <sstream>
     22#include <stack>
    2023#include <string>
    21 #include <cstdlib>
     24#include <typeindex>
    2225
    2326#include "Common/utility.h"
     27#include "Common/PassVisitor.h"
    2428#include "Common/VectorMap.h"
    2529#include "GenPoly/GenPoly.h"
     
    2731#include "SynTree/Declaration.h"
    2832#include "SynTree/Initializer.h"
    29 #include "SynTree/Visitor.h"
    3033
    3134namespace CodeTools {
    3235
    33     std::ostream & operator<<(std::ostream & out, CodeLocation const & loc) {
    34         return out << loc.filename << '[' << loc.linenumber << ']';
    35     }
     36        std::ostream & operator<<(std::ostream & out, CodeLocation const & loc) {
     37                return out << loc.filename << '[' << loc.linenumber << ']';
     38        }
    3639
    37         class LocationPrinter : public Visitor {
    38                 unsigned int printLevel;
    39                 unsigned int currentLevel;
     40        class LocationPrinter {
     41                size_t printLevel;
    4042
    41                 CodeLocation *parent;
    4243                CodeLocation *lastNode;
    4344
    44     public:
    45         LocationPrinter(unsigned int printLevel) :
    46             Visitor(), printLevel(printLevel), currentLevel(0),
    47                         parent(nullptr), lastNode(nullptr)
    48         {}
     45                std::stack< CodeLocation * > parents;
     46        public:
     47                LocationPrinter(size_t printLevel) :
     48                        printLevel(printLevel), lastNode(nullptr)
     49                {}
    4950
    50         void print(char const * name, BaseSyntaxNode *node) {
    51             for (unsigned int i = 0 ; i < currentLevel ; ++i) {
     51                void print( const std::string& name, BaseSyntaxNode *node) {
     52                        for (size_t i = 0 ; i < parents.size() ; ++i) {
    5253                                std::cout << "    ";
    5354                        }
    54             if (2 <= printLevel) {
     55                        if (2 <= printLevel) {
    5556                                std::cout << name << '@';
    5657                        }
    5758                        std::cout << node->location << std::endl;
    58         }
     59                }
    5960
    60                 void atNode(char const * name, BaseSyntaxNode *node) {
    61                         if (-1 == node->location.linenumber) {
    62                                 if (nullptr != parent) {
    63                                         node->location.linenumber = parent->linenumber;
    64                                         node->location.filename = parent->filename;
    65                                 } else if (nullptr != lastNode) {
    66                                         node->location.linenumber = lastNode->linenumber;
    67                                         node->location.filename = lastNode->filename;
    68                                 } else {
    69                                         std::cerr << "Top level node has no CodeLocation " <<
    70                                                                 name << std::endl;
     61                void atNode( BaseSyntaxNode *node ) {
     62                        std::string name = std::type_index(typeid(*node)).name();
     63                        if ( node->location.isUnset() ) {
     64                                if ( !parents.empty() ) {
     65                                        node->location = *parents.top();
     66                                }
     67                                else if (nullptr != lastNode) {
     68                                        node->location = *lastNode;
     69                                }
     70                                else {
     71                                        std::cerr << "Top level node has no CodeLocation " << name << std::endl;
    7172                                        exit(EXIT_FAILURE);
    7273                                }
    7374                        }
     75
    7476                        if (0 < printLevel) {
    75                                 print(name, node);
     77                                print( name, node );
    7678                        }
    7779                        lastNode = &node->location;
    7880                }
    7981
    80 #define VISIT_FUNCTION(SyntaxNodeType)                          \
    81                 virtual void visit(SyntaxNodeType *node) {      \
    82                         atNode(#SyntaxNodeType, node);                  \
    83                         ++currentLevel;                                                 \
    84                         CodeLocation * myParent = parent;               \
    85                         parent = &node->location;                               \
    86                         Visitor::visit(node);                                   \
    87                         parent = myParent;                                              \
    88                         --currentLevel;                                                 \
     82                void previsit(BaseSyntaxNode * node) {
     83                        atNode(node);
     84                        parents.push( &node->location );
    8985                }
    9086
    91                 VISIT_FUNCTION(ObjectDecl)
    92                 VISIT_FUNCTION(FunctionDecl)
    93                 VISIT_FUNCTION(StructDecl)
    94                 VISIT_FUNCTION(UnionDecl)
    95                 VISIT_FUNCTION(EnumDecl)
    96                 VISIT_FUNCTION(TraitDecl)
    97                 VISIT_FUNCTION(TypeDecl)
    98                 VISIT_FUNCTION(TypedefDecl)
    99                 VISIT_FUNCTION(AsmDecl)
    100 
    101                 VISIT_FUNCTION(CompoundStmt)
    102                 VISIT_FUNCTION(ExprStmt)
    103                 VISIT_FUNCTION(AsmStmt)
    104                 VISIT_FUNCTION(IfStmt)
    105                 VISIT_FUNCTION(WhileStmt)
    106                 VISIT_FUNCTION(ForStmt)
    107                 VISIT_FUNCTION(SwitchStmt)
    108                 VISIT_FUNCTION(CaseStmt)
    109                 VISIT_FUNCTION(BranchStmt)
    110                 VISIT_FUNCTION(ReturnStmt)
    111                 VISIT_FUNCTION(TryStmt)
    112                 VISIT_FUNCTION(CatchStmt)
    113                 VISIT_FUNCTION(FinallyStmt)
    114                 VISIT_FUNCTION(NullStmt)
    115                 VISIT_FUNCTION(DeclStmt)
    116                 VISIT_FUNCTION(ImplicitCtorDtorStmt)
    117 
    118                 VISIT_FUNCTION(ApplicationExpr)
    119                 VISIT_FUNCTION(UntypedExpr)
    120                 VISIT_FUNCTION(NameExpr)
    121                 VISIT_FUNCTION(CastExpr)
    122                 VISIT_FUNCTION(AddressExpr)
    123                 VISIT_FUNCTION(LabelAddressExpr)
    124                 VISIT_FUNCTION(UntypedMemberExpr)
    125                 VISIT_FUNCTION(MemberExpr)
    126                 VISIT_FUNCTION(VariableExpr)
    127                 VISIT_FUNCTION(ConstantExpr)
    128                 VISIT_FUNCTION(SizeofExpr)
    129                 VISIT_FUNCTION(AlignofExpr)
    130                 VISIT_FUNCTION(UntypedOffsetofExpr)
    131                 VISIT_FUNCTION(OffsetofExpr)
    132                 VISIT_FUNCTION(OffsetPackExpr)
    133                 VISIT_FUNCTION(AttrExpr)
    134                 VISIT_FUNCTION(LogicalExpr)
    135                 VISIT_FUNCTION(ConditionalExpr)
    136                 VISIT_FUNCTION(CommaExpr)
    137                 VISIT_FUNCTION(TypeExpr)
    138                 VISIT_FUNCTION(AsmExpr)
    139                 VISIT_FUNCTION(ImplicitCopyCtorExpr)
    140                 VISIT_FUNCTION(ConstructorExpr)
    141                 VISIT_FUNCTION(CompoundLiteralExpr)
    142                 VISIT_FUNCTION(UntypedValofExpr)
    143                 VISIT_FUNCTION(RangeExpr)
    144                 VISIT_FUNCTION(UntypedTupleExpr)
    145                 VISIT_FUNCTION(TupleExpr)
    146                 VISIT_FUNCTION(TupleIndexExpr)
    147                 VISIT_FUNCTION(MemberTupleExpr)
    148                 VISIT_FUNCTION(TupleAssignExpr)
    149                 VISIT_FUNCTION(StmtExpr)
    150                 VISIT_FUNCTION(UniqueExpr)
    151 
    152                 VISIT_FUNCTION(VoidType)
    153                 VISIT_FUNCTION(BasicType)
    154                 VISIT_FUNCTION(PointerType)
    155                 VISIT_FUNCTION(ArrayType)
    156                 VISIT_FUNCTION(FunctionType)
    157                 VISIT_FUNCTION(StructInstType)
    158                 VISIT_FUNCTION(UnionInstType)
    159                 VISIT_FUNCTION(EnumInstType)
    160                 VISIT_FUNCTION(TraitInstType)
    161                 VISIT_FUNCTION(TypeInstType)
    162                 VISIT_FUNCTION(TupleType)
    163                 VISIT_FUNCTION(TypeofType)
    164                 VISIT_FUNCTION(AttrType)
    165                 VISIT_FUNCTION(VarArgsType)
    166                 VISIT_FUNCTION(ZeroType)
    167                 VISIT_FUNCTION(OneType)
    168 
    169                 VISIT_FUNCTION(SingleInit)
    170                 VISIT_FUNCTION(ListInit)
    171                 VISIT_FUNCTION(ConstructorInit)
    172 
    173                 //VISIT_FUNCTION(Subrange)
    174 
    175                 //VISIT_FUNCTION(Constant)
     87                void postvisit( __attribute__((unused)) BaseSyntaxNode * node ) {
     88                        parents.pop();
     89                }
    17690
    17791        }; // LocationPrinter
    17892
    179         void fillLocations( std::list< Declaration * > & translationUnit,
    180                         unsigned int printLevel) {
    181                 LocationPrinter printer(printLevel);
     93        void fillLocations( std::list< Declaration * > & translationUnit, size_t printLevel) {
     94                PassVisitor<LocationPrinter> printer(printLevel);
    18295                acceptAll( translationUnit, printer );
    18396        }
  • src/CodeTools/TrackLoc.h

    r9c951e3 rb1e63ac5  
    2424        // printLevel: how much printing while filling in the node locations.
    2525        // 0 - No Printing, 1 - Print Location, 2 - Print Node Type and Location
    26         void fillLocations( std::list< Declaration * > &translationUnit,
    27                         unsigned int printLevel = 0 );
     26        void fillLocations( std::list< Declaration * > &translationUnit, size_t printLevel = 0 );
    2827
    2928}  // namespace CodeTools
  • src/Common/Assert.cc

    r9c951e3 rb1e63ac5  
    2121extern const char * __progname;                                                 // global name of running executable (argv[0])
    2222
    23 #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\""
     23#define CFA_ASSERT_FMT "*CFA assertion error* \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
    2424
    2525// called by macro assert in assert.h
    2626void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    27         fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
     27        fprintf( stderr, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    2828        abort();
    2929}
     
    3131// called by macro assertf
    3232void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    33         fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file );
     33        fprintf( stderr, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
    3434        va_list args;
    3535        va_start( args, fmt );
  • src/Common/utility.h

    r9c951e3 rb1e63ac5  
    246246};
    247247
     248template< typename T >
     249struct ValueGuardPtr {
     250        T old;
     251        T* ref;
     252
     253        ValueGuardPtr(T * inRef) : old( inRef ? *inRef : T() ), ref(inRef) {}
     254        ~ValueGuardPtr() { if( ref ) *ref = old; }
     255};
     256
     257template< typename T >
     258struct ValueGuardPtr< std::list< T > > {
     259        std::list< T > old;
     260        std::list< T >* ref;
     261
     262        ValueGuardPtr( std::list< T > * inRef) : old(), ref(inRef) {
     263                if( ref ) { swap( *ref, old ); }
     264        }
     265        ~ValueGuardPtr() { if( ref ) { swap( *ref, old ); } }
     266};
     267
    248268// -----------------------------------------------------------------------------
    249269// Helper struct and function to support
     
    285305// for ( val : group_iterate( container1, container2, ... ) ) {}
    286306// syntax to have a for each that iterates multiple containers of the same length
    287 // TODO: update to use variadic arguments
     307// TODO: update to use variadic arguments, perfect forwarding
    288308
    289309template< typename T1, typename T2 >
     
    334354        {}
    335355
     356        CodeLocation( const CodeLocation& rhs ) = default;
     357
    336358        bool isSet () const {
    337359                return -1 != linenumber;
  • src/Concurrency/Keywords.cc

    r9c951e3 rb1e63ac5  
    6565                FunctionDecl * forwardDeclare( StructDecl * );
    6666                ObjectDecl * addField( StructDecl * );
    67                 void addRoutines( StructDecl *, ObjectDecl *, FunctionDecl * );
     67                void addRoutines( ObjectDecl *, FunctionDecl * );
    6868
    6969                virtual bool is_target( StructDecl * decl ) = 0;
     
    247247        void ConcurrentSueKeyword::visit(StructDecl * decl) {
    248248                Visitor::visit(decl);
    249                 if( decl->get_name() == type_name ) {
     249                if( decl->get_name() == type_name && decl->has_body() ) {
    250250                        assert( !type_decl );
    251251                        type_decl = decl;
     
    264264                FunctionDecl * func = forwardDeclare( decl );
    265265                ObjectDecl * field = addField( decl );
    266                 addRoutines( decl, field, func );
     266                addRoutines( field, func );
    267267        }
    268268
     
    359359        }
    360360
    361         void ConcurrentSueKeyword::addRoutines( StructDecl * decl, ObjectDecl * field, FunctionDecl * func ) {
     361        void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) {
    362362                CompoundStmt * statement = new CompoundStmt( noLabels );
    363363                statement->push_back(
  • src/ControlStruct/ForExprMutator.cc

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ForExprMutator.cc -- 
     7// ForExprMutator.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    1919
    2020namespace ControlStruct {
    21         Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
    22                 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
    23                 forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
    24 
    25                 std::list<Statement *> &init = forStmt->get_initialization();
     21        Statement *ForExprMutator::postmutate( ForStmt *forStmt ) {
     22                // hoist any initializer declarations to make them C89 (rather than C99)
     23                std::list<Statement *> &init = forStmt->get_initialization();
    2624                if ( init.size() == 0 ) {
    2725                        return forStmt;
     
    3937                forStmt->set_initialization( std::list<Statement *>() );
    4038                return block;
    41 
    42                 return forStmt;
    4339        }
    4440} // namespace ControlStruct
  • src/ControlStruct/ForExprMutator.h

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ForExprMutator.h -- 
     7// ForExprMutator.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2121
    2222namespace ControlStruct {
    23         class ForExprMutator : public Mutator {
     23        class ForExprMutator {
    2424          public:
    25                 virtual Statement *mutate( ForStmt * );
     25                Statement *postmutate( ForStmt * );
    2626        };
    2727} // namespace ControlStruct
  • src/ControlStruct/Mutate.cc

    r9c951e3 rb1e63ac5  
    2626
    2727#include "Common/utility.h"
     28#include "Common/PassVisitor.h"
    2829
    2930#include "SynTree/Visitor.h"
     
    3435        void mutate( std::list< Declaration * > translationUnit ) {
    3536                // hoist initialization out of for statements
    36                 ForExprMutator formut;
     37                PassVisitor<ForExprMutator> formut;
    3738
    3839                // normalizes label definitions and generates multi-level exit labels
  • src/ControlStruct/module.mk

    r9c951e3 rb1e63ac5  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu Aug  4 11:38:06 2016
    14 ## Update Count     : 3
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Wed Jun 28 16:15:00 2017
     14## Update Count     : 4
    1515###############################################################################
    1616
    1717SRC +=  ControlStruct/LabelGenerator.cc \
    1818        ControlStruct/LabelFixer.cc \
    19         ControlStruct/MLEMutator.cc \
     19        ControlStruct/MLEMutator.cc \
    2020        ControlStruct/Mutate.cc \
    21         ControlStruct/ForExprMutator.cc
    22 
     21        ControlStruct/ForExprMutator.cc \
     22        ControlStruct/ExceptTranslate.cc
  • src/GenPoly/Box.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 13 09:26:38 2017
    13 // Update Count     : 341
     12// Last Modified On : Wed Jun 21 15:49:59 2017
     13// Update Count     : 346
    1414//
    1515
     
    6262namespace GenPoly {
    6363        namespace {
    64                 const std::list<Label> noLabels;
    65 
    6664                FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
    6765
     
    103101                        void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    104102                        /// wraps a function application with a new temporary for the out-parameter return value
    105                         Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg );
     103                        Expression *addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg );
    106104                        /// Replaces all the type parameters of a generic type with their concrete equivalents under the current environment
    107105                        void replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params );
     
    110108                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    111109                        /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value
    112                         Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg );
     110                        Expression *addDynRetParam( ApplicationExpr *appExpr, Type *polyType, std::list< Expression *>::iterator &arg );
    113111                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    114112                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    136134                  public:
    137135                        template< typename DeclClass >
    138                         DeclClass *handleDecl( DeclClass *decl, Type *type );
     136                        DeclClass *handleDecl( DeclClass *decl );
    139137                        template< typename AggDecl >
    140138                        AggDecl * handleAggDecl( AggDecl * aggDecl );
     
    343341        Statement *makeAlignTo( Expression *lhs, Expression *rhs ) {
    344342                // check that the lhs is zeroed out to the level of rhs
    345                 Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "1" ) ) ) );
     343                Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    346344                // if not aligned, increment to alignment
    347345                Expression *ifExpr = makeOp( "?+=?", lhs->clone(), makeOp( "?-?", rhs->clone(), ifCond->clone() ) );
     
    386384
    387385                // initialize size and alignment to 0 and 1 (will have at least one member to re-edit size)
    388                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "0" ) ) ) );
    389                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
     386                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 0 ) ) ) );
     387                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    390388                unsigned long n_members = 0;
    391389                bool firstMember = true;
     
    443441
    444442                // calculate union layout in function body
    445                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
    446                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
     443                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     444                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    447445                for ( std::list< Declaration* >::const_iterator member = unionDecl->get_members().begin(); member != unionDecl->get_members().end(); ++member ) {
    448446                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
     
    506504                DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) {
    507505                        if ( functionDecl->get_statements() ) {         // empty routine body ?
     506                                // std::cerr << "mutating function: " << functionDecl->get_mangleName() << std::endl;
    508507                                doBeginScope();
    509508                                scopeTyVars.beginScope();
     
    550549                                retval = oldRetval;
    551550                                doEndScope();
     551                                // std::cerr << "end function: " << functionDecl->get_mangleName() << std::endl;
    552552                        } // if
    553553                        return functionDecl;
     
    665665                }
    666666
    667                 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) {
     667                Expression *Pass1::addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg ) {
    668668                        // Create temporary to hold return value of polymorphic function and produce that temporary as a result
    669669                        // using a comma expression.
     
    728728                }
    729729
    730                 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) {
     730                Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, Type *dynType, std::list< Expression *>::iterator &arg ) {
    731731                        assert( env );
    732732                        Type *concrete = replaceWithConcrete( appExpr, dynType );
    733733                        // add out-parameter for return value
    734                         return addRetParam( appExpr, function, concrete, arg );
     734                        return addRetParam( appExpr, concrete, arg );
    735735                }
    736736
     
    739739//                      if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
    740740                        if ( isDynRet( function, tyVars ) ) {
    741                                 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
     741                                ret = addRetParam( appExpr, function->get_returnVals().front()->get_type(), arg );
    742742                        } // if
    743743                        std::string mangleName = mangleAdapterName( function, tyVars );
     
    11181118
    11191119                Expression *Pass1::mutate( ApplicationExpr *appExpr ) {
    1120                         // std::cerr << "mutate appExpr: ";
     1120                        // std::cerr << "mutate appExpr: " << InitTweak::getFunctionName( appExpr ) << std::endl;
    11211121                        // for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
    11221122                        //      std::cerr << i->first << " ";
     
    11431143                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
    11441144
     1145                        // std::cerr << function << std::endl;
     1146                        // std::cerr << "scopeTyVars: ";
     1147                        // printTyVarMap( std::cerr, scopeTyVars );
     1148                        // std::cerr << "exprTyVars: ";
     1149                        // printTyVarMap( std::cerr, exprTyVars );
     1150                        // std::cerr << "env: " << *env << std::endl;
     1151                        // std::cerr << needsAdapter( function, scopeTyVars ) << ! needsAdapter( function, exprTyVars) << std::endl;
     1152
    11451153                        // NOTE: addDynRetParam needs to know the actual (generated) return type so it can make a temp variable, so pass the result type from the appExpr
    11461154                        // passTypeVars needs to know the program-text return type (i.e. the distinction between _conc_T30 and T3(int))
    11471155                        // concRetType may not be a good name in one or both of these places. A more appropriate name change is welcome.
    11481156                        if ( dynRetType ) {
     1157                                // std::cerr << "dynRetType: " << dynRetType << std::endl;
    11491158                                Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();
    1150                                 ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType
     1159                                ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType
    11511160                        } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...?
    11521161                                // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed.
     
    12821291
    12831292                template< typename DeclClass >
    1284                 DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) {
     1293                DeclClass * Pass2::handleDecl( DeclClass *decl ) {
    12851294                        DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    12861295
     
    12961305
    12971306                DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) {
    1298                         functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl, functionDecl->get_functionType() ) );
     1307                        functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl ) );
    12991308                        FunctionType * ftype = functionDecl->get_functionType();
    13001309                        if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) {
     
    13211330
    13221331                ObjectDecl * Pass2::mutate( ObjectDecl *objectDecl ) {
    1323                         return handleDecl( objectDecl, objectDecl->get_type() );
     1332                        return handleDecl( objectDecl );
    13241333                }
    13251334
     
    13441353                        addToTyVarMap( typeDecl, scopeTyVars );
    13451354                        if ( typeDecl->get_base() ) {
    1346                                 return handleDecl( typeDecl, typeDecl->get_base() );
     1355                                return handleDecl( typeDecl );
    13471356                        } else {
    13481357                                return Parent::mutate( typeDecl );
     
    13511360
    13521361                TypedefDecl * Pass2::mutate( TypedefDecl *typedefDecl ) {
    1353                         return handleDecl( typedefDecl, typedefDecl->get_base() );
     1362                        return handleDecl( typedefDecl );
    13541363                }
    13551364
     
    15661575                /// Returns an index expression into the offset array for a type
    15671576                Expression *makeOffsetIndex( Type *objectType, long i ) {
    1568                         std::stringstream offset_namer;
    1569                         offset_namer << i;
    1570                         ConstantExpr *fieldIndex = new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), offset_namer.str() ) );
     1577                        ConstantExpr *fieldIndex = new ConstantExpr( Constant::from_ulong( i ) );
    15711578                        UntypedExpr *fieldOffset = new UntypedExpr( new NameExpr( "?[?]" ) );
    15721579                        fieldOffset->get_args().push_back( new NameExpr( offsetofName( mangleType( objectType ) ) ) );
     
    17811788                                // all union members are at offset zero
    17821789                                delete offsetofExpr;
    1783                                 return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0" ) );
     1790                                return new ConstantExpr( Constant::from_ulong( 0 ) );
    17841791                        } else return offsetofExpr;
    17851792                }
     
    18061813                                        std::list< Initializer* > inits;
    18071814                                        for ( std::list< Declaration* >::const_iterator member = baseMembers.begin(); member != baseMembers.end(); ++member ) {
    1808                                                 DeclarationWithType *memberDecl;
    1809                                                 if ( DeclarationWithType *origMember = dynamic_cast< DeclarationWithType* >( *member ) ) {
    1810                                                         memberDecl = origMember->clone();
     1815                                                if ( DeclarationWithType *memberDecl = dynamic_cast< DeclarationWithType* >( *member ) ) {
     1816                                                        inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) );
    18111817                                                } else {
    1812                                                         memberDecl = new ObjectDecl( (*member)->get_name(), Type::StorageClasses(), LinkageSpec::Cforall, 0, offsetType->clone(), 0 );
     1818                                                        assertf( false, "Requesting offset of Non-DWT member: %s", toString( *member ).c_str() );
    18131819                                                }
    1814                                                 inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) );
    18151820                                        }
    18161821
  • src/GenPoly/CopyParams.cc

    r9c951e3 rb1e63ac5  
    4545
    4646        CopyParams::CopyParams() : namer( "_cp" ) {}
    47 
    48         static const std::list< Label > noLabels;
    4947
    5048        void CopyParams::visit( FunctionDecl *funcDecl ) {
  • src/GenPoly/DeclMutator.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri Nov 27 14:44:00 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:16:43 2016
    13 // Update Count     : 3
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:49:00 2017
     13// Update Count     : 4
    1414//
    1515
     
    2020
    2121namespace GenPoly {
    22         namespace {
    23                 const std::list<Label> noLabels;
    24         }
    25 
    2622        DeclMutator::DeclMutator() : Mutator(), declsToAdd(1), declsToAddAfter(1) {}
    2723
    2824        DeclMutator::~DeclMutator() {}
    29        
     25
    3026        void DeclMutator::mutateDeclarationList( std::list< Declaration* > &decls ) {
    3127                for ( std::list< Declaration* >::iterator decl = decls.begin(); ; ++decl ) {
     
    3430
    3531                        if ( decl == decls.end() ) break;
    36                        
     32
    3733                        // run mutator on declaration
    3834                        *decl = maybeMutate( *decl, *this );
     
    5551                newBack->splice( newBack->end(), *back );
    5652                declsToAdd.pop_back();
    57                
     53
    5854                back = declsToAddAfter.rbegin();
    5955                newBack = back + 1;
     
    6662                CompoundStmt *compoundStmt = dynamic_cast< CompoundStmt* >(stmt);
    6763                if ( compoundStmt ) return mutate( compoundStmt );
    68                
     64
    6965                doBeginScope();
    70                
     66
    7167                // run mutator on statement
    7268                stmt = maybeMutate( stmt, *this );
     
    10298                doBeginScope();
    10399
    104                
     100
    105101                for ( std::list< Statement* >::iterator stmt = stmts.begin(); ; ++stmt ) {
    106102                        // add any new declarations after the previous statement
     
    112108
    113109                        if ( stmt == stmts.end() ) break;
    114                        
     110
    115111                        // run mutator on statement
    116112                        *stmt = maybeMutate( *stmt, *this );
     
    123119                        declsToAdd.back().clear();
    124120                }
    125                
     121
    126122                doEndScope();
    127123        }
     
    139135                return compoundStmt;
    140136        }
    141        
     137
    142138        Statement* DeclMutator::mutate(IfStmt *ifStmt) {
    143139                ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
     
    146142                return ifStmt;
    147143        }
    148        
     144
    149145        Statement* DeclMutator::mutate(WhileStmt *whileStmt) {
    150146                whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
     
    152148                return whileStmt;
    153149        }
    154        
     150
    155151        Statement* DeclMutator::mutate(ForStmt *forStmt) {
    156152                mutateAll( forStmt->get_initialization(), *this );
     
    160156                return forStmt;
    161157        }
    162        
     158
    163159        Statement* DeclMutator::mutate(SwitchStmt *switchStmt) {
    164160                switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
     
    166162                return switchStmt;
    167163        }
    168        
     164
    169165        Statement* DeclMutator::mutate(CaseStmt *caseStmt) {
    170166                caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
     
    172168                return caseStmt;
    173169        }
    174        
     170
    175171        Statement* DeclMutator::mutate(TryStmt *tryStmt) {
    176172                tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
     
    179175                return tryStmt;
    180176        }
    181        
     177
    182178        Statement* DeclMutator::mutate(CatchStmt *catchStmt) {
    183179                catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
     180                catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    184181                catchStmt->set_body( mutateStatement( catchStmt->get_body() ) );
    185182                return catchStmt;
  • src/GenPoly/InstantiateGeneric.cc

    r9c951e3 rb1e63ac5  
    2222#include "InstantiateGeneric.h"
    2323
    24 #include "DeclMutator.h"
    2524#include "GenPoly.h"
    2625#include "ScopedSet.h"
    2726#include "ScrubTyVars.h"
    28 #include "PolyMutator.h"
     27
     28#include "Common/PassVisitor.h"
     29#include "Common/ScopedMap.h"
     30#include "Common/UniqueName.h"
     31#include "Common/utility.h"
    2932
    3033#include "ResolvExpr/typeops.h"
     
    3437#include "SynTree/Type.h"
    3538
    36 #include "Common/ScopedMap.h"
    37 #include "Common/UniqueName.h"
    38 #include "Common/utility.h"
     39
     40#include "InitTweak/InitTweak.h"
     41
    3942
    4043namespace GenPoly {
     
    153156        }
    154157
    155         // collect the environments of each TypeInstType so that type variables can be replaced
    156         // xxx - possibly temporary solution. Access to type environments is required in GenericInstantiator, but it needs to be a DeclMutator which does not provide easy access to the type environments.
    157         class EnvFinder final : public GenPoly::PolyMutator {
    158         public:
    159                 using GenPoly::PolyMutator::mutate;
    160                 virtual Type * mutate( TypeInstType * inst ) override {
    161                         if ( env ) envMap[inst] = env;
    162                         return inst;
    163                 }
    164 
    165                 // don't want to associate an environment with TypeInstTypes that occur in function types - this may actually only apply to function types belonging to DeclarationWithTypes (or even just FunctionDecl)?
    166                 virtual Type * mutate( FunctionType * ftype ) override {
    167                         return ftype;
    168                 }
    169                 std::unordered_map< ReferenceToType *, TypeSubstitution * > envMap;
    170         };
    171 
    172158        /// Mutator pass that replaces concrete instantiations of generic types with actual struct declarations, scoped appropriately
    173         class GenericInstantiator final : public DeclMutator {
     159        struct GenericInstantiator final : public WithTypeSubstitution, public WithDeclsToAdd, public WithVisitorRef<GenericInstantiator>, public WithGuards {
    174160                /// Map of (generic type, parameter list) pairs to concrete type instantiations
    175161                InstantiationMap< AggregateDecl, AggregateDecl > instantiations;
     
    178164                /// Namer for concrete types
    179165                UniqueName typeNamer;
    180                 /// Reference to mapping of environments
    181                 const std::unordered_map< ReferenceToType *, TypeSubstitution * > & envMap;
    182         public:
    183                 GenericInstantiator( const std::unordered_map< ReferenceToType *, TypeSubstitution * > & envMap ) : DeclMutator(), instantiations(), dtypeStatics(), typeNamer("_conc_"), envMap( envMap ) {}
    184 
    185                 using DeclMutator::mutate;
    186                 virtual Type* mutate( StructInstType *inst ) override;
    187                 virtual Type* mutate( UnionInstType *inst ) override;
    188 
    189                 virtual void doBeginScope() override;
    190                 virtual void doEndScope() override;
     166                /// Should not make use of type environment to replace types of function parameter and return values.
     167                bool inFunctionType = false;
     168                GenericInstantiator() : instantiations(), dtypeStatics(), typeNamer("_conc_") {}
     169
     170                Type* postmutate( StructInstType *inst );
     171                Type* postmutate( UnionInstType *inst );
     172
     173                void premutate( FunctionType * ftype ) {
     174                        GuardValue( inFunctionType );
     175                        inFunctionType = true;
     176                }
     177
     178                void beginScope();
     179                void endScope();
    191180        private:
    192181                /// Wrap instantiation lookup for structs
     
    207196
    208197        void instantiateGeneric( std::list< Declaration* > &translationUnit ) {
    209                 EnvFinder finder;
    210                 mutateAll( translationUnit, finder );
    211                 GenericInstantiator instantiator( finder.envMap );
    212                 instantiator.mutateDeclarationList( translationUnit );
     198                PassVisitor<GenericInstantiator> instantiator;
     199                mutateAll( translationUnit, instantiator );
    213200        }
    214201
     
    306293        Type *GenericInstantiator::replaceWithConcrete( Type *type, bool doClone ) {
    307294                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    308                         if ( envMap.count( typeInst ) ) {
    309                                 TypeSubstitution * env = envMap.at( typeInst );
     295                        if ( env && ! inFunctionType ) {
    310296                                Type *concrete = env->lookup( typeInst->get_name() );
    311297                                if ( concrete ) {
     
    331317
    332318
    333         Type* GenericInstantiator::mutate( StructInstType *inst ) {
    334                 // mutate subtypes
    335                 Type *mutated = Mutator::mutate( inst );
    336                 inst = dynamic_cast< StructInstType* >( mutated );
    337                 if ( ! inst ) return mutated;
    338 
     319        Type* GenericInstantiator::postmutate( StructInstType *inst ) {
    339320                // exit early if no need for further mutation
    340321                if ( inst->get_parameters().empty() ) return inst;
     
    367348                                concDecl->set_body( inst->get_baseStruct()->has_body() );
    368349                                substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    369                                 DeclMutator::addDeclaration( concDecl );
    370                                 insert( inst, typeSubs, concDecl );
    371                                 concDecl->acceptMutator( *this ); // recursively instantiate members
     350                                insert( inst, typeSubs, concDecl ); // must insert before recursion
     351                                concDecl->acceptMutator( *visitor ); // recursively instantiate members
     352                                declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first
    372353                        }
    373354                        StructInstType *newInst = new StructInstType( inst->get_qualifiers(), concDecl->get_name() );
     
    388369        }
    389370
    390         Type* GenericInstantiator::mutate( UnionInstType *inst ) {
    391                 // mutate subtypes
    392                 Type *mutated = Mutator::mutate( inst );
    393                 inst = dynamic_cast< UnionInstType* >( mutated );
    394                 if ( ! inst ) return mutated;
    395 
     371        Type* GenericInstantiator::postmutate( UnionInstType *inst ) {
    396372                // exit early if no need for further mutation
    397373                if ( inst->get_parameters().empty() ) return inst;
     
    422398                                concDecl->set_body( inst->get_baseUnion()->has_body() );
    423399                                substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    424                                 DeclMutator::addDeclaration( concDecl );
    425                                 insert( inst, typeSubs, concDecl );
    426                                 concDecl->acceptMutator( *this ); // recursively instantiate members
     400                                insert( inst, typeSubs, concDecl ); // must insert before recursion
     401                                concDecl->acceptMutator( *visitor ); // recursively instantiate members
     402                                declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first
    427403                        }
    428404                        UnionInstType *newInst = new UnionInstType( inst->get_qualifiers(), concDecl->get_name() );
     
    442418        }
    443419
    444         void GenericInstantiator::doBeginScope() {
    445                 DeclMutator::doBeginScope();
     420        void GenericInstantiator::beginScope() {
    446421                instantiations.beginScope();
    447422                dtypeStatics.beginScope();
    448423        }
    449424
    450         void GenericInstantiator::doEndScope() {
    451                 DeclMutator::doEndScope();
     425        void GenericInstantiator::endScope() {
    452426                instantiations.endScope();
    453427                dtypeStatics.endScope();
  • src/GenPoly/Lvalue.cc

    r9c951e3 rb1e63ac5  
    3636namespace GenPoly {
    3737        namespace {
    38                 const std::list<Label> noLabels;
    39 
    4038                /// Replace uses of lvalue returns with appropriate pointers
    4139                class Pass1 : public Mutator {
  • src/GenPoly/PolyMutator.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:26:22 2016
    13 // Update Count     : 16
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:47:00 2017
     13// Update Count     : 17
    1414//
    1515
     
    123123
    124124        Statement * PolyMutator::mutate(TryStmt *tryStmt) {
    125                 tryStmt->set_block(  maybeMutate( tryStmt->get_block(), *this ) );
     125                tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    126126                mutateAll( tryStmt->get_catchers(), *this );
     127                tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    127128                return tryStmt;
    128129        }
    129130
    130131        Statement * PolyMutator::mutate(CatchStmt *cathStmt) {
    131                 cathStmt->set_body(  mutateStatement( cathStmt->get_body() ) );
    132                 cathStmt->set_decl(  maybeMutate( cathStmt->get_decl(), *this ) );
     132                cathStmt->set_body( mutateStatement( cathStmt->get_body() ) );
     133                cathStmt->set_cond( maybeMutate( cathStmt->get_cond(), *this ) );
     134                cathStmt->set_decl( maybeMutate( cathStmt->get_decl(), *this ) );
    133135                return cathStmt;
    134136        }
  • src/GenPoly/Specialize.cc

    r9c951e3 rb1e63ac5  
    9393        }
    9494
    95         bool needsTupleSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) {
     95        bool needsTupleSpecialization( Type *formalType, Type *actualType ) {
    9696                // Needs tuple specialization if the structure of the formal type and actual type do not match.
    9797                // This is the case if the formal type has ttype polymorphism, or if the structure  of tuple types
     
    9999                if ( FunctionType * fftype = getFunctionType( formalType ) ) {
    100100                        if ( fftype->isTtype() ) return true;
     101                        // conversion of 0 (null) to function type does not require tuple specialization
     102                        if ( dynamic_cast< ZeroType * >( actualType ) ) return false;
    101103                        FunctionType * aftype = getFunctionType( actualType );
    102104                        assertf( aftype, "formal type is a function type, but actual type is not." );
     
    112114
    113115        bool needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) {
    114                 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType, env );
     116                return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType );
    115117        }
    116118
  • src/InitTweak/FixGlobalInit.cc

    r9c951e3 rb1e63ac5  
    2626
    2727namespace InitTweak {
    28         namespace {
    29                 const std::list<Label> noLabels;
    30         }
    31 
    3228        class GlobalFixer : public Visitor {
    3329          public:
     
    129125
    130126        // only modify global variables
    131         void GlobalFixer::visit( FunctionDecl *functionDecl ) {}
    132         void GlobalFixer::visit( StructDecl *aggregateDecl ) {}
    133         void GlobalFixer::visit( UnionDecl *aggregateDecl ) {}
    134         void GlobalFixer::visit( EnumDecl *aggregateDecl ) {}
    135         void GlobalFixer::visit( TraitDecl *aggregateDecl ) {}
    136         void GlobalFixer::visit( TypeDecl *typeDecl ) {}
     127        void GlobalFixer::visit( __attribute__((unused)) FunctionDecl *functionDecl ) {}
     128        void GlobalFixer::visit( __attribute__((unused)) StructDecl *aggregateDecl ) {}
     129        void GlobalFixer::visit( __attribute__((unused)) UnionDecl *aggregateDecl ) {}
     130        void GlobalFixer::visit( __attribute__((unused)) EnumDecl *aggregateDecl ) {}
     131        void GlobalFixer::visit( __attribute__((unused)) TraitDecl *aggregateDecl ) {}
     132        void GlobalFixer::visit( __attribute__((unused)) TypeDecl *typeDecl ) {}
    137133
    138134} // namespace InitTweak
  • src/InitTweak/FixInit.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:13:47 2017
    13 // Update Count     : 71
     12// Last Modified On : Wed Jun 21 17:35:05 2017
     13// Update Count     : 74
    1414//
    1515
     
    2020#include <unordered_map>
    2121#include <unordered_set>
     22
    2223#include "InitTweak.h"
    2324#include "GenInit.h"
    2425#include "FixInit.h"
    2526#include "FixGlobalInit.h"
     27#include "CodeGen/GenType.h"  // for warning/error messages
     28#include "Common/PassVisitor.h"
     29#include "GenPoly/DeclMutator.h"
     30#include "GenPoly/PolyMutator.h"
    2631#include "ResolvExpr/Resolver.h"
    2732#include "ResolvExpr/typeops.h"
     33#include "SymTab/Autogen.h"
     34#include "SymTab/Indexer.h"
     35#include "SynTree/AddStmtVisitor.h"
     36#include "SynTree/Attribute.h"
    2837#include "SynTree/Declaration.h"
    29 #include "SynTree/Type.h"
    3038#include "SynTree/Expression.h"
    31 #include "SynTree/Attribute.h"
    32 #include "SynTree/Statement.h"
    3339#include "SynTree/Initializer.h"
    3440#include "SynTree/Mutator.h"
    35 #include "SymTab/Indexer.h"
    36 #include "SymTab/Autogen.h"
    37 #include "GenPoly/PolyMutator.h"
    38 #include "GenPoly/DeclMutator.h"
    39 #include "SynTree/AddStmtVisitor.h"
    40 #include "CodeGen/GenType.h"  // for warning/error messages
     41#include "SynTree/Statement.h"
     42#include "SynTree/Type.h"
    4143#include "Tuples/Tuples.h"
    4244
     
    5456                typedef std::unordered_map< int, int > UnqCount;
    5557
    56                 class InsertImplicitCalls final : public GenPoly::PolyMutator {
     58                class InsertImplicitCalls : public WithTypeSubstitution {
    5759                public:
    5860                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    6163
    6264                        InsertImplicitCalls( EnvMap & envMap ) : envMap( envMap ) {}
    63                         typedef GenPoly::PolyMutator Parent;
    64                         using Parent::mutate;
    65                         virtual Expression * mutate( ApplicationExpr * appExpr ) override;
    66                         virtual Expression * mutate( StmtExpr * stmtExpr ) override;
     65
     66                        Expression * postmutate( ApplicationExpr * appExpr );
     67                        void premutate( StmtExpr * stmtExpr );
    6768
    6869                        // collects environments for relevant nodes
     
    103104                        typedef AddStmtVisitor Parent;
    104105                        using Parent::visit;
    105                         typedef std::set< ObjectDecl * > ObjectSet;
     106                        // use ordered data structure to maintain ordering for set_difference and for consistent error messages
     107                        typedef std::list< ObjectDecl * > ObjectSet;
    106108                        virtual void visit( CompoundStmt *compoundStmt ) override;
    107109                        virtual void visit( DeclStmt *stmt ) override;
    108110
    109111                        // don't go into other functions
    110                         virtual void visit( FunctionDecl *decl ) override {}
     112                        virtual void visit( __attribute__((unused)) FunctionDecl *decl ) override {}
    111113
    112114                  protected:
     
    115117
    116118                // debug
    117                 struct printSet {
    118                         typedef ObjDeclCollector::ObjectSet ObjectSet;
    119                         printSet( const ObjectSet & objs ) : objs( objs ) {}
     119                template<typename ObjectSet>
     120                struct PrintSet {
     121                        PrintSet( const ObjectSet & objs ) : objs( objs ) {}
    120122                        const ObjectSet & objs;
    121123                };
    122                 std::ostream & operator<<( std::ostream & out, const printSet & set) {
     124                template<typename ObjectSet>
     125                PrintSet<ObjectSet> printSet( const ObjectSet & objs ) { return PrintSet<ObjectSet>( objs ); }
     126                template<typename ObjectSet>
     127                std::ostream & operator<<( std::ostream & out, const PrintSet<ObjectSet> & set) {
    123128                        out << "{ ";
    124129                        for ( ObjectDecl * obj : set.objs ) {
     
    190195                };
    191196
    192                 class FixInit final : public GenPoly::PolyMutator {
     197                class FixInit : public WithStmtsToAdd {
    193198                  public:
    194199                        /// expand each object declaration to use its constructor after it is declared.
    195200                        static void fixInitializers( std::list< Declaration * > &translationUnit );
    196201
    197                         typedef GenPoly::PolyMutator Parent;
    198                         using Parent::mutate;
    199                         virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override;
     202                        DeclarationWithType * postmutate( ObjectDecl *objDecl );
    200203
    201204                        std::list< Declaration * > staticDtorDecls;
     
    300303        namespace {
    301304                void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) {
    302                         InsertImplicitCalls inserter( envMap );
     305                        PassVisitor<InsertImplicitCalls> inserter( envMap );
    303306                        mutateAll( translationUnit, inserter );
    304307                }
     
    310313
    311314                void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) {
    312                         FixInit fixer;
     315                        PassVisitor<FixInit> fixer;
    313316
    314317                        // can't use mutateAll, because need to insert declarations at top-level
     
    318321                                try {
    319322                                        *i = maybeMutate( *i, fixer );
    320                                         translationUnit.splice( i, fixer.staticDtorDecls );
     323                                        translationUnit.splice( i, fixer.pass.staticDtorDecls );
    321324                                } catch( SemanticError &e ) {
    322325                                        e.set_location( (*i)->location );
     
    350353                }
    351354
    352                 Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) {
    353                         appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) );
     355                Expression * InsertImplicitCalls::postmutate( ApplicationExpr * appExpr ) {
    354356                        assert( appExpr );
    355357
     
    393395                }
    394396
    395                 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) {
     397                void InsertImplicitCalls::premutate( StmtExpr * stmtExpr ) {
    396398                        assert( env );
    397399                        envMap[stmtExpr] = env;
    398                         return Parent::mutate( stmtExpr );
    399400                }
    400401
     
    696697                }
    697698
    698                 DeclarationWithType *FixInit::mutate( ObjectDecl *objDecl ) {
    699                         // first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors when the init
    700                         // is removed from the ObjectDecl
    701                         objDecl = dynamic_cast< ObjectDecl * >( Parent::mutate( objDecl ) );
     699                DeclarationWithType *FixInit::postmutate( ObjectDecl *objDecl ) {
     700                        // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
    702701                        if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    703702                                // a decision should have been made by the resolver, so ctor and init are not both non-NULL
     
    729728                                                // static bool __objName_uninitialized = true
    730729                                                BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    731                                                 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators );
     730                                                SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ) );
    732731                                                ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
    733732                                                isUninitializedVar->fixUniqueId();
     
    736735                                                UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) );
    737736                                                setTrue->get_args().push_back( new VariableExpr( isUninitializedVar ) );
    738                                                 setTrue->get_args().push_back( new ConstantExpr( Constant( boolType->clone(), "0" ) ) );
     737                                                setTrue->get_args().push_back( new ConstantExpr( Constant::from_int( 0 ) ) );
    739738
    740739                                                // generate body of if
     
    750749
    751750                                                Statement * dtor = ctorInit->get_dtor();
    752                                                 objDecl->set_init( NULL );
    753                                                 ctorInit->set_ctor( NULL );
     751                                                objDecl->set_init( nullptr );
     752                                                ctorInit->set_ctor( nullptr );
    754753                                                ctorInit->set_dtor( nullptr );
    755754                                                if ( dtor ) {
     
    804803                                                } else {
    805804                                                        stmtsToAddAfter.push_back( ctor );
    806                                                         objDecl->set_init( NULL );
    807                                                         ctorInit->set_ctor( NULL );
     805                                                        objDecl->set_init( nullptr );
     806                                                        ctorInit->set_ctor( nullptr );
    808807                                                }
    809808                                        } // if
    810809                                } else if ( Initializer * init = ctorInit->get_init() ) {
    811810                                        objDecl->set_init( init );
    812                                         ctorInit->set_init( NULL );
     811                                        ctorInit->set_init( nullptr );
    813812                                } else {
    814813                                        // no constructor and no initializer, which is okay
    815                                         objDecl->set_init( NULL );
     814                                        objDecl->set_init( nullptr );
    816815                                } // if
    817816                                delete ctorInit;
     
    821820
    822821                void ObjDeclCollector::visit( CompoundStmt * compoundStmt ) {
    823                         std::set< ObjectDecl * > prevVars = curVars;
     822                        ObjectSet prevVars = curVars;
    824823                        Parent::visit( compoundStmt );
    825824                        curVars = prevVars;
     
    829828                        // keep track of all variables currently in scope
    830829                        if ( ObjectDecl * objDecl = dynamic_cast< ObjectDecl * > ( stmt->get_decl() ) ) {
    831                                 curVars.insert( objDecl );
     830                                curVars.push_back( objDecl );
    832831                        } // if
    833832                        Parent::visit( stmt );
     
    896895                        Parent::visit( compoundStmt );
    897896
    898                         // add destructors for the current scope that we're exiting
     897                        // add destructors for the current scope that we're exiting, unless the last statement is a return, which
     898                        // causes unreachable code warnings
    899899                        std::list< Statement * > & statements = compoundStmt->get_kids();
    900                         insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( statements ) );
     900                        if ( ! statements.empty() && ! dynamic_cast< ReturnStmt * >( statements.back() ) ) {
     901                                insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( statements ) );
     902                        }
    901903                        reverseDeclOrder.pop_front();
    902904                }
    903905
    904                 void InsertDtors::visit( ReturnStmt * returnStmt ) {
     906                void InsertDtors::visit( __attribute((unused)) ReturnStmt * returnStmt ) {
    905907                        // return exits all scopes, so dump destructors for all scopes
    906908                        for ( OrderedDecls & od : reverseDeclOrder ) {
     
    941943                        )
    942944                        if ( ! diff.empty() ) {
     945                                // create an auxilliary set for fast lookup -- can't make diff a set, because diff ordering should be consistent for error messages.
     946                                std::unordered_set<ObjectDecl *> needsDestructor( diff.begin(), diff.end() );
     947
    943948                                // go through decl ordered list of objectdecl. for each element that occurs in diff, output destructor
    944949                                OrderedDecls ordered;
    945950                                for ( OrderedDecls & rdo : reverseDeclOrder ) {
    946951                                        // add elements from reverseDeclOrder into ordered if they occur in diff - it is key that this happens in reverse declaration order.
    947                                         copy_if( rdo.begin(), rdo.end(), back_inserter( ordered ), [&]( ObjectDecl * objDecl ) { return diff.count( objDecl ); } );
     952                                        copy_if( rdo.begin(), rdo.end(), back_inserter( ordered ), [&]( ObjectDecl * objDecl ) { return needsDestructor.count( objDecl ); } );
    948953                                } // for
    949954                                insertDtors( ordered.begin(), ordered.end(), back_inserter( stmtsToAdd ) );
  • src/InitTweak/GenInit.cc

    r9c951e3 rb1e63ac5  
    1616#include <stack>
    1717#include <list>
     18
     19#include "InitTweak.h"
    1820#include "GenInit.h"
    19 #include "InitTweak.h"
     21
     22#include "Common/PassVisitor.h"
     23
     24#include "GenPoly/DeclMutator.h"
     25#include "GenPoly/PolyMutator.h"
     26#include "GenPoly/ScopedSet.h"
     27
     28#include "ResolvExpr/typeops.h"
     29
    2030#include "SynTree/Declaration.h"
    21 #include "SynTree/Type.h"
    2231#include "SynTree/Expression.h"
    23 #include "SynTree/Statement.h"
    2432#include "SynTree/Initializer.h"
    2533#include "SynTree/Mutator.h"
     34#include "SynTree/Statement.h"
     35#include "SynTree/Type.h"
     36
    2637#include "SymTab/Autogen.h"
    2738#include "SymTab/Mangler.h"
    28 #include "GenPoly/PolyMutator.h"
    29 #include "GenPoly/DeclMutator.h"
    30 #include "GenPoly/ScopedSet.h"
    31 #include "ResolvExpr/typeops.h"
    3239
    3340namespace InitTweak {
     
    3744        }
    3845
    39         class ReturnFixer final : public GenPoly::PolyMutator {
    40           public:
     46        struct ReturnFixer : public WithStmtsToAdd, public WithGuards {
    4147                /// consistently allocates a temporary variable for the return value
    4248                /// of a function so that anything which the resolver decides can be constructed
     
    4450                static void makeReturnTemp( std::list< Declaration * > &translationUnit );
    4551
    46                 ReturnFixer();
    47 
    48                 typedef GenPoly::PolyMutator Parent;
    49                 using Parent::mutate;
    50                 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override;
    51                 virtual Statement * mutate( ReturnStmt * returnStmt ) override;
     52                void premutate( FunctionDecl *functionDecl );
     53                void premutate( ReturnStmt * returnStmt );
    5254
    5355          protected:
     
    5658        };
    5759
    58         class CtorDtor final : public GenPoly::PolyMutator {
    59           public:
    60                 typedef GenPoly::PolyMutator Parent;
    61                 using Parent::mutate;
     60        struct CtorDtor : public WithGuards, public WithShortCircuiting  {
    6261                /// create constructor and destructor statements for object declarations.
    6362                /// the actual call statements will be added in after the resolver has run
     
    6665                static void generateCtorDtor( std::list< Declaration * > &translationUnit );
    6766
    68                 virtual DeclarationWithType * mutate( ObjectDecl * ) override;
    69                 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override;
     67                void previsit( ObjectDecl * );
     68                void previsit( FunctionDecl *functionDecl );
     69
    7070                // should not traverse into any of these declarations to find objects
    7171                // that need to be constructed or destructed
    72                 virtual Declaration* mutate( StructDecl *aggregateDecl ) override;
    73                 virtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; }
    74                 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; }
    75                 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; }
    76                 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; }
    77                 virtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; }
    78 
    79                 virtual Type * mutate( FunctionType *funcType ) override { return funcType; }
    80 
    81                 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override;
     72                void previsit( StructDecl *aggregateDecl );
     73                void previsit( UnionDecl *aggregateDecl ) { visit_children = false; }
     74                void previsit( EnumDecl *aggregateDecl ) { visit_children = false; }
     75                void previsit( TraitDecl *aggregateDecl ) { visit_children = false; }
     76                void previsit( TypeDecl *typeDecl ) { visit_children = false; }
     77                void previsit( TypedefDecl *typeDecl ) { visit_children = false; }
     78
     79                void previsit( FunctionType *funcType ) { visit_children = false; }
     80
     81                void previsit( CompoundStmt * compoundStmt );
    8282
    8383          private:
     
    131131
    132132        void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) {
    133                 ReturnFixer fixer;
     133                PassVisitor<ReturnFixer> fixer;
    134134                mutateAll( translationUnit, fixer );
    135135        }
    136136
    137         ReturnFixer::ReturnFixer() {}
    138 
    139         Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
     137        void ReturnFixer::premutate( ReturnStmt *returnStmt ) {
    140138                std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
    141139                assert( returnVals.size() == 0 || returnVals.size() == 1 );
     
    148146                        construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) );
    149147                        construct->get_args().push_back( returnStmt->get_expr() );
    150                         stmtsToAdd.push_back(new ExprStmt(noLabels, construct));
     148                        stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct));
    151149
    152150                        // return the retVal object
    153151                        returnStmt->set_expr( new VariableExpr( returnVals.front() ) );
    154152                } // if
    155                 return returnStmt;
    156         }
    157 
    158         DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    159                 ValueGuard< FunctionType * > oldFtype( ftype );
    160                 ValueGuard< std::string > oldFuncName( funcName );
     153        }
     154
     155        void ReturnFixer::premutate( FunctionDecl *functionDecl ) {
     156                GuardValue( ftype );
     157                GuardValue( funcName );
    161158
    162159                ftype = functionDecl->get_functionType();
    163160                funcName = functionDecl->get_name();
    164                 return Parent::mutate( functionDecl );
    165161        }
    166162
     
    212208
    213209        void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) {
    214                 CtorDtor ctordtor;
    215                 mutateAll( translationUnit, ctordtor );
     210                PassVisitor<CtorDtor> ctordtor;
     211                acceptAll( translationUnit, ctordtor );
    216212        }
    217213
     
    291287        }
    292288
    293         DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) {
     289        void CtorDtor::previsit( ObjectDecl * objDecl ) {
    294290                handleDWT( objDecl );
    295291                // hands off if @=, extern, builtin, etc.
     
    303299                        objDecl->set_init( genCtorInit( objDecl ) );
    304300                }
    305                 return Parent::mutate( objDecl );
    306         }
    307 
    308         DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) {
    309                 ValueGuard< bool > oldInFunc = inFunction;
     301        }
     302
     303        void CtorDtor::previsit( FunctionDecl *functionDecl ) {
     304                GuardValue( inFunction );
    310305                inFunction = true;
    311306
    312307                handleDWT( functionDecl );
    313308
    314                 managedTypes.beginScope();
     309                GuardScope( managedTypes );
    315310                // go through assertions and recursively add seen ctor/dtors
    316311                for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) {
    317312                        for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
    318                                 assertion = assertion->acceptMutator( *this );
     313                                handleDWT( assertion );
    319314                        }
    320315                }
    321                 // parameters should not be constructed and destructed, so don't mutate FunctionType
    322                 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
    323 
    324                 managedTypes.endScope();
    325                 return functionDecl;
    326         }
    327 
    328         Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) {
     316
     317                PassVisitor<CtorDtor> newCtorDtor;
     318                newCtorDtor.pass = *this;
     319                maybeAccept( functionDecl->get_statements(), newCtorDtor );
     320                visit_children = false;  // do not try and construct parameters or forall parameters - must happen after maybeAccept
     321        }
     322
     323        void CtorDtor::previsit( StructDecl *aggregateDecl ) {
     324                visit_children = false; // do not try to construct and destruct aggregate members
     325
    329326                // don't construct members, but need to take note if there is a managed member,
    330327                // because that means that this type is also managed
     
    338335                        }
    339336                }
    340                 return aggregateDecl;
    341         }
    342 
    343         CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) {
    344                 managedTypes.beginScope();
    345                 CompoundStmt * stmt = Parent::mutate( compoundStmt );
    346                 managedTypes.endScope();
    347                 return stmt;
    348         }
    349 
     337        }
     338
     339        void CtorDtor::previsit( CompoundStmt * compoundStmt ) {
     340                GuardScope( managedTypes );
     341        }
    350342} // namespace InitTweak
    351343
  • src/InitTweak/InitTweak.cc

    r9c951e3 rb1e63ac5  
    1414                public:
    1515                        bool hasDesignations = false;
    16                         template<typename Init>
    17                         void handleInit( Init * init ) {
    18                                 if ( ! init->get_designators().empty() ) hasDesignations = true;
    19                                 else Visitor::visit( init );
    20                         }
    21                         virtual void visit( SingleInit * singleInit ) { handleInit( singleInit); }
    22                         virtual void visit( ListInit * listInit ) { handleInit( listInit); }
     16                        virtual void visit( Designation * des ) {
     17                                if ( ! des->get_designators().empty() ) hasDesignations = true;
     18                                else Visitor::visit( des );
     19                        }
    2320                };
    2421
     
    9289                InitImpl( Initializer * init ) : init( init ) {}
    9390
    94                 virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     91                virtual std::list< Expression * > next( __attribute((unused)) std::list< Expression * > & indices ) {
    9592                        // this is wrong, but just a placeholder for now
    9693                        // if ( ! flattened ) flatten( indices );
     
    248245        }
    249246
    250         Statement * ExprImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) {
     247        Statement * ExprImpl::buildListInit( __attribute((unused)) UntypedExpr * dst, __attribute((unused)) std::list< Expression * > & indices ) {
    251248                return NULL;
    252249        }
     
    477474                ConstExprChecker() : isConstExpr( true ) {}
    478475
    479                 virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    480                 virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }
     476                using Visitor::visit;
     477
     478                virtual void visit( __attribute((unused)) ApplicationExpr *applicationExpr ) { isConstExpr = false; }
     479                virtual void visit( __attribute((unused)) UntypedExpr *untypedExpr ) { isConstExpr = false; }
    481480                virtual void visit( NameExpr *nameExpr ) {
    482481                        // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today
     
    489488                        if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
    490489                }
    491                 virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    492                 virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    493                 virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    494                 virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
     490                virtual void visit( __attribute((unused)) LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
     491                virtual void visit( __attribute((unused)) UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
     492                virtual void visit( __attribute((unused)) MemberExpr *memberExpr ) { isConstExpr = false; }
     493                virtual void visit( __attribute((unused)) VariableExpr *variableExpr ) { isConstExpr = false; }
    495494                // these might be okay?
    496495                // virtual void visit( SizeofExpr *sizeofExpr );
     
    503502                // virtual void visit( LogicalExpr *logicalExpr );
    504503                // virtual void visit( ConditionalExpr *conditionalExpr );
    505                 virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }
    506                 virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }
    507                 virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }
    508                 virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
    509                 virtual void visit( UntypedTupleExpr *tupleExpr ) { isConstExpr = false; }
    510                 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
    511                 virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
     504                virtual void visit( __attribute((unused)) TypeExpr *typeExpr ) { isConstExpr = false; }
     505                virtual void visit( __attribute((unused)) AsmExpr *asmExpr ) { isConstExpr = false; }
     506                virtual void visit( __attribute((unused)) UntypedValofExpr *valofExpr ) { isConstExpr = false; }
     507                virtual void visit( __attribute((unused)) CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
     508                virtual void visit( __attribute((unused)) UntypedTupleExpr *tupleExpr ) { isConstExpr = false; }
     509                virtual void visit( __attribute((unused)) TupleExpr *tupleExpr ) { isConstExpr = false; }
     510                virtual void visit( __attribute((unused)) TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
    512511
    513512                bool isConstExpr;
  • src/MakeLibCfa.cc

    r9c951e3 rb1e63ac5  
    7575                  case CodeGen::OT_POSTFIXASSIGN:
    7676                  case CodeGen::OT_INFIXASSIGN:
     77                  case CodeGen::OT_CTOR:
     78                  case CodeGen::OT_DTOR:
    7779                                funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
    7880                                break;
    79                   case CodeGen::OT_CTOR:
    80                         // ctors don't return a value
    81                         if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) {
    82                                 // intrinsic default constructors should do nothing
    83                                 // delete newExpr;
    84                                 break;
    85                         } else {
    86                                 assert( funcDecl->get_functionType()->get_parameters().size() == 2 );
    87                                 // anything else is a single parameter constructor that is effectively a C-style assignment
    88                                 // delete newExpr->get_function();
    89                                 assert(newExpr->get_args().size()==2);
    90                                 newExpr->set_function( new NameExpr( "?=?" ) );
    91                                 funcDecl->get_statements()->get_kids().push_back( new ExprStmt( std::list< Label >(), newExpr ) );
    92                         }
    93                         break;
    94                   case CodeGen::OT_DTOR:
    95                         // intrinsic destructors should do nothing
    96                         // delete newExpr;
    97                         break;
    9881                  case CodeGen::OT_CONSTANT:
    9982                  case CodeGen::OT_LABELADDRESS:
     
    10992                assert( ! objDecl->get_init() );
    11093                std::list< Expression* > noDesignators;
    111                 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators, false ) ); // cannot be constructed
     94                objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), false ) ); // cannot be constructed
    11295                newDecls.push_back( objDecl );
    11396        }
  • src/Makefile.am

    r9c951e3 rb1e63ac5  
    4343driver_cfa_cpp_SOURCES = ${SRC}
    4444driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    45 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2
     45driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
    4646driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
    4747
  • src/Makefile.in

    r9c951e3 rb1e63ac5  
    119119        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    120120        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
     121        ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT) \
    121122        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    122123        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    143144        Parser/driver_cfa_cpp-TypeData.$(OBJEXT) \
    144145        Parser/driver_cfa_cpp-LinkageSpec.$(OBJEXT) \
    145         Parser/driver_cfa_cpp-parseutility.$(OBJEXT) \
     146        Parser/driver_cfa_cpp-parserutility.$(OBJEXT) \
    146147        ResolvExpr/driver_cfa_cpp-AlternativeFinder.$(OBJEXT) \
    147148        ResolvExpr/driver_cfa_cpp-Alternative.$(OBJEXT) \
     
    161162        ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT) \
    162163        ResolvExpr/driver_cfa_cpp-TypeEnvironment.$(OBJEXT) \
     164        ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT) \
    163165        SymTab/driver_cfa_cpp-Indexer.$(OBJEXT) \
    164166        SymTab/driver_cfa_cpp-Mangler.$(OBJEXT) \
     
    173175        SynTree/driver_cfa_cpp-PointerType.$(OBJEXT) \
    174176        SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT) \
    175         SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT) \
    176177        SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT) \
    177178        SynTree/driver_cfa_cpp-ReferenceToType.$(OBJEXT) \
     
    395396        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    396397        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    397         ControlStruct/ForExprMutator.cc GenPoly/Box.cc \
     398        ControlStruct/ForExprMutator.cc \
     399        ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \
    398400        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    399401        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
     
    406408        Parser/ExpressionNode.cc Parser/StatementNode.cc \
    407409        Parser/InitializerNode.cc Parser/TypeData.cc \
    408         Parser/LinkageSpec.cc Parser/parseutility.cc \
     410        Parser/LinkageSpec.cc Parser/parserutility.cc \
    409411        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    410412        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    415417        ResolvExpr/RenameVars.cc ResolvExpr/FindOpenVars.cc \
    416418        ResolvExpr/PolyCost.cc ResolvExpr/Occurs.cc \
    417         ResolvExpr/TypeEnvironment.cc SymTab/Indexer.cc \
    418         SymTab/Mangler.cc SymTab/Validate.cc SymTab/FixFunction.cc \
    419         SymTab/ImplementationType.cc SymTab/TypeEquality.cc \
    420         SymTab/Autogen.cc SynTree/Type.cc SynTree/VoidType.cc \
    421         SynTree/BasicType.cc SynTree/PointerType.cc \
    422         SynTree/ArrayType.cc SynTree/ReferenceType.cc \
     419        ResolvExpr/TypeEnvironment.cc ResolvExpr/CurrentObject.cc \
     420        SymTab/Indexer.cc SymTab/Mangler.cc SymTab/Validate.cc \
     421        SymTab/FixFunction.cc SymTab/ImplementationType.cc \
     422        SymTab/TypeEquality.cc SymTab/Autogen.cc SynTree/Type.cc \
     423        SynTree/VoidType.cc SynTree/BasicType.cc \
     424        SynTree/PointerType.cc SynTree/ArrayType.cc \
    423425        SynTree/FunctionType.cc SynTree/ReferenceToType.cc \
    424426        SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \
     
    448450driver_cfa_cpp_SOURCES = ${SRC}
    449451driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    450 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2
     452driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
    451453driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
    452454all: $(BUILT_SOURCES)
     
    595597        ControlStruct/$(am__dirstamp) \
    596598        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     599ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT):  \
     600        ControlStruct/$(am__dirstamp) \
     601        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    597602GenPoly/$(am__dirstamp):
    598603        @$(MKDIR_P) GenPoly
     
    664669Parser/driver_cfa_cpp-LinkageSpec.$(OBJEXT): Parser/$(am__dirstamp) \
    665670        Parser/$(DEPDIR)/$(am__dirstamp)
    666 Parser/driver_cfa_cpp-parseutility.$(OBJEXT): Parser/$(am__dirstamp) \
     671Parser/driver_cfa_cpp-parserutility.$(OBJEXT): Parser/$(am__dirstamp) \
    667672        Parser/$(DEPDIR)/$(am__dirstamp)
    668673ResolvExpr/$(am__dirstamp):
     
    722727        ResolvExpr/$(am__dirstamp) \
    723728        ResolvExpr/$(DEPDIR)/$(am__dirstamp)
     729ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT):  \
     730        ResolvExpr/$(am__dirstamp) \
     731        ResolvExpr/$(DEPDIR)/$(am__dirstamp)
    724732SymTab/$(am__dirstamp):
    725733        @$(MKDIR_P) SymTab
     
    758766SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \
    759767        SynTree/$(DEPDIR)/$(am__dirstamp)
    760 SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT):  \
    761         SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    762768SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT):  \
    763769        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    856862        -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT)
    857863        -rm -f Concurrency/driver_cfa_cpp-Keywords.$(OBJEXT)
     864        -rm -f ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT)
    858865        -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT)
    859866        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
     
    885892        -rm -f Parser/driver_cfa_cpp-lex.$(OBJEXT)
    886893        -rm -f Parser/driver_cfa_cpp-parser.$(OBJEXT)
    887         -rm -f Parser/driver_cfa_cpp-parseutility.$(OBJEXT)
     894        -rm -f Parser/driver_cfa_cpp-parserutility.$(OBJEXT)
    888895        -rm -f ResolvExpr/driver_cfa_cpp-AdjustExprType.$(OBJEXT)
    889896        -rm -f ResolvExpr/driver_cfa_cpp-Alternative.$(OBJEXT)
     
    893900        -rm -f ResolvExpr/driver_cfa_cpp-CommonType.$(OBJEXT)
    894901        -rm -f ResolvExpr/driver_cfa_cpp-ConversionCost.$(OBJEXT)
     902        -rm -f ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT)
    895903        -rm -f ResolvExpr/driver_cfa_cpp-FindOpenVars.$(OBJEXT)
    896904        -rm -f ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT)
     
    933941        -rm -f SynTree/driver_cfa_cpp-PointerType.$(OBJEXT)
    934942        -rm -f SynTree/driver_cfa_cpp-ReferenceToType.$(OBJEXT)
    935         -rm -f SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT)
    936943        -rm -f SynTree/driver_cfa_cpp-Statement.$(OBJEXT)
    937944        -rm -f SynTree/driver_cfa_cpp-TupleExpr.$(OBJEXT)
     
    969976@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@
    970977@AMDEP_TRUE@@am__include@ @am__quote@Concurrency/$(DEPDIR)/driver_cfa_cpp-Keywords.Po@am__quote@
     978@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Po@am__quote@
    971979@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@
    972980@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
     
    9981006@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-lex.Po@am__quote@
    9991007@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-parser.Po@am__quote@
    1000 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Po@am__quote@
     1008@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Po@am__quote@
    10011009@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-AdjustExprType.Po@am__quote@
    10021010@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Alternative.Po@am__quote@
     
    10061014@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CommonType.Po@am__quote@
    10071015@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ConversionCost.Po@am__quote@
     1016@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po@am__quote@
    10081017@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-FindOpenVars.Po@am__quote@
    10091018@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Occurs.Po@am__quote@
     
    10461055@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-PointerType.Po@am__quote@
    10471056@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceToType.Po@am__quote@
    1048 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po@am__quote@
    10491057@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Statement.Po@am__quote@
    10501058@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TupleExpr.Po@am__quote@
     
    13601368@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi`
    13611369
     1370ControlStruct/driver_cfa_cpp-ExceptTranslate.o: ControlStruct/ExceptTranslate.cc
     1371@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-ExceptTranslate.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Tpo -c -o ControlStruct/driver_cfa_cpp-ExceptTranslate.o `test -f 'ControlStruct/ExceptTranslate.cc' || echo '$(srcdir)/'`ControlStruct/ExceptTranslate.cc
     1372@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Po
     1373@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/ExceptTranslate.cc' object='ControlStruct/driver_cfa_cpp-ExceptTranslate.o' libtool=no @AMDEPBACKSLASH@
     1374@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1375@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ExceptTranslate.o `test -f 'ControlStruct/ExceptTranslate.cc' || echo '$(srcdir)/'`ControlStruct/ExceptTranslate.cc
     1376
     1377ControlStruct/driver_cfa_cpp-ExceptTranslate.obj: ControlStruct/ExceptTranslate.cc
     1378@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-ExceptTranslate.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Tpo -c -o ControlStruct/driver_cfa_cpp-ExceptTranslate.obj `if test -f 'ControlStruct/ExceptTranslate.cc'; then $(CYGPATH_W) 'ControlStruct/ExceptTranslate.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ExceptTranslate.cc'; fi`
     1379@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-ExceptTranslate.Po
     1380@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/ExceptTranslate.cc' object='ControlStruct/driver_cfa_cpp-ExceptTranslate.obj' libtool=no @AMDEPBACKSLASH@
     1381@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1382@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ExceptTranslate.obj `if test -f 'ControlStruct/ExceptTranslate.cc'; then $(CYGPATH_W) 'ControlStruct/ExceptTranslate.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ExceptTranslate.cc'; fi`
     1383
    13621384GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    13631385@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc
     
    16961718@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Parser/driver_cfa_cpp-LinkageSpec.obj `if test -f 'Parser/LinkageSpec.cc'; then $(CYGPATH_W) 'Parser/LinkageSpec.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/LinkageSpec.cc'; fi`
    16971719
    1698 Parser/driver_cfa_cpp-parseutility.o: Parser/parseutility.cc
    1699 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parseutility.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Tpo -c -o Parser/driver_cfa_cpp-parseutility.o `test -f 'Parser/parseutility.cc' || echo '$(srcdir)/'`Parser/parseutility.cc
    1700 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Po
    1701 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Parser/parseutility.cc' object='Parser/driver_cfa_cpp-parseutility.o' libtool=no @AMDEPBACKSLASH@
    1702 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1703 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Parser/driver_cfa_cpp-parseutility.o `test -f 'Parser/parseutility.cc' || echo '$(srcdir)/'`Parser/parseutility.cc
    1704 
    1705 Parser/driver_cfa_cpp-parseutility.obj: Parser/parseutility.cc
    1706 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parseutility.obj -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Tpo -c -o Parser/driver_cfa_cpp-parseutility.obj `if test -f 'Parser/parseutility.cc'; then $(CYGPATH_W) 'Parser/parseutility.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/parseutility.cc'; fi`
    1707 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Po
    1708 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Parser/parseutility.cc' object='Parser/driver_cfa_cpp-parseutility.obj' libtool=no @AMDEPBACKSLASH@
    1709 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1710 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Parser/driver_cfa_cpp-parseutility.obj `if test -f 'Parser/parseutility.cc'; then $(CYGPATH_W) 'Parser/parseutility.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/parseutility.cc'; fi`
     1720Parser/driver_cfa_cpp-parserutility.o: Parser/parserutility.cc
     1721@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parserutility.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Tpo -c -o Parser/driver_cfa_cpp-parserutility.o `test -f 'Parser/parserutility.cc' || echo '$(srcdir)/'`Parser/parserutility.cc
     1722@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Po
     1723@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Parser/parserutility.cc' object='Parser/driver_cfa_cpp-parserutility.o' libtool=no @AMDEPBACKSLASH@
     1724@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1725@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Parser/driver_cfa_cpp-parserutility.o `test -f 'Parser/parserutility.cc' || echo '$(srcdir)/'`Parser/parserutility.cc
     1726
     1727Parser/driver_cfa_cpp-parserutility.obj: Parser/parserutility.cc
     1728@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parserutility.obj -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Tpo -c -o Parser/driver_cfa_cpp-parserutility.obj `if test -f 'Parser/parserutility.cc'; then $(CYGPATH_W) 'Parser/parserutility.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/parserutility.cc'; fi`
     1729@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Po
     1730@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Parser/parserutility.cc' object='Parser/driver_cfa_cpp-parserutility.obj' libtool=no @AMDEPBACKSLASH@
     1731@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1732@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Parser/driver_cfa_cpp-parserutility.obj `if test -f 'Parser/parserutility.cc'; then $(CYGPATH_W) 'Parser/parserutility.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/parserutility.cc'; fi`
    17111733
    17121734ResolvExpr/driver_cfa_cpp-AlternativeFinder.o: ResolvExpr/AlternativeFinder.cc
     
    19481970@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-TypeEnvironment.obj `if test -f 'ResolvExpr/TypeEnvironment.cc'; then $(CYGPATH_W) 'ResolvExpr/TypeEnvironment.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/TypeEnvironment.cc'; fi`
    19491971
     1972ResolvExpr/driver_cfa_cpp-CurrentObject.o: ResolvExpr/CurrentObject.cc
     1973@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-CurrentObject.o -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.o `test -f 'ResolvExpr/CurrentObject.cc' || echo '$(srcdir)/'`ResolvExpr/CurrentObject.cc
     1974@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po
     1975@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ResolvExpr/CurrentObject.cc' object='ResolvExpr/driver_cfa_cpp-CurrentObject.o' libtool=no @AMDEPBACKSLASH@
     1976@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1977@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.o `test -f 'ResolvExpr/CurrentObject.cc' || echo '$(srcdir)/'`ResolvExpr/CurrentObject.cc
     1978
     1979ResolvExpr/driver_cfa_cpp-CurrentObject.obj: ResolvExpr/CurrentObject.cc
     1980@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-CurrentObject.obj -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.obj `if test -f 'ResolvExpr/CurrentObject.cc'; then $(CYGPATH_W) 'ResolvExpr/CurrentObject.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/CurrentObject.cc'; fi`
     1981@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po
     1982@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ResolvExpr/CurrentObject.cc' object='ResolvExpr/driver_cfa_cpp-CurrentObject.obj' libtool=no @AMDEPBACKSLASH@
     1983@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1984@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.obj `if test -f 'ResolvExpr/CurrentObject.cc'; then $(CYGPATH_W) 'ResolvExpr/CurrentObject.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/CurrentObject.cc'; fi`
     1985
    19501986SymTab/driver_cfa_cpp-Indexer.o: SymTab/Indexer.cc
    19511987@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Indexer.o -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Indexer.Tpo -c -o SymTab/driver_cfa_cpp-Indexer.o `test -f 'SymTab/Indexer.cc' || echo '$(srcdir)/'`SymTab/Indexer.cc
     
    21152151@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    21162152@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ArrayType.obj `if test -f 'SynTree/ArrayType.cc'; then $(CYGPATH_W) 'SynTree/ArrayType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ArrayType.cc'; fi`
    2117 
    2118 SynTree/driver_cfa_cpp-ReferenceType.o: SynTree/ReferenceType.cc
    2119 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ReferenceType.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo -c -o SynTree/driver_cfa_cpp-ReferenceType.o `test -f 'SynTree/ReferenceType.cc' || echo '$(srcdir)/'`SynTree/ReferenceType.cc
    2120 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po
    2121 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ReferenceType.cc' object='SynTree/driver_cfa_cpp-ReferenceType.o' libtool=no @AMDEPBACKSLASH@
    2122 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2123 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ReferenceType.o `test -f 'SynTree/ReferenceType.cc' || echo '$(srcdir)/'`SynTree/ReferenceType.cc
    2124 
    2125 SynTree/driver_cfa_cpp-ReferenceType.obj: SynTree/ReferenceType.cc
    2126 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-ReferenceType.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo -c -o SynTree/driver_cfa_cpp-ReferenceType.obj `if test -f 'SynTree/ReferenceType.cc'; then $(CYGPATH_W) 'SynTree/ReferenceType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ReferenceType.cc'; fi`
    2127 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po
    2128 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/ReferenceType.cc' object='SynTree/driver_cfa_cpp-ReferenceType.obj' libtool=no @AMDEPBACKSLASH@
    2129 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2130 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-ReferenceType.obj `if test -f 'SynTree/ReferenceType.cc'; then $(CYGPATH_W) 'SynTree/ReferenceType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/ReferenceType.cc'; fi`
    21312153
    21322154SynTree/driver_cfa_cpp-FunctionType.o: SynTree/FunctionType.cc
  • src/Parser/DeclarationNode.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 12:34:05 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:46:33 2017
    13 // Update Count     : 1018
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:27:00 2017
     13// Update Count     : 1019
    1414//
    1515
     
    5757        variable.tyClass = NoTypeClass;
    5858        variable.assertions = nullptr;
     59        variable.initializer = nullptr;
    5960
    6061//      attr.name = nullptr;
     
    7071//      delete variable.name;
    7172        delete variable.assertions;
     73        delete variable.initializer;
    7274
    7375        delete type;
     
    101103        newnode->variable.tyClass = variable.tyClass;
    102104        newnode->variable.assertions = maybeClone( variable.assertions );
     105        newnode->variable.initializer = maybeClone( variable.initializer );
    103106
    104107//      newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
     
    857860}
    858861
     862DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) {
     863        assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." );
     864        variable.initializer = init;
     865        return this;
     866}
     867
    859868DeclarationNode * DeclarationNode::cloneType( string * newName ) {
    860869        DeclarationNode * newnode = new DeclarationNode;
     
    10141023                assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." );
    10151024                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1016                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
     1025                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.initializer ? variable.initializer->buildType() : nullptr );
    10171026                buildList( variable.assertions, ret->get_assertions() );
    10181027                return ret;
     
    10541063          case TypeData::Enum:
    10551064          case TypeData::Aggregate: {
    1056                   ReferenceToType * ret = buildComAggInst( type, attributes );
     1065                  ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
    10571066                  buildList( type->aggregate.actuals, ret->get_parameters() );
    10581067                  return ret;
  • src/Parser/ExpressionNode.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 17:02:46 2017
    13 // Update Count     : 515
     12// Last Modified On : Wed Jun 28 21:08:15 2017
     13// Update Count     : 542
    1414//
    1515
     
    2727#include "SynTree/Declaration.h"
    2828#include "Common/UnimplementedError.h"
    29 #include "parseutility.h"
     29#include "parserutility.h"
    3030#include "Common/utility.h"
    3131
     
    6262        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    6363        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    64         unsigned long long v;                                                           // converted integral value
     64        unsigned long long int v;                                                               // converted integral value
    6565        size_t last = str.length() - 1;                                         // last character of constant
    6666
     
    118118        } // if
    119119
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str ) );
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
    121121        delete &str;                                                                            // created by lex
    122122        return ret;
     
    133133        // floating-point constant has minimum of 2 characters: 1. or .1
    134134        size_t last = str.length() - 1;
     135        double v;
     136
     137        sscanf( str.c_str(), "%lg", &v );
    135138
    136139        if ( checkI( str[last] ) ) {                                            // imaginary ?
     
    150153        } // if
    151154
    152         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str ) );
     155        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
    153156        delete &str;                                                                            // created by lex
    154157        return ret;
     
    156159
    157160Expression *build_constantChar( const std::string & str ) {
    158         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str ) );
     161        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    159162        delete &str;                                                                            // created by lex
    160163        return ret;
     
    164167        // string should probably be a primitive type
    165168        ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    166                                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::UnsignedInt ),
    167                                                                                         toString( str.size()+1-2 ) ) ),  // +1 for '\0' and -2 for '"'
     169                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
    168170                                                                   false, false );
    169         ConstantExpr * ret = new ConstantExpr( Constant( at, str ) );
     171        // constant 0 is ignored for pure string value
     172        ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) );
    170173        delete &str;                                                                            // created by lex
    171174        return ret;
     
    173176
    174177Expression *build_constantZeroOne( const std::string & str ) {
    175         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str ) );
     178        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
     179                                                                                                   str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    176180        delete &str;                                                                            // created by lex
    177181        return ret;
     
    184188        std::stringstream ss( str );
    185189        ss >> a >> dot >> b;
    186         UntypedMemberExpr * ret = new UntypedMemberExpr(
    187                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( b ) ) ),
    188                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( a ) ) ) );
     190        UntypedMemberExpr * ret = new UntypedMemberExpr( new ConstantExpr( Constant::from_int( b ) ), new ConstantExpr( Constant::from_int( a ) ) );
    189191        delete &str;
    190192        return ret;
     
    207209} // build_field_name_fraction_constants
    208210
     211
     212
    209213Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) {
    210         assert( str[0] == '.' );
     214        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str );
    211215        Expression * ret = build_constantInteger( *new std::string( str.substr(1) ) );
    212216        delete &str;
     
    215219
    216220Expression * build_field_name_REALDECIMALconstant( const std::string & str ) {
    217         assert( str[str.size()-1] == '.' );
     221        if ( str[str.size()-1] != '.' ) throw SemanticError( "invalid tuple index " + str );
    218222        Expression * ret = build_constantInteger( *new std::string( str.substr( 0, str.size()-1 ) ) );
    219223        delete &str;
     
    221225} // build_field_name_REALDECIMALconstant
    222226
    223 NameExpr * build_varref( const string *name, bool labelp ) {
     227NameExpr * build_varref( const string *name ) {
    224228        NameExpr *expr = new NameExpr( *name, nullptr );
    225229        delete name;
     
    344348
    345349Expression *build_valexpr( StatementNode *s ) {
    346         return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr );
     350        return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
    347351}
    348352Expression *build_typevalue( DeclarationNode *decl ) {
  • src/Parser/InitializerNode.cc

    r9c951e3 rb1e63ac5  
    7474
    7575        InitializerNode *moreInit;
    76         if  ( get_next() != 0 && ((moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) != 0) )
     76        if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
    7777                moreInit->printOneLine( os );
     78        }
    7879}
    7980
    8081Initializer *InitializerNode::build() const {
    8182        if ( aggregate ) {
     83                // steal designators from children
     84                std::list< Designation * > designlist;
     85                InitializerNode * child = next_init();
     86                for ( ; child != nullptr; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) {
     87                        std::list< Expression * > desList;
     88                        buildList< Expression, ExpressionNode >( child->designator, desList );
     89                        designlist.push_back( new Designation( desList ) );
     90                } // for
    8291                std::list< Initializer * > initlist;
    8392                buildList< Initializer, InitializerNode >( next_init(), initlist );
    84 
    85                 std::list< Expression * > designlist;
    86 
    87                 if ( designator != 0 ) {
    88                         buildList< Expression, ExpressionNode >( designator, designlist );
    89                 } // if
    90 
    9193                return new ListInit( initlist, designlist, maybeConstructed );
    9294        } else {
    93                 std::list< Expression * > designators;
    94 
    95                 if ( designator != 0 )
    96                         buildList< Expression, ExpressionNode >( designator, designators );
    97 
    98                 if ( get_expression() != 0)
    99                         return new SingleInit( maybeBuild< Expression >( get_expression() ), designators, maybeConstructed );
     95                if ( get_expression() != 0) {
     96                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
     97                }
    10098        } // if
    101 
    10299        return 0;
    103100}
  • src/Parser/LinkageSpec.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct  2 23:16:21 2016
    13 // Update Count     : 23
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 11:51:00 2017
     13// Update Count     : 24
    1414//
    1515
     
    2828        } else if ( *spec == "\"C\"" ) {
    2929                return C;
     30        } else if ( *spec == "\"BuiltinC\"" ) {
     31                return BuiltinC;
    3032        } else {
    3133                throw SemanticError( "Invalid linkage specifier " + *spec );
     
    3638        assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
    3739        static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
    38                 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
     40                "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", "cfa built-in", "c built-in",
    3941        };
    4042        return linkageKinds[linkage];
    4143}
    4244
    43 bool LinkageSpec::isDecoratable( Spec spec ) {
     45bool LinkageSpec::isMangled( Spec spec ) {
    4446        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    4547        static bool decoratable[LinkageSpec::NoOfSpecs] = {
    46                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     48                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    4749                        true,           true,           false,  true,           false,
     50                //      Builtin,        BuiltinC,
     51                        true,           false,
    4852        };
    4953        return decoratable[spec];
     
    5357        assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    5458        static bool generatable[LinkageSpec::NoOfSpecs] = {
    55                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     59                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    5660                        true,           true,           true,   true,           false,
     61                //      Builtin,        BuiltinC,
     62                        true,           true,
    5763        };
    5864        return generatable[spec];
     
    6268        assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    6369        static bool overridable[LinkageSpec::NoOfSpecs] = {
    64                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     70                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    6571                        true,           false,          false,  true,           false,
     72                //      Builtin,        BuiltinC,
     73                        false,          false,
    6674        };
    6775        return overridable[spec];
     
    7179        assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    7280        static bool builtin[LinkageSpec::NoOfSpecs] = {
    73                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
     81                //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    7482                        true,           false,          false,  false,          true,
     83                //      Builtin,        BuiltinC,
     84                        true,           true,
    7585        };
    7686        return builtin[spec];
  • src/Parser/LinkageSpec.h

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  1 23:03:17 2016
    13 // Update Count     : 11
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 11:50:00 2017
     13// Update Count     : 12
    1414//
    1515
     
    2626                AutoGen,                                                                                // built by translator (struct assignment)
    2727                Compiler,                                                                               // gcc internal
     28                Builtin,                                                                                // mangled builtins
     29                BuiltinC,                                                                               // non-mangled builtins
    2830                NoOfSpecs
    2931        };
     
    3234        static std::string linkageName( Spec );
    3335 
    34         static bool isDecoratable( Spec );
     36        static bool isMangled( Spec );
    3537        static bool isGeneratable( Spec );
    3638        static bool isOverridable( Spec );
  • src/Parser/ParseNode.h

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:42:18 2017
    13 // Update Count     : 777
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 13:00:00 2017
     13// Update Count     : 779
    1414//
    1515
     
    6161        }
    6262
    63         virtual void print( std::ostream &os, int indent = 0 ) const {}
    64         virtual void printList( std::ostream &os, int indent = 0 ) const {}
     63        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
     64        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    6565
    6666        static int indent_by;
     
    113113        ExpressionNode * set_extension( bool exten ) { extension = exten; return this; }
    114114
    115         virtual void print( std::ostream &os, int indent = 0 ) const override {}
    116         void printOneLine( std::ostream &os, int indent = 0 ) const {}
     115        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
     116        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    117117
    118118        template<typename T>
     
    166166Expression * build_field_name_REALDECIMALconstant( const std::string & str );
    167167
    168 NameExpr * build_varref( const std::string * name, bool labelp = false );
     168NameExpr * build_varref( const std::string * name );
    169169Expression * build_typevalue( DeclarationNode * decl );
    170170
     
    274274        DeclarationNode * addIdList( DeclarationNode * list ); // old-style functions
    275275        DeclarationNode * addInitializer( InitializerNode * init );
     276        DeclarationNode * addTypeInitializer( DeclarationNode * init );
    276277
    277278        DeclarationNode * cloneType( std::string * newName );
     
    282283        }
    283284
    284         virtual void print( std::ostream &os, int indent = 0 ) const override;
    285         virtual void printList( std::ostream &os, int indent = 0 ) const override;
     285        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
     286        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
    286287
    287288        Declaration * build() const;
     
    301302                DeclarationNode::TypeClass tyClass;
    302303                DeclarationNode * assertions;
     304                DeclarationNode * initializer;
    303305        };
    304306        Variable_t variable;
     
    361363        virtual StatementNode * append_last_case( StatementNode * );
    362364
    363         virtual void print( std::ostream &os, int indent = 0 ) const override {}
    364         virtual void printList( std::ostream &os, int indent = 0 ) const override {}
     365        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
     366        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
    365367  private:
    366368        std::unique_ptr<Statement> stmt;
     
    391393Statement * build_return( ExpressionNode * ctl );
    392394Statement * build_throw( ExpressionNode * ctl );
     395Statement * build_resume( ExpressionNode * ctl );
     396Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
    393397Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt );
    394 Statement * build_catch( DeclarationNode * decl, StatementNode * stmt, bool catchAny = false );
     398Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body );
    395399Statement * build_finally( StatementNode * stmt );
    396400Statement * build_compound( StatementNode * first );
     
    411415                                result->location = cur->location;
    412416                                * out++ = result;
     417                        } else {
     418                                assertf(false, "buildList unknown type");
    413419                        } // if
    414420                } catch( SemanticError &e ) {
  • src/Parser/StatementNode.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  2 22:16:40 2017
    13 // Update Count     : 327
     12// Last Modified On : Wed Jun 28 21:08:37 2017
     13// Update Count     : 330
    1414//
    1515
     
    2121#include "SynTree/Statement.h"
    2222#include "SynTree/Expression.h"
    23 #include "parseutility.h"
     23#include "parserutility.h"
    2424#include "Common/utility.h"
    2525
     
    152152        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr );
    153153}
     154
    154155Statement *build_throw( ExpressionNode *ctl ) {
    155156        std::list< Expression * > exps;
    156157        buildMoveList( ctl, exps );
    157158        assertf( exps.size() < 2, "This means we are leaking memory");
    158         return new ReturnStmt( noLabels, !exps.empty() ? exps.back() : nullptr, true );
     159        return new ThrowStmt( noLabels, ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr );
     160}
     161
     162Statement *build_resume( ExpressionNode *ctl ) {
     163        std::list< Expression * > exps;
     164        buildMoveList( ctl, exps );
     165        assertf( exps.size() < 2, "This means we are leaking memory");
     166        return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );
     167}
     168
     169Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) {
     170        (void)ctl;
     171        (void)target;
     172        assertf( false, "resume at (non-local throw) is not yet supported," );
    159173}
    160174
    161175Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
    162         std::list< Statement * > branches;
    163         buildMoveList< Statement, StatementNode >( catch_stmt, branches );
     176        std::list< CatchStmt * > branches;
     177        buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
    164178        CompoundStmt *tryBlock = safe_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    165179        FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
    166180        return new TryStmt( noLabels, tryBlock, branches, finallyBlock );
    167181}
    168 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {
    169         std::list< Statement * > branches;
    170         buildMoveList< Statement, StatementNode >( stmt, branches );
    171         assert( branches.size() == 1 );
    172         return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny );
     182Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) {
     183        std::list< Statement * > branches;
     184        buildMoveList< Statement, StatementNode >( body, branches );
     185        assert( branches.size() == 1 );
     186        return new CatchStmt( noLabels, kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
    173187}
    174188Statement *build_finally( StatementNode *stmt ) {
  • src/Parser/TypeData.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:52:43 2017
    13 // Update Count     : 563
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:28:00 2017
     13// Update Count     : 564
    1414//
    1515
     
    630630} // buildReference
    631631
    632 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes ) {
     632AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    633633        assert( td->kind == TypeData::Aggregate );
    634634        AggregateDecl * at;
     
    638638          case DeclarationNode::Monitor:
    639639          case DeclarationNode::Thread:
    640                 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes );
     640                at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage );
    641641                buildForall( td->aggregate.params, at->get_parameters() );
    642642                break;
     
    659659} // buildAggregate
    660660
    661 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes ) {
     661ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    662662        switch ( type->kind ) {
    663663          case TypeData::Enum: {
     
    672672                  ReferenceToType * ret;
    673673                  if ( type->aggregate.body ) {
    674                           AggregateDecl * typedecl = buildAggregate( type, attributes );
     674                          AggregateDecl * typedecl = buildAggregate( type, attributes, linkage );
    675675                          switch ( type->aggregate.kind ) {
    676676                                case DeclarationNode::Struct:
     
    776776                if ( cur->has_enumeratorValue() ) {
    777777                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    778                         member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), list< Expression * >() ) );
     778                        member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) );
    779779                } // if
    780780        } // for
     
    793793TupleType * buildTuple( const TypeData * td ) {
    794794        assert( td->kind == TypeData::Tuple );
    795         TupleType * ret = new TupleType( buildQualifiers( td ) );
    796         buildTypeList( td->tuple, ret->get_types() );
     795        std::list< Type * > types;
     796        buildTypeList( td->tuple, types );
     797        TupleType * ret = new TupleType( buildQualifiers( td ), types );
    797798        buildForall( td->forall, ret->get_forall() );
    798799        return ret;
     
    818819                return decl->set_asmName( asmName );
    819820        } else if ( td->kind == TypeData::Aggregate ) {
    820                 return buildAggregate( td, attributes );
     821                return buildAggregate( td, attributes, linkage );
    821822        } else if ( td->kind == TypeData::Enum ) {
    822823                return buildEnum( td, attributes );
  • src/Parser/TypeData.h

    r9c951e3 rb1e63ac5  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:18:36 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:32:39 2017
    13 // Update Count     : 185
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:29:00 2017
     13// Update Count     : 186
    1414//
    1515
     
    103103ReferenceType * buildReference( const TypeData * );
    104104AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
    105 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes );
     105ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage );
    106106ReferenceToType * buildAggInst( const TypeData * );
    107107TypeDecl * buildVariable( const TypeData * );
  • src/Parser/TypedefTable.h

    r9c951e3 rb1e63ac5  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 18:25:04 2016
    13 // Update Count     : 28
     12// Last Modified On : Wed Jun 28 21:56:34 2017
     13// Update Count     : 33
    1414//
    1515
     
    2222#include <stack>
    2323
    24 #include "lex.h"
     24#include "parser.hh"
    2525#include "parser.h"
    2626
  • src/Parser/lex.ll

    r9c951e3 rb1e63ac5  
    55 * file "LICENCE" distributed with Cforall.
    66 *
    7  * lex.l --
     7 * lex.ll --
    88 *
    99 * Author           : Peter A. Buhr
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Mon Mar 13 08:36:17 2017
    13  * Update Count     : 506
     12 * Last Modified On : Wed Jun 28 21:03:45 2017
     13 * Update Count     : 529
    1414 */
    1515
     
    2727#include <cstdio>                                                                               // FILENAME_MAX
    2828
    29 #include "lex.h"
    30 #include "parser.h"                                                                             // YACC generated definitions based on C++ grammar
    3129#include "ParseNode.h"
    3230#include "TypedefTable.h"
     
    7775                                // numeric constants, CFA: '_' in constant
    7876hex_quad {hex}("_"?{hex}){3}
    79 integer_suffix "_"?(([uU][lL]?)|([uU]("ll"|"LL")?)|([lL][uU]?)|("ll"|"LL")[uU]?)
     77integer_suffix "_"?(([uU](("ll"|"LL"|[lL])[iI]|[iI]?("ll"|"LL"|[lL])?))|([iI](("ll"|"LL"|[lL])[uU]|[uU]?("ll"|"LL"|[lL])?))|(("ll"|"LL"|[lL])([iI][uU]|[uU]?[iI]?)))
    8078
    8179octal_digits ({octal})|({octal}({octal}|"_")*{octal})
     
    9189
    9290decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    93 real_decimal {decimal_digits}"."
    94 real_fraction "."{decimal_digits}
    95 real_constant {decimal_digits}?{real_fraction}
     91real_decimal {decimal_digits}"."{exponent}?{floating_suffix}?
     92real_fraction "."{decimal_digits}{exponent}?{floating_suffix}?
     93real_constant {decimal_digits}{real_fraction}
    9694exponent "_"?[eE]"_"?[+-]?{decimal_digits}
    97                                 // GCC: D (double), DL (long double) and iI (imaginary) suffixes
    98 floating_suffix "_"?([fFdDlL][iI]?|"DL"|[iI][lLfFdD]?)
    99                                 //floating_suffix "_"?([fFdD]|[lL]|[D][L])|([iI][lLfFdD])|([lLfFdD][iI]))
     95                                // GCC: D (double) and iI (imaginary) suffixes, and DL (long double)
     96floating_suffix "_"?([fFdDlL][iI]?|[iI][lLfFdD]?|"DL")
    10097floating_constant (({real_constant}{exponent}?)|({decimal_digits}{exponent})){floating_suffix}?
    10198
     
    236233long                    { KEYWORD_RETURN(LONG); }
    237234lvalue                  { KEYWORD_RETURN(LVALUE); }                             // CFA
    238 monitor         { KEYWORD_RETURN(MONITOR); }                    // CFA
     235monitor                 { KEYWORD_RETURN(MONITOR); }                    // CFA
    239236mutex                   { KEYWORD_RETURN(MUTEX); }                              // CFA
    240237_Noreturn               { KEYWORD_RETURN(NORETURN); }                   // C11
     
    378375"?"{op_binary_over}"?"  { IDENTIFIER_RETURN(); }                // binary
    379376        /*
    380           This rule handles ambiguous cases with operator identifiers, e.g., "int *?*?()", where the string "*?*?"
    381           can be lexed as "*"/"?*?" or "*?"/"*?". Since it is common practise to put a unary operator juxtaposed
    382           to an identifier, e.g., "*i", users will be annoyed if they cannot do this with respect to operator
    383           identifiers. Even with this special hack, there are 5 general cases that cannot be handled. The first
    384           case is for the function-call identifier "?()":
    385 
    386           int * ?()();  // declaration: space required after '*'
    387           * ?()();      // expression: space required after '*'
    388 
    389           Without the space, the string "*?()" is ambiguous without N character look ahead; it requires scanning
    390           ahead to determine if there is a '(', which is the start of an argument/parameter list.
    391 
    392           The 4 remaining cases occur in expressions:
    393 
    394           i++?i:0;              // space required before '?'
    395           i--?i:0;              // space required before '?'
    396           i?++i:0;              // space required after '?'
    397           i?--i:0;              // space required after '?'
    398 
    399           In the first two cases, the string "i++?" is ambiguous, where this string can be lexed as "i"/"++?" or
    400           "i++"/"?"; it requires scanning ahead to determine if there is a '(', which is the start of an argument
    401           list.  In the second two cases, the string "?++x" is ambiguous, where this string can be lexed as
    402           "?++"/"x" or "?"/"++x"; it requires scanning ahead to determine if there is a '(', which is the start of
    403           an argument list.
     377          This rule handles ambiguous cases with operator identifiers, e.g., "int *?*?()", where the string "*?*?"  can be
     378          lexed as "*?"/"*?" or "*"/"?*?". Since it is common practise to put a unary operator juxtaposed to an identifier,
     379          e.g., "*i", users will be annoyed if they cannot do this with respect to operator identifiers. Therefore, there is
     380          a lexical look-ahead for the second case, with backtracking to return the leading unary operator and then
     381          reparsing the trailing operator identifier.  Otherwise a space is needed between the unary operator and operator
     382          identifier to disambiguate this common case.
     383
     384          A similar issue occurs with the dereference, *?(...), and routine-call, ?()(...) identifiers.  The ambiguity
     385          occurs when the deference operator has no parameters, *?() and *?()(...), requiring arbitrary whitespace
     386          look-ahead for the routine-call parameter-list to disambiguate.  However, the dereference operator must have a
     387          parameter/argument to dereference *?(...).  Hence, always interpreting the string *?() as * ?() does not preclude
     388          any meaningful program.
     389
     390          The remaining cases are with the increment/decrement operators and conditional expression:
     391
     392          i++? ...(...);
     393          i?++ ...(...);
     394
     395          requiring arbitrary whitespace look-ahead for the operator parameter-list, even though that interpretation is an
     396      incorrect expression (juxtaposed identifiers).  Therefore, it is necessary to disambiguate these cases with a
     397      space:
     398
     399          i++ ? i : 0;
     400          i? ++i : 0;
    404401        */
    405 {op_unary}"?"({op_unary_pre_post}|"[?]"|{op_binary_over}"?") {
     402{op_unary}"?"({op_unary_pre_post}|"()"|"[?]"|{op_binary_over}"?") {
    406403        // 1 or 2 character unary operator ?
    407404        int i = yytext[1] == '?' ? 1 : 2;
  • src/Parser/module.mk

    r9c951e3 rb1e63ac5  
    1111## Created On       : Sat May 16 15:29:09 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Aug 16 17:28:34 2016
    14 ## Update Count     : 101
     13## Last Modified On : Wed Jun 28 21:58:29 2017
     14## Update Count     : 104
    1515###############################################################################
    1616
     
    2929       Parser/TypeData.cc \
    3030       Parser/LinkageSpec.cc \
    31        Parser/parseutility.cc
     31       Parser/parserutility.cc
    3232
    3333MAINTAINERCLEANFILES += Parser/parser.output
  • src/Parser/parser.hh

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // lex.h --
     7// parser.hh --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep 22 08:58:10 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 21 11:28:47 2016
    13 // Update Count     : 347
     12// Last Modified On : Wed Jun 28 22:10:17 2017
     13// Update Count     : 349
    1414//
    1515
    16 #ifndef PARSER_LEX_H
    17 #define PARSER_LEX_H
     16#ifndef PARSER_HH
     17#define PARSER_HH
    1818
    1919int yylex();
     
    4242}; // Token
    4343
    44 #endif // PARSER_LEX_H
     44#endif // PARSER_HH
    4545
    4646// Local Variables: //
  • src/Parser/parser.yy

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // cfa.y --
     7// parser.yy --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 15:42:32 2017
    13 // Update Count     : 2318
     12// Last Modified On : Wed Jun 28 22:11:22 2017
     13// Update Count     : 2414
    1414//
    1515
     
    4848#include <cstdio>
    4949#include <stack>
    50 #include "lex.h"
    51 #include "parser.h"
    5250#include "ParseNode.h"
    5351#include "TypedefTable.h"
     
    8583        } // for
    8684} // distExt
     85
     86bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    8787%}
     88
     89// Types declaration
     90%union
     91{
     92        Token tok;
     93        ParseNode * pn;
     94        ExpressionNode * en;
     95        DeclarationNode * decl;
     96        DeclarationNode::Aggregate aggKey;
     97        DeclarationNode::TypeClass tclass;
     98        StatementNode * sn;
     99        ConstantExpr * constant;
     100        ForCtl * fctl;
     101        LabelNode * label;
     102        InitializerNode * in;
     103        OperKinds op;
     104        std::string * str;
     105        bool flag;
     106}
    88107
    89108//************************* TERMINAL TOKENS ********************************
     
    138157%token ATassign                                                                                 // @=
    139158
    140 // Types declaration
    141 %union
    142 {
    143         Token tok;
    144         ParseNode * pn;
    145         ExpressionNode * en;
    146         DeclarationNode * decl;
    147         DeclarationNode::Aggregate aggKey;
    148         DeclarationNode::TypeClass tclass;
    149         StatementNode * sn;
    150         ConstantExpr * constant;
    151         ForCtl * fctl;
    152         LabelNode * label;
    153         InitializerNode * in;
    154         OperKinds op;
    155         std::string * str;
    156         bool flag;
    157 }
    158 
    159 %type<tok> identifier  no_01_identifier  no_attr_identifier zero_one
    160 %type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  no_01_identifier_or_type_name  attr_name
     159%type<tok> identifier  no_attr_identifier  zero_one
     160%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    161161%type<constant> string_literal
    162162%type<str> string_literal_list
     
    191191%type<sn> case_value_list                               case_label                                      case_label_list
    192192%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    193 %type<sn> handler_list                                  handler_clause                          finally_clause
     193%type<sn> /* handler_list */                    handler_clause                          finally_clause
    194194
    195195// declarations
     
    205205%type<en>   bit_subrange_size_opt bit_subrange_size
    206206
    207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name
     207%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
    208208
    209209%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     
    259259%type<decl> type_declarator type_declarator_name type_declaring_list
    260260
    261 %type<decl> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression
     261%type<decl> type_declaration_specifier type_type_specifier type_name typegen_name
     262%type<decl> typedef typedef_declaration typedef_expression
    262263
    263264%type<decl> variable_type_redeclarator type_ptr type_array type_function
    264265
    265266%type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function
    266 %type<decl> typegen_declaration_specifier typegen_type_specifier typegen_name
    267 
    268 %type<decl> type_name type_name_no_function
    269 %type<decl> type_parameter type_parameter_list
    270 
    271 %type<en> type_name_list
     267
     268%type<decl> type type_no_function
     269%type<decl> type_parameter type_parameter_list type_initializer_opt
     270
     271%type<en> type_list
    272272
    273273%type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list
     
    349349        IDENTIFIER
    350350        | ATTR_IDENTIFIER                                                                       // CFA
    351         | zero_one                                                                                      // CFA
    352         ;
    353 
    354 no_01_identifier:
    355         IDENTIFIER
    356         | ATTR_IDENTIFIER                                                                       // CFA
    357351        ;
    358352
    359353no_attr_identifier:
    360354        IDENTIFIER
    361         | zero_one                                                                                      // CFA
    362355        ;
    363356
     
    365358        ZERO
    366359        | ONE
    367         ;
     360        ;
    368361
    369362string_literal:
     
    393386        | '(' compound_statement ')'                                            // GCC, lambda expression
    394387                { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    395         | primary_expression '{' argument_expression_list '}' // CFA
     388        | primary_expression '{' argument_expression_list '}' // CFA, constructor call
    396389                {
    397390                        Token fn;
     
    399392                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    400393                }
     394        | type_name '.' no_attr_identifier                                      // CFA, nested type
     395                { $$ = nullptr; }                                                               // FIX ME
     396        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
     397                { $$ = nullptr; }                                                               // FIX ME
    401398        ;
    402399
     
    429426        | postfix_expression DECR
    430427                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
    431         | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
     428        | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    432429                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
    433430        | '^' primary_expression '{' argument_expression_list '}' // CFA
     
    481478        | no_attr_identifier fraction_constants
    482479                {
    483                         if( (*$1) == "0" || (*$1) == "1" ) {
    484                                 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
    485                         } else {
    486                                 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    487                         }
     480                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     481                }
     482        | zero_one fraction_constants
     483                {
     484                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
    488485                }
    489486        ;
     
    533530        | SIZEOF unary_expression
    534531                { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); }
    535         | SIZEOF '(' type_name_no_function ')'
     532        | SIZEOF '(' type_no_function ')'
    536533                { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); }
    537534        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    538535                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
    539         | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
     536        | ALIGNOF '(' type_no_function ')'                              // GCC, type alignment
    540537                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    541         | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
     538        | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
    542539                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    543540        | ATTR_IDENTIFIER
     
    545542        | ATTR_IDENTIFIER '(' argument_expression ')'
    546543                { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); }
    547         | ATTR_IDENTIFIER '(' type_name ')'
     544        | ATTR_IDENTIFIER '(' type ')'
    548545                { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); }
    549546//      | ANDAND IDENTIFIER                                                                     // GCC, address of label
    550 //              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); }
     547//              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); }
    551548        ;
    552549
     
    567564cast_expression:
    568565        unary_expression
    569         | '(' type_name_no_function ')' cast_expression
     566        | '(' type_no_function ')' cast_expression
    570567                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    571 //      | '(' type_name_no_function ')' tuple
     568//      | '(' type_no_function ')' tuple
    572569//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    573570        ;
     
    656653        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    657654                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
    658 //      | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    659 //              { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    660655        ;
    661656
     
    669664        | unary_expression assignment_operator assignment_expression
    670665                { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
    671 //      | tuple assignment_opt                                                          // CFA, tuple expression
    672 //              { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
    673666        ;
    674667
     
    936929                { $$ = new StatementNode( build_throw( $2 ) ); }
    937930        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
    938                 { $$ = new StatementNode( build_throw( $2 ) ); }
     931                { $$ = new StatementNode( build_resume( $2 ) ); }
    939932        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    940                 { $$ = new StatementNode( build_throw( $2 ) ); }
     933                { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
    941934        ;
    942935
    943936exception_statement:
    944         TRY compound_statement handler_list
     937        TRY compound_statement handler_clause
    945938                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    946939        | TRY compound_statement finally_clause
    947940                { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
    948         | TRY compound_statement handler_list finally_clause
     941        | TRY compound_statement handler_clause finally_clause
    949942                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
    950943        ;
    951944
    952 handler_list:
    953         handler_clause
    954                 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    955         | CATCH '(' ELLIPSIS ')' compound_statement
    956                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    957         | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    958                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    959         | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    960                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    961         | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    962                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    963         ;
     945//handler_list:
     946//      handler_clause
     947//              // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
     948//      | CATCH '(' ELLIPSIS ')' compound_statement
     949//              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     950//      | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
     951//              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     952//      | CATCHRESUME '(' ELLIPSIS ')' compound_statement
     953//              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     954//      | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
     955//              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     956//      ;
    964957
    965958handler_clause:
    966         CATCH '(' push push exception_declaration pop ')' compound_statement pop
    967                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     959        // TEMPORARY, TEST EXCEPTIONS
     960        CATCH '(' push push INTEGERconstant pop ')' compound_statement pop
     961                { $$ = new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
     962        | handler_clause CATCH '(' push push INTEGERconstant pop ')' compound_statement pop
     963                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
     964
     965        | CATCH '(' push push exception_declaration pop ')' compound_statement pop
     966                { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); }
    968967        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    969                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     968                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); }
    970969        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    971                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     970                { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); }
    972971        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    973                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     972                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); }
    974973        ;
    975974
     
    13501349        basic_declaration_specifier
    13511350        | sue_declaration_specifier
    1352         | typedef_declaration_specifier
    1353         | typegen_declaration_specifier
     1351        | type_declaration_specifier
    13541352        ;
    13551353
     
    13621360        basic_declaration_specifier
    13631361        | sue_declaration_specifier_nobody
    1364         | typedef_declaration_specifier
    1365         | typegen_declaration_specifier
     1362        | type_declaration_specifier
    13661363        ;
    13671364
     
    13691366        basic_type_specifier
    13701367        | sue_type_specifier
    1371         | typedef_type_specifier
    1372         | typegen_type_specifier
     1368        | type_type_specifier
    13731369        ;
    13741370
     
    13811377        basic_type_specifier
    13821378        | sue_type_specifier_nobody
    1383         | typedef_type_specifier
    1384         | typegen_type_specifier
     1379        | type_type_specifier
    13851380        ;
    13861381
     
    15171512
    15181513basic_type_specifier:
    1519         direct_type_name
    1520         | type_qualifier_list_opt indirect_type_name type_qualifier_list_opt
     1514        direct_type
     1515        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    15211516                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
    15221517        ;
    15231518
    1524 direct_type_name:
     1519direct_type:
    15251520                // A semantic check is necessary for conflicting type qualifiers.
    15261521        basic_type_name
    15271522        | type_qualifier_list basic_type_name
    15281523                { $$ = $2->addQualifiers( $1 ); }
    1529         | direct_type_name type_qualifier
     1524        | direct_type type_qualifier
    15301525                { $$ = $1->addQualifiers( $2 ); }
    1531         | direct_type_name basic_type_name
     1526        | direct_type basic_type_name
    15321527                { $$ = $1->addType( $2 ); }
    15331528        ;
    15341529
    1535 indirect_type_name:
    1536         TYPEOF '(' type_name ')'                                                        // GCC: typeof(x) y;
     1530indirect_type:
     1531        TYPEOF '(' type ')'                                                                     // GCC: typeof(x) y;
    15371532                { $$ = $3; }
    15381533        | TYPEOF '(' comma_expression ')'                                       // GCC: typeof(a+b) y;
    15391534                { $$ = DeclarationNode::newTypeof( $3 ); }
    1540         | ATTR_TYPEGENname '(' type_name ')'                            // CFA: e.g., @type(x) y;
     1535        | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type(x) y;
    15411536                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    15421537        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
     
    15561551sue_type_specifier:                                                                             // struct, union, enum + type specifier
    15571552        elaborated_type
    1558         | type_qualifier_list elaborated_type
    1559                 { $$ = $2->addQualifiers( $1 ); }
     1553        | type_qualifier_list
     1554                { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type
     1555          elaborated_type
     1556                { $$ = $3->addQualifiers( $1 ); }
    15601557        | sue_type_specifier type_qualifier
    15611558                { $$ = $1->addQualifiers( $2 ); }
     
    15801577        ;
    15811578
    1582 typedef_declaration_specifier:
    1583         typedef_type_specifier
    1584         | declaration_qualifier_list typedef_type_specifier
     1579type_declaration_specifier:
     1580        type_type_specifier
     1581        | declaration_qualifier_list type_type_specifier
    15851582                { $$ = $2->addQualifiers( $1 ); }
    1586         | typedef_declaration_specifier storage_class           // remaining OBSOLESCENT (see 2)
     1583        | type_declaration_specifier storage_class                      // remaining OBSOLESCENT (see 2)
    15871584                { $$ = $1->addQualifiers( $2 ); }
    1588         | typedef_declaration_specifier storage_class type_qualifier_list
     1585        | type_declaration_specifier storage_class type_qualifier_list
    15891586                { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }
    15901587        ;
    15911588
    1592 typedef_type_specifier:                                                                 // typedef types
     1589type_type_specifier:                                                                    // typedef types
     1590        type_name
     1591        | type_qualifier_list type_name
     1592                { $$ = $2->addQualifiers( $1 ); }
     1593        | type_type_specifier type_qualifier
     1594                { $$ = $1->addQualifiers( $2 ); }
     1595        ;
     1596
     1597type_name:
    15931598        TYPEDEFname
    15941599                { $$ = DeclarationNode::newFromTypedef( $1 ); }
    1595         | type_qualifier_list TYPEDEFname
    1596                 { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); }
    1597         | typedef_type_specifier type_qualifier
    1598                 { $$ = $1->addQualifiers( $2 ); }
     1600        | '.' TYPEDEFname
     1601                { $$ = DeclarationNode::newFromTypedef( $2 ); } // FIX ME
     1602        | type_name '.' TYPEDEFname
     1603                { $$ = DeclarationNode::newFromTypedef( $3 ); } // FIX ME
     1604        | typegen_name
     1605        | '.' typegen_name
     1606                { $$ = $2; }                                                                    // FIX ME
     1607        | type_name '.' typegen_name
     1608                { $$ = $3; }                                                                    // FIX ME
     1609        ;
     1610
     1611typegen_name:                                                                                   // CFA
     1612        TYPEGENname '(' ')'
     1613                { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
     1614        | TYPEGENname '(' type_list ')'
     1615                { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
    15991616        ;
    16001617
     
    16131630                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }
    16141631        | aggregate_key attribute_list_opt no_attr_identifier_or_type_name
    1615                 { typedefTable.makeTypedef( *$3 ); }
     1632                {
     1633                        typedefTable.makeTypedef( *$3 );                        // create typedef
     1634                        if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update
     1635                        forall = false;                                                         // reset
     1636                }
    16161637          '{' field_declaration_list '}'
    16171638                { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); }
    1618         | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA
     1639        | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list '}' // CFA
    16191640                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }
    16201641        | aggregate_type_nobody
     
    16221643
    16231644aggregate_type_nobody:                                                                  // struct, union - {...}
    1624         aggregate_key attribute_list_opt no_attr_identifier_or_type_name
     1645        aggregate_key attribute_list_opt no_attr_identifier
    16251646                {
    16261647                        typedefTable.makeTypedef( *$3 );
    16271648                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    16281649                }
    1629         | aggregate_key attribute_list_opt typegen_name         // CFA, S/R conflict
     1650        | aggregate_key attribute_list_opt TYPEDEFname
     1651                {
     1652                        typedefTable.makeTypedef( *$3 );
     1653                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     1654                }
     1655        | aggregate_key attribute_list_opt typegen_name         // CFA
    16301656                { $$ = $3->addQualifiers( $2 ); }
    16311657        ;
     
    18651891        ;
    18661892
    1867 no_01_identifier_or_type_name:
    1868         no_01_identifier
    1869         | TYPEDEFname
    1870         | TYPEGENname
    1871         ;
    1872 
    18731893no_attr_identifier_or_type_name:
    18741894        no_attr_identifier
     
    18771897        ;
    18781898
    1879 type_name_no_function:                                                                  // sizeof, alignof, cast (constructor)
     1899type_no_function:                                                                               // sizeof, alignof, cast (constructor)
    18801900        cfa_abstract_declarator_tuple                                           // CFA
    18811901        | type_specifier
     
    18841904        ;
    18851905
    1886 type_name:                                                                                              // typeof, assertion
    1887         type_name_no_function
     1906type:                                                                                                   // typeof, assertion
     1907        type_no_function
    18881908        | cfa_abstract_function                                                         // CFA
    18891909        ;
     
    19251945designation:
    19261946        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    1927         | no_attr_identifier_or_type_name ':'                           // GCC, field name
     1947        | no_attr_identifier ':'                                                        // GCC, field name
    19281948                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    19291949        ;
     
    19371957
    19381958designator:
    1939         '.' no_attr_identifier_or_type_name                                     // C99, field name
     1959        '.' no_attr_identifier                                                          // C99, field name
    19401960                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    19411961        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    19681988//     on type arguments of polymorphic functions.
    19691989
    1970 typegen_declaration_specifier:                                                  // CFA
    1971         typegen_type_specifier
    1972         | declaration_qualifier_list typegen_type_specifier
    1973                 { $$ = $2->addQualifiers( $1 ); }
    1974         | typegen_declaration_specifier storage_class           // remaining OBSOLESCENT (see 2)
    1975                 { $$ = $1->addQualifiers( $2 ); }
    1976         | typegen_declaration_specifier storage_class type_qualifier_list
    1977                 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }
    1978         ;
    1979 
    1980 typegen_type_specifier:                                                                 // CFA
    1981         typegen_name
    1982         | type_qualifier_list typegen_name
    1983                 { $$ = $2->addQualifiers( $1 ); }
    1984         | typegen_type_specifier type_qualifier
    1985                 { $$ = $1->addQualifiers( $2 ); }
    1986         ;
    1987 
    1988 typegen_name:                                                                                   // CFA
    1989         TYPEGENname '(' type_name_list ')'
    1990                 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
    1991         ;
    1992 
    19931990type_parameter_list:                                                                    // CFA
    1994         type_parameter assignment_opt
    1995         | type_parameter_list ',' type_parameter assignment_opt
     1991        type_parameter
     1992                { $$ = $1; }
     1993        | type_parameter_list ',' type_parameter
    19961994                { $$ = $1->appendList( $3 ); }
     1995        ;
     1996
     1997type_initializer_opt:                                                                   // CFA
     1998        // empty
     1999                { $$ = nullptr; }
     2000        | '=' type
     2001                { $$ = $2; }
    19972002        ;
    19982003
     
    20002005        type_class no_attr_identifier_or_type_name
    20012006                { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); }
    2002           assertion_list_opt
    2003                 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); }
     2007          type_initializer_opt assertion_list_opt
     2008                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    20042009        | type_specifier identifier_parameter_declarator
    20052010        ;
     
    20242029
    20252030assertion:                                                                                              // CFA
    2026         '|' no_attr_identifier_or_type_name '(' type_name_list ')'
     2031        '|' no_attr_identifier_or_type_name '(' type_list ')'
    20272032                {
    20282033                        typedefTable.openTrait( *$2 );
     
    20312036        | '|' '{' push trait_declaration_list '}'
    20322037                { $$ = $4; }
    2033         | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
     2038        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'
    20342039                { $$ = nullptr; }
    20352040        ;
    20362041
    2037 type_name_list:                                                                                 // CFA
    2038         type_name
     2042type_list:                                                                                              // CFA
     2043        type
    20392044                { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
    20402045        | assignment_expression
    2041         | type_name_list ',' type_name
     2046        | type_list ',' type
    20422047                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
    2043         | type_name_list ',' assignment_expression
     2048        | type_list ',' assignment_expression
    20442049                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    20452050        ;
     
    20572062        type_declarator_name assertion_list_opt
    20582063                { $$ = $1->addAssertions( $2 ); }
    2059         | type_declarator_name assertion_list_opt '=' type_name
     2064        | type_declarator_name assertion_list_opt '=' type
    20602065                { $$ = $1->addAssertions( $2 )->addType( $4 ); }
    20612066        ;
     
    20672072                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    20682073                }
    2069         | no_01_identifier_or_type_name '(' push type_parameter_list pop ')'
     2074        | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')'
    20702075                {
    20712076                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TG );
     
    20932098        ;
    20942099
    2095 trait_declaration_list:                                                         // CFA
     2100trait_declaration_list:                                                                 // CFA
    20962101        trait_declaration
    20972102        | trait_declaration_list push trait_declaration
     
    20992104        ;
    21002105
    2101 trait_declaration:                                                                      // CFA
     2106trait_declaration:                                                                              // CFA
    21022107        cfa_trait_declaring_list pop ';'
    21032108        | trait_declaring_list pop ';'
  • src/Parser/parserutility.cc

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // parseutility.cc --
     7// parserutility.cc --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:30:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 14 23:45:03 2016
    13 // Update Count     : 3
     12// Last Modified On : Wed Jun 28 22:11:32 2017
     13// Update Count     : 7
    1414//
    1515
    16 #include "parseutility.h"
     16#include "parserutility.h"
    1717#include "SynTree/Type.h"
    1818#include "SynTree/Expression.h"
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/Parser/parserutility.h

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // parseutility.h --
     7// parserutility.h --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:31:46 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 15:32:58 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Jun 28 22:11:40 2017
     13// Update Count     : 3
    1414//
    1515
  • src/ResolvExpr/AlternativeFinder.cc

    r9c951e3 rb1e63ac5  
    9797                /// Prunes a list of alternatives down to those that have the minimum conversion cost for a given return type; skips ambiguous interpretations
    9898                template< typename InputIterator, typename OutputIterator >
    99                 void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out, const SymTab::Indexer &indexer ) {
     99                void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out ) {
    100100                        // select the alternatives that have the minimum conversion cost for a particular set of result types
    101101                        std::map< std::string, PruneStruct > selected;
     
    183183                        )
    184184                        AltList::iterator oldBegin = alternatives.begin();
    185                         pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer );
     185                        pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) );
    186186                        if ( alternatives.begin() == oldBegin ) {
    187187                                std::ostringstream stream;
     
    604604//          )
    605605                SymTab::Indexer decls( indexer );
    606                 PRINT(
    607                         std::cerr << "============= original indexer" << std::endl;
    608                         indexer.print( std::cerr );
    609                         std::cerr << "============= new indexer" << std::endl;
    610                         decls.print( std::cerr );
    611                 )
     606                // PRINT(
     607                //      std::cerr << "============= original indexer" << std::endl;
     608                //      indexer.print( std::cerr );
     609                //      std::cerr << "============= new indexer" << std::endl;
     610                //      decls.print( std::cerr );
     611                // )
    612612                addToIndexer( have, decls );
    613613                AssertionSet newNeed;
     
    627627                TypeEnvironment resultEnv;
    628628                makeUnifiableVars( funcType, openVars, resultNeed );
     629                resultEnv.add( funcType->get_forall() ); // add all type variables as open variables now so that those not used in the parameter list are still considered open
    629630                AltList instantiatedActuals; // filled by instantiate function
    630631                if ( targetType && ! targetType->isVoid() && ! funcType->get_returnVals().empty() ) {
     
    808809        }
    809810
     811        Expression * restructureCast( Expression * argExpr, Type * toType ) {
     812                if ( argExpr->get_result()->size() > 1 && ! toType->isVoid() ) {
     813                        // Argument expression is a tuple and the target type is not void. Cast each member of the tuple
     814                        // to its corresponding target type, producing the tuple of those cast expressions. If there are
     815                        // more components of the tuple than components in the target type, then excess components do not
     816                        // come out in the result expression (but UniqueExprs ensure that side effects will still be done).
     817                        if ( Tuples::maybeImpure( argExpr ) && ! dynamic_cast< UniqueExpr * >( argExpr ) ) {
     818                                // expressions which may contain side effects require a single unique instance of the expression.
     819                                argExpr = new UniqueExpr( argExpr );
     820                        }
     821                        std::list< Expression * > componentExprs;
     822                        for ( unsigned int i = 0; i < toType->size(); i++ ) {
     823                                // cast each component
     824                                TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i );
     825                                componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) );
     826                        }
     827                        delete argExpr;
     828                        assert( componentExprs.size() > 0 );
     829                        // produce the tuple of casts
     830                        return new TupleExpr( componentExprs );
     831                } else {
     832                        // handle normally
     833                        return new CastExpr( argExpr, toType->clone() );
     834                }
     835        }
     836
    810837        void AlternativeFinder::visit( CastExpr *castExpr ) {
    811838                Type *& toType = castExpr->get_result();
     
    839866                                thisCost += Cost( 0, 0, discardedValues );
    840867
    841                                 Expression * argExpr = i->expr->clone();
    842                                 if ( argExpr->get_result()->size() > 1 && ! castExpr->get_result()->isVoid() ) {
    843                                         // Argument expression is a tuple and the target type is not void. Cast each member of the tuple
    844                                         // to its corresponding target type, producing the tuple of those cast expressions. If there are
    845                                         // more components of the tuple than components in the target type, then excess components do not
    846                                         // come out in the result expression (but UniqueExprs ensure that side effects will still be done).
    847                                         if ( Tuples::maybeImpure( argExpr ) && ! dynamic_cast< UniqueExpr * >( argExpr ) ) {
    848                                                 // expressions which may contain side effects require a single unique instance of the expression.
    849                                                 argExpr = new UniqueExpr( argExpr );
    850                                         }
    851                                         std::list< Expression * > componentExprs;
    852                                         for ( unsigned int i = 0; i < castExpr->get_result()->size(); i++ ) {
    853                                                 // cast each component
    854                                                 TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i );
    855                                                 componentExprs.push_back( new CastExpr( idx, castExpr->get_result()->getComponent( i )->clone() ) );
    856                                         }
    857                                         delete argExpr;
    858                                         assert( componentExprs.size() > 0 );
    859                                         // produce the tuple of casts
    860                                         candidates.push_back( Alternative( new TupleExpr( componentExprs ), i->env, i->cost, thisCost ) );
    861                                 } else {
    862                                         // handle normally
    863                                         candidates.push_back( Alternative( new CastExpr( argExpr->clone(), toType->clone() ), i->env, i->cost, thisCost ) );
    864                                 }
     868                                candidates.push_back( Alternative( restructureCast( i->expr->clone(), toType ), i->env, i->cost, thisCost ) );
    865869                        } // if
    866870                } // for
     
    11811185        }
    11821186
     1187        void AlternativeFinder::visit( UntypedInitExpr *initExpr ) {
     1188                // handle each option like a cast
     1189                AltList candidates;
     1190                PRINT( std::cerr << "untyped init expr: " << initExpr << std::endl; )
     1191                // O(N^2) checks of d-types with e-types
     1192                for ( InitAlternative & initAlt : initExpr->get_initAlts() ) {
     1193                        Type * toType = resolveTypeof( initAlt.type, indexer );
     1194                        SymTab::validateType( toType, &indexer );
     1195                        adjustExprType( toType, env, indexer );
     1196                        // Ideally the call to findWithAdjustment could be moved out of the loop, but unfortunately it currently has to occur inside or else
     1197                        // polymorphic return types are not properly bound to the initialization type, since return type variables are only open for the duration of resolving
     1198                        // the UntypedExpr. This is only actually an issue in initialization contexts that allow more than one possible initialization type, but it is still suboptimal.
     1199                        AlternativeFinder finder( indexer, env );
     1200                        finder.targetType = toType;
     1201                        finder.findWithAdjustment( initExpr->get_expr() );
     1202                        for ( Alternative & alt : finder.get_alternatives() ) {
     1203                                TypeEnvironment newEnv( alt.env );
     1204                                AssertionSet needAssertions, haveAssertions;
     1205                                OpenVarSet openVars;  // find things in env that don't have a "representative type" and claim those are open vars?
     1206                                PRINT( std::cerr << "  @ " << toType << " " << initAlt.designation << std::endl; )
     1207                                // It's possible that a cast can throw away some values in a multiply-valued expression.  (An example is a
     1208                                // cast-to-void, which casts from one value to zero.)  Figure out the prefix of the subexpression results
     1209                                // that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
     1210                                // to.
     1211                                int discardedValues = alt.expr->get_result()->size() - toType->size();
     1212                                if ( discardedValues < 0 ) continue;
     1213                                // xxx - may need to go into tuple types and extract relevant types and use unifyList. Note that currently, this does not
     1214                                // allow casting a tuple to an atomic type (e.g. (int)([1, 2, 3]))
     1215                                // unification run for side-effects
     1216                                unify( toType, alt.expr->get_result(), newEnv, needAssertions, haveAssertions, openVars, indexer ); // xxx - do some inspecting on this line... why isn't result bound to initAlt.type??
     1217
     1218                                Cost thisCost = castCost( alt.expr->get_result(), toType, indexer, newEnv );
     1219                                if ( thisCost != Cost::infinity ) {
     1220                                        // count one safe conversion for each value that is thrown away
     1221                                        thisCost += Cost( 0, 0, discardedValues );
     1222                                        candidates.push_back( Alternative( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ) );
     1223                                }
     1224                        }
     1225                }
     1226
     1227                // findMinCost selects the alternatives with the lowest "cost" members, but has the side effect of copying the
     1228                // cvtCost member to the cost member (since the old cost is now irrelevant).  Thus, calling findMinCost twice
     1229                // selects first based on argument cost, then on conversion cost.
     1230                AltList minArgCost;
     1231                findMinCost( candidates.begin(), candidates.end(), std::back_inserter( minArgCost ) );
     1232                findMinCost( minArgCost.begin(), minArgCost.end(), std::back_inserter( alternatives ) );
     1233        }
    11831234} // namespace ResolvExpr
    11841235
  • src/ResolvExpr/AlternativeFinder.h

    r9c951e3 rb1e63ac5  
    7373                virtual void visit( UniqueExpr *unqExpr );
    7474                virtual void visit( StmtExpr *stmtExpr );
     75                virtual void visit( UntypedInitExpr *initExpr );
    7576                /// Runs a new alternative finder on each element in [begin, end)
    7677                /// and writes each alternative finder to out.
  • src/ResolvExpr/CastCost.cc

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CastCost.cc -- 
     7// CastCost.cc --
    88//
    99// Author           : Richard C. Bilson
     
    2626          public:
    2727                CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    28  
     28
    2929                virtual void visit( BasicType *basicType );
    3030                virtual void visit( PointerType *pointerType );
     
    3636                        NamedTypeDecl *namedType;
    3737                        if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    38                                 return castCost( src, eqvClass.type, indexer, env );
     38                                if ( eqvClass.type ) {
     39                                        return castCost( src, eqvClass.type, indexer, env );
     40                                } else {
     41                                        return Cost::infinity;
     42                                }
    3943                        } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) {
    4044                                TypeDecl *type = dynamic_cast< TypeDecl* >( namedType );
  • src/ResolvExpr/CommonType.cc

    r9c951e3 rb1e63ac5  
    4343
    4444                void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer );
    45                 template< typename RefType > void handleRefType( RefType *inst, Type *other );
    4645
    4746                Type *result;
     
    126125        }
    127126
    128         void CommonType::visit( VoidType *voidType ) {
    129         }
     127        void CommonType::visit( __attribute((unused)) VoidType *voidType ) {}
    130128
    131129        void CommonType::visit( BasicType *basicType ) {
     
    159157        void CommonType::visit( PointerType *pointerType ) {
    160158                if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) {
    161                         if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) ) {
     159                        if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base()) ) {
    162160                                getCommonWithVoidPointer( otherPointer, pointerType );
    163                         } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base(), indexer) ) {
     161                        } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base()) ) {
    164162                                getCommonWithVoidPointer( pointerType, otherPointer );
    165163                        } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst )
     
    189187        }
    190188
    191         void CommonType::visit( ArrayType *arrayType ) {
    192         }
    193 
    194         void CommonType::visit( FunctionType *functionType ) {
    195         }
    196 
    197         template< typename RefType > void CommonType::handleRefType( RefType *inst, Type *other ) {
    198         }
    199 
    200         void CommonType::visit( StructInstType *aggregateUseType ) {
    201         }
    202 
    203         void CommonType::visit( UnionInstType *aggregateUseType ) {
    204         }
     189        void CommonType::visit( __attribute((unused)) ArrayType *arrayType ) {}
     190        void CommonType::visit( __attribute((unused)) FunctionType *functionType ) {}
     191        void CommonType::visit( __attribute((unused)) StructInstType *aggregateUseType ) {}
     192        void CommonType::visit( __attribute((unused)) UnionInstType *aggregateUseType ) {}
    205193
    206194        void CommonType::visit( EnumInstType *enumInstType ) {
     
    214202        }
    215203
    216         void CommonType::visit( TraitInstType *aggregateUseType ) {
     204        void CommonType::visit( __attribute((unused)) TraitInstType *aggregateUseType ) {
    217205        }
    218206
     
    239227        }
    240228
    241         void CommonType::visit( TupleType *tupleType ) {
    242         }
    243 
    244         void CommonType::visit( VarArgsType *varArgsType ) {
    245         }
     229        void CommonType::visit( __attribute((unused)) TupleType *tupleType ) {}
     230        void CommonType::visit( __attribute((unused)) VarArgsType *varArgsType ) {}
    246231
    247232        void CommonType::visit( ZeroType *zeroType ) {
  • src/ResolvExpr/ConversionCost.cc

    r9c951e3 rb1e63ac5  
    3030///     std::cout << "type inst " << destAsTypeInst->get_name();
    3131                        if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    32                                 return conversionCost( src, eqvClass.type, indexer, env );
     32                                if ( eqvClass.type ) {
     33                                        return conversionCost( src, eqvClass.type, indexer, env );
     34                                } else {
     35                                        return Cost::infinity;
     36                                }
    3337                        } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) {
    3438///       std::cout << " found" << std::endl;
     
    145149        };
    146150
    147         void ConversionCost::visit(VoidType *voidType) {
     151        void ConversionCost::visit( __attribute((unused)) VoidType *voidType ) {
    148152                cost = Cost::infinity;
    149153        }
     
    182186        }
    183187
    184         void ConversionCost::visit(ArrayType *arrayType) {
    185         }
    186 
    187         void ConversionCost::visit(FunctionType *functionType) {
    188         }
     188        void ConversionCost::visit(__attribute((unused)) ArrayType *arrayType) {}
     189        void ConversionCost::visit(__attribute((unused)) FunctionType *functionType) {}
    189190
    190191        void ConversionCost::visit(StructInstType *inst) {
     
    204205        }
    205206
    206         void ConversionCost::visit(EnumInstType *inst) {
     207        void ConversionCost::visit( __attribute((unused)) EnumInstType *inst ) {
    207208                static Type::Qualifiers q;
    208209                static BasicType integer( q, BasicType::SignedInt );
     
    213214        }
    214215
    215         void ConversionCost::visit(TraitInstType *inst) {
     216        void ConversionCost::visit( __attribute((unused)) TraitInstType *inst) {
    216217        }
    217218
     
    235236        }
    236237
    237         void ConversionCost::visit(TupleType *tupleType) {
     238        void ConversionCost::visit( __attribute((unused)) TupleType *tupleType) {
    238239                Cost c;
    239240                if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
     
    255256        }
    256257
    257         void ConversionCost::visit(VarArgsType *varArgsType) {
     258        void ConversionCost::visit( __attribute((unused)) VarArgsType *varArgsType) {
    258259                if ( dynamic_cast< VarArgsType* >( dest ) ) {
    259260                        cost = Cost::zero;
     
    261262        }
    262263
    263         void ConversionCost::visit(ZeroType *zeroType) {
     264        void ConversionCost::visit( __attribute((unused)) ZeroType *zeroType) {
    264265                if ( dynamic_cast< ZeroType* >( dest ) ) {
    265266                        cost = Cost::zero;
     
    277278        }
    278279
    279         void ConversionCost::visit(OneType *oneType) {
     280        void ConversionCost::visit( __attribute((unused)) OneType *oneType) {
    280281                if ( dynamic_cast< OneType* >( dest ) ) {
    281282                        cost = Cost::zero;
  • src/ResolvExpr/PtrsAssignable.cc

    r9c951e3 rb1e63ac5  
    6363        }
    6464
    65         PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {
    66         }
     65        PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {}
    6766
    68         void PtrsAssignable::visit( VoidType *voidType ) {
     67        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    6968                if ( dynamic_cast< FunctionType* >( dest ) ) {
    7069                        result = 0;
     
    7473        }
    7574
    76         void PtrsAssignable::visit( BasicType *basicType ) {
    77         }
    78 
    79         void PtrsAssignable::visit( PointerType *pointerType ) {
    80         }
    81 
    82         void PtrsAssignable::visit( ArrayType *arrayType ) {
    83         }
    84 
    85         void PtrsAssignable::visit( FunctionType *functionType ) {
     75        void PtrsAssignable::visit( __attribute__((unused)) BasicType *basicType ) {}
     76        void PtrsAssignable::visit( __attribute__((unused)) PointerType *pointerType ) {}
     77        void PtrsAssignable::visit( __attribute__((unused)) ArrayType *arrayType ) {}
     78        void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {
    8679                result = -1;
    8780        }
    8881
    89         void PtrsAssignable::visit( StructInstType *inst ) {
    90                 // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    91         }
    92 
    93         void PtrsAssignable::visit( UnionInstType *inst ) {
    94                 // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    95         }
     82        void PtrsAssignable::visit(  __attribute__((unused)) StructInstType *inst ) {}
     83        void PtrsAssignable::visit(  __attribute__((unused)) UnionInstType *inst ) {}
    9684
    9785        void PtrsAssignable::visit( EnumInstType *inst ) {
     
    10391        }
    10492
    105         void PtrsAssignable::visit( TraitInstType *inst ) {
    106                 // I definitely don't think we should be doing anything here
    107         }
    108 
     93        void PtrsAssignable::visit(  __attribute__((unused)) TraitInstType *inst ) {}
    10994        void PtrsAssignable::visit( TypeInstType *inst ) {
    11095                EqvClass eqvClass;
     
    116101        }
    117102
    118         void PtrsAssignable::visit( TupleType *tupleType ) {
    119 ///  // This code doesn't belong here, but it might be useful somewhere else
    120 ///   if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
    121 ///     int ret = 0;
    122 ///     std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
    123 ///     std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin();
    124 ///     while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    125 ///       int assignResult = ptrsAssignable( *srcIt++, *destIt++ );
    126 ///       if ( assignResult == 0 ) {
    127 ///         result = assignResult;
    128 ///         return;
    129 ///       } else if ( assignResult < 0 ) {
    130 ///         ret = -1;
    131 ///       } else if ( ret > 0 ) {
    132 ///         ret += assignResult;
    133 ///       }
    134 ///     }
    135 ///     if ( srcIt == tupleType->get_types().end() && destIt == destAsTuple->get_types().end() ) {
    136 ///       result = ret;
    137 ///     } else {
    138 ///       result = 0;
    139 ///     }
    140 ///   }
    141         }
    142 
    143         void PtrsAssignable::visit( VarArgsType *varArgsType ) {
    144         }
    145 
    146         void PtrsAssignable::visit( ZeroType *zeroType ) {
    147         }
    148        
    149         void PtrsAssignable::visit( OneType *oneType ) {
    150         }
     103        void PtrsAssignable::visit(  __attribute__((unused)) TupleType *tupleType ) {}
     104        void PtrsAssignable::visit(  __attribute__((unused)) VarArgsType *varArgsType ) {}
     105        void PtrsAssignable::visit(  __attribute__((unused)) ZeroType *zeroType ) {}
     106        void PtrsAssignable::visit(  __attribute__((unused)) OneType *oneType ) {}
    151107       
    152108} // namespace ResolvExpr
  • src/ResolvExpr/PtrsCastable.cc

    r9c951e3 rb1e63ac5  
    9292        }
    9393
    94         void PtrsCastable::visit(VoidType *voidType) {
     94        void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {
    9595                result = objectCast( dest, env, indexer );
    9696        }
    9797
    98         void PtrsCastable::visit(BasicType *basicType) {
     98        void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {
    9999                result = objectCast( dest, env, indexer );
    100100        }
    101101
    102         void PtrsCastable::visit(PointerType *pointerType) {
     102        void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {
    103103                result = objectCast( dest, env, indexer );
    104104        }
    105105
    106         void PtrsCastable::visit(ArrayType *arrayType) {
     106        void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {
    107107                result = objectCast( dest, env, indexer );
    108108        }
    109109
    110         void PtrsCastable::visit(FunctionType *functionType) {
     110        void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {
    111111                // result = -1;
    112112                result = functionCast( dest, env, indexer );
    113113        }
    114114
    115         void PtrsCastable::visit(StructInstType *inst) {
     115        void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {
    116116                result = objectCast( dest, env, indexer );
    117117        }
    118118
    119         void PtrsCastable::visit(UnionInstType *inst) {
     119        void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {
    120120                result = objectCast( dest, env, indexer );
    121121        }
    122122
    123         void PtrsCastable::visit(EnumInstType *inst) {
     123        void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {
    124124                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    125125                        result = 1;
     
    135135        }
    136136
    137         void PtrsCastable::visit(TraitInstType *inst) {
    138                 // I definitely don't think we should be doing anything here
    139         }
     137        void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {}
    140138
    141139        void PtrsCastable::visit(TypeInstType *inst) {
     
    144142        }
    145143
    146         void PtrsCastable::visit(TupleType *tupleType) {
     144        void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {
    147145                result = objectCast( dest, env, indexer );
    148146        }
    149147
    150         void PtrsCastable::visit(VarArgsType *varArgsType) {
     148        void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {
    151149                result = objectCast( dest, env, indexer );
    152150        }
    153151
    154         void PtrsCastable::visit(ZeroType *zeroType) {
     152        void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {
    155153                result = objectCast( dest, env, indexer );
    156154        }
    157155
    158         void PtrsCastable::visit(OneType *oneType) {
     156        void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {
    159157                result = objectCast( dest, env, indexer );
    160158        }
  • src/ResolvExpr/Resolver.cc

    r9c951e3 rb1e63ac5  
    1414//
    1515
     16#include <iostream>
     17
     18#include "Alternative.h"
     19#include "AlternativeFinder.h"
     20#include "CurrentObject.h"
     21#include "RenameVars.h"
    1622#include "Resolver.h"
    17 #include "AlternativeFinder.h"
    18 #include "Alternative.h"
    19 #include "RenameVars.h"
    2023#include "ResolveTypeof.h"
    2124#include "typeops.h"
     25
     26#include "SynTree/Expression.h"
     27#include "SynTree/Initializer.h"
    2228#include "SynTree/Statement.h"
    2329#include "SynTree/Type.h"
    24 #include "SynTree/Expression.h"
    25 #include "SynTree/Initializer.h"
     30
     31#include "SymTab/Autogen.h"
    2632#include "SymTab/Indexer.h"
    27 #include "SymTab/Autogen.h"
     33
    2834#include "Common/utility.h"
     35
    2936#include "InitTweak/InitTweak.h"
    3037
    31 #include <iostream>
    3238using namespace std;
    3339
     
    3945                        if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) {
    4046                                functionReturn = res->functionReturn;
    41                                 initContext = res->initContext;
     47                                currentObject = res->currentObject;
    4248                                inEnumDecl = res->inEnumDecl;
    4349                        }
     
    7985
    8086                Type * functionReturn = nullptr;
    81                 Type *initContext = nullptr;
     87                CurrentObject currentObject = nullptr;
    8288                bool inEnumDecl = false;
    8389        };
     
    124130                        } // if
    125131#endif
    126                         assert( finder.get_alternatives().size() == 1 );
     132                        assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." );
    127133                        Alternative &choice = finder.get_alternatives().front();
    128134                        Expression *newExpr = choice.expr->clone();
     
    186192                // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting
    187193                // the RHS.
    188                 Type *temp = initContext;
    189                 initContext = new_type;
    190                 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
     194                ValueGuard<CurrentObject> temp( currentObject );
     195                currentObject = CurrentObject( objectDecl->get_type() );
     196                if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) {
    191197                        // enumerator initializers should not use the enum type to initialize, since
    192198                        // the enum type is still incomplete at this point. Use signed int instead.
    193                         initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
     199                        currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    194200                }
    195201                Parent::visit( objectDecl );
    196                 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
     202                if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) {
    197203                        // delete newly created signed int type
    198                         delete initContext;
    199                 }
    200                 initContext = temp;
     204                        // delete currentObject.getType();
     205                }
    201206        }
    202207
     
    315320
    316321        void Resolver::visit( SwitchStmt *switchStmt ) {
    317                 ValueGuard< Type * > oldInitContext( initContext );
     322                ValueGuard< CurrentObject > oldCurrentObject( currentObject );
    318323                Expression *newExpr;
    319324                newExpr = findIntegralExpression( switchStmt->get_condition(), *this );
     
    321326                switchStmt->set_condition( newExpr );
    322327
    323                 initContext = newExpr->get_result();
     328                currentObject = CurrentObject( newExpr->get_result() );
    324329                Parent::visit( switchStmt );
    325330        }
     
    327332        void Resolver::visit( CaseStmt *caseStmt ) {
    328333                if ( caseStmt->get_condition() ) {
    329                         assert( initContext );
    330                         CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initContext->clone() );
     334                        std::list< InitAlternative > initAlts = currentObject.getOptions();
     335                        assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." );
     336                        CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initAlts.front().type->clone() );
    331337                        Expression * newExpr = findSingleExpression( castExpr, *this );
    332338                        castExpr = safe_dynamic_cast< CastExpr * >( newExpr );
     
    370376
    371377        void Resolver::visit( SingleInit *singleInit ) {
    372                 if ( singleInit->get_value() ) {
    373                         // // find all the d's
    374                         // std::list<Expression *> &designators = singleInit->get_designators();
    375                         // std::list<Type *> types1{ initContext }, types2;
    376                         // for ( Expression * expr: designators ) {
    377                         //      cerr << expr << endl;
    378                         //      if ( NameExpr * nexpr = dynamic_cast<NameExpr *>( expr ) ) {
    379                         //              for ( Type * type: types1 ) {
    380                         //                      cerr << type << endl;
    381                         //                      ReferenceToType * fred = dynamic_cast<ReferenceToType *>(type);
    382                         //                      std::list<Declaration *> members;
    383                         //                      if ( fred ) {
    384                         //                              fred->lookup( nexpr->get_name(), members ); // concatenate identical field name
    385                         //                              for ( Declaration * mem: members ) {
    386                         //                                      if ( DeclarationWithType * dwt = dynamic_cast<DeclarationWithType *>(mem) ) {
    387                         //                                              types2.push_back( dwt->get_type() );
    388                         //                                      } // if
    389                         //                              } // for
    390                         //                      } // if
    391                         //              } // for
    392                         //              types1 = types2;
    393                         //              types2.clear();
    394                         //      } // if
    395                         // } // for
    396                         // // for ( Type * type: types1 ) {
    397                         // //   cerr << type << endl;
    398                         // // } // for
    399                        
    400                         // // O(N^2) checks of d-types with f-types
    401                         // // find the minimum cost
    402                         CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
    403                         Expression *newExpr = findSingleExpression( castExpr, *this );
    404                         delete castExpr;
    405                         singleInit->set_value( newExpr );
    406 
    407                         // check if initializing type is char[]
    408                         if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
    409                                 if ( isCharType( at->get_base() ) ) {
    410                                         // check if the resolved type is char *
    411                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    412                                                 if ( isCharType( pt->get_base() ) ) {
    413                                                         // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
    414                                                         CastExpr *ce = dynamic_cast< CastExpr * >( newExpr );
    415                                                         singleInit->set_value( ce->get_arg() );
    416                                                         ce->set_arg( NULL );
    417                                                         delete ce;
    418                                                 }
     378                // resolve initialization using the possibilities as determined by the currentObject cursor
     379                UntypedInitExpr * untyped = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() );
     380                Expression * newExpr = findSingleExpression( untyped, *this );
     381                InitExpr * initExpr = safe_dynamic_cast< InitExpr * >( newExpr );
     382
     383                // move cursor to the object that is actually initialized
     384                currentObject.setNext( initExpr->get_designation() );
     385
     386                // discard InitExpr wrapper and retain relevant pieces
     387                newExpr = initExpr->get_expr();
     388                newExpr->set_env( initExpr->get_env() );
     389                initExpr->set_expr( nullptr );
     390                initExpr->set_env( nullptr );
     391                delete initExpr;
     392
     393                // get the actual object's type (may not exactly match what comes back from the resolver due to conversions)
     394                Type * initContext = currentObject.getCurrentType();
     395
     396                // check if actual object's type is char[]
     397                if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
     398                        if ( isCharType( at->get_base() ) ) {
     399                                // check if the resolved type is char *
     400                                if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
     401                                        if ( isCharType( pt->get_base() ) ) {
     402                                                // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     403                                                CastExpr *ce = safe_dynamic_cast< CastExpr * >( newExpr );
     404                                                newExpr = ce->get_arg();
     405                                                ce->set_arg( nullptr );
     406                                                delete ce;
    419407                                        }
    420408                                }
    421409                        }
    422                 } // if
    423         }
    424 
    425         template< typename AggrInst >
    426         TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) {
    427                 assert( inst );
    428                 assert( inst->get_baseParameters() );
    429                 std::list< TypeDecl * > baseParams = *inst->get_baseParameters();
    430                 std::list< Expression * > typeSubs = inst->get_parameters();
    431                 TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() );
    432                 return subs;
    433         }
    434 
    435         ReferenceToType * isStructOrUnion( Type * type ) {
    436                 if ( StructInstType * sit = dynamic_cast< StructInstType * >( type ) ) {
    437                         return sit;
    438                 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( type ) ) {
    439                         return uit;
    440                 }
    441                 return nullptr;
    442         }
    443 
    444         void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd, TypeSubstitution sub ) {
    445                 DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl );
    446                 assert( dt );
    447                 // need to substitute for generic types, so that casts are to concrete types
    448                 initContext = dt->get_type()->clone();
    449                 sub.apply( initContext );
    450 
    451                 try {
    452                         if ( init == initEnd ) return; // stop when there are no more initializers
    453                         (*init)->accept( *this );
    454                         ++init; // made it past an initializer
    455                 } catch( SemanticError & ) {
    456                         // need to delve deeper, if you can
    457                         if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
    458                                 resolveAggrInit( type, init, initEnd );
    459                         } else {
    460                                 // member is not an aggregate type, so can't go any deeper
    461 
    462                                 // might need to rethink what is being thrown
    463                                 throw;
    464                         } // if
    465                 }
    466         }
    467 
    468         void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) {
    469                 if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) {
    470                         TypeSubstitution sub = makeGenericSubstitutuion( sit );
    471                         StructDecl * st = sit->get_baseStruct();
    472                         if(st->get_members().empty()) return;
    473                         // want to resolve each initializer to the members of the struct,
    474                         // but if there are more initializers than members we should stop
    475                         list< Declaration * >::iterator it = st->get_members().begin();
    476                         for ( ; it != st->get_members().end(); ++it) {
    477                                 resolveSingleAggrInit( *it, init, initEnd, sub );
    478                         }
    479                 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
    480                         TypeSubstitution sub = makeGenericSubstitutuion( uit );
    481                         UnionDecl * un = uit->get_baseUnion();
    482                         if(un->get_members().empty()) return;
    483                         // only resolve to the first member of a union
    484                         resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub );
    485                 } // if
     410                }
     411
     412                // set initializer expr to resolved express
     413                singleInit->set_value( newExpr );
     414
     415                // move cursor to next object in preparation for next initializer
     416                currentObject.increment();
    486417        }
    487418
    488419        void Resolver::visit( ListInit * listInit ) {
    489                 InitIterator iter = listInit->begin();
    490                 InitIterator end = listInit->end();
    491 
    492                 if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
    493                         // resolve each member to the base type of the array
    494                         for ( ; iter != end; ++iter ) {
    495                                 initContext = at->get_base();
    496                                 (*iter)->accept( *this );
    497                         } // for
    498                 } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
    499                         for ( Type * t : *tt ) {
    500                                 if ( iter == end ) break;
    501                                 initContext = t;
    502                                 (*iter++)->accept( *this );
    503                         }
    504                 } else if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
    505                         resolveAggrInit( type, iter, end );
    506                 } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
    507                         Type * base = tt->get_baseType()->get_base();
    508                         if ( base ) {
    509                                 // know the implementation type, so try using that as the initContext
    510                                 initContext = base;
    511                                 visit( listInit );
    512                         } else {
    513                                 // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
    514                                 Parent::visit( listInit );
    515                         }
    516                 } else {
    517                         assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
    518                                 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) );
    519                         // basic types are handled here
    520                         Parent::visit( listInit );
    521                 }
    522 
    523 #if 0
    524                 if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) {
    525                         std::list<Initializer *>::iterator iter( listInit->begin_initializers() );
    526                         for ( ; iter != listInit->end_initializers(); ++iter ) {
    527                                 initContext = at->get_base();
    528                                 (*iter)->accept( *this );
    529                         } // for
    530                 } else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) {
    531                         StructDecl *baseStruct = st->get_baseStruct();
    532                         std::list<Declaration *>::iterator iter1( baseStruct->get_members().begin() );
    533                         std::list<Initializer *>::iterator iter2( listInit->begin_initializers() );
    534                         for ( ; iter1 != baseStruct->get_members().end() && iter2 != listInit->end_initializers(); ++iter2 ) {
    535                                 if ( (*iter2)->get_designators().empty() ) {
    536                                         DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *iter1 );
    537                                         initContext = dt->get_type();
    538                                         (*iter2)->accept( *this );
    539                                         ++iter1;
    540                                 } else {
    541                                         StructDecl *st = baseStruct;
    542                                         iter1 = st->get_members().begin();
    543                                         std::list<Expression *>::iterator iter3( (*iter2)->get_designators().begin() );
    544                                         for ( ; iter3 != (*iter2)->get_designators().end(); ++iter3 ) {
    545                                                 NameExpr *key = dynamic_cast<NameExpr *>( *iter3 );
    546                                                 assert( key );
    547                                                 for ( ; iter1 != st->get_members().end(); ++iter1 ) {
    548                                                         if ( key->get_name() == (*iter1)->get_name() ) {
    549                                                                 (*iter1)->print( cout );
    550                                                                 cout << key->get_name() << endl;
    551                                                                 ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
    552                                                                 assert( fred );
    553                                                                 StructInstType *mary = dynamic_cast<StructInstType*>( fred->get_type() );
    554                                                                 assert( mary );
    555                                                                 st = mary->get_baseStruct();
    556                                                                 iter1 = st->get_members().begin();
    557                                                                 break;
    558                                                         } // if
    559                                                 }  // for
    560                                         } // for
    561                                         ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
    562                                         assert( fred );
    563                                         initContext = fred->get_type();
    564                                         (*listInit->begin_initializers())->accept( *this );
    565                                 } // if
    566                         } // for
    567                 } else if ( UnionInstType *st = dynamic_cast<UnionInstType*>(initContext) ) {
    568                         DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *st->get_baseUnion()->get_members().begin() );
    569                         initContext = dt->get_type();
    570                         (*listInit->begin_initializers())->accept( *this );
    571                 } // if
    572 #endif
     420                // move cursor into brace-enclosed initializer-list
     421                currentObject.enterListInit();
     422                // xxx - fix this so that the list isn't copied, iterator should be used to change current element
     423                std::list<Designation *> newDesignations;
     424                for ( auto p : group_iterate(listInit->get_designations(), listInit->get_initializers()) ) {
     425                        // iterate designations and initializers in pairs, moving the cursor to the current designated object and resolving
     426                        // the initializer against that object.
     427                        Designation * des = std::get<0>(p);
     428                        Initializer * init = std::get<1>(p);
     429                        newDesignations.push_back( currentObject.findNext( des ) );
     430                        init->accept( *this );
     431                }
     432                // set the set of 'resolved' designations and leave the brace-enclosed initializer-list
     433                listInit->get_designations() = newDesignations; // xxx - memory management
     434                currentObject.exitListInit();
     435
     436                // xxx - this part has not be folded into CurrentObject yet
     437                // } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
     438                //      Type * base = tt->get_baseType()->get_base();
     439                //      if ( base ) {
     440                //              // know the implementation type, so try using that as the initContext
     441                //              ObjectDecl tmpObj( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, base->clone(), nullptr );
     442                //              currentObject = &tmpObj;
     443                //              visit( listInit );
     444                //      } else {
     445                //              // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
     446                //              Parent::visit( listInit );
     447                //      }
     448                // } else {
    573449        }
    574450
  • src/ResolvExpr/TypeMap.h

    r9c951e3 rb1e63ac5  
    110110                        }
    111111
    112                         virtual void visit( VoidType *voidType ) {
     112                        virtual void visit( __attribute__((unused)) VoidType *voidType ) {
    113113                                findAndReplace( typeMap.voidValue );
    114114                        }
     
    138138                        }
    139139
    140                         virtual void visit( FunctionType *functionType ) {
     140                        virtual void visit( __attribute__((unused)) FunctionType *functionType ) {
    141141                                findAndReplace( typeMap.functionPointerValue );
    142142                        }
  • src/ResolvExpr/Unify.cc

    r9c951e3 rb1e63ac5  
    115115        }
    116116
    117         bool isFtype( Type *type, const SymTab::Indexer &indexer ) {
     117        bool isFtype( Type *type ) {
    118118                if ( dynamic_cast< FunctionType* >( type ) ) {
    119119                        return true;
     
    124124        }
    125125
    126         bool tyVarCompatible( const TypeDecl::Data & data, Type *type, const SymTab::Indexer &indexer ) {
     126        bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
    127127                switch ( data.kind ) {
    128128                  case TypeDecl::Any:
     
    132132                        // type must also be complete
    133133                        // xxx - should this also check that type is not a tuple type and that it's not a ttype?
    134                         return ! isFtype( type, indexer ) && (! data.isComplete || type->isComplete() );
     134                        return ! isFtype( type ) && (! data.isComplete || type->isComplete() );
    135135                  case TypeDecl::Ftype:
    136                         return isFtype( type, indexer );
     136                        return isFtype( type );
    137137                  case TypeDecl::Ttype:
    138138                        // ttype unifies with any tuple type
     
    145145                OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );
    146146                assert( tyvar != openVars.end() );
    147                 if ( ! tyVarCompatible( tyvar->second, other, indexer ) ) {
     147                if ( ! tyVarCompatible( tyvar->second, other ) ) {
    148148                        return false;
    149149                } // if
     
    345345                std::cerr << "unifyInexact type 1 is ";
    346346                type1->print( std::cerr );
    347                 std::cerr << "type 2 is ";
     347                std::cerr << " type 2 is ";
    348348                type2->print( std::cerr );
    349349                std::cerr << std::endl;
     
    389389        }
    390390
    391         void Unify::visit(VoidType *voidType) {
     391        void Unify::visit( __attribute__((unused)) VoidType *voidType) {
    392392                result = dynamic_cast< VoidType* >( type2 );
    393393        }
     
    615615                        } else if ( tupleParam ) {
    616616                                // bundle other parameters into tuple to match
    617                                 TupleType* binder = new TupleType{ paramTy->get_qualifiers() };
     617                                std::list< Type * > binderTypes;
    618618
    619619                                do {
    620                                         binder->get_types().push_back( otherParam->get_type()->clone() );
     620                                        binderTypes.push_back( otherParam->get_type()->clone() );
    621621                                        ++jt;
    622622
     
    627627                                } while (true);
    628628
    629                                 otherParamTy = binder;
     629                                otherParamTy = new TupleType{ paramTy->get_qualifiers(), binderTypes };
    630630                                ++it;  // skip ttype parameter for break
    631631                        } else if ( otherTupleParam ) {
    632632                                // bundle parameters into tuple to match other
    633                                 TupleType* binder = new TupleType{ otherParamTy->get_qualifiers() };
     633                                std::list< Type * > binderTypes;
    634634
    635635                                do {
    636                                         binder->get_types().push_back( param->get_type()->clone() );
     636                                        binderTypes.push_back( param->get_type()->clone() );
    637637                                        ++it;
    638638
     
    643643                                } while (true);
    644644
    645                                 paramTy = binder;
     645                                paramTy = new TupleType{ otherParamTy->get_qualifiers(), binderTypes };
    646646                                ++jt;  // skip ttype parameter for break
    647647                        }
     
    692692
    693693        template< typename Iterator1, typename Iterator2 >
    694         bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
     694        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
    695695                auto get_type = [](Type * t) { return t; };
    696696                for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
     
    742742                        flatten( flat2.get(), back_inserter( types2 ) );
    743743
    744                         result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, widenMode, indexer );
    745                 } // if
    746         }
    747 
    748         void Unify::visit(VarArgsType *varArgsType) {
     744                        result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer );
     745                } // if
     746        }
     747
     748        void Unify::visit( __attribute__((unused)) VarArgsType *varArgsType ) {
    749749                result = dynamic_cast< VarArgsType* >( type2 );
    750750        }
    751751
    752         void Unify::visit(ZeroType *zeroType) {
     752        void Unify::visit( __attribute__((unused)) ZeroType *zeroType ) {
    753753                result = dynamic_cast< ZeroType* >( type2 );
    754754        }
    755755
    756         void Unify::visit(OneType *oneType) {
     756        void Unify::visit( __attribute__((unused)) OneType *oneType ) {
    757757                result = dynamic_cast< OneType* >( type2 );
    758758        }
     
    765765                        return function->get_returnVals().front()->get_type()->clone();
    766766                } else {
    767                         TupleType * tupleType = new TupleType( Type::Qualifiers() );
     767                        std::list< Type * > types;
    768768                        for ( DeclarationWithType * decl : function->get_returnVals() ) {
    769                                 tupleType->get_types().push_back( decl->get_type()->clone() );
     769                                types.push_back( decl->get_type()->clone() );
    770770                        } // for
    771                         return tupleType;
     771                        return new TupleType( Type::Qualifiers(), types );
    772772                }
    773773        }
  • src/ResolvExpr/module.mk

    r9c951e3 rb1e63ac5  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    3131       ResolvExpr/PolyCost.cc \
    3232       ResolvExpr/Occurs.cc \
    33        ResolvExpr/TypeEnvironment.cc
     33       ResolvExpr/TypeEnvironment.cc \
     34       ResolvExpr/CurrentObject.cc
  • src/ResolvExpr/typeops.h

    r9c951e3 rb1e63ac5  
    118118
    119119        // in Unify.cc
    120         bool isFtype( Type *type, const SymTab::Indexer &indexer );
     120        bool isFtype( Type *type );
    121121        bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    122122        bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
     
    130130                TypeEnvironment env;
    131131                return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );
    132         }
    133 
    134         template< typename Container1, typename Container2 >
    135         bool typesCompatibleList( Container1 &c1, Container2 &c2, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    136                 typename Container1::iterator i1 = c1.begin();
    137                 typename Container2::iterator i2 = c2.begin();
    138                 for ( ; i1 != c1.end() && i2 != c2.end(); ++i1, ++i2 ) {
    139                         if ( ! typesCompatible( *i1, *i2, indexer ) ) {
    140                                 return false;
    141                         } // if
    142                 }
    143                 return ( i1 == c1.end() ) && ( i2 == c2.end() );
    144132        }
    145133
  • src/SymTab/Autogen.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Mar 03 15:45:56 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:41:08 2017
    13 // Update Count     : 60
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:30:00 2017
     13// Update Count     : 61
    1414//
    1515
     
    263263        // E ?=?(E volatile*, int),
    264264        //   ?=?(E _Atomic volatile*, int);
    265         void makeEnumFunctions( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
     265        void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
    266266
    267267                // T ?=?(E *, E);
     
    401401        /// generates struct constructors, destructor, and assignment functions
    402402        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) {
     403                // Builtins do not use autogeneration.
     404                if ( aggregateDecl->get_linkage() == LinkageSpec::Builtin ||
     405                         aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) {
     406                        return;
     407                }
     408
    403409                // Make function polymorphic in same parameters as generic struct, if applicable
    404410                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
     
    487493
    488494        /// generates the body of a union assignment/copy constructor/field constructor
    489         void makeUnionAssignBody( FunctionDecl * funcDecl, bool isDynamicLayout ) {
     495        void makeUnionAssignBody( FunctionDecl * funcDecl ) {
    490496                FunctionType * ftype = funcDecl->get_functionType();
    491497                assert( ftype->get_parameters().size() == 2 );
     
    507513                // Make function polymorphic in same parameters as generic union, if applicable
    508514                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    509                 bool isDynamicLayout = hasDynamicLayout( aggregateDecl );  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)
    510 
     515               
    511516                // default ctor/dtor need only first parameter
    512517                // void ?{}(T *); void ^?{}(T *);
     
    534539                FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting );
    535540
    536                 makeUnionAssignBody( assignDecl, isDynamicLayout );
     541                makeUnionAssignBody( assignDecl );
    537542
    538543                // body of assignment and copy ctor is the same
    539                 makeUnionAssignBody( copyCtorDecl, isDynamicLayout );
     544                makeUnionAssignBody( copyCtorDecl );
    540545
    541546                // create a constructor which takes the first member type as a parameter.
     
    552557                                FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting );
    553558
    554                                 makeUnionAssignBody( ctor, isDynamicLayout );
     559                                makeUnionAssignBody( ctor );
    555560                                memCtors.push_back( ctor );
    556561                                // only generate a ctor for the first field
     
    579584                        EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
    580585                        // enumInst->set_baseEnum( enumDecl );
    581                         makeEnumFunctions( enumDecl, enumInst, functionNesting, declsToAddAfter );
     586                        makeEnumFunctions( enumInst, functionNesting, declsToAddAfter );
    582587                }
    583588        }
  • src/SymTab/Autogen.h

    r9c951e3 rb1e63ac5  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:10:41 2017
    13 // Update Count     : 9
     12// Last Modified On : Wed Jun 21 17:25:26 2017
     13// Update Count     : 14
    1414//
    1515
     
    4343        template< typename OutputIterator >
    4444        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    45                 // want to be able to generate assignment, ctor, and dtor generically,
    46                 // so fname is either ?=?, ?{}, or ^?{}
    47                 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
     45        // want to be able to generate assignment, ctor, and dtor generically,
     46        // so fname is either ?=?, ?{}, or ^?{}
     47        UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
    4848
    49                 // do something special for unnamed members
    50                 dstParam = new AddressExpr( dstParam );
    51                 if ( addCast ) {
    52                         // cast to T* with qualifiers removed, so that qualified objects can be constructed
    53                         // and destructed with the same functions as non-qualified objects.
    54                         // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
    55                         // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
    56                         // remove lvalue as a qualifier, this can change to
    57                         //   type->get_qualifiers() = Type::Qualifiers();
    58                         assert( type );
    59                         Type * castType = type->clone();
    60 //                      castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
    61                         castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    62                         castType->set_lvalue( true ); // xxx - might not need this
    63                         dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
    64                 }
    65                 fExpr->get_args().push_back( dstParam );
     49        // do something special for unnamed members
     50        dstParam = new AddressExpr( dstParam );
     51        if ( addCast ) {
     52                // cast to T* with qualifiers removed, so that qualified objects can be constructed
     53                // and destructed with the same functions as non-qualified objects.
     54                // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
     55                // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
     56                // remove lvalue as a qualifier, this can change to
     57                //   type->get_qualifiers() = Type::Qualifiers();
     58                assert( type );
     59                Type * castType = type->clone();
     60                castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     61                castType->set_lvalue( true ); // xxx - might not need this
     62                dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
     63        }
     64        fExpr->get_args().push_back( dstParam );
    6665
    67                 Statement * listInit = srcParam.buildListInit( fExpr );
     66        Statement * listInit = srcParam.buildListInit( fExpr );
    6867
    69                 std::list< Expression * > args = *++srcParam;
    70                 fExpr->get_args().splice( fExpr->get_args().end(), args );
     68        std::list< Expression * > args = *++srcParam;
     69        fExpr->get_args().splice( fExpr->get_args().end(), args );
    7170
    72                 *out++ = new ExprStmt( noLabels, fExpr );
     71        *out++ = new ExprStmt( noLabels, fExpr );
    7372
    74                 srcParam.clearArrayIndices();
     73        srcParam.clearArrayIndices();
    7574
    76                 return listInit;
     75        return listInit;
    7776        }
    7877
     
    8887                Expression * begin, * end, * update, * cmp;
    8988                if ( forward ) {
    90                         // generate: for ( int i = 0; i < 0; ++i )
    91                         begin = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
     89                        // generate: for ( int i = 0; i < N; ++i )
     90                        begin = new ConstantExpr( Constant::from_int( 0 ) );
    9291                        end = array->get_dimension()->clone();
    9392                        cmp = new NameExpr( "?<?" );
     
    9796                        begin = new UntypedExpr( new NameExpr( "?-?" ) );
    9897                        ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
    99                         ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant( new OneType( emptyQualifiers ), "1" ) ) );
    100                         end = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
     98                        ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant::from_int( 1 ) ) );
     99                        end = new ConstantExpr( Constant::from_int( 0 ) );
    101100                        cmp = new NameExpr( "?>=?" );
    102101                        update = new NameExpr( "--?" );
    103102                }
    104103
    105                 ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
     104                ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin ) );
    106105
    107106                UntypedExpr *cond = new UntypedExpr( cmp );
  • src/SymTab/FixFunction.cc

    r9c951e3 rb1e63ac5  
    2424
    2525        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
    26                 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );
     26                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
    2727                functionDecl->get_attributes().clear();
     28                // can't delete function type because it may contain assertions, but can't transfer ownership without a clone since set_type checks for nullptr
     29                functionDecl->set_type( functionDecl->get_type()->clone() );
    2830                delete functionDecl;
    2931                return pointer;
  • src/SymTab/ImplementationType.cc

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ImplementationType.cc -- 
     7// ImplementationType.cc --
    88//
    99// Author           : Richard C. Bilson
     
    6161        }
    6262
    63         void ImplementationType::visit(VoidType *voidType) {
    64         }
    65 
    66         void ImplementationType::visit(BasicType *basicType) {
    67         }
     63        void ImplementationType::visit( __attribute__((unused)) VoidType *voidType ) {}
     64        void ImplementationType::visit( __attribute__((unused)) BasicType *basicType ) {}
    6865
    6966        void ImplementationType::visit(PointerType *pointerType) {
     
    7976        }
    8077
    81         void ImplementationType::visit(FunctionType *functionType) {
    82 ///   FunctionType *newType = functionType->clone();
    83 ///   for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
    84 ///     i->set_type( implementationType( i->get_type(), indexer ) );
    85 ///   }
    86 ///   for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
    87 ///     i->set_type( implementationType( i->get_type(), indexer ) );
    88 ///   }
    89         }
    90 
    91         void ImplementationType::visit(StructInstType *aggregateUseType) {
    92         }
    93 
    94         void ImplementationType::visit(UnionInstType *aggregateUseType) {
    95         }
    96 
    97         void ImplementationType::visit(EnumInstType *aggregateUseType) {
    98         }
    99 
    100         void ImplementationType::visit(TraitInstType *aggregateUseType) {
    101         }
     78        void ImplementationType::visit( __attribute__((unused)) FunctionType *functionType ) {}
     79        void ImplementationType::visit( __attribute__((unused)) StructInstType * aggregateUseType ) {}
     80        void ImplementationType::visit( __attribute__((unused)) UnionInstType * aggregateUseType ) {}
     81        void ImplementationType::visit( __attribute__((unused)) EnumInstType * aggregateUseType ) {}
     82        void ImplementationType::visit( __attribute__((unused)) TraitInstType * aggregateUseType ) {}
    10283
    10384        void ImplementationType::visit(TypeInstType *inst) {
     
    11192
    11293        void ImplementationType::visit(TupleType *tupleType) {
    113                 TupleType *newType = new TupleType( Type::Qualifiers() );
     94                std::list< Type * > types;
    11495                for ( std::list< Type* >::iterator i = tupleType->get_types().begin(); i != tupleType->get_types().end(); ++i ) {
    11596                        Type *implType = implementationType( *i, indexer );
    11697                        implType->get_qualifiers() |= tupleType->get_qualifiers();
    117                         newType->get_types().push_back( implType );
     98                        types.push_back( implType );
    11899                } // for
    119                 result = newType;
     100                result = new TupleType( Type::Qualifiers(), types );
    120101        }
    121102
    122         void ImplementationType::visit(VarArgsType *varArgsType) {
    123         }
    124 
    125         void ImplementationType::visit(ZeroType *zeroType) {
    126         }
    127 
    128         void ImplementationType::visit(OneType *oneType) {
    129         }
     103        void ImplementationType::visit( __attribute__((unused)) VarArgsType *varArgsType ) {}
     104        void ImplementationType::visit( __attribute__((unused)) ZeroType *zeroType ) {}
     105        void ImplementationType::visit( __attribute__((unused)) OneType *oneType ) {}
    130106} // namespace SymTab
    131107
  • src/SymTab/Indexer.cc

    r9c951e3 rb1e63ac5  
    124124                        };
    125125                        // properties for this type
    126                         bool userDefinedFunc = false; // any user-defined function found
    127                         bool userDefinedCtor = false; // any user-defined constructor found
    128                         bool userDefinedDtor = false; // any user-defined destructor found
    129                         bool userDefinedCopyFunc = false; // user-defined copy ctor found
     126                        bool existsUserDefinedFunc = false;    // any user-defined function found
     127                        bool existsUserDefinedCtor = false;    // any user-defined constructor found
     128                        bool existsUserDefinedDtor = false;    // any user-defined destructor found
     129                        bool existsUserDefinedCopyFunc = false;    // user-defined copy ctor found
     130                        bool existsUserDefinedDefaultCtor = false; // user-defined default ctor found
    130131                        std::list< DeclBall > decls;
    131132
     
    138139                                bool isCopyFunc = InitTweak::isCopyFunction( function, function->get_name() );
    139140                                decls.push_back( DeclBall{ function, isUserDefinedFunc, isDefaultCtor, isDtor, isCopyFunc } );
    140                                 userDefinedFunc = userDefinedFunc || isUserDefinedFunc;
    141                                 userDefinedCtor = userDefinedCtor || (isUserDefinedFunc && InitTweak::isConstructor( function->get_name() ) );
    142                                 userDefinedDtor = userDefinedDtor || (isUserDefinedFunc && isDtor);
    143                                 userDefinedCopyFunc = userDefinedCopyFunc || (isUserDefinedFunc && isCopyFunc);
     141                                existsUserDefinedFunc = existsUserDefinedFunc || isUserDefinedFunc;
     142                                existsUserDefinedCtor = existsUserDefinedCtor || (isUserDefinedFunc && InitTweak::isConstructor( function->get_name() ) );
     143                                existsUserDefinedDtor = existsUserDefinedDtor || (isUserDefinedFunc && isDtor);
     144                                existsUserDefinedCopyFunc = existsUserDefinedCopyFunc || (isUserDefinedFunc && isCopyFunc);
     145                                existsUserDefinedDefaultCtor = existsUserDefinedDefaultCtor || (isUserDefinedFunc && isDefaultCtor);
    144146                                return *this;
    145147                        }
     
    164166                }
    165167
    166                 // if a type contains user defined ctor/dtors, then special rules trigger, which determine
    167                 // the set of ctor/dtors that are seen by the requester. In particular, if the user defines
     168                // if a type contains user defined ctor/dtor/assign, then special rules trigger, which determine
     169                // the set of ctor/dtor/assign that are seen by the requester. In particular, if the user defines
    168170                // a default ctor, then the generated default ctor should never be seen, likewise for copy ctor
    169171                // and dtor. If the user defines any ctor/dtor, then no generated field ctors should be seen.
    170                 // If the user defines any ctor then the generated default ctor should not be seen.
     172                // If the user defines any ctor then the generated default ctor should not be seen (intrinsic default
     173                // ctor must be overridden exactly).
    171174                for ( std::pair< const std::string, ValueType > & pair : funcMap ) {
    172175                        ValueType & val = pair.second;
    173176                        for ( ValueType::DeclBall ball : val.decls ) {
    174                                 if ( ! val.userDefinedFunc || ball.isUserDefinedFunc || (! val.userDefinedCtor && ball.isDefaultCtor) || (! val.userDefinedCopyFunc && ball.isCopyFunc) || (! val.userDefinedDtor && ball.isDtor) ) {
     177                                bool noUserDefinedFunc = ! val.existsUserDefinedFunc;
     178                                bool isUserDefinedFunc = ball.isUserDefinedFunc;
     179                                bool isAcceptableDefaultCtor = (! val.existsUserDefinedCtor || (! val.existsUserDefinedDefaultCtor && ball.decl->get_linkage() == LinkageSpec::Intrinsic)) && ball.isDefaultCtor; // allow default constructors only when no user-defined constructors exist, except in the case of intrinsics, which require exact overrides
     180                                bool isAcceptableCopyFunc = ! val.existsUserDefinedCopyFunc && ball.isCopyFunc; // handles copy ctor and assignment operator
     181                                bool isAcceptableDtor = ! val.existsUserDefinedDtor && ball.isDtor;
     182                                if ( noUserDefinedFunc || isUserDefinedFunc || isAcceptableDefaultCtor || isAcceptableCopyFunc || isAcceptableDtor ) {
    175183                                        // decl conforms to the rules described above, so it should be seen by the requester
    176184                                        out.push_back( ball.decl );
     
    278286                addType( typeDecl );
    279287                acceptAll( typeDecl->get_assertions(), *this );
     288                acceptNewScope( typeDecl->get_init(), *this );
    280289        }
    281290
     
    487496        }
    488497
    489         void Indexer::visit( UntypedValofExpr *valofExpr ) {
    490                 acceptNewScope( valofExpr->get_result(), *this );
    491                 maybeAccept( valofExpr->get_body(), *this );
    492         }
    493 
    494498        void Indexer::visit( RangeExpr *rangeExpr ) {
    495499                maybeAccept( rangeExpr->get_low(), *this );
     
    510514                acceptNewScope( tupleExpr->get_result(), *this );
    511515                maybeAccept( tupleExpr->get_tuple(), *this );
    512         }
    513 
    514         void Indexer::visit( MemberTupleExpr *tupleExpr ) {
    515                 acceptNewScope( tupleExpr->get_result(), *this );
    516                 maybeAccept( tupleExpr->get_member(), *this );
    517                 maybeAccept( tupleExpr->get_aggregate(), *this );
    518516        }
    519517
  • src/SymTab/Indexer.h

    r9c951e3 rb1e63ac5  
    6969                virtual void visit( ConstructorExpr * ctorExpr );
    7070                virtual void visit( CompoundLiteralExpr *compLitExpr );
    71                 virtual void visit( UntypedValofExpr *valofExpr );
    7271                virtual void visit( RangeExpr *rangeExpr );
    7372                virtual void visit( UntypedTupleExpr *tupleExpr );
    7473                virtual void visit( TupleExpr *tupleExpr );
    7574                virtual void visit( TupleIndexExpr *tupleExpr );
    76                 virtual void visit( MemberTupleExpr *tupleExpr );
    7775                virtual void visit( TupleAssignExpr *tupleExpr );
    7876                virtual void visit( StmtExpr * stmtExpr );
  • src/SymTab/Mangler.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:40:29 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:40:01 2017
    13 // Update Count     : 20
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:31:00 2017
     13// Update Count     : 21
    1414//
    1515
     
    7272                        } else {
    7373                                // if we add another kind of overridable function, this has to change
    74                                 assert( false );
     74                                assert( false && "unknown overrideable linkage" );
    7575                        } // if
    7676                }
     
    236236        }
    237237
    238         void Mangler::visit( ZeroType *zeroType ) {
     238        void Mangler::visit( __attribute__((unused)) ZeroType *zeroType ) {
    239239                mangleName << "Z";
    240240        }
    241241
    242         void Mangler::visit( OneType *oneType ) {
     242        void Mangler::visit( __attribute__((unused)) OneType *oneType ) {
    243243                mangleName << "O";
    244244        }
  • src/SymTab/Validate.cc

    r9c951e3 rb1e63ac5  
    3838//   definition occurs later in the input.
    3939
     40#include <algorithm>
     41#include <iterator>
    4042#include <list>
    41 #include <iterator>
     43
     44#include "CodeGen/CodeGenerator.h"
     45
     46#include "Common/PassVisitor.h"
    4247#include "Common/ScopedMap.h"
     48#include "Common/UniqueName.h"
    4349#include "Common/utility.h"
    44 #include "Common/UniqueName.h"
     50
    4551#include "Concurrency/Keywords.h"
    46 #include "Validate.h"
    47 #include "SynTree/Visitor.h"
    48 #include "SynTree/Mutator.h"
    49 #include "SynTree/Type.h"
    50 #include "SynTree/Expression.h"
    51 #include "SynTree/Statement.h"
    52 #include "SynTree/TypeSubstitution.h"
    53 #include "Indexer.h"
     52
     53#include "GenPoly/DeclMutator.h"
     54
     55#include "InitTweak/InitTweak.h"
     56
     57#include "AddVisit.h"
     58#include "Autogen.h"
    5459#include "FixFunction.h"
    5560// #include "ImplementationType.h"
    56 #include "GenPoly/DeclMutator.h"
    57 #include "AddVisit.h"
     61#include "Indexer.h"
    5862#include "MakeLibCfa.h"
    5963#include "TypeEquality.h"
    60 #include "Autogen.h"
     64#include "Validate.h"
     65
    6166#include "ResolvExpr/typeops.h"
    62 #include <algorithm>
    63 #include "InitTweak/InitTweak.h"
    64 #include "CodeGen/CodeGenerator.h"
     67
     68#include "SynTree/Attribute.h"
     69#include "SynTree/Expression.h"
     70#include "SynTree/Mutator.h"
     71#include "SynTree/Statement.h"
     72#include "SynTree/Type.h"
     73#include "SynTree/TypeSubstitution.h"
     74#include "SynTree/Visitor.h"
    6575
    6676#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
     
    96106
    97107        /// Fix return types so that every function returns exactly one value
    98         class ReturnTypeFixer final : public Visitor {
    99           public:
    100                 typedef Visitor Parent;
    101                 using Parent::visit;
    102 
     108        struct ReturnTypeFixer {
    103109                static void fix( std::list< Declaration * > &translationUnit );
    104110
    105                 virtual void visit( FunctionDecl * functionDecl );
    106                 virtual void visit( FunctionType * ftype );
     111                void postvisit( FunctionDecl * functionDecl );
     112                void postvisit( FunctionType * ftype );
    107113        };
    108114
    109115        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    110         class EnumAndPointerDecayPass final : public Visitor {
    111                 typedef Visitor Parent;
    112                 virtual void visit( EnumDecl *aggregateDecl );
    113                 virtual void visit( FunctionType *func );
     116        struct EnumAndPointerDecay {
     117                void previsit( EnumDecl *aggregateDecl );
     118                void previsit( FunctionType *func );
    114119        };
    115120
     
    119124          public:
    120125                LinkReferenceToTypes( bool doDebug, const Indexer *indexer );
    121           private:
    122126                using Parent::visit;
    123127                void visit( EnumInstType *enumInst ) final;
     
    129133                void visit( UnionDecl *unionDecl ) final;
    130134                void visit( TypeInstType *typeInst ) final;
    131 
     135          private:
    132136                const Indexer *indexer;
    133137
     
    140144        };
    141145
    142         /// Replaces array and function types in forall lists by appropriate pointer type
    143         class Pass3 final : public Indexer {
     146        /// Replaces array and function types in forall lists by appropriate pointer type and assigns each Object and Function declaration a unique ID.
     147        class ForallPointerDecay final : public Indexer {
    144148                typedef Indexer Parent;
    145149          public:
    146150                using Parent::visit;
    147                 Pass3( const Indexer *indexer );
    148           private:
     151                ForallPointerDecay( const Indexer *indexer );
     152
    149153                virtual void visit( ObjectDecl *object ) override;
    150154                virtual void visit( FunctionDecl *func ) override;
     
    153157        };
    154158
    155         class ReturnChecker : public Visitor {
    156           public:
     159        struct ReturnChecker : public WithGuards {
    157160                /// Checks that return statements return nothing if their return type is void
    158161                /// and return something if the return type is non-void.
    159162                static void checkFunctionReturns( std::list< Declaration * > & translationUnit );
    160           private:
    161                 virtual void visit( FunctionDecl * functionDecl );
    162                 virtual void visit( ReturnStmt * returnStmt );
    163 
    164                 std::list< DeclarationWithType * > returnVals;
     163
     164                void previsit( FunctionDecl * functionDecl );
     165                void previsit( ReturnStmt * returnStmt );
     166
     167                typedef std::list< DeclarationWithType * > ReturnVals;
     168                ReturnVals returnVals;
    165169        };
    166170
     
    198202        };
    199203
    200         class VerifyCtorDtorAssign : public Visitor {
    201         public:
     204        struct VerifyCtorDtorAssign {
    202205                /// ensure that constructors, destructors, and assignment have at least one
    203206                /// parameter, the first of which must be a pointer, and that ctor/dtors have no
     
    205208                static void verify( std::list< Declaration * > &translationUnit );
    206209
    207                 virtual void visit( FunctionDecl *funcDecl );
    208         };
    209 
    210         class ArrayLength : public Visitor {
    211         public:
     210                void previsit( FunctionDecl *funcDecl );
     211        };
     212
     213        /// ensure that generic types have the correct number of type arguments
     214        struct ValidateGenericParameters {
     215                void previsit( StructInstType * inst );
     216                void previsit( UnionInstType * inst );
     217        };
     218
     219        struct ArrayLength {
    212220                /// for array types without an explicit length, compute the length and store it so that it
    213221                /// is known to the rest of the phases. For example,
     
    219227                static void computeLength( std::list< Declaration * > & translationUnit );
    220228
    221                 virtual void visit( ObjectDecl * objDecl );
    222         };
    223 
    224         class CompoundLiteral final : public GenPoly::DeclMutator {
     229                void previsit( ObjectDecl * objDecl );
     230        };
     231
     232        struct CompoundLiteral final : public WithDeclsToAdd, public WithVisitorRef<CompoundLiteral> {
    225233                Type::StorageClasses storageClasses;
    226234
    227                 using GenPoly::DeclMutator::mutate;
    228                 DeclarationWithType * mutate( ObjectDecl *objectDecl ) final;
    229                 Expression *mutate( CompoundLiteralExpr *compLitExpr ) final;
     235                void premutate( ObjectDecl *objectDecl );
     236                Expression * postmutate( CompoundLiteralExpr *compLitExpr );
    230237        };
    231238
    232239        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    233                 EnumAndPointerDecayPass epc;
     240                PassVisitor<EnumAndPointerDecay> epc;
    234241                LinkReferenceToTypes lrt( doDebug, 0 );
    235                 Pass3 pass3( 0 );
    236                 CompoundLiteral compoundliteral;
    237 
    238                 HoistStruct::hoistStruct( translationUnit );
     242                ForallPointerDecay fpd( 0 );
     243                PassVisitor<CompoundLiteral> compoundliteral;
     244                PassVisitor<ValidateGenericParameters> genericParams;
     245
    239246                EliminateTypedef::eliminateTypedef( translationUnit );
     247                HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order
    240248                ReturnTypeFixer::fix( translationUnit ); // must happen before autogen
    241249                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
     250                acceptAll( translationUnit, genericParams );  // check as early as possible - can't happen before LinkReferenceToTypes
    242251                acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist
    243252                VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    244253                Concurrency::applyKeywords( translationUnit );
    245                 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass
     254                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay
    246255                Concurrency::implementMutexFuncs( translationUnit );
    247256                Concurrency::implementThreadStarter( translationUnit );
    248257                ReturnChecker::checkFunctionReturns( translationUnit );
    249                 compoundliteral.mutateDeclarationList( translationUnit );
    250                 acceptAll( translationUnit, pass3 );
     258                mutateAll( translationUnit, compoundliteral );
     259                acceptAll( translationUnit, fpd );
    251260                ArrayLength::computeLength( translationUnit );
    252261        }
    253262
    254263        void validateType( Type *type, const Indexer *indexer ) {
    255                 EnumAndPointerDecayPass epc;
     264                PassVisitor<EnumAndPointerDecay> epc;
    256265                LinkReferenceToTypes lrt( false, indexer );
    257                 Pass3 pass3( indexer );
     266                ForallPointerDecay fpd( indexer );
    258267                type->accept( epc );
    259268                type->accept( lrt );
    260                 type->accept( pass3 );
     269                type->accept( fpd );
    261270        }
    262271
     
    337346        }
    338347
    339         void EnumAndPointerDecayPass::visit( EnumDecl *enumDecl ) {
     348        void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) {
    340349                // Set the type of each member of the enumeration to be EnumConstant
    341350                for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
     
    344353                        obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) );
    345354                } // for
    346                 Parent::visit( enumDecl );
    347355        }
    348356
     
    351359                void fixFunctionList( DWTList & dwts, FunctionType * func ) {
    352360                        // the only case in which "void" is valid is where it is the only one in the list; then it should be removed
    353                         // entirely other fix ups are handled by the FixFunction class
     361                        // entirely. other fix ups are handled by the FixFunction class
    354362                        typedef typename DWTList::iterator DWTIterator;
    355363                        DWTIterator begin( dwts.begin() ), end( dwts.end() );
     
    370378                                for ( ; i != end; ++i ) {
    371379                                        FixFunction fixer;
    372                                         *i = (*i )->acceptMutator( fixer );
     380                                        *i = (*i)->acceptMutator( fixer );
    373381                                        if ( fixer.get_isVoid() ) {
    374382                                                throw SemanticError( "invalid type void in function type ", func );
     
    379387        }
    380388
    381         void EnumAndPointerDecayPass::visit( FunctionType *func ) {
     389        void EnumAndPointerDecay::previsit( FunctionType *func ) {
    382390                // Fix up parameters and return types
    383391                fixFunctionList( func->get_parameters(), func );
    384392                fixFunctionList( func->get_returnVals(), func );
    385                 Visitor::visit( func );
    386393        }
    387394
     
    496503        void LinkReferenceToTypes::visit( StructDecl *structDecl ) {
    497504                // visit struct members first so that the types of self-referencing members are updated properly
     505                // xxx - need to ensure that type parameters match up between forward declarations and definition (most importantly, number of type parameters and and their defaults)
    498506                Parent::visit( structDecl );
    499507                if ( ! structDecl->get_members().empty() ) {
     
    529537        }
    530538
    531         Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
     539        ForallPointerDecay::ForallPointerDecay( const Indexer *other_indexer ) :  Indexer( false ) {
    532540                if ( other_indexer ) {
    533541                        indexer = other_indexer;
     
    567575        }
    568576
    569         void Pass3::visit( ObjectDecl *object ) {
     577        void ForallPointerDecay::visit( ObjectDecl *object ) {
    570578                forallFixer( object->get_type() );
    571579                if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
     
    576584        }
    577585
    578         void Pass3::visit( FunctionDecl *func ) {
     586        void ForallPointerDecay::visit( FunctionDecl *func ) {
    579587                forallFixer( func->get_type() );
    580588                Parent::visit( func );
     
    583591
    584592        void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) {
    585                 ReturnChecker checker;
     593                PassVisitor<ReturnChecker> checker;
    586594                acceptAll( translationUnit, checker );
    587595        }
    588596
    589         void ReturnChecker::visit( FunctionDecl * functionDecl ) {
    590                 std::list< DeclarationWithType * > oldReturnVals = returnVals;
     597        void ReturnChecker::previsit( FunctionDecl * functionDecl ) {
     598                GuardValue( returnVals );
    591599                returnVals = functionDecl->get_functionType()->get_returnVals();
    592                 Visitor::visit( functionDecl );
    593                 returnVals = oldReturnVals;
    594         }
    595 
    596         void ReturnChecker::visit( ReturnStmt * returnStmt ) {
     600        }
     601
     602        void ReturnChecker::previsit( ReturnStmt * returnStmt ) {
    597603                // Previously this also checked for the existence of an expr paired with no return values on
    598604                // the  function return type. This is incorrect, since you can have an expression attached to
     
    804810
    805811        void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) {
    806                 VerifyCtorDtorAssign verifier;
     812                PassVisitor<VerifyCtorDtorAssign> verifier;
    807813                acceptAll( translationUnit, verifier );
    808814        }
    809815
    810         void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) {
     816        void VerifyCtorDtorAssign::previsit( FunctionDecl * funcDecl ) {
    811817                FunctionType * funcType = funcDecl->get_functionType();
    812818                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
     
    826832                        }
    827833                }
    828 
    829                 Visitor::visit( funcDecl );
    830         }
    831 
    832         DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) {
     834        }
     835
     836        template< typename Aggr >
     837        void validateGeneric( Aggr * inst ) {
     838                std::list< TypeDecl * > * params = inst->get_baseParameters();
     839                if ( params != NULL ) {
     840                        std::list< Expression * > & args = inst->get_parameters();
     841
     842                        // insert defaults arguments when a type argument is missing (currently only supports missing arguments at the end of the list).
     843                        // A substitution is used to ensure that defaults are replaced correctly, e.g.,
     844                        //   forall(otype T, otype alloc = heap_allocator(T)) struct vector;
     845                        //   vector(int) v;
     846                        // after insertion of default values becomes
     847                        //   vector(int, heap_allocator(T))
     848                        // and the substitution is built with T=int so that after substitution, the result is
     849                        //   vector(int, heap_allocator(int))
     850                        TypeSubstitution sub;
     851                        auto paramIter = params->begin();
     852                        for ( size_t i = 0; paramIter != params->end(); ++paramIter, ++i ) {
     853                                if ( i < args.size() ) {
     854                                        TypeExpr * expr = safe_dynamic_cast< TypeExpr * >( *std::next( args.begin(), i ) );
     855                                        sub.add( (*paramIter)->get_name(), expr->get_type()->clone() );
     856                                } else if ( i == args.size() ) {
     857                                        Type * defaultType = (*paramIter)->get_init();
     858                                        if ( defaultType ) {
     859                                                args.push_back( new TypeExpr( defaultType->clone() ) );
     860                                                sub.add( (*paramIter)->get_name(), defaultType->clone() );
     861                                        }
     862                                }
     863                        }
     864
     865                        sub.apply( inst );
     866                        if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst );
     867                        if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst );
     868                }
     869        }
     870
     871        void ValidateGenericParameters::previsit( StructInstType * inst ) {
     872                validateGeneric( inst );
     873        }
     874
     875        void ValidateGenericParameters::previsit( UnionInstType * inst ) {
     876                validateGeneric( inst );
     877        }
     878
     879        void CompoundLiteral::premutate( ObjectDecl *objectDecl ) {
    833880                storageClasses = objectDecl->get_storageClasses();
    834                 DeclarationWithType * temp = Mutator::mutate( objectDecl );
    835                 return temp;
    836         }
    837 
    838         Expression *CompoundLiteral::mutate( CompoundLiteralExpr *compLitExpr ) {
     881        }
     882
     883        Expression *CompoundLiteral::postmutate( CompoundLiteralExpr *compLitExpr ) {
    839884                // transform [storage_class] ... (struct S){ 3, ... };
    840885                // into [storage_class] struct S temp =  { 3, ... };
    841886                static UniqueName indexName( "_compLit" );
    842887
    843                 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_result(), compLitExpr->get_initializer() );
    844                 compLitExpr->set_result( 0 );
    845                 compLitExpr->set_initializer( 0 );
     888                ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() );
     889                compLitExpr->set_result( nullptr );
     890                compLitExpr->set_initializer( nullptr );
    846891                delete compLitExpr;
    847                 DeclarationWithType * newtempvar = mutate( tempvar );
    848                 addDeclaration( newtempvar );                                   // add modified temporary to current block
    849                 return new VariableExpr( newtempvar );
     892                declsToAddBefore.push_back( tempvar );                                  // add modified temporary to current block
     893                return new VariableExpr( tempvar );
    850894        }
    851895
    852896        void ReturnTypeFixer::fix( std::list< Declaration * > &translationUnit ) {
    853                 ReturnTypeFixer fixer;
     897                PassVisitor<ReturnTypeFixer> fixer;
    854898                acceptAll( translationUnit, fixer );
    855899        }
    856900
    857         void ReturnTypeFixer::visit( FunctionDecl * functionDecl ) {
    858                 Parent::visit( functionDecl );
     901        void ReturnTypeFixer::postvisit( FunctionDecl * functionDecl ) {
    859902                FunctionType * ftype = functionDecl->get_functionType();
    860903                std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();
     
    867910                                ret->set_name( toString( "_retval_", CodeGen::genName( functionDecl ) ) );
    868911                        }
    869                 }
    870         }
    871 
    872         void ReturnTypeFixer::visit( FunctionType * ftype ) {
     912                        ret->get_attributes().push_back( new Attribute( "unused" ) );
     913                }
     914        }
     915
     916        void ReturnTypeFixer::postvisit( FunctionType * ftype ) {
    873917                // xxx - need to handle named return values - this information needs to be saved somehow
    874918                // so that resolution has access to the names.
     
    888932
    889933        void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) {
    890                 ArrayLength len;
     934                PassVisitor<ArrayLength> len;
    891935                acceptAll( translationUnit, len );
    892936        }
    893937
    894         void ArrayLength::visit( ObjectDecl * objDecl ) {
     938        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    895939                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
    896940                        if ( at->get_dimension() != nullptr ) return;
  • src/SynTree/AggregateDecl.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 23:56:39 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:07 2017
    13 // Update Count     : 20
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jun 27 15:30:00 2017
     13// Update Count     : 21
    1414//
    1515
     
    2020
    2121
    22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {
     22AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) {
    2323}
    2424
  • src/SynTree/Attribute.h

    r9c951e3 rb1e63ac5  
    4040};
    4141
     42const std::list< Attribute * > noAttributes;
     43
    4244#endif
    4345
  • src/SynTree/BaseSyntaxNode.h

    r9c951e3 rb1e63ac5  
    2424        CodeLocation location;
    2525
    26         virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast
     26        virtual ~BaseSyntaxNode() {}
     27
     28        virtual void accept( Visitor & v ) = 0;
    2729};
    2830
  • src/SynTree/Constant.cc

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Constant.cc -- 
     7// Constant.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 15:18:38 2015
    13 // Update Count     : 12
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:11:00 2017
     13// Update Count     : 28
    1414//
    1515
     
    2121#include "Type.h"
    2222
    23 Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {}
     23Constant::Constant( Type * type, std::string rep, unsigned long long val ) : type( type ), rep( rep ), val( val ) {}
     24Constant::Constant( Type * type, std::string rep, double val ) : type( type ), rep( rep ), val( val ) {}
    2425
    25 Constant::Constant( const Constant &other ) {
     26Constant::Constant( const Constant &other ) : rep( other.rep ), val( other.val ) {
    2627        type = other.type->clone();
    27         value = other.value;
    2828}
    2929
    3030Constant::~Constant() { delete type; }
    3131
     32Constant Constant::from_bool( bool b ) {
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b );
     34}
     35
    3236Constant Constant::from_int( int i ) {
    33         return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ), (unsigned long long int)i );
    3438}
    3539
    3640Constant Constant::from_ulong( unsigned long i ) {
    37         return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ), (unsigned long long int)i );
    3842}
    3943
    4044Constant Constant::from_double( double d ) {
    41         return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
     45        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d );
    4246}
    4347
    44 Constant *Constant::clone() const { assert( false ); return 0; }
     48unsigned long long Constant::get_ival() const {
     49        assertf( safe_dynamic_cast<BasicType*>(type)->isInteger(), "Attempt to retrieve ival from non-integer constant." );
     50        return val.ival;
     51}
     52
     53double Constant::get_dval() const {
     54        assertf( ! safe_dynamic_cast<BasicType*>(type)->isInteger(), "Attempt to retrieve dval from integer constant." );
     55        return val.dval;
     56}
    4557
    4658void Constant::print( std::ostream &os ) const {
    47         os << "(" << value;
     59        os << "(" << rep << " " << val.ival;
    4860        if ( type ) {
    4961                os << ": ";
  • src/SynTree/Constant.h

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Constant.h -- 
     7// Constant.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 13:33:17 2016
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:13:00 2017
     13// Update Count     : 15
    1414//
    1515
     
    2323class Constant {
    2424  public:
    25         Constant( Type *type, std::string value );
    26         Constant( const Constant &other );
     25        Constant( Type * type, std::string rep, unsigned long long val );
     26        Constant( Type * type, std::string rep, double val );
     27        Constant( const Constant & other );
    2728        virtual ~Constant();
    2829
    29         Type *get_type() { return type; }
    30         void set_type( Type *newValue ) { type = newValue; }
    31         std::string &get_value() { return value; }
    32         void set_value( std::string newValue ) { value = newValue; }
     30        Type * get_type() { return type; }
     31        void set_type( Type * newValue ) { type = newValue; }
     32        std::string & get_value() { return rep; }
     33        void set_value( std::string newValue ) { rep = newValue; }
     34        unsigned long long get_ival() const;
     35        double get_dval() const;
    3336
     37        /// generates a boolean constant of the given bool
     38        static Constant from_bool( bool b );
    3439        /// generates an integer constant of the given int
    3540        static Constant from_int( int i );
     
    3944        static Constant from_double( double d );
    4045
    41         virtual Constant *clone() const;
    42         virtual void accept( Visitor &v ) { v.visit( this ); }
    43         virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    44         virtual void print( std::ostream &os ) const;
     46        virtual void accept( Visitor & v ) { v.visit( this ); }
     47        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     48        virtual void print( std::ostream & os ) const;
    4549  private:
    46         Type *type;
    47         std::string value;
     50        Type * type;
     51        std::string rep;
     52        union Val {
     53                unsigned long long ival;
     54                double dval;
     55                Val( unsigned long long ival ) : ival( ival ) {}
     56                Val( double dval ) : dval( dval ) {}
     57        } val;
    4858};
    4959
  • src/SynTree/Declaration.h

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 16:05:08 2017
    13 // Update Count     : 121
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jun 27 15:31:00 2017
     13// Update Count     : 122
    1414//
    1515
     
    194194        };
    195195
    196         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind );
     196        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
    197197        TypeDecl( const TypeDecl &other );
     198        virtual ~TypeDecl();
    198199
    199200        Kind get_kind() const { return kind; }
     201
     202        Type * get_init() const { return init; }
     203        TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
    200204
    201205        bool isComplete() const { return kind == Any || sized; }
     
    209213        virtual void accept( Visitor &v ) { v.visit( this ); }
    210214        virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     215        virtual void print( std::ostream &os, int indent = 0 ) const;
     216
    211217  private:
    212218        Kind kind;
     219        Type * init;
    213220        bool sized;
    214221};
     
    231238        typedef Declaration Parent;
    232239  public:
    233         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >() );
     240        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    234241        AggregateDecl( const AggregateDecl &other );
    235242        virtual ~AggregateDecl();
     
    259266        typedef AggregateDecl Parent;
    260267  public:
    261         StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >() ) : Parent( name, attributes ), kind( kind ) {}
     268        StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
    262269        StructDecl( const StructDecl &other ) : Parent( other ) {}
    263270
     
    277284        typedef AggregateDecl Parent;
    278285  public:
    279         UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >() ) : Parent( name, attributes ) {}
     286        UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    280287        UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    281288
     
    290297        typedef AggregateDecl Parent;
    291298  public:
    292         EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >() ) : Parent( name, attributes ) {}
     299        EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    293300        EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    294301
  • src/SynTree/Expression.cc

    r9c951e3 rb1e63ac5  
    2121#include <iterator>
    2222
     23#include "Declaration.h"
     24#include "Expression.h"
     25#include "Initializer.h"
     26#include "Statement.h"
    2327#include "Type.h"
    24 #include "Initializer.h"
    25 #include "Expression.h"
    26 #include "Declaration.h"
    27 #include "Statement.h"
    2828#include "TypeSubstitution.h"
     29#include "VarExprReplacer.h"
     30
    2931#include "Common/utility.h"
     32#include "Common/PassVisitor.h"
     33
    3034#include "InitTweak/InitTweak.h"
    3135
     
    9296
    9397        Declaration *decl = get_var();
    94         // if ( decl != 0) decl->print(os, indent + 2);
    9598        if ( decl != 0) decl->printShort(os, indent + 2);
    9699        os << std::endl;
     
    287290        delete arg;
    288291}
    289 
    290 // CastExpr *CastExpr::clone() const { return 0; }
    291292
    292293void CastExpr::print( std::ostream &os, int indent ) const {
     
    355356}
    356357
    357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    358358MemberExpr::MemberExpr( const MemberExpr &other ) :
    359359                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    361361
    362362MemberExpr::~MemberExpr() {
    363         // delete member;
     363        // don't delete the member declaration, since it points somewhere else in the tree
    364364        delete aggregate;
    365365}
     
    591591}
    592592
    593 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    594 
    595 UntypedValofExpr::~UntypedValofExpr() { delete body; }
    596 
    597 void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    598         os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
    599         if ( get_body() != 0 )
    600                 get_body()->print( os, indent + 2 );
    601 }
    602 
    603593RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    604594RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     
    670660}
    671661
     662InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
     663InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
     664InitAlternative::~InitAlternative() {
     665        delete type;
     666        delete designation;
     667}
     668
     669UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
     670UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
     671UntypedInitExpr::~UntypedInitExpr() {
     672        delete expr;
     673}
     674
     675void UntypedInitExpr::print( std::ostream & os, int indent ) const {
     676        os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );
     677        expr->print( os, indent+2 );
     678        if ( ! initAlts.empty() ) {
     679                for ( const InitAlternative & alt : initAlts ) {
     680                        os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
     681                        alt.type->print( os, indent+2 );
     682                        alt.designation->print( os, indent+2 );
     683                }
     684        }
     685}
     686
     687InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) {
     688        set_result( expr->get_result()->clone() );
     689}
     690InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
     691InitExpr::~InitExpr() {
     692        delete expr;
     693        delete designation;
     694}
     695
     696void InitExpr::print( std::ostream & os, int indent ) const {
     697        os << "Init Expression" << std::endl << std::string( indent+2, ' ' );
     698        expr->print( os, indent+2 );
     699        os << std::string( indent+2, ' ' ) << "with designation: ";
     700        designation->print( os, indent+2 );
     701}
     702
     703
    672704std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    673705        if ( expr ) {
  • src/SynTree/Expression.h

    r9c951e3 rb1e63ac5  
    226226};
    227227
    228 /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
     228/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer.
     229/// Does not take ownership of member.
    229230class MemberExpr : public Expression {
    230231  public:
     
    247248};
    248249
    249 /// VariableExpr represents an expression that simply refers to the value of a named variable
     250/// VariableExpr represents an expression that simply refers to the value of a named variable.
     251/// Does not take ownership of var.
    250252class VariableExpr : public Expression {
    251253  public:
     
    598600};
    599601
    600 /// ValofExpr represents a GCC 'lambda expression'
    601 class UntypedValofExpr : public Expression {
    602   public:
    603         UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {}
    604         UntypedValofExpr( const UntypedValofExpr & other );
    605         virtual ~UntypedValofExpr();
    606 
    607         Expression * get_value();
    608         Statement * get_body() const { return body; }
    609 
    610         virtual UntypedValofExpr * clone() const { return new UntypedValofExpr( * this ); }
    611         virtual void accept( Visitor & v ) { v.visit( this ); }
    612         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    613         virtual void print( std::ostream & os, int indent = 0 ) const;
    614   private:
    615         Statement * body;
    616 };
    617 
    618602/// RangeExpr represents a range e.g. '3 ... 5' or '1~10'
    619603class RangeExpr : public Expression {
     
    688672        Expression * tuple;
    689673        unsigned int index;
    690 };
    691 
    692 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer
    693 class MemberTupleExpr : public Expression {
    694   public:
    695         MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );
    696         MemberTupleExpr( const MemberTupleExpr & other );
    697         virtual ~MemberTupleExpr();
    698 
    699         Expression * get_member() const { return member; }
    700         Expression * get_aggregate() const { return aggregate; }
    701         MemberTupleExpr * set_member( Expression * newValue ) { member = newValue; return this; }
    702         MemberTupleExpr * set_aggregate( Expression * newValue ) { aggregate = newValue; return this; }
    703 
    704         virtual MemberTupleExpr * clone() const { return new MemberTupleExpr( * this ); }
    705         virtual void accept( Visitor & v ) { v.visit( this ); }
    706         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    707         virtual void print( std::ostream & os, int indent = 0 ) const;
    708   private:
    709         Expression * member;
    710         Expression * aggregate;
    711674};
    712675
     
    781744};
    782745
     746struct InitAlternative {
     747public:
     748        Type * type = nullptr;
     749        Designation * designation = nullptr;
     750        InitAlternative( Type * type, Designation * designation );
     751        InitAlternative( const InitAlternative & other );
     752        InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
     753        ~InitAlternative();
     754};
     755
     756class UntypedInitExpr : public Expression {
     757public:
     758        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
     759        UntypedInitExpr( const UntypedInitExpr & other );
     760        ~UntypedInitExpr();
     761
     762        Expression * get_expr() const { return expr; }
     763        UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
     764
     765        std::list<InitAlternative> & get_initAlts() { return initAlts; }
     766
     767        virtual UntypedInitExpr * clone() const { return new UntypedInitExpr( * this ); }
     768        virtual void accept( Visitor & v ) { v.visit( this ); }
     769        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     770        virtual void print( std::ostream & os, int indent = 0 ) const;
     771private:
     772        Expression * expr;
     773        std::list<InitAlternative> initAlts;
     774};
     775
     776class InitExpr : public Expression {
     777public:
     778        InitExpr( Expression * expr, Designation * designation );
     779        InitExpr( const InitExpr & other );
     780        ~InitExpr();
     781
     782        Expression * get_expr() const { return expr; }
     783        InitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
     784
     785        Designation * get_designation() const { return designation; }
     786        InitExpr * set_designation( Designation * newValue ) { designation = newValue; return this; }
     787
     788        virtual InitExpr * clone() const { return new InitExpr( * this ); }
     789        virtual void accept( Visitor & v ) { v.visit( this ); }
     790        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     791        virtual void print( std::ostream & os, int indent = 0 ) const;
     792private:
     793        Expression * expr;
     794        Designation * designation;
     795};
     796
     797
    783798std::ostream & operator<<( std::ostream & out, const Expression * expr );
    784799
  • src/SynTree/Initializer.cc

    r9c951e3 rb1e63ac5  
    1919#include "Common/utility.h"
    2020
     21Designation::Designation( const std::list< Expression * > & designators ) : designators( designators ) {}
     22Designation::Designation( const Designation & other ) : BaseSyntaxNode( other ) {
     23        // std::cerr << "cloning designation" << std::endl;
     24        cloneAll( other.designators, designators );
     25        // std::cerr << "finished cloning designation" << std::endl;
     26}
     27
     28Designation::~Designation() {
     29        // std::cerr << "destroying designation" << std::endl;
     30        deleteAll( designators );
     31        // std::cerr << "finished destroying designation" << std::endl;
     32}
     33
     34void Designation::print( std::ostream &os, int indent ) const {
     35        if ( ! designators.empty() ) {
     36                os << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;
     37                for ( std::list < Expression * >::const_iterator i = designators.begin(); i != designators.end(); i++ ) {
     38                        os << std::string(indent + 4, ' ' );
     39                        ( *i )->print(os, indent + 4 );
     40                }
     41                os << std::endl;
     42        } // if
     43}
     44
    2145Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
    2246Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ), maybeConstructed( other.maybeConstructed ) {
    2347}
    24 
    25 
    2648Initializer::~Initializer() {}
    2749
    28 std::string Initializer::designator_name( Expression *des ) {
    29         if ( NameExpr *n = dynamic_cast<NameExpr *>(des) )
    30                 return n->get_name();
    31         else
    32                 throw 0;
    33 }
    34 
    35 void Initializer::print( std::ostream &os, int indent ) {}
    36 
    37 SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) {
     50SingleInit::SingleInit( Expression *v, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ) {
    3851}
    3952
    4053SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) {
    41         cloneAll(other.designators, designators );
    4254}
    4355
    4456SingleInit::~SingleInit() {
    4557        delete value;
    46         deleteAll(designators);
    4758}
    4859
    49 void SingleInit::print( std::ostream &os, int indent ) {
    50         os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
     60void SingleInit::print( std::ostream &os, int indent ) const {
     61        os << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
    5162        os << std::string(indent+4, ' ' );
    5263        value->print( os, indent+4 );
    53 
    54         if ( ! designators.empty() ) {
    55                 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;
    56                 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) {
    57                         os << std::string(indent + 4, ' ' );
    58                         ( *i )->print(os, indent + 4 );
    59                 }
    60         } // if
    6164}
    6265
    63 ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed )
    64         : Initializer( maybeConstructed ), initializers( _initializers ), designators( _designators ) {
     66
     67ListInit::ListInit( const std::list<Initializer*> &inits, const std::list<Designation *> &des, bool maybeConstructed )
     68        : Initializer( maybeConstructed ), initializers( inits ), designations( des ) {
     69                // handle the common case where a ListInit is created without designations by making a list of empty designations with the same length as the initializer
     70                if ( designations.empty() ) {
     71                        for ( auto & i : initializers ) {
     72                                (void)i;
     73                                designations.push_back( new Designation( {} ) );
     74                        }
     75                }
     76                assertf( initializers.size() == designations.size(), "Created ListInit with mismatching initializers (%d) and designations (%d)", initializers.size(), designations.size() );
    6577}
    6678
    6779ListInit::ListInit( const ListInit & other ) : Initializer( other ) {
    6880        cloneAll( other.initializers, initializers );
    69         cloneAll( other.designators, designators );
     81        cloneAll( other.designations, designations );
    7082}
    71 
    7283
    7384ListInit::~ListInit() {
    7485        deleteAll( initializers );
    75         deleteAll( designators );
     86        deleteAll( designations );
    7687}
    7788
    78 void ListInit::print( std::ostream &os, int indent ) {
    79         os << std::endl << std::string(indent, ' ') << "Compound initializer:  ";
    80         if ( ! designators.empty() ) {
    81                 os << std::string(indent + 2, ' ' ) << "designated by: [";
    82                 for ( std::list < Expression * >::iterator i = designators.begin();
    83                           i != designators.end(); i++ ) {
    84                         ( *i )->print(os, indent + 4 );
    85                 } // for
     89void ListInit::print( std::ostream &os, int indent ) const {
     90        os << std::string(indent, ' ') << "Compound initializer:  " << std::endl;
     91        for ( Designation * d : designations ) {
     92                d->print( os, indent + 2 );
     93        }
    8694
    87                 os << std::string(indent + 2, ' ' ) << "]";
    88         } // if
    89 
    90         for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ )
    91                 (*i)->print( os, indent + 2 );
     95        for ( const Initializer * init : initializers ) {
     96                init->print( os, indent + 2 );
     97                os << std::endl;
     98        }
    9299}
    93100
     
    103110}
    104111
    105 void ConstructorInit::print( std::ostream &os, int indent ) {
     112void ConstructorInit::print( std::ostream &os, int indent ) const {
    106113        os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl;
    107114        if ( ctor ) {
     
    124131}
    125132
    126 std::ostream & operator<<( std::ostream & out, Initializer * init ) {
    127         init->print( out );
     133std::ostream & operator<<( std::ostream & out, const Initializer * init ) {
     134        if ( init ) {
     135                init->print( out );
     136        } else {
     137                out << "nullptr";
     138        }
     139        return out;
     140}
     141
     142std::ostream & operator<<( std::ostream & out, const Designation * des ) {
     143        if ( des ) {
     144                des->print( out );
     145        } else {
     146                out << "nullptr";
     147        }
    128148        return out;
    129149}
  • src/SynTree/Initializer.h

    r9c951e3 rb1e63ac5  
    2525#include "Visitor.h"
    2626
    27 const std::list<Expression*> noDesignators;
     27// Designation: list of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an object being initialized.
     28class Designation : public BaseSyntaxNode {
     29public:
     30        Designation( const std::list< Expression * > & designators );
     31        Designation( const Designation & other );
     32        virtual ~Designation();
     33
     34        std::list< Expression * > & get_designators() { return designators; }
     35
     36        virtual Designation * clone() const { return new Designation( *this ); };
     37        virtual void accept( Visitor &v ) { v.visit( this ); }
     38        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
     39        virtual void print( std::ostream &os, int indent = 0 ) const;
     40private:
     41        std::list< Expression * > designators;
     42};
     43
     44const std::list<Designation *> noDesignators;
    2845
    2946// Initializer: base class for object initializers (provide default values)
    3047class Initializer : public BaseSyntaxNode {
    3148  public:
    32         //      Initializer( std::string _name = std::string(""), int _pos = 0 );
    3349        Initializer( bool maybeConstructed );
    3450        Initializer( const Initializer & other );
    3551        virtual ~Initializer();
    36 
    37         static std::string designator_name( Expression *designator );
    38 
    39         //      void set_name( std::string newValue ) { name = newValue; }
    40         //      std::string get_name() const { return name; }
    41 
    42         //      void set_pos( int newValue ) { pos = newValue; }
    43         //      int get_pos() const { return pos; }
    44         virtual void set_designators( std::list<Expression *> & ) { assert(false); }
    45         virtual std::list<Expression *> &get_designators() {
    46                 assert(false);
    47                 std::list<Expression *> *ret = 0; return *ret;  // never reached
    48         }
    4952
    5053        bool get_maybeConstructed() { return maybeConstructed; }
     
    5356        virtual void accept( Visitor &v ) = 0;
    5457        virtual Initializer *acceptMutator( Mutator &m ) = 0;
    55         virtual void print( std::ostream &os, int indent = 0 );
     58        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    5659  private:
    57         //      std::string name;
    58         //      int pos;
    5960        bool maybeConstructed;
    6061};
     
    6364class SingleInit : public Initializer {
    6465  public:
    65         SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
     66        SingleInit( Expression *value, bool maybeConstructed = false );
    6667        SingleInit( const SingleInit &other );
    6768        virtual ~SingleInit();
     
    7071        void set_value( Expression *newValue ) { value = newValue; }
    7172
    72         std::list<Expression *> &get_designators() { return designators; }
    73         void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
    74 
    7573        virtual SingleInit *clone() const { return new SingleInit( *this); }
    7674        virtual void accept( Visitor &v ) { v.visit( this ); }
    7775        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    78         virtual void print( std::ostream &os, int indent = 0 );
     76        virtual void print( std::ostream &os, int indent = 0 ) const;
    7977  private:
    8078        //Constant *value;
    8179        Expression *value;      // has to be a compile-time constant
    82         std::list< Expression * > designators;
    8380};
    8481
     
    8885  public:
    8986        ListInit( const std::list<Initializer*> &initializers,
    90                           const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
     87                          const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
    9188        ListInit( const ListInit & other );
    9289        virtual ~ListInit();
    9390
    94         void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
    95         std::list<Expression *> &get_designators() { return designators; }
    96         void set_initializers( std::list<Initializer*> &newValue ) { initializers = newValue; }
    97         std::list<Initializer*> &get_initializers() { return initializers; }
     91        std::list<Designation *> & get_designations() { return designations; }
     92        std::list<Initializer *> & get_initializers() { return initializers; }
    9893
    9994        typedef std::list<Initializer*>::iterator iterator;
     95        typedef std::list<Initializer*>::const_iterator const_iterator;
    10096        iterator begin() { return initializers.begin(); }
    10197        iterator end() { return initializers.end(); }
     98        const_iterator begin() const { return initializers.begin(); }
     99        const_iterator end() const { return initializers.end(); }
    102100
    103101        virtual ListInit *clone() const { return new ListInit( *this ); }
    104102        virtual void accept( Visitor &v ) { v.visit( this ); }
    105103        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    106         virtual void print( std::ostream &os, int indent = 0 );
     104        virtual void print( std::ostream &os, int indent = 0 ) const;
    107105  private:
    108         std::list<Initializer*> initializers;  // order *is* important
    109         std::list<Expression *> designators;
     106        std::list<Initializer *> initializers;  // order *is* important
     107        std::list<Designation *> designations;  // order/length is consistent with initializers
    110108};
    111109
     
    130128        virtual void accept( Visitor &v ) { v.visit( this ); }
    131129        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    132         virtual void print( std::ostream &os, int indent = 0 );
     130        virtual void print( std::ostream &os, int indent = 0 ) const;
    133131
    134132  private:
     
    140138};
    141139
    142 std::ostream & operator<<( std::ostream & out, Initializer * init );
     140std::ostream & operator<<( std::ostream & out, const Initializer * init );
     141std::ostream & operator<<( std::ostream & out, const Designation * des );
    143142
    144143#endif // INITIALIZER_H
  • src/SynTree/Mutator.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 16:45:19 2017
    13 // Update Count     : 22
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:43:00 2017
     13// Update Count     : 24
    1414//
    1515
     
    7777TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) {
    7878        handleNamedTypeDecl( typeDecl );
     79        typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) );
    7980        return typeDecl;
    8081}
     
    152153}
    153154
     155Statement *Mutator::mutate( ThrowStmt *throwStmt ) {
     156        throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) );
     157        throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) );
     158        return throwStmt;
     159}
     160
    154161Statement *Mutator::mutate( TryStmt *tryStmt ) {
    155162        tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    156163        mutateAll( tryStmt->get_catchers(), *this );
     164        tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    157165        return tryStmt;
    158166}
     
    160168Statement *Mutator::mutate( CatchStmt *catchStmt ) {
    161169        catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
     170        catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    162171        catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
    163172        return catchStmt;
     
    373382}
    374383
    375 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    376         valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
    377         valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    378         return valofExpr;
    379 }
    380 
    381384Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
    382385        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
     
    404407        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    405408        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
    406         return tupleExpr;
    407 }
    408 
    409 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
    410         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    411         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    412         tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
    413         tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );
    414409        return tupleExpr;
    415410}
     
    438433}
    439434
     435Expression *Mutator::mutate( UntypedInitExpr * initExpr ) {
     436        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
     437        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
     438        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
     439        // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
     440        return initExpr;
     441}
     442
     443Expression *Mutator::mutate( InitExpr * initExpr ) {
     444        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
     445        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
     446        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
     447        initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
     448        return initExpr;
     449}
     450
    440451
    441452Type *Mutator::mutate( VoidType *voidType ) {
     
    510521        mutateAll( tupleType->get_forall(), *this );
    511522        mutateAll( tupleType->get_types(), *this );
     523        mutateAll( tupleType->get_members(), *this );
    512524        return tupleType;
    513525}
     
    546558
    547559
     560Designation *Mutator::mutate( Designation * designation ) {
     561        mutateAll( designation->get_designators(), *this );
     562        return designation;
     563}
     564
    548565Initializer *Mutator::mutate( SingleInit *singleInit ) {
    549566        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
     
    552569
    553570Initializer *Mutator::mutate( ListInit *listInit ) {
    554         mutateAll( listInit->get_designators(), *this );
     571        mutateAll( listInit->get_designations(), *this );
    555572        mutateAll( listInit->get_initializers(), *this );
    556573        return listInit;
  • src/SynTree/Mutator.h

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 14:23:23 2017
    13 // Update Count     : 13
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun  8 15:45:00 2017
     13// Update Count     : 14
    1414//
    1515#include <cassert>
     
    4646        virtual Statement* mutate( BranchStmt *branchStmt );
    4747        virtual Statement* mutate( ReturnStmt *returnStmt );
    48         virtual Statement* mutate( TryStmt *returnStmt );
     48        virtual Statement* mutate( ThrowStmt *throwStmt );
     49        virtual Statement* mutate( TryStmt *tryStmt );
    4950        virtual Statement* mutate( CatchStmt *catchStmt );
    5051        virtual Statement* mutate( FinallyStmt *catchStmt );
     
    7778        virtual Expression* mutate( ConstructorExpr *ctorExpr );
    7879        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    79         virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8080        virtual Expression* mutate( RangeExpr *rangeExpr );
    8181        virtual Expression* mutate( UntypedTupleExpr *tupleExpr );
    8282        virtual Expression* mutate( TupleExpr *tupleExpr );
    8383        virtual Expression* mutate( TupleIndexExpr *tupleExpr );
    84         virtual Expression* mutate( MemberTupleExpr *tupleExpr );
    8584        virtual Expression* mutate( TupleAssignExpr *assignExpr );
    8685        virtual Expression* mutate( StmtExpr * stmtExpr );
    8786        virtual Expression* mutate( UniqueExpr * uniqueExpr );
     87        virtual Expression* mutate( UntypedInitExpr * initExpr );
     88        virtual Expression* mutate( InitExpr * initExpr );
    8889
    8990        virtual Type* mutate( VoidType *basicType );
     
    105106        virtual Type* mutate( OneType *oneType );
    106107
     108        virtual Designation* mutate( Designation *designation );
    107109        virtual Initializer* mutate( SingleInit *singleInit );
    108110        virtual Initializer* mutate( ListInit *listInit );
  • src/SynTree/ObjectDecl.cc

    r9c951e3 rb1e63ac5  
    5656
    5757        if ( init ) {
    58                 os << " with initializer ";
    59                 init->print( os, indent );
    60                 os << std::endl << std::string(indent, ' ');
     58                os << " with initializer " << std::endl;
     59                init->print( os, indent+2 );
     60                os << std::endl << std::string(indent+2, ' ');
    6161                os << "maybeConstructed? " << init->get_maybeConstructed();
    6262        } // if
  • src/SynTree/Statement.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 12 13:58:48 2016
    13 // Update Count     : 62
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 10:37:00 2017
     13// Update Count     : 64
    1414//
    1515
     
    3030Statement::Statement( std::list<Label> _labels ) : labels( _labels ) {}
    3131
    32 void Statement::print( std::ostream &, int indent ) const {}
     32void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {}
    3333
    3434Statement::~Statement() {}
     
    101101}
    102102
    103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
    104 
    105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
     103ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {}
     104
     105ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    106106
    107107ReturnStmt::~ReturnStmt() {
     
    110110
    111111void ReturnStmt::print( std::ostream &os, int indent ) const {
    112         os << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
     112        os <<  "Return Statement, returning: ";
    113113        if ( expr != 0 ) {
    114114                os << endl << string( indent+2, ' ' );
     
    287287}
    288288
    289 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
     289ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) :
     290                Statement( labels ), kind(kind), expr(expr), target(target)     {
     291        assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." );
     292}
     293
     294ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
     295        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
     296}
     297
     298ThrowStmt::~ThrowStmt() {
     299        delete expr;
     300        delete target;
     301}
     302
     303void ThrowStmt::print( std::ostream &os, int indent) const {
     304        if ( target ) {
     305                os << "Non-Local ";
     306        }
     307        os << "Throw Statement, raising: ";
     308        expr->print(os, indent + 4);
     309        if ( target ) {
     310                os << "At: ";
     311                target->print(os, indent + 4);
     312        }
     313}
     314
     315TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) :
    290316        Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock ) {
    291317}
     
    308334        // handlers
    309335        os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    310         for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
     336        for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
    311337                (*i )->print( os, indent + 4 );
    312338
     
    318344}
    319345
    320 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :
    321         Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {
     346CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) :
     347        Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) {
    322348}
    323349
    324350CatchStmt::CatchStmt( const CatchStmt & other ) :
    325         Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
     351        Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) {
    326352}
    327353
     
    332358
    333359void CatchStmt::print( std::ostream &os, int indent ) const {
    334         os << "Catch Statement" << endl;
     360        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    335361
    336362        os << string( indent, ' ' ) << "... catching" << endl;
     
    338364                decl->printShort( os, indent + 4 );
    339365                os << endl;
    340         } else if ( catchRest )
    341                 os << string( indent + 4 , ' ' ) << "the rest" << endl;
     366        }
    342367        else
    343368                os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
     
    365390NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
    366391
    367 void NullStmt::print( std::ostream &os, int indent ) const {
     392void NullStmt::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    368393        os << "Null Statement" << endl ;
    369394}
  • src/SynTree/Statement.h

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 12 13:57:46 2016
    13 // Update Count     : 65
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 13:35:00 2017
     13// Update Count     : 67
    1414//
    1515
     
    5757  private:
    5858        std::list<Statement*> kids;
     59};
     60
     61class NullStmt : public CompoundStmt {
     62  public:
     63        NullStmt();
     64        NullStmt( std::list<Label> labels );
     65
     66        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     67        virtual void accept( Visitor &v ) { v.visit( this ); }
     68        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     69        virtual void print( std::ostream &os, int indent = 0 ) const;
     70
     71  private:
    5972};
    6073
     
    261274class ReturnStmt : public Statement {
    262275  public:
    263         ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     276        ReturnStmt( std::list<Label> labels, Expression *expr );
    264277        ReturnStmt( const ReturnStmt &other );
    265278        virtual ~ReturnStmt();
     
    274287  private:
    275288        Expression *expr;
    276         bool isThrow;
    277 };
    278 
    279 
    280 class NullStmt : public CompoundStmt {
    281   public:
    282         NullStmt();
    283         NullStmt( std::list<Label> labels );
    284 
    285         virtual NullStmt *clone() const { return new NullStmt( *this ); }
    286         virtual void accept( Visitor &v ) { v.visit( this ); }
    287         virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    288         virtual void print( std::ostream &os, int indent = 0 ) const;
    289 
    290   private:
     289};
     290
     291class ThrowStmt : public Statement {
     292  public:
     293        enum Kind { Terminate, Resume };
     294
     295        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     296        ThrowStmt( const ThrowStmt &other );
     297        virtual ~ThrowStmt();
     298
     299        Kind get_kind() { return kind; }
     300        Expression * get_expr() { return expr; }
     301        void set_expr( Expression * newExpr ) { expr = newExpr; }
     302        Expression * get_target() { return target; }
     303        void set_target( Expression * newTarget ) { target = newTarget; }
     304
     305        virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); }
     306        virtual void accept( Visitor &v ) { v.visit( this ); }
     307        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     308        virtual void print( std::ostream &os, int indent = 0 ) const;
     309  private:
     310        Kind kind;
     311        Expression * expr;
     312        Expression * target;
    291313};
    292314
    293315class TryStmt : public Statement {
    294316  public:
    295         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     317        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    296318        TryStmt( const TryStmt &other );
    297319        virtual ~TryStmt();
     
    299321        CompoundStmt *get_block() const { return block; }
    300322        void set_block( CompoundStmt *newValue ) { block = newValue; }
    301         std::list<Statement *>& get_catchers() { return handlers; }
     323        std::list<CatchStmt *>& get_catchers() { return handlers; }
    302324
    303325        FinallyStmt *get_finally() const { return finallyBlock; }
     
    311333  private:
    312334        CompoundStmt *block;
    313         std::list<Statement *> handlers;
     335        std::list<CatchStmt *> handlers;
    314336        FinallyStmt *finallyBlock;
    315337};
     
    317339class CatchStmt : public Statement {
    318340  public:
    319         CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false );
     341        enum Kind { Terminate, Resume };
     342
     343        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     344                   Expression *cond, Statement *body );
    320345        CatchStmt( const CatchStmt &other );
    321346        virtual ~CatchStmt();
    322347
     348        Kind get_kind() { return kind; }
    323349        Declaration *get_decl() { return decl; }
    324350        void set_decl( Declaration *newValue ) { decl = newValue; }
    325 
     351        Expression *get_cond() { return cond; }
     352        void set_cond( Expression *newCond ) { cond = newCond; }
    326353        Statement *get_body() { return body; }
    327354        void set_body( Statement *newValue ) { body = newValue; }
     
    333360
    334361  private:
     362        Kind kind;
    335363        Declaration *decl;
     364        Expression *cond;
    336365        Statement *body;
    337         bool catchRest;
    338366};
    339367
  • src/SynTree/SynTree.h

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 14:23:49 2017
    13 // Update Count     : 8
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun  8 17:00:00 2017
     13// Update Count     : 9
    1414//
    1515
     
    5151class BranchStmt;
    5252class ReturnStmt;
     53class ThrowStmt;
    5354class TryStmt;
    5455class CatchStmt;
     
    8990class TupleExpr;
    9091class TupleIndexExpr;
    91 class MemberTupleExpr;
    9292class TupleAssignExpr;
    9393class StmtExpr;
    9494class UniqueExpr;
     95class UntypedInitExpr;
     96class InitExpr;
    9597
    9698class Type;
     
    114116class OneType;
    115117
     118class Designation;
    116119class Initializer;
    117120class SingleInit;
  • src/SynTree/TupleExpr.cc

    r9c951e3 rb1e63ac5  
    7878}
    7979
    80 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
    81         set_result( maybeClone( member->get_result() ) ); // xxx - ???
    82 }
    83 
    84 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
    85 }
    86 
    87 MemberTupleExpr::~MemberTupleExpr() {
    88         delete member;
    89         delete aggregate;
    90 }
    91 
    92 void MemberTupleExpr::print( std::ostream &os, int indent ) const {
    93         os << "Member Tuple Expression, with aggregate:" << std::endl;
    94         os << std::string( indent+2, ' ' );
    95         aggregate->print( os, indent+2 );
    96         os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
    97         os << std::string( indent+2, ' ' );
    98         member->print( os, indent+2 );
    99         Expression::print( os, indent );
    100 }
    101 
    10280TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) {
    10381        // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments
  • src/SynTree/TupleType.cc

    r9c951e3 rb1e63ac5  
    1414//
    1515
     16#include "Declaration.h"
     17#include "Initializer.h"
    1618#include "Type.h"
    1719#include "Common/utility.h"
     20#include "Parser/LinkageSpec.h"
    1821
    1922TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), types( types ) {
     23        for ( Type * t : *this ) {
     24                // xxx - this is very awkward. TupleTypes should contain objects so that members can be named, but if they don't have an initializer node then
     25                // they end up getting constructors, which end up being inserted causing problems. This happens because the object decls have to be visited so that
     26                // their types are kept in sync with the types list here. Ultimately, the types list here should be eliminated and perhaps replaced with a list-view
     27                // of the object types list, but I digress. The temporary solution here is to make a ListInit with maybeConstructed = false, that way even when the
     28                // object is visited, it is never constructed. Ultimately, a better solution might be either:
     29                // a) to separate TupleType from its declarations, into TupleDecl and Tuple{Inst?}Type, ala StructDecl and StructInstType
     30                // b) separate initializer nodes better, e.g. add a MaybeConstructed node that is replaced by genInit, rather than what currently exists in a bool
     31                members.push_back( new ObjectDecl( "" , Type::StorageClasses(), LinkageSpec::Cforall, nullptr, t->clone(), new ListInit( {}, {}, false ) ) );
     32        }
    2033}
    2134
    2235TupleType::TupleType( const TupleType& other ) : Type( other ) {
    2336        cloneAll( other.types, types );
     37        cloneAll( other.members, members );
    2438}
    2539
    2640TupleType::~TupleType() {
    2741        deleteAll( types );
     42        deleteAll( members );
    2843}
    2944
  • src/SynTree/Type.h

    r9c951e3 rb1e63ac5  
    307307private:
    308308        Type *base;
    309         unsigned int level = 0;
    310309};
    311310
     
    354353        virtual void print( std::ostream & os, int indent = 0 ) const;
    355354
    356         virtual void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const {}
     355        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
    357356  protected:
    358357        virtual std::string typeString() const = 0;
     
    501500class TupleType : public Type {
    502501  public:
    503         TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     502        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    504503        TupleType( const TupleType& );
    505504        virtual ~TupleType();
     
    508507        typedef value_type::iterator iterator;
    509508
    510         std::list<Type*>& get_types() { return types; }
     509        std::list<Type *> & get_types() { return types; }
    511510        virtual unsigned size() const { return types.size(); };
     511
     512        // For now, this is entirely synthetic -- tuple types always have unnamed members.
     513        // Eventually, we may allow named tuples, in which case members should subsume types
     514        std::list<Declaration *> & get_members() { return members; }
    512515
    513516        iterator begin() { return types.begin(); }
     
    526529        virtual void print( std::ostream & os, int indent = 0 ) const;
    527530  private:
    528         std::list<Type*> types;
     531        std::list<Type *> types;
     532        std::list<Declaration *> members;
    529533};
    530534
  • src/SynTree/TypeDecl.cc

    r9c951e3 rb1e63ac5  
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
     20TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype ) {
    2121}
    2222
    23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) {
     23TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) {
     24}
     25
     26TypeDecl::~TypeDecl() {
     27  delete init;
    2428}
    2529
     
    3438}
    3539
     40void TypeDecl::print( std::ostream &os, int indent ) const {
     41  NamedTypeDecl::print( os, indent );
     42  if ( init ) {
     43    os << std::endl << std::string( indent, ' ' ) << "with type initializer: ";
     44    init->print( os, indent + 2 );
     45  }
     46}
     47
     48
    3649std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    3750  return os << data.kind << ", " << data.isComplete;
  • src/SynTree/TypeSubstitution.cc

    r9c951e3 rb1e63ac5  
    166166                        boundVars.insert( (*tyvar )->get_name() );
    167167                } // for
    168         } // if
    169         // bind type variables from generic type instantiations
    170         std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
    171         if ( baseParameters && ! type->get_parameters().empty() ) {
    172                 for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
    173                         boundVars.insert( (*tyvar)->get_name() );
    174                 } // for
     168                // bind type variables from generic type instantiations
     169                std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
     170                if ( baseParameters && ! type->get_parameters().empty() ) {
     171                        for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
     172                                boundVars.insert( (*tyvar)->get_name() );
     173                        } // for
     174                } // if
    175175        } // if
    176176        Type *ret = Mutator::mutate( type );
  • src/SynTree/VarExprReplacer.cc

    r9c951e3 rb1e63ac5  
    1414//
    1515
     16#include "Declaration.h"
    1617#include "Expression.h"
    1718#include "VarExprReplacer.h"
    1819
    19 VarExprReplacer::VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {}
     20VarExprReplacer::VarExprReplacer( const DeclMap & declMap, bool debug ) : declMap( declMap ), debug( debug ) {}
    2021
    2122// replace variable with new node from decl map
    2223void VarExprReplacer::visit( VariableExpr * varExpr ) {
    23   // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
    24   if ( declMap.count( varExpr->get_var() ) ) {
    25     varExpr->set_var( declMap.at( varExpr->get_var() ) );
    26   }
     24        // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
     25        if ( declMap.count( varExpr->get_var() ) ) {
     26                if ( debug ) {
     27                        std::cerr << "replacing variable reference: " << (void*)varExpr->get_var() << " " << varExpr->get_var() << " with " << (void*)declMap.at( varExpr->get_var() ) << " " << declMap.at( varExpr->get_var() ) << std::endl;
     28                }
     29                varExpr->set_var( declMap.at( varExpr->get_var() ) );
     30        }
    2731}
  • src/SynTree/VarExprReplacer.h

    r9c951e3 rb1e63ac5  
    2727private:
    2828        const DeclMap & declMap;
     29  bool debug;
    2930public:
    30         VarExprReplacer( const DeclMap & declMap );
     31        VarExprReplacer( const DeclMap & declMap, bool debug = false );
    3132
    3233        // replace variable with new node from decl map
  • src/SynTree/Visitor.cc

    r9c951e3 rb1e63ac5  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 16:45:25 2017
    13 // Update Count     : 24
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:41:00 2017
     13// Update Count     : 26
    1414//
    1515
     
    6767void Visitor::visit( TypeDecl *typeDecl ) {
    6868        handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
     69        maybeAccept( typeDecl->get_init(), *this );
    6970}
    7071
     
    121122}
    122123
    123 void Visitor::visit( BranchStmt *branchStmt ) {
     124void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) {
    124125}
    125126
    126127void Visitor::visit( ReturnStmt *returnStmt ) {
    127128        maybeAccept( returnStmt->get_expr(), *this );
     129}
     130
     131void Visitor::visit( ThrowStmt * throwStmt ) {
     132        maybeAccept( throwStmt->get_expr(), *this );
     133        maybeAccept( throwStmt->get_target(), *this );
    128134}
    129135
     
    131137        maybeAccept( tryStmt->get_block(), *this );
    132138        acceptAll( tryStmt->get_catchers(), *this );
     139        maybeAccept( tryStmt->get_finally(), *this );
    133140}
    134141
    135142void Visitor::visit( CatchStmt *catchStmt ) {
    136143        maybeAccept( catchStmt->get_decl(), *this );
     144        maybeAccept( catchStmt->get_cond(), *this );
    137145        maybeAccept( catchStmt->get_body(), *this );
    138146}
     
    142150}
    143151
    144 void Visitor::visit( NullStmt *nullStmt ) {
     152void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
    145153}
    146154
     
    295303}
    296304
    297 void Visitor::visit( UntypedValofExpr *valofExpr ) {
    298         maybeAccept( valofExpr->get_result(), *this );
    299         maybeAccept( valofExpr->get_body(), *this );
    300 }
    301 
    302305void Visitor::visit( RangeExpr *rangeExpr ) {
    303306        maybeAccept( rangeExpr->get_low(), *this );
     
    318321        maybeAccept( tupleExpr->get_result(), *this );
    319322        maybeAccept( tupleExpr->get_tuple(), *this );
    320 }
    321 
    322 void Visitor::visit( MemberTupleExpr *tupleExpr ) {
    323         maybeAccept( tupleExpr->get_result(), *this );
    324         maybeAccept( tupleExpr->get_member(), *this );
    325         maybeAccept( tupleExpr->get_aggregate(), *this );
    326323}
    327324
     
    343340}
    344341
     342void Visitor::visit( UntypedInitExpr * initExpr ) {
     343        maybeAccept( initExpr->get_result(), *this );
     344        maybeAccept( initExpr->get_expr(), *this );
     345        // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
     346}
     347
     348void Visitor::visit( InitExpr * initExpr ) {
     349        maybeAccept( initExpr->get_result(), *this );
     350        maybeAccept( initExpr->get_expr(), *this );
     351        maybeAccept( initExpr->get_designation(), *this );
     352}
     353
    345354
    346355void Visitor::visit( VoidType *voidType ) {
     
    404413        acceptAll( tupleType->get_forall(), *this );
    405414        acceptAll( tupleType->get_types(), *this );
     415        acceptAll( tupleType->get_members(), *this );
    406416}
    407417
     
    433443}
    434444
     445void Visitor::visit( Designation * designation ) {
     446        acceptAll( designation->get_designators(), *this );
     447}
    435448
    436449void Visitor::visit( SingleInit *singleInit ) {
     
    439452
    440453void Visitor::visit( ListInit *listInit ) {
    441         acceptAll( listInit->get_designators(), *this );
     454        acceptAll( listInit->get_designations(), *this );
    442455        acceptAll( listInit->get_initializers(), *this );
    443456}
     
    450463
    451464
    452 void Visitor::visit( Subrange *subrange ) {}
    453 
    454 
    455 void Visitor::visit( Constant *constant ) {}
     465void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
     466
     467
     468void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
    456469// Local Variables: //
    457470// tab-width: 4 //
  • src/SynTree/Visitor.h

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May  3 08:58:00 2017
    13 // Update Count     : 10
     12// Last Modified On : Thr Jun 08 15:45:00 2017
     13// Update Count     : 11
    1414//
    1515
     
    4949        virtual void visit( BranchStmt *branchStmt );
    5050        virtual void visit( ReturnStmt *returnStmt );
     51        virtual void visit( ThrowStmt *throwStmt );
    5152        virtual void visit( TryStmt *tryStmt );
    5253        virtual void visit( CatchStmt *catchStmt );
     
    8081        virtual void visit( ConstructorExpr * ctorExpr );
    8182        virtual void visit( CompoundLiteralExpr *compLitExpr );
    82         virtual void visit( UntypedValofExpr *valofExpr );
    8383        virtual void visit( RangeExpr *rangeExpr );
    8484        virtual void visit( UntypedTupleExpr *tupleExpr );
    8585        virtual void visit( TupleExpr *tupleExpr );
    8686        virtual void visit( TupleIndexExpr *tupleExpr );
    87         virtual void visit( MemberTupleExpr *tupleExpr );
    8887        virtual void visit( TupleAssignExpr *assignExpr );
    8988        virtual void visit( StmtExpr * stmtExpr );
    9089        virtual void visit( UniqueExpr * uniqueExpr );
     90        virtual void visit( UntypedInitExpr * initExpr );
     91        virtual void visit( InitExpr * initExpr );
    9192
    9293        virtual void visit( VoidType *basicType );
     
    108109        virtual void visit( OneType *oneType );
    109110
     111        virtual void visit( Designation *designation );
    110112        virtual void visit( SingleInit *singleInit );
    111113        virtual void visit( ListInit *listInit );
  • src/SynTree/ZeroOneType.cc

    r9c951e3 rb1e63ac5  
    2020ZeroType::ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {}
    2121
    22 void ZeroType::print( std::ostream &os, int indent ) const {
     22void ZeroType::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    2323        os << "zero_t";
    2424}
     
    2828OneType::OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {}
    2929
    30 void OneType::print( std::ostream &os, int indent ) const {
     30void OneType::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    3131        os << "one_t";
    3232}
  • src/Tuples/TupleExpansion.cc

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:05:17 2017
    13 // Update Count     : 15
     12// Last Modified On : Wed Jun 21 17:35:04 2017
     13// Update Count     : 19
    1414//
    1515
     
    1818#include <cassert>
    1919#include "Tuples.h"
     20#include "Common/PassVisitor.h"
     21#include "Common/ScopedMap.h"
    2022#include "GenPoly/DeclMutator.h"
     23#include "InitTweak/GenInit.h"
     24#include "InitTweak/InitTweak.h"
     25#include "ResolvExpr/typeops.h"
     26#include "SymTab/Mangler.h"
     27#include "SynTree/Declaration.h"
     28#include "SynTree/Expression.h"
     29#include "SynTree/Initializer.h"
    2130#include "SynTree/Mutator.h"
    2231#include "SynTree/Statement.h"
    23 #include "SynTree/Declaration.h"
    2432#include "SynTree/Type.h"
    25 #include "SynTree/Expression.h"
    26 #include "SynTree/Initializer.h"
    27 #include "SymTab/Mangler.h"
    28 #include "Common/ScopedMap.h"
    29 #include "ResolvExpr/typeops.h"
    30 #include "InitTweak/GenInit.h"
    31 #include "InitTweak/InitTweak.h"
    3233
    3334namespace Tuples {
     
    8283                };
    8384
    84                 class TupleIndexExpander final : public Mutator {
    85                 public:
    86                         typedef Mutator Parent;
    87                         using Parent::mutate;
    88 
    89                         virtual Expression * mutate( TupleIndexExpr * tupleExpr ) override;
     85                class TupleIndexExpander {
     86                public:
     87                        Expression * postmutate( TupleIndexExpr * tupleExpr );
    9088                };
    9189
     
    116114                replacer.mutateDeclarationList( translationUnit );
    117115
    118                 TupleIndexExpander idxExpander;
     116                PassVisitor<TupleIndexExpander> idxExpander;
    119117                mutateAll( translationUnit, idxExpander );
    120118
     
    193191                                commaExpr->set_arg1( nullptr );
    194192                        }
    195                         BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    196                         ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) );
     193                        ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ),
     194                                                                                                        new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ) ) );
    197195                        addDeclaration( finished );
    198196                        // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N))
    199197                        // This pattern ensures that each unique expression is evaluated once, regardless of evaluation order of the generated C code.
    200                         Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant( boolType->clone(), "1" ) ) );
     198                        Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant::from_int( 1 ) ) );
    201199                        ConditionalExpr * condExpr = new ConditionalExpr( new VariableExpr( finished ), var->clone(),
    202200                                new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) );
     
    250248        }
    251249
    252         Expression * TupleIndexExpander::mutate( TupleIndexExpr * tupleExpr ) {
    253                 Expression * tuple = maybeMutate( tupleExpr->get_tuple(), *this );
     250        Expression * TupleIndexExpander::postmutate( TupleIndexExpr * tupleExpr ) {
     251                Expression * tuple = tupleExpr->get_tuple();
    254252                assert( tuple );
    255253                tupleExpr->set_tuple( nullptr );
     
    312310        Type * makeTupleType( const std::list< Expression * > & exprs ) {
    313311                // produce the TupleType which aggregates the types of the exprs
    314                 TupleType *tupleType = new TupleType( Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ) );
    315                 Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
     312                std::list< Type * > types;
     313                Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex );
    316314                for ( Expression * expr : exprs ) {
    317315                        assert( expr->get_result() );
    318316                        if ( expr->get_result()->isVoid() ) {
    319317                                // if the type of any expr is void, the type of the entire tuple is void
    320                                 delete tupleType;
    321318                                return new VoidType( Type::Qualifiers() );
    322319                        }
    323320                        Type * type = expr->get_result()->clone();
    324                         tupleType->get_types().push_back( type );
     321                        types.push_back( type );
    325322                        // the qualifiers on the tuple type are the qualifiers that exist on all component types
    326323                        qualifiers &= type->get_qualifiers();
    327324                } // for
    328325                if ( exprs.empty() ) qualifiers = Type::Qualifiers();
    329                 return tupleType;
     326                return new TupleType( qualifiers, types );
    330327        }
    331328
    332329        TypeInstType * isTtype( Type * type ) {
    333330                if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( type ) ) {
    334                         if ( inst->get_baseType()->get_kind() == TypeDecl::Ttype ) {
     331                        if ( inst->get_baseType() && inst->get_baseType()->get_kind() == TypeDecl::Ttype ) {
    335332                                return inst;
    336333                        }
     
    356353                                maybeImpure = true;
    357354                        }
    358                         virtual void visit( UntypedExpr * untypedExpr ) { maybeImpure = true; }
     355                        virtual void visit( __attribute__((unused)) UntypedExpr * untypedExpr ) { maybeImpure = true; }
    359356                        bool maybeImpure = false;
    360357                };
  • src/driver/Makefile.am

    r9c951e3 rb1e63ac5  
    1616
    1717# applies to both programs
    18 AM_CXXFLAGS = -Wall -O2
     18AM_CXXFLAGS = -Wall -O2 -g -std=c++14
    1919if BUILD_NO_LIB
    2020else
  • src/driver/Makefile.in

    r9c951e3 rb1e63ac5  
    208208
    209209# applies to both programs
    210 AM_CXXFLAGS = -Wall -O2 $(am__append_1) $(am__append_2) \
     210AM_CXXFLAGS = -Wall -O2 -g -std=c++14 $(am__append_1) $(am__append_2) \
    211211        $(am__append_3)
    212212cfa_SOURCES = cfa.cc
  • src/driver/cc1.cc

    r9c951e3 rb1e63ac5  
    8484
    8585
    86 void sigTermHandler( int signal ) {
     86void sigTermHandler( __attribute__((unused)) int signal ) {
    8787        if ( tmpfilefd != -1 ) {                                                        // RACE, file created ?
    8888                rmtmpfile();                                                                    // remove
     
    469469
    470470
    471 int main( const int argc, const char * const argv[], const char * const env[] ) {
     471int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    472472#ifdef __DEBUG_H__
    473473        for ( int i = 0; env[i] != NULL; i += 1 ) {
  • src/driver/cfa.cc

    r9c951e3 rb1e63ac5  
    271271                args[nargs] = "-ldl";
    272272                nargs += 1;
     273                args[nargs] = "-lrt";
     274                nargs += 1;
    273275                args[nargs] = "-Xlinker";
    274276                nargs += 1;
  • src/libcfa/Makefile.am

    r9c951e3 rb1e63ac5  
    1010## Author           : Peter A. Buhr
    1111## Created On       : Sun May 31 08:54:01 2015
    12 ## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sun May 14 21:04:21 2017
    14 ## Update Count     : 214
     12## Last Modified By : Andrew Beach
     13## Last Modified On : Wed Jun 28 15:36:00 2017
     14## Update Count     : 215
    1515###############################################################################
    1616
     
    4141CC = ${abs_top_srcdir}/src/driver/cfa
    4242
    43 headers = limits stdlib math iostream fstream iterator rational assert containers/pair containers/vector
     43headers = assert fstream iostream iterator limits math rational stdlib \
     44          containers/maybe containers/pair containers/result containers/vector
    4445
    4546# not all platforms support concurrency, add option do disable it
     
    5354# not all platforms support concurrency, add option do disable it
    5455if BUILD_CONCURRENCY
    55 libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
     56libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c
    5657endif
    5758
     
    6364        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    6465
     66libcfa_a-exception.o : exception.c
     67        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
     68
    6569concurrency/libcfa_d_a-invoke.o : concurrency/invoke.c
     70        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
     71
     72libcfa_d_a-exception.o : exception.c
    6673        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    6774
     
    7178libcfa_a_CFLAGS = -nodebug -O2
    7279libcfa_d_a_SOURCES = ${libsrc}
    73 libcfa_d_a_CFLAGS = -debug -O0
     80libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug
    7481
    7582stdhdr = ${shell echo stdhdr/*}
  • src/libcfa/Makefile.in

    r9c951e3 rb1e63ac5  
    4646
    4747# not all platforms support concurrency, add option do disable it
    48 @BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
     48@BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c
    4949subdir = src/libcfa
    5050DIST_COMMON = $(am__nobase_cfa_include_HEADERS_DIST) \
     
    9898libcfa_d_a_LIBADD =
    9999am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    100         libhdr/libdebug.c limits.c stdlib.c math.c iostream.c \
    101         fstream.c iterator.c rational.c assert.c containers/pair.c \
    102         containers/vector.c concurrency/coroutine.c \
    103         concurrency/thread.c concurrency/kernel.c \
    104         concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    105         concurrency/invoke.c
     100        libhdr/libdebug.c assert.c fstream.c iostream.c iterator.c \
     101        limits.c math.c rational.c stdlib.c containers/maybe.c \
     102        containers/pair.c containers/result.c containers/vector.c \
     103        concurrency/coroutine.c concurrency/thread.c \
     104        concurrency/kernel.c concurrency/monitor.c \
     105        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     106        concurrency/invoke.c concurrency/preemption.c
    106107am__dirstamp = $(am__leading_dot)dirstamp
    107108@BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
     
    109110@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-kernel.$(OBJEXT) \
    110111@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-monitor.$(OBJEXT)
    111 am__objects_2 = libcfa_d_a-limits.$(OBJEXT) \
    112         libcfa_d_a-stdlib.$(OBJEXT) libcfa_d_a-math.$(OBJEXT) \
    113         libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-fstream.$(OBJEXT) \
    114         libcfa_d_a-iterator.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
    115         libcfa_d_a-assert.$(OBJEXT) \
     112am__objects_2 = libcfa_d_a-assert.$(OBJEXT) \
     113        libcfa_d_a-fstream.$(OBJEXT) libcfa_d_a-iostream.$(OBJEXT) \
     114        libcfa_d_a-iterator.$(OBJEXT) libcfa_d_a-limits.$(OBJEXT) \
     115        libcfa_d_a-math.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
     116        libcfa_d_a-stdlib.$(OBJEXT) \
     117        containers/libcfa_d_a-maybe.$(OBJEXT) \
    116118        containers/libcfa_d_a-pair.$(OBJEXT) \
     119        containers/libcfa_d_a-result.$(OBJEXT) \
    117120        containers/libcfa_d_a-vector.$(OBJEXT) $(am__objects_1)
    118121@BUILD_CONCURRENCY_TRUE@am__objects_3 = concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
    119 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-invoke.$(OBJEXT)
     122@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-alarm.$(OBJEXT) \
     123@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-invoke.$(OBJEXT) \
     124@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-preemption.$(OBJEXT)
    120125am__objects_4 = libcfa_d_a-libcfa-prelude.$(OBJEXT) \
    121126        libcfa_d_a-interpose.$(OBJEXT) \
     
    127132libcfa_a_LIBADD =
    128133am__libcfa_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    129         libhdr/libdebug.c limits.c stdlib.c math.c iostream.c \
    130         fstream.c iterator.c rational.c assert.c containers/pair.c \
    131         containers/vector.c concurrency/coroutine.c \
    132         concurrency/thread.c concurrency/kernel.c \
    133         concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    134         concurrency/invoke.c
     134        libhdr/libdebug.c assert.c fstream.c iostream.c iterator.c \
     135        limits.c math.c rational.c stdlib.c containers/maybe.c \
     136        containers/pair.c containers/result.c containers/vector.c \
     137        concurrency/coroutine.c concurrency/thread.c \
     138        concurrency/kernel.c concurrency/monitor.c \
     139        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     140        concurrency/invoke.c concurrency/preemption.c
    135141@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    136142@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
    137143@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-kernel.$(OBJEXT) \
    138144@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-monitor.$(OBJEXT)
    139 am__objects_6 = libcfa_a-limits.$(OBJEXT) libcfa_a-stdlib.$(OBJEXT) \
    140         libcfa_a-math.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \
    141         libcfa_a-fstream.$(OBJEXT) libcfa_a-iterator.$(OBJEXT) \
    142         libcfa_a-rational.$(OBJEXT) libcfa_a-assert.$(OBJEXT) \
     145am__objects_6 = libcfa_a-assert.$(OBJEXT) libcfa_a-fstream.$(OBJEXT) \
     146        libcfa_a-iostream.$(OBJEXT) libcfa_a-iterator.$(OBJEXT) \
     147        libcfa_a-limits.$(OBJEXT) libcfa_a-math.$(OBJEXT) \
     148        libcfa_a-rational.$(OBJEXT) libcfa_a-stdlib.$(OBJEXT) \
     149        containers/libcfa_a-maybe.$(OBJEXT) \
    143150        containers/libcfa_a-pair.$(OBJEXT) \
     151        containers/libcfa_a-result.$(OBJEXT) \
    144152        containers/libcfa_a-vector.$(OBJEXT) $(am__objects_5)
    145153@BUILD_CONCURRENCY_TRUE@am__objects_7 = concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
    146 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-invoke.$(OBJEXT)
     154@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-alarm.$(OBJEXT) \
     155@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-invoke.$(OBJEXT) \
     156@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-preemption.$(OBJEXT)
    147157am__objects_8 = libcfa_a-libcfa-prelude.$(OBJEXT) \
    148158        libcfa_a-interpose.$(OBJEXT) \
     
    179189DIST_SOURCES = $(am__libcfa_d_a_SOURCES_DIST) \
    180190        $(am__libcfa_a_SOURCES_DIST)
    181 am__nobase_cfa_include_HEADERS_DIST = limits stdlib math iostream \
    182         fstream iterator rational assert containers/pair \
    183         containers/vector concurrency/coroutine concurrency/thread \
    184         concurrency/kernel concurrency/monitor ${shell echo stdhdr/*} \
    185         gmp concurrency/invoke.h
     191am__nobase_cfa_include_HEADERS_DIST = assert fstream iostream iterator \
     192        limits math rational stdlib containers/maybe containers/pair \
     193        containers/result containers/vector concurrency/coroutine \
     194        concurrency/thread concurrency/kernel concurrency/monitor \
     195        ${shell echo stdhdr/*} gmp concurrency/invoke.h
    186196HEADERS = $(nobase_cfa_include_HEADERS)
    187197ETAGS = etags
     
    313323EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -I${abs_top_srcdir}/src/libcfa/libhdr -imacros libcfa-prelude.c @CFA_FLAGS@
    314324AM_CCASFLAGS = @CFA_FLAGS@
    315 headers = limits stdlib math iostream fstream iterator rational assert \
    316         containers/pair containers/vector $(am__append_3)
     325headers = assert fstream iostream iterator limits math rational stdlib \
     326        containers/maybe containers/pair containers/result \
     327        containers/vector $(am__append_3)
    317328libobjs = ${headers:=.o}
    318329libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \
     
    321332libcfa_a_CFLAGS = -nodebug -O2
    322333libcfa_d_a_SOURCES = ${libsrc}
    323 libcfa_d_a_CFLAGS = -debug -O0
     334libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug
    324335stdhdr = ${shell echo stdhdr/*}
    325336cfa_includedir = $(CFA_INCDIR)
     
    404415        @$(MKDIR_P) containers/$(DEPDIR)
    405416        @: > containers/$(DEPDIR)/$(am__dirstamp)
     417containers/libcfa_d_a-maybe.$(OBJEXT): containers/$(am__dirstamp) \
     418        containers/$(DEPDIR)/$(am__dirstamp)
    406419containers/libcfa_d_a-pair.$(OBJEXT): containers/$(am__dirstamp) \
     420        containers/$(DEPDIR)/$(am__dirstamp)
     421containers/libcfa_d_a-result.$(OBJEXT): containers/$(am__dirstamp) \
    407422        containers/$(DEPDIR)/$(am__dirstamp)
    408423containers/libcfa_d_a-vector.$(OBJEXT): containers/$(am__dirstamp) \
     
    426441        concurrency/$(am__dirstamp) \
    427442        concurrency/$(DEPDIR)/$(am__dirstamp)
     443concurrency/libcfa_d_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \
     444        concurrency/$(DEPDIR)/$(am__dirstamp)
    428445concurrency/libcfa_d_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
     446        concurrency/$(DEPDIR)/$(am__dirstamp)
     447concurrency/libcfa_d_a-preemption.$(OBJEXT):  \
     448        concurrency/$(am__dirstamp) \
    429449        concurrency/$(DEPDIR)/$(am__dirstamp)
    430450libcfa-d.a: $(libcfa_d_a_OBJECTS) $(libcfa_d_a_DEPENDENCIES) $(EXTRA_libcfa_d_a_DEPENDENCIES)
     
    434454libhdr/libcfa_a-libdebug.$(OBJEXT): libhdr/$(am__dirstamp) \
    435455        libhdr/$(DEPDIR)/$(am__dirstamp)
     456containers/libcfa_a-maybe.$(OBJEXT): containers/$(am__dirstamp) \
     457        containers/$(DEPDIR)/$(am__dirstamp)
    436458containers/libcfa_a-pair.$(OBJEXT): containers/$(am__dirstamp) \
     459        containers/$(DEPDIR)/$(am__dirstamp)
     460containers/libcfa_a-result.$(OBJEXT): containers/$(am__dirstamp) \
    437461        containers/$(DEPDIR)/$(am__dirstamp)
    438462containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \
     
    446470concurrency/libcfa_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \
    447471        concurrency/$(DEPDIR)/$(am__dirstamp)
     472concurrency/libcfa_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \
     473        concurrency/$(DEPDIR)/$(am__dirstamp)
    448474concurrency/libcfa_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
     475        concurrency/$(DEPDIR)/$(am__dirstamp)
     476concurrency/libcfa_a-preemption.$(OBJEXT):  \
     477        concurrency/$(am__dirstamp) \
    449478        concurrency/$(DEPDIR)/$(am__dirstamp)
    450479libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES)
     
    456485        -rm -f *.$(OBJEXT)
    457486        -rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT)
     487        -rm -f concurrency/libcfa_a-alarm.$(OBJEXT)
    458488        -rm -f concurrency/libcfa_a-coroutine.$(OBJEXT)
    459489        -rm -f concurrency/libcfa_a-invoke.$(OBJEXT)
    460490        -rm -f concurrency/libcfa_a-kernel.$(OBJEXT)
    461491        -rm -f concurrency/libcfa_a-monitor.$(OBJEXT)
     492        -rm -f concurrency/libcfa_a-preemption.$(OBJEXT)
    462493        -rm -f concurrency/libcfa_a-thread.$(OBJEXT)
     494        -rm -f concurrency/libcfa_d_a-alarm.$(OBJEXT)
    463495        -rm -f concurrency/libcfa_d_a-coroutine.$(OBJEXT)
    464496        -rm -f concurrency/libcfa_d_a-invoke.$(OBJEXT)
    465497        -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT)
    466498        -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT)
     499        -rm -f concurrency/libcfa_d_a-preemption.$(OBJEXT)
    467500        -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT)
     501        -rm -f containers/libcfa_a-maybe.$(OBJEXT)
    468502        -rm -f containers/libcfa_a-pair.$(OBJEXT)
     503        -rm -f containers/libcfa_a-result.$(OBJEXT)
    469504        -rm -f containers/libcfa_a-vector.$(OBJEXT)
     505        -rm -f containers/libcfa_d_a-maybe.$(OBJEXT)
    470506        -rm -f containers/libcfa_d_a-pair.$(OBJEXT)
     507        -rm -f containers/libcfa_d_a-result.$(OBJEXT)
    471508        -rm -f containers/libcfa_d_a-vector.$(OBJEXT)
    472509        -rm -f libhdr/libcfa_a-libdebug.$(OBJEXT)
     
    497534@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@
    498535@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@
     536@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-alarm.Po@am__quote@
    499537@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@
    500538@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@
    501539@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@
    502540@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@
     541@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-preemption.Po@am__quote@
    503542@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@
     543@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-alarm.Po@am__quote@
    504544@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po@am__quote@
    505545@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-invoke.Po@am__quote@
    506546@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@
    507547@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@
     548@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po@am__quote@
    508549@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@
     550@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-maybe.Po@am__quote@
    509551@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-pair.Po@am__quote@
     552@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-result.Po@am__quote@
    510553@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@
     554@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-maybe.Po@am__quote@
    511555@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-pair.Po@am__quote@
     556@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-result.Po@am__quote@
    512557@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@
    513558@AMDEP_TRUE@@am__include@ @am__quote@libhdr/$(DEPDIR)/libcfa_a-libdebug.Po@am__quote@
     
    581626@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_d_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
    582627
     628libcfa_d_a-assert.o: assert.c
     629@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     630@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
     631@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.o' libtool=no @AMDEPBACKSLASH@
     632@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     633@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     634
     635libcfa_d_a-assert.obj: assert.c
     636@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     637@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
     638@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.obj' libtool=no @AMDEPBACKSLASH@
     639@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     640@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     641
     642libcfa_d_a-fstream.o: fstream.c
     643@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-fstream.Tpo -c -o libcfa_d_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     644@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-fstream.Tpo $(DEPDIR)/libcfa_d_a-fstream.Po
     645@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_d_a-fstream.o' libtool=no @AMDEPBACKSLASH@
     646@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     647@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     648
     649libcfa_d_a-fstream.obj: fstream.c
     650@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-fstream.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-fstream.Tpo -c -o libcfa_d_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
     651@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-fstream.Tpo $(DEPDIR)/libcfa_d_a-fstream.Po
     652@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_d_a-fstream.obj' libtool=no @AMDEPBACKSLASH@
     653@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     654@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
     655
     656libcfa_d_a-iostream.o: iostream.c
     657@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iostream.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-iostream.Tpo -c -o libcfa_d_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
     658@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iostream.Tpo $(DEPDIR)/libcfa_d_a-iostream.Po
     659@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_d_a-iostream.o' libtool=no @AMDEPBACKSLASH@
     660@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     661@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
     662
     663libcfa_d_a-iostream.obj: iostream.c
     664@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iostream.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-iostream.Tpo -c -o libcfa_d_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
     665@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iostream.Tpo $(DEPDIR)/libcfa_d_a-iostream.Po
     666@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_d_a-iostream.obj' libtool=no @AMDEPBACKSLASH@
     667@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     668@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
     669
     670libcfa_d_a-iterator.o: iterator.c
     671@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iterator.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-iterator.Tpo -c -o libcfa_d_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
     672@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iterator.Tpo $(DEPDIR)/libcfa_d_a-iterator.Po
     673@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_d_a-iterator.o' libtool=no @AMDEPBACKSLASH@
     674@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     675@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
     676
     677libcfa_d_a-iterator.obj: iterator.c
     678@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iterator.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-iterator.Tpo -c -o libcfa_d_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
     679@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iterator.Tpo $(DEPDIR)/libcfa_d_a-iterator.Po
     680@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_d_a-iterator.obj' libtool=no @AMDEPBACKSLASH@
     681@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     682@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
     683
    583684libcfa_d_a-limits.o: limits.c
    584685@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-limits.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-limits.Tpo -c -o libcfa_d_a-limits.o `test -f 'limits.c' || echo '$(srcdir)/'`limits.c
     
    595696@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
    596697
     698libcfa_d_a-math.o: math.c
     699@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     700@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
     701@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.o' libtool=no @AMDEPBACKSLASH@
     702@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     703@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     704
     705libcfa_d_a-math.obj: math.c
     706@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     707@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
     708@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.obj' libtool=no @AMDEPBACKSLASH@
     709@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     710@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     711
     712libcfa_d_a-rational.o: rational.c
     713@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-rational.Tpo -c -o libcfa_d_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     714@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-rational.Tpo $(DEPDIR)/libcfa_d_a-rational.Po
     715@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_d_a-rational.o' libtool=no @AMDEPBACKSLASH@
     716@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     717@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     718
     719libcfa_d_a-rational.obj: rational.c
     720@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-rational.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-rational.Tpo -c -o libcfa_d_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
     721@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-rational.Tpo $(DEPDIR)/libcfa_d_a-rational.Po
     722@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_d_a-rational.obj' libtool=no @AMDEPBACKSLASH@
     723@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     724@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
     725
    597726libcfa_d_a-stdlib.o: stdlib.c
    598727@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-stdlib.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-stdlib.Tpo -c -o libcfa_d_a-stdlib.o `test -f 'stdlib.c' || echo '$(srcdir)/'`stdlib.c
     
    609738@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
    610739
    611 libcfa_d_a-math.o: math.c
    612 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
    613 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
    614 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.o' libtool=no @AMDEPBACKSLASH@
    615 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    616 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
    617 
    618 libcfa_d_a-math.obj: math.c
    619 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
    620 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
    621 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.obj' libtool=no @AMDEPBACKSLASH@
    622 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    623 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
    624 
    625 libcfa_d_a-iostream.o: iostream.c
    626 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iostream.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-iostream.Tpo -c -o libcfa_d_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
    627 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iostream.Tpo $(DEPDIR)/libcfa_d_a-iostream.Po
    628 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_d_a-iostream.o' libtool=no @AMDEPBACKSLASH@
    629 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    630 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
    631 
    632 libcfa_d_a-iostream.obj: iostream.c
    633 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iostream.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-iostream.Tpo -c -o libcfa_d_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
    634 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iostream.Tpo $(DEPDIR)/libcfa_d_a-iostream.Po
    635 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_d_a-iostream.obj' libtool=no @AMDEPBACKSLASH@
    636 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    637 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
    638 
    639 libcfa_d_a-fstream.o: fstream.c
    640 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-fstream.Tpo -c -o libcfa_d_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
    641 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-fstream.Tpo $(DEPDIR)/libcfa_d_a-fstream.Po
    642 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_d_a-fstream.o' libtool=no @AMDEPBACKSLASH@
    643 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    644 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
    645 
    646 libcfa_d_a-fstream.obj: fstream.c
    647 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-fstream.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-fstream.Tpo -c -o libcfa_d_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
    648 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-fstream.Tpo $(DEPDIR)/libcfa_d_a-fstream.Po
    649 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_d_a-fstream.obj' libtool=no @AMDEPBACKSLASH@
    650 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    651 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
    652 
    653 libcfa_d_a-iterator.o: iterator.c
    654 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iterator.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-iterator.Tpo -c -o libcfa_d_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
    655 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iterator.Tpo $(DEPDIR)/libcfa_d_a-iterator.Po
    656 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_d_a-iterator.o' libtool=no @AMDEPBACKSLASH@
    657 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    658 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
    659 
    660 libcfa_d_a-iterator.obj: iterator.c
    661 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-iterator.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-iterator.Tpo -c -o libcfa_d_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
    662 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-iterator.Tpo $(DEPDIR)/libcfa_d_a-iterator.Po
    663 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_d_a-iterator.obj' libtool=no @AMDEPBACKSLASH@
    664 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    665 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
    666 
    667 libcfa_d_a-rational.o: rational.c
    668 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-rational.Tpo -c -o libcfa_d_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
    669 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-rational.Tpo $(DEPDIR)/libcfa_d_a-rational.Po
    670 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_d_a-rational.o' libtool=no @AMDEPBACKSLASH@
    671 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    672 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
    673 
    674 libcfa_d_a-rational.obj: rational.c
    675 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-rational.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-rational.Tpo -c -o libcfa_d_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
    676 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-rational.Tpo $(DEPDIR)/libcfa_d_a-rational.Po
    677 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_d_a-rational.obj' libtool=no @AMDEPBACKSLASH@
    678 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    679 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
    680 
    681 libcfa_d_a-assert.o: assert.c
    682 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    683 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
    684 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.o' libtool=no @AMDEPBACKSLASH@
    685 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    686 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    687 
    688 libcfa_d_a-assert.obj: assert.c
    689 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    690 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
    691 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.obj' libtool=no @AMDEPBACKSLASH@
    692 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    693 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     740containers/libcfa_d_a-maybe.o: containers/maybe.c
     741@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-maybe.o -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-maybe.Tpo -c -o containers/libcfa_d_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
     742@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_d_a-maybe.Tpo containers/$(DEPDIR)/libcfa_d_a-maybe.Po
     743@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_d_a-maybe.o' libtool=no @AMDEPBACKSLASH@
     744@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     745@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
     746
     747containers/libcfa_d_a-maybe.obj: containers/maybe.c
     748@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-maybe.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-maybe.Tpo -c -o containers/libcfa_d_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
     749@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_d_a-maybe.Tpo containers/$(DEPDIR)/libcfa_d_a-maybe.Po
     750@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_d_a-maybe.obj' libtool=no @AMDEPBACKSLASH@
     751@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     752@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
    694753
    695754containers/libcfa_d_a-pair.o: containers/pair.c
     
    707766@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-pair.obj `if test -f 'containers/pair.c'; then $(CYGPATH_W) 'containers/pair.c'; else $(CYGPATH_W) '$(srcdir)/containers/pair.c'; fi`
    708767
     768containers/libcfa_d_a-result.o: containers/result.c
     769@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-result.o -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-result.Tpo -c -o containers/libcfa_d_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
     770@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_d_a-result.Tpo containers/$(DEPDIR)/libcfa_d_a-result.Po
     771@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/result.c' object='containers/libcfa_d_a-result.o' libtool=no @AMDEPBACKSLASH@
     772@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     773@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
     774
     775containers/libcfa_d_a-result.obj: containers/result.c
     776@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-result.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-result.Tpo -c -o containers/libcfa_d_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
     777@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_d_a-result.Tpo containers/$(DEPDIR)/libcfa_d_a-result.Po
     778@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/result.c' object='containers/libcfa_d_a-result.obj' libtool=no @AMDEPBACKSLASH@
     779@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     780@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
     781
    709782containers/libcfa_d_a-vector.o: containers/vector.c
    710783@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-vector.o -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-vector.Tpo -c -o containers/libcfa_d_a-vector.o `test -f 'containers/vector.c' || echo '$(srcdir)/'`containers/vector.c
     
    777850@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    778851
     852concurrency/libcfa_d_a-alarm.o: concurrency/alarm.c
     853@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo -c -o concurrency/libcfa_d_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     854@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_d_a-alarm.Po
     855@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_d_a-alarm.o' libtool=no @AMDEPBACKSLASH@
     856@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     857@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     858
     859concurrency/libcfa_d_a-alarm.obj: concurrency/alarm.c
     860@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-alarm.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo -c -o concurrency/libcfa_d_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
     861@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_d_a-alarm.Po
     862@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_d_a-alarm.obj' libtool=no @AMDEPBACKSLASH@
     863@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     864@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
     865
    779866concurrency/libcfa_d_a-invoke.obj: concurrency/invoke.c
    780867@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-invoke.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-invoke.Tpo -c -o concurrency/libcfa_d_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
     
    784871@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
    785872
     873concurrency/libcfa_d_a-preemption.o: concurrency/preemption.c
     874@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-preemption.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo -c -o concurrency/libcfa_d_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     875@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po
     876@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_d_a-preemption.o' libtool=no @AMDEPBACKSLASH@
     877@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     878@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     879
     880concurrency/libcfa_d_a-preemption.obj: concurrency/preemption.c
     881@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-preemption.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo -c -o concurrency/libcfa_d_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
     882@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po
     883@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_d_a-preemption.obj' libtool=no @AMDEPBACKSLASH@
     884@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     885@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
     886
    786887libcfa_a-libcfa-prelude.obj: libcfa-prelude.c
    787888@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-libcfa-prelude.obj -MD -MP -MF $(DEPDIR)/libcfa_a-libcfa-prelude.Tpo -c -o libcfa_a-libcfa-prelude.obj `if test -f 'libcfa-prelude.c'; then $(CYGPATH_W) 'libcfa-prelude.c'; else $(CYGPATH_W) '$(srcdir)/libcfa-prelude.c'; fi`
     
    819920@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
    820921
     922libcfa_a-assert.o: assert.c
     923@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     924@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
     925@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.o' libtool=no @AMDEPBACKSLASH@
     926@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     927@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     928
     929libcfa_a-assert.obj: assert.c
     930@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     931@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
     932@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.obj' libtool=no @AMDEPBACKSLASH@
     933@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     934@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     935
     936libcfa_a-fstream.o: fstream.c
     937@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     938@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
     939@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.o' libtool=no @AMDEPBACKSLASH@
     940@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     941@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     942
     943libcfa_a-fstream.obj: fstream.c
     944@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
     945@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
     946@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.obj' libtool=no @AMDEPBACKSLASH@
     947@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     948@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
     949
     950libcfa_a-iostream.o: iostream.c
     951@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.o -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
     952@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
     953@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.o' libtool=no @AMDEPBACKSLASH@
     954@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     955@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
     956
     957libcfa_a-iostream.obj: iostream.c
     958@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
     959@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
     960@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.obj' libtool=no @AMDEPBACKSLASH@
     961@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     962@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
     963
     964libcfa_a-iterator.o: iterator.c
     965@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.o -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
     966@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
     967@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.o' libtool=no @AMDEPBACKSLASH@
     968@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     969@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
     970
     971libcfa_a-iterator.obj: iterator.c
     972@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
     973@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
     974@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.obj' libtool=no @AMDEPBACKSLASH@
     975@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     976@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
     977
    821978libcfa_a-limits.o: limits.c
    822979@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-limits.o -MD -MP -MF $(DEPDIR)/libcfa_a-limits.Tpo -c -o libcfa_a-limits.o `test -f 'limits.c' || echo '$(srcdir)/'`limits.c
     
    833990@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
    834991
     992libcfa_a-math.o: math.c
     993@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     994@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
     995@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.o' libtool=no @AMDEPBACKSLASH@
     996@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     997@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     998
     999libcfa_a-math.obj: math.c
     1000@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     1001@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
     1002@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.obj' libtool=no @AMDEPBACKSLASH@
     1003@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1004@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     1005
     1006libcfa_a-rational.o: rational.c
     1007@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     1008@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
     1009@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_a-rational.o' libtool=no @AMDEPBACKSLASH@
     1010@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1011@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     1012
     1013libcfa_a-rational.obj: rational.c
     1014@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.obj -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
     1015@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
     1016@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_a-rational.obj' libtool=no @AMDEPBACKSLASH@
     1017@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1018@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
     1019
    8351020libcfa_a-stdlib.o: stdlib.c
    8361021@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-stdlib.o -MD -MP -MF $(DEPDIR)/libcfa_a-stdlib.Tpo -c -o libcfa_a-stdlib.o `test -f 'stdlib.c' || echo '$(srcdir)/'`stdlib.c
     
    8471032@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
    8481033
    849 libcfa_a-math.o: math.c
    850 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
    851 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
    852 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.o' libtool=no @AMDEPBACKSLASH@
    853 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    854 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
    855 
    856 libcfa_a-math.obj: math.c
    857 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
    858 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
    859 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.obj' libtool=no @AMDEPBACKSLASH@
    860 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    861 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
    862 
    863 libcfa_a-iostream.o: iostream.c
    864 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.o -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
    865 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
    866 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.o' libtool=no @AMDEPBACKSLASH@
    867 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    868 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
    869 
    870 libcfa_a-iostream.obj: iostream.c
    871 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
    872 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
    873 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.obj' libtool=no @AMDEPBACKSLASH@
    874 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    875 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
    876 
    877 libcfa_a-fstream.o: fstream.c
    878 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
    879 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
    880 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.o' libtool=no @AMDEPBACKSLASH@
    881 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    882 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
    883 
    884 libcfa_a-fstream.obj: fstream.c
    885 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
    886 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
    887 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.obj' libtool=no @AMDEPBACKSLASH@
    888 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    889 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
    890 
    891 libcfa_a-iterator.o: iterator.c
    892 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.o -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
    893 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
    894 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.o' libtool=no @AMDEPBACKSLASH@
    895 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    896 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
    897 
    898 libcfa_a-iterator.obj: iterator.c
    899 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
    900 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
    901 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.obj' libtool=no @AMDEPBACKSLASH@
    902 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    903 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
    904 
    905 libcfa_a-rational.o: rational.c
    906 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
    907 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
    908 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_a-rational.o' libtool=no @AMDEPBACKSLASH@
    909 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    910 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
    911 
    912 libcfa_a-rational.obj: rational.c
    913 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.obj -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
    914 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
    915 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='rational.c' object='libcfa_a-rational.obj' libtool=no @AMDEPBACKSLASH@
    916 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    917 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
    918 
    919 libcfa_a-assert.o: assert.c
    920 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    921 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
    922 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.o' libtool=no @AMDEPBACKSLASH@
    923 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    924 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    925 
    926 libcfa_a-assert.obj: assert.c
    927 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    928 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
    929 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.obj' libtool=no @AMDEPBACKSLASH@
    930 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    931 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     1034containers/libcfa_a-maybe.o: containers/maybe.c
     1035@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-maybe.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-maybe.Tpo -c -o containers/libcfa_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
     1036@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-maybe.Tpo containers/$(DEPDIR)/libcfa_a-maybe.Po
     1037@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_a-maybe.o' libtool=no @AMDEPBACKSLASH@
     1038@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1039@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
     1040
     1041containers/libcfa_a-maybe.obj: containers/maybe.c
     1042@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-maybe.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-maybe.Tpo -c -o containers/libcfa_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
     1043@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-maybe.Tpo containers/$(DEPDIR)/libcfa_a-maybe.Po
     1044@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_a-maybe.obj' libtool=no @AMDEPBACKSLASH@
     1045@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1046@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
    9321047
    9331048containers/libcfa_a-pair.o: containers/pair.c
     
    9451060@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-pair.obj `if test -f 'containers/pair.c'; then $(CYGPATH_W) 'containers/pair.c'; else $(CYGPATH_W) '$(srcdir)/containers/pair.c'; fi`
    9461061
     1062containers/libcfa_a-result.o: containers/result.c
     1063@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-result.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-result.Tpo -c -o containers/libcfa_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
     1064@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-result.Tpo containers/$(DEPDIR)/libcfa_a-result.Po
     1065@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/result.c' object='containers/libcfa_a-result.o' libtool=no @AMDEPBACKSLASH@
     1066@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1067@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
     1068
     1069containers/libcfa_a-result.obj: containers/result.c
     1070@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-result.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-result.Tpo -c -o containers/libcfa_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
     1071@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-result.Tpo containers/$(DEPDIR)/libcfa_a-result.Po
     1072@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='containers/result.c' object='containers/libcfa_a-result.obj' libtool=no @AMDEPBACKSLASH@
     1073@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1074@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
     1075
    9471076containers/libcfa_a-vector.o: containers/vector.c
    9481077@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-vector.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-vector.Tpo -c -o containers/libcfa_a-vector.o `test -f 'containers/vector.c' || echo '$(srcdir)/'`containers/vector.c
     
    10151144@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    10161145
     1146concurrency/libcfa_a-alarm.o: concurrency/alarm.c
     1147@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo -c -o concurrency/libcfa_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     1148@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_a-alarm.Po
     1149@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_a-alarm.o' libtool=no @AMDEPBACKSLASH@
     1150@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1151@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     1152
     1153concurrency/libcfa_a-alarm.obj: concurrency/alarm.c
     1154@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-alarm.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo -c -o concurrency/libcfa_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
     1155@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_a-alarm.Po
     1156@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_a-alarm.obj' libtool=no @AMDEPBACKSLASH@
     1157@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1158@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
     1159
    10171160concurrency/libcfa_a-invoke.obj: concurrency/invoke.c
    10181161@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-invoke.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-invoke.Tpo -c -o concurrency/libcfa_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
     
    10211164@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    10221165@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
     1166
     1167concurrency/libcfa_a-preemption.o: concurrency/preemption.c
     1168@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     1169@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
     1170@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.o' libtool=no @AMDEPBACKSLASH@
     1171@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1172@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     1173
     1174concurrency/libcfa_a-preemption.obj: concurrency/preemption.c
     1175@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
     1176@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
     1177@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.obj' libtool=no @AMDEPBACKSLASH@
     1178@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1179@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
    10231180install-nobase_cfa_includeHEADERS: $(nobase_cfa_include_HEADERS)
    10241181        @$(NORMAL_INSTALL)
     
    12711428        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    12721429
     1430libcfa_a-exception.o : exception.c
     1431        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
     1432
    12731433concurrency/libcfa_d_a-invoke.o : concurrency/invoke.c
     1434        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
     1435
     1436libcfa_d_a-exception.o : exception.c
    12741437        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    12751438
  • src/libcfa/concurrency/coroutine

    r9c951e3 rb1e63ac5  
    7171// Suspend implementation inlined for performance
    7272static inline void suspend() {
    73       coroutine_desc * src = this_coroutine();          // optimization
     73        coroutine_desc * src = this_coroutine();                // optimization
    7474
    7575        assertf( src->last != 0,
     
    9191        coroutine_desc * dst = get_coroutine(cor);
    9292
    93       if( unlikely(!dst->stack.base) ) {
     93        if( unlikely(!dst->stack.base) ) {
    9494                create_stack(&dst->stack, dst->stack.size);
    9595                CtxStart(cor, CtxInvokeCoroutine);
    9696        }
    9797
    98       // not resuming self ?
     98        // not resuming self ?
    9999        if ( src != dst ) {
    100100                assertf( dst->state != Halted ,
     
    103103                        src->name, src, dst->name, dst );
    104104
    105             // set last resumer
     105                // set last resumer
    106106                dst->last = src;
    107107        } // if
    108108
    109       // always done for performance testing
     109        // always done for performance testing
    110110        CoroutineCtxSwitch( src, dst );
    111111}
     
    114114        coroutine_desc * src = this_coroutine();                // optimization
    115115
    116       // not resuming self ?
     116        // not resuming self ?
    117117        if ( src != dst ) {
    118118                assertf( dst->state != Halted ,
     
    121121                        src->name, src, dst->name, dst );
    122122
    123             // set last resumer
     123                // set last resumer
    124124                dst->last = src;
    125125        } // if
    126126
    127       // always done for performance testing
     127        // always done for performance testing
    128128        CoroutineCtxSwitch( src, dst );
    129129}
  • src/libcfa/concurrency/kernel

    r9c951e3 rb1e63ac5  
    2828//-----------------------------------------------------------------------------
    2929// Locks
     30bool try_lock( spinlock * );
    3031void lock( spinlock * );
    3132void unlock( spinlock * );
     
    8586
    8687        struct FinishAction finish;
     88
     89        struct alarm_node_t * preemption_alarm;
     90        unsigned int preemption;
     91
     92        unsigned short disable_preempt_count;
     93
     94        bool pending_preemption;
    8795};
    8896
     
    94102
    95103// Local Variables: //
    96 // mode: c //
    97 // tab-width: 4 //
     104// mode: CFA //
     105// tab-width: 6 //
    98106// End: //
  • src/libcfa/concurrency/kernel.c

    r9c951e3 rb1e63ac5  
    3636//CFA Includes
    3737#include "libhdr.h"
     38#include "preemption.h"
    3839
    3940//Private includes
     
    4748KERNEL_STORAGE(processorCtx_t, systemProcessorCtx);
    4849KERNEL_STORAGE(cluster, systemCluster);
    49 KERNEL_STORAGE(processor, systemProcessor);
     50KERNEL_STORAGE(system_proc_t, systemProcessor);
    5051KERNEL_STORAGE(thread_desc, mainThread);
    5152KERNEL_STORAGE(machine_context_t, mainThread_context);
    5253
    5354cluster * systemCluster;
    54 processor * systemProcessor;
     55system_proc_t * systemProcessor;
    5556thread_desc * mainThread;
    5657
     
    118119// Processor coroutine
    119120void ?{}(processorCtx_t * this, processor * proc) {
    120         (&this->__cor){};
     121        (&this->__cor){ "Processor" };
    121122        this->proc = proc;
    122123        proc->runner = this;
     
    139140        (&this->terminated){};
    140141        this->is_terminated = false;
     142        this->preemption_alarm = NULL;
     143        this->preemption = default_preemption();
     144        this->disable_preempt_count = 1;                //Start with interrupts disabled
     145        this->pending_preemption = false;
    141146
    142147        start( this );
     
    149154        (&this->terminated){};
    150155        this->is_terminated = false;
     156        this->disable_preempt_count = 0;
     157        this->pending_preemption = false;
    151158
    152159        this->runner = runner;
    153160        LIB_DEBUG_PRINT_SAFE("Kernel : constructing processor context %p\n", runner);
    154161        runner{ this };
     162}
     163
     164void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) {
     165        (&this->alarms){};
     166        (&this->alarm_lock){};
     167        this->pending_alarm = false;
     168
     169        (&this->proc){ cltr, runner };
    155170}
    156171
     
    178193void main(processorCtx_t * runner) {
    179194        processor * this = runner->proc;
     195
    180196        LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this);
    181197
    182         thread_desc * readyThread = NULL;
    183         for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    184198        {
    185                 readyThread = nextThread( this->cltr );
    186 
    187                 if(readyThread)
     199                // Setup preemption data
     200                preemption_scope scope = { this };
     201
     202                LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
     203
     204                thread_desc * readyThread = NULL;
     205                for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    188206                {
    189                         runThread(this, readyThread);
    190 
    191                         //Some actions need to be taken from the kernel
    192                         finishRunning(this);
    193 
    194                         spin_count = 0;
    195                 }
    196                 else
    197                 {
    198                         spin(this, &spin_count);
    199                 }               
    200         }
    201 
    202         LIB_DEBUG_PRINT_SAFE("Kernel : core %p unlocking thread\n", this);
     207                        readyThread = nextThread( this->cltr );
     208
     209                        if(readyThread)
     210                        {
     211                                runThread(this, readyThread);
     212
     213                                //Some actions need to be taken from the kernel
     214                                finishRunning(this);
     215
     216                                spin_count = 0;
     217                        }
     218                        else
     219                        {
     220                                spin(this, &spin_count);
     221                        }
     222                }
     223
     224                LIB_DEBUG_PRINT_SAFE("Kernel : core %p stopping\n", this);
     225        }
     226
    203227        signal( &this->terminated );
    204228        LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
     
    287311        // appropriate stack.
    288312        proc_cor_storage.__cor.state = Active;
    289       main( &proc_cor_storage );
    290       proc_cor_storage.__cor.state = Halted;
     313        main( &proc_cor_storage );
     314        proc_cor_storage.__cor.state = Halted;
    291315
    292316        // Main routine of the core returned, the core is now fully terminated
     
    299323        LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
    300324       
    301         // pthread_attr_t attributes;
    302         // pthread_attr_init( &attributes );
    303 
    304325        pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
    305 
    306         // pthread_attr_destroy( &attributes );
    307326
    308327        LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);       
     
    314333        if( !thrd ) return;
    315334
    316         assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
     335        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    317336       
    318         lock( &systemProcessor->cltr->lock );
    319         append( &systemProcessor->cltr->ready_queue, thrd );
    320         unlock( &systemProcessor->cltr->lock );
     337        lock( &systemProcessor->proc.cltr->lock );
     338        append( &systemProcessor->proc.cltr->ready_queue, thrd );
     339        unlock( &systemProcessor->proc.cltr->lock );
    321340}
    322341
     
    367386}
    368387
     388//=============================================================================================
     389// Kernel Setup logic
     390//=============================================================================================
    369391//-----------------------------------------------------------------------------
    370392// Kernel boot procedures
     
    379401        mainThread{ &info };
    380402
     403        LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n");
     404
     405        // Enable preemption
     406        kernel_start_preemption();
     407
    381408        // Initialize the system cluster
    382409        systemCluster = (cluster *)&systemCluster_storage;
    383410        systemCluster{};
    384411
     412        LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n");
     413
    385414        // Initialize the system processor and the system processor ctx
    386415        // (the coroutine that contains the processing control flow)
    387         systemProcessor = (processor *)&systemProcessor_storage;
     416        systemProcessor = (system_proc_t *)&systemProcessor_storage;
    388417        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage };
    389418
    390419        // Add the main thread to the ready queue
    391         // once resume is called on systemProcessor->ctx the mainThread needs to be scheduled like any normal thread
     420        // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
    392421        ScheduleThread(mainThread);
    393422
    394423        //initialize the global state variables
    395         this_processor = systemProcessor;
     424        this_processor = &systemProcessor->proc;
    396425        this_processor->current_thread = mainThread;
    397426        this_processor->current_coroutine = &mainThread->cor;
     
    400429        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    401430        // mainThread is on the ready queue when this call is made.
    402         resume(systemProcessor->runner);
     431        resume( systemProcessor->proc.runner );
    403432
    404433
     
    414443        // When its coroutine terminates, it return control to the mainThread
    415444        // which is currently here
    416         systemProcessor->is_terminated = true;
     445        systemProcessor->proc.is_terminated = true;
    417446        suspend();
    418447
     
    421450        // Destroy the system processor and its context in reverse order of construction
    422451        // These were manually constructed so we need manually destroy them
    423         ^(systemProcessor->runner){};
     452        ^(systemProcessor->proc.runner){};
    424453        ^(systemProcessor){};
    425454
     
    484513}
    485514
     515//=============================================================================================
     516// Kernel Utilities
     517//=============================================================================================
    486518//-----------------------------------------------------------------------------
    487519// Locks
     
    491523void ^?{}( spinlock * this ) {
    492524
     525}
     526
     527bool try_lock( spinlock * this ) {
     528        return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    493529}
    494530
     
    541577
    542578void append( __thread_queue_t * this, thread_desc * t ) {
    543         assert(this->tail != NULL);
     579        verify(this->tail != NULL);
    544580        *this->tail = t;
    545581        this->tail = &t->next;
     
    563599
    564600void push( __condition_stack_t * this, __condition_criterion_t * t ) {
    565         assert( !t->next );
     601        verify( !t->next );
    566602        t->next = this->top;
    567603        this->top = t;
  • src/libcfa/concurrency/kernel_private.h

    r9c951e3 rb1e63ac5  
    2121#include "thread"
    2222
     23#include "alarm.h"
     24
     25#include "libhdr.h"
     26
    2327//-----------------------------------------------------------------------------
    2428// Scheduler
     
    3539//-----------------------------------------------------------------------------
    3640// Processor
    37 struct processorCtx_t {
     41coroutine processorCtx_t {
    3842        processor * proc;
    39         coroutine_desc __cor;
    4043};
    41 
    42 DECL_COROUTINE(processorCtx_t);
    4344
    4445void main(processorCtx_t *);
     
    4748void finishRunning(processor * this);
    4849void spin(processor * this, unsigned int * spin_count);
     50
     51struct system_proc_t {
     52        processor proc;
     53
     54        alarm_list_t alarms;
     55        spinlock alarm_lock;
     56
     57        bool pending_alarm;
     58};
     59
     60extern cluster * systemCluster;
     61extern system_proc_t * systemProcessor;
     62extern thread_local processor * this_processor;
     63
     64static inline void disable_interrupts() {
     65        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, 1, __ATOMIC_SEQ_CST );
     66        assert( prev != (unsigned short) -1 );
     67}
     68
     69static inline void enable_interrupts_noRF() {
     70        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     71        verify( prev != (unsigned short) 0 );
     72}
     73
     74static inline void enable_interrupts() {
     75        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     76        verify( prev != (unsigned short) 0 );
     77        if( prev == 1 && this_processor->pending_preemption ) {
     78                ScheduleInternal( this_processor->current_thread );
     79                this_processor->pending_preemption = false;
     80        }
     81}
    4982
    5083//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/monitor

    r9c951e3 rb1e63ac5  
    2626static inline void ?{}(monitor_desc * this) {
    2727        this->owner = NULL;
    28       this->stack_owner = NULL;
     28        this->stack_owner = NULL;
    2929        this->recursion = 0;
    3030}
     
    3333        monitor_desc ** m;
    3434        int count;
    35       monitor_desc ** prev_mntrs;
    36       unsigned short  prev_count;
     35        monitor_desc ** prev_mntrs;
     36        unsigned short  prev_count;
    3737};
    3838
     
    5959        unsigned short count;                           //Number of criterions in the criteria
    6060        __condition_node_t * next;                      //Intrusive linked list Next field
     61        uintptr_t user_info;                            //Custom user info accessible before signalling
    6162};
    6263
     
    8586}
    8687
    87 void wait( condition * this );
    88 void signal( condition * this );
     88void wait( condition * this, uintptr_t user_info = 0 );
     89bool signal( condition * this );
     90bool signal_block( condition * this );
     91static inline bool is_empty( condition * this ) { return !this->blocked.head; }
     92uintptr_t front( condition * this );
     93
     94struct __acceptable_t {
     95        void (*func)(void);
     96        unsigned short count;
     97        monitor_desc * monitors[1];
     98};
     99
     100void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) );
     101
    89102#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r9c951e3 rb1e63ac5  
    5656                else if( this->owner == thrd) {
    5757                        //We already have the monitor, just not how many times we took it
    58                         assert( this->recursion > 0 );
     58                        verify( this->recursion > 0 );
    5959                        this->recursion += 1;
    6060                }
     
    6262                        //Some one else has the monitor, wait in line for it
    6363                        append( &this->entry_queue, thrd );
     64                        LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd);
    6465                        ScheduleInternal( &this->lock );
    6566
     
    7778                lock( &this->lock );
    7879
    79                 thread_desc * thrd = this_thread();
    80 
    8180                LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion);
    82                 assertf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
     81                verifyf( this_thread() == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread(), this->owner, this->recursion );
    8382
    8483                //Leaving a recursion level, decrement the counter
     
    9796                unlock( &this->lock );
    9897
     98                LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner);
     99
    99100                //We need to wake-up the thread
    100101                ScheduleThread( new_owner );
     
    134135}
    135136
    136 void debug_break() __attribute__(( noinline ))
    137 {
    138        
     137void ?{}(__condition_node_t * this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) {
     138        this->waiting_thread = waiting_thread;
     139        this->count = count;
     140        this->next = NULL;
     141        this->user_info = user_info;
     142}
     143
     144void ?{}(__condition_criterion_t * this ) {
     145        this->ready  = false;
     146        this->target = NULL;
     147        this->owner  = NULL;
     148        this->next   = NULL;
     149}
     150
     151void ?{}(__condition_criterion_t * this, monitor_desc * target, __condition_node_t * owner ) {
     152        this->ready  = false;
     153        this->target = target;
     154        this->owner  = owner;
     155        this->next   = NULL;
    139156}
    140157
    141158//-----------------------------------------------------------------------------
    142159// Internal scheduling
    143 void wait( condition * this ) {
     160void wait( condition * this, uintptr_t user_info = 0 ) {
    144161        LIB_DEBUG_PRINT_SAFE("Waiting\n");
    145162
     
    148165        //Check that everything is as expected
    149166        assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
    150         assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     167        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     168        verifyf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );
    151169
    152170        unsigned short count = this->monitor_count;
     
    156174        LIB_DEBUG_PRINT_SAFE("count %i\n", count);
    157175
    158         __condition_node_t waiter;
    159         waiter.waiting_thread = this_thread();
    160         waiter.count = count;
    161         waiter.next = NULL;
     176        __condition_node_t waiter = { this_thread(), count, user_info };
    162177
    163178        __condition_criterion_t criteria[count];
    164179        for(int i = 0; i < count; i++) {
    165                 criteria[i].ready  = false;
    166                 criteria[i].target = this->monitors[i];
    167                 criteria[i].owner  = &waiter;
    168                 criteria[i].next   = NULL;
     180                (&criteria[i]){ this->monitors[i], &waiter };
    169181                LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
    170182        }
     
    184196        }
    185197
    186         debug_break();
    187 
    188198        for( int i = 0; i < count; i++) {
    189199                thread_desc * new_owner = next_thread( this->monitors[i] );
    190200                thread_count = insert_unique( threads, thread_count, new_owner );
    191201        }
    192 
    193         debug_break();
    194202
    195203        LIB_DEBUG_PRINT_SAFE("Will unblock: ");
     
    212220}
    213221
    214 void signal( condition * this ) {
    215         if( !this->blocked.head ) {
     222bool signal( condition * this ) {
     223        if( is_empty( this ) ) {
    216224                LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
    217                 return;
     225                return false;
    218226        }
    219227
    220228        //Check that everything is as expected
    221         assert( this->monitors );
    222         assert( this->monitor_count != 0 );
     229        verify( this->monitors );
     230        verify( this->monitor_count != 0 );
    223231
    224232        unsigned short count = this->monitor_count;
    225233       
     234        //Some more checking in debug
    226235        LIB_DEBUG_DO(
    227236                thread_desc * this_thrd = this_thread();
     
    237246        );
    238247
     248        //Lock all the monitors
    239249        lock_all( this->monitors, NULL, count );
    240250        LIB_DEBUG_PRINT_SAFE("Signalling");
    241251
     252        //Pop the head of the waiting queue
    242253        __condition_node_t * node = pop_head( &this->blocked );
     254
     255        //Add the thread to the proper AS stack
    243256        for(int i = 0; i < count; i++) {
    244257                __condition_criterion_t * crit = &node->criteria[i];
     
    250263        LIB_DEBUG_PRINT_SAFE("\n");
    251264
     265        //Release
    252266        unlock_all( this->monitors, count );
     267
     268        return true;
     269}
     270
     271bool signal_block( condition * this ) {
     272        if( !this->blocked.head ) {
     273                LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
     274                return false;
     275        }
     276
     277        //Check that everything is as expected
     278        verifyf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
     279        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     280
     281        unsigned short count = this->monitor_count;
     282        unsigned int recursions[ count ];               //Save the current recursion levels to restore them later
     283        spinlock *   locks     [ count ];               //We need to pass-in an array of locks to ScheduleInternal
     284
     285        lock_all( this->monitors, locks, count );
     286
     287        //create creteria
     288        __condition_node_t waiter = { this_thread(), count, 0 };
     289
     290        __condition_criterion_t criteria[count];
     291        for(int i = 0; i < count; i++) {
     292                (&criteria[i]){ this->monitors[i], &waiter };
     293                LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
     294                push( &criteria[i].target->signal_stack, &criteria[i] );
     295        }
     296
     297        waiter.criteria = criteria;
     298
     299        //save contexts
     300        save_recursion( this->monitors, recursions, count );
     301
     302        //Find the thread to run
     303        thread_desc * signallee = pop_head( &this->blocked )->waiting_thread;
     304        for(int i = 0; i < count; i++) {
     305                set_owner( this->monitors[i], signallee );
     306        }
     307
     308        LIB_DEBUG_PRINT_SAFE( "Waiting on signal block\n" );
     309
     310        //Everything is ready to go to sleep
     311        ScheduleInternal( locks, count, &signallee, 1 );
     312
     313
     314
     315
     316        LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" );
     317
     318        //We are back, restore the owners and recursions
     319        lock_all( locks, count );
     320        restore_recursion( this->monitors, recursions, count );
     321        unlock_all( locks, count );
     322
     323        return true;
     324}
     325
     326uintptr_t front( condition * this ) {
     327        verifyf( !is_empty(this),
     328                "Attempt to access user data on an empty condition.\n"
     329                "Possible cause is not checking if the condition is empty before reading stored data."
     330        );
     331        return this->blocked.head->user_info;
     332}
     333
     334//-----------------------------------------------------------------------------
     335// Internal scheduling
     336void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ) {
     337        // thread_desc * this = this_thread();
     338
     339        // unsigned short count = this->current_monitor_count;
     340        // unsigned int recursions[ count ];            //Save the current recursion levels to restore them later
     341        // spinlock *   locks     [ count ];            //We need to pass-in an array of locks to ScheduleInternal
     342
     343        // lock_all( this->current_monitors, locks, count );
     344
     345
     346
     347
     348
     349        // // // Everything is ready to go to sleep
     350        // // ScheduleInternal( locks, count, threads, thread_count );
     351
     352
     353        // //WE WOKE UP
     354
     355
     356        // //We are back, restore the owners and recursions
     357        // lock_all( locks, count );
     358        // restore_recursion( this->monitors, recursions, count );
     359        // unlock_all( locks, count );
    253360}
    254361
     
    335442
    336443        for(    int i = 0; i < count; i++ ) {
     444
    337445                LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target );
    338446                if( &criteria[i] == target ) {
     
    379487
    380488void append( __condition_blocked_queue_t * this, __condition_node_t * c ) {
    381         assert(this->tail != NULL);
     489        verify(this->tail != NULL);
    382490        *this->tail = c;
    383491        this->tail = &c->next;
  • src/libcfa/concurrency/thread

    r9c951e3 rb1e63ac5  
    8282
    8383void yield();
     84void yield( unsigned times );
    8485
    8586#endif //THREADS_H
  • src/libcfa/concurrency/thread.c

    r9c951e3 rb1e63ac5  
    8787}
    8888
     89void yield( unsigned times ) {
     90        for( unsigned i = 0; i < times; i++ ) {
     91                yield();
     92        }
     93}
     94
    8995void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    9096        // set state of current coroutine to inactive
  • src/libcfa/containers/vector

    r9c951e3 rb1e63ac5  
    2222
    2323//------------------------------------------------------------------------------
     24//Allocator
     25forall(otype T)
     26struct heap_allocator
     27{
     28        T* storage;
     29        size_t capacity;
     30};
     31
     32forall(otype T)
     33void ?{}(heap_allocator(T)* this);
     34
     35forall(otype T)
     36void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
     37
     38forall(otype T)
     39heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
     40
     41forall(otype T)
     42void ^?{}(heap_allocator(T)* this);
     43
     44forall(otype T)
     45void realloc_storage(heap_allocator(T)* this, size_t size);
     46
     47forall(otype T)
     48static inline T* data(heap_allocator(T)* this)
     49{
     50        return this->storage;
     51}
     52
     53//------------------------------------------------------------------------------
    2454//Declaration
    2555trait allocator_c(otype T, otype allocator_t)
     
    2959};
    3060
    31 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     61forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t))
    3262struct vector;
    3363
     
    4676void ^?{}(vector(T, allocator_t)* this);
    4777
    48 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     78forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t))
    4979struct vector
    5080{
     
    136166// }
    137167
    138 //------------------------------------------------------------------------------
    139 //Allocator
    140 forall(otype T)
    141 struct heap_allocator
    142 {
    143         T* storage;
    144         size_t capacity;
    145 };
    146 
    147 forall(otype T)
    148 void ?{}(heap_allocator(T)* this);
    149 
    150 forall(otype T)
    151 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
    152 
    153 forall(otype T)
    154 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
    155 
    156 forall(otype T)
    157 void ^?{}(heap_allocator(T)* this);
    158 
    159 forall(otype T)
    160 void realloc_storage(heap_allocator(T)* this, size_t size);
    161 
    162 forall(otype T)
    163 static inline T* data(heap_allocator(T)* this)
    164 {
    165         return this->storage;
    166 }
    167 
    168168#endif // VECTOR_H
    169169
  • src/libcfa/gmp

    r9c951e3 rb1e63ac5  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 23:47:36 2017
    13 // Update Count     : 9
     12// Last Modified On : Sat May 27 09:55:51 2017
     13// Update Count     : 14
    1414//
    1515
     
    2222
    2323// constructor
    24 void ?{}( Int * this ) { mpz_init( this->mpz ); }
    25 void ?{}( Int * this, Int init ) { mpz_init_set( this->mpz, init.mpz ); }
    26 void ?{}( Int * this, zero_t ) { mpz_init_set_si( this->mpz, 0 ); }
    27 void ?{}( Int * this, one_t ) { mpz_init_set_si( this->mpz, 1 ); }
    28 void ?{}( Int * this, signed long int init ) { mpz_init_set_si( this->mpz, init ); }
    29 void ?{}( Int * this, unsigned long int init ) { mpz_init_set_ui( this->mpz, init ); }
    30 void ?{}( Int * this, const char * val ) { if ( mpz_init_set_str( this->mpz, val, 0 ) ) abort(); }
    31 void ^?{}( Int * this ) { mpz_clear( this->mpz ); }
     24static inline void ?{}( Int * this ) { mpz_init( this->mpz ); }
     25static inline void ?{}( Int * this, Int init ) { mpz_init_set( this->mpz, init.mpz ); }
     26static inline void ?{}( Int * this, zero_t ) { mpz_init_set_si( this->mpz, 0 ); }
     27static inline void ?{}( Int * this, one_t ) { mpz_init_set_si( this->mpz, 1 ); }
     28static inline void ?{}( Int * this, signed long int init ) { mpz_init_set_si( this->mpz, init ); }
     29static inline void ?{}( Int * this, unsigned long int init ) { mpz_init_set_ui( this->mpz, init ); }
     30static inline void ?{}( Int * this, const char * val ) { if ( mpz_init_set_str( this->mpz, val, 0 ) ) abort(); }
     31static inline void ^?{}( Int * this ) { mpz_clear( this->mpz ); }
    3232
    3333// assignment
    34 Int ?=?( Int * lhs, Int rhs ) { mpz_set( lhs->mpz, rhs.mpz ); return *lhs; }
    35 Int ?=?( Int * lhs, long int rhs ) { mpz_set_si( lhs->mpz, rhs ); return *lhs; }
    36 Int ?=?( Int * lhs, unsigned long int rhs ) { mpz_set_ui( lhs->mpz, rhs ); return *lhs; }
    37 //Int ?=?( Int * lhs, const char * rhs ) { if ( mpq_set_str( lhs->mpz, rhs, 0 ) ) abort(); return *lhs; }
    38 
    39 char ?=?( char * lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
    40 short int ?=?( short int * lhs, Int rhs ) { short int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
    41 int ?=?( int * lhs, Int rhs ) { int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
    42 long int ?=?( long int * lhs, Int rhs ) { long int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
    43 unsigned char ?=?( unsigned char * lhs, Int rhs ) { unsigned char val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
    44 unsigned short int ?=?( unsigned short int * lhs, Int rhs ) { unsigned short int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
    45 unsigned int ?=?( unsigned int * lhs, Int rhs ) { unsigned int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
    46 unsigned long int ?=?( unsigned long int * lhs, Int rhs ) { unsigned long int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
     34static inline Int ?=?( Int * lhs, Int rhs ) { mpz_set( lhs->mpz, rhs.mpz ); return *lhs; }
     35static inline Int ?=?( Int * lhs, long int rhs ) { mpz_set_si( lhs->mpz, rhs ); return *lhs; }
     36static inline Int ?=?( Int * lhs, unsigned long int rhs ) { mpz_set_ui( lhs->mpz, rhs ); return *lhs; }
     37static inline Int ?=?( Int * lhs, const char * rhs ) { if ( mpz_set_str( lhs->mpz, rhs, 0 ) ) { printf( "invalid string conversion\n" ); abort(); } return *lhs; }
     38
     39static inline char ?=?( char * lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
     40static inline short int ?=?( short int * lhs, Int rhs ) { short int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
     41static inline int ?=?( int * lhs, Int rhs ) { int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
     42static inline long int ?=?( long int * lhs, Int rhs ) { long int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; }
     43static inline unsigned char ?=?( unsigned char * lhs, Int rhs ) { unsigned char val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
     44static inline unsigned short int ?=?( unsigned short int * lhs, Int rhs ) { unsigned short int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
     45static inline unsigned int ?=?( unsigned int * lhs, Int rhs ) { unsigned int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
     46static inline unsigned long int ?=?( unsigned long int * lhs, Int rhs ) { unsigned long int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; }
    4747
    4848// conversions
    49 long int narrow( Int val ) { return mpz_get_si( val.mpz ); }
    50 unsigned long int narrow( Int val ) { return mpz_get_ui( val.mpz ); }
     49static inline long int narrow( Int val ) { return mpz_get_si( val.mpz ); }
     50static inline unsigned long int narrow( Int val ) { return mpz_get_ui( val.mpz ); }
    5151
    5252// comparison
    53 int ?==?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) == 0; }
    54 int ?==?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; }
    55 int ?==?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; }
    56 int ?==?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; }
    57 int ?==?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; }
    58 
    59 int ?!=?( Int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
    60 int ?!=?( Int oper1, long int oper2 ) { return ! ( oper1 == oper2 ); }
    61 int ?!=?( long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
    62 int ?!=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 == oper2 ); }
    63 int ?!=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
    64 
    65 int ?<?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) < 0; }
    66 int ?<?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; }
    67 int ?<?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; }
    68 int ?<?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; }
    69 int ?<?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; }
    70 
    71 int ?<=?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) <= 0; }
    72 int ?<=?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; }
    73 int ?<=?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; }
    74 int ?<=?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; }
    75 int ?<=?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; }
    76 
    77 int ?>?( Int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
    78 int ?>?( Int oper1, long int oper2 ) { return ! ( oper1 <= oper2 ); }
    79 int ?>?( long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
    80 int ?>?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 <= oper2 ); }
    81 int ?>?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
    82 
    83 int ?>=?( Int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
    84 int ?>=?( Int oper1, long int oper2 ) { return ! ( oper1 < oper2 ); }
    85 int ?>=?( long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
    86 int ?>=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 < oper2 ); }
    87 int ?>=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
     53static inline int ?==?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) == 0; }
     54static inline int ?==?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; }
     55static inline int ?==?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; }
     56static inline int ?==?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; }
     57static inline int ?==?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; }
     58
     59static inline int ?!=?( Int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
     60static inline int ?!=?( Int oper1, long int oper2 ) { return ! ( oper1 == oper2 ); }
     61static inline int ?!=?( long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
     62static inline int ?!=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 == oper2 ); }
     63static inline int ?!=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); }
     64
     65static inline int ?<?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) < 0; }
     66static inline int ?<?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; }
     67static inline int ?<?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; }
     68static inline int ?<?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; }
     69static inline int ?<?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; }
     70
     71static inline int ?<=?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) <= 0; }
     72static inline int ?<=?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; }
     73static inline int ?<=?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; }
     74static inline int ?<=?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; }
     75static inline int ?<=?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; }
     76
     77static inline int ?>?( Int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
     78static inline int ?>?( Int oper1, long int oper2 ) { return ! ( oper1 <= oper2 ); }
     79static inline int ?>?( long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
     80static inline int ?>?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 <= oper2 ); }
     81static inline int ?>?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); }
     82
     83static inline int ?>=?( Int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
     84static inline int ?>=?( Int oper1, long int oper2 ) { return ! ( oper1 < oper2 ); }
     85static inline int ?>=?( long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
     86static inline int ?>=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 < oper2 ); }
     87static inline int ?>=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); }
    8888
    8989// arithmetic
    90 Int +?( Int oper ) { Int pos; mpz_set( pos.mpz, oper.mpz ); return pos; }
    91 Int -?( Int oper ) { Int neg; mpz_neg( neg.mpz, oper.mpz ); return neg; }
    92 Int ~?( Int oper ) { Int comp; mpz_com( comp.mpz, oper.mpz ); return comp; }
    93 
    94 Int ?&?( Int oper1, Int oper2 ) { Int conjunction; mpz_and( conjunction.mpz, oper1.mpz, oper2.mpz ); return conjunction; }
    95 Int ?&?( Int oper1, long int oper2 ) { Int conjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_and( conjunction.mpz, oper1.mpz, temp.mpz ); return conjunction; }
    96 Int ?&?( long int oper1, Int oper2 ) { Int conjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_and( conjunction.mpz, temp.mpz, oper2.mpz ); return conjunction; }
    97 Int ?&?( Int oper1, unsigned long int oper2 ) { Int conjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_and( conjunction.mpz, oper1.mpz, temp.mpz ); return conjunction; }
    98 Int ?&?( unsigned long int oper1, Int oper2 ) { Int conjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_and( conjunction.mpz, temp.mpz, oper2.mpz ); return conjunction; }
    99 Int ?&=?( Int * lhs, Int rhs ) { return *lhs = *lhs & rhs; }
    100 
    101 Int ?|?( Int oper1, Int oper2 ) { Int disjunction; mpz_ior( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; }
    102 Int ?|?( Int oper1, long int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
    103 Int ?|?( long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
    104 Int ?|?( Int oper1, unsigned long int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
    105 Int ?|?( unsigned long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
    106 Int ?|=?( Int * lhs, Int rhs ) { return *lhs = *lhs | rhs; }
    107 
    108 Int ?^?( Int oper1, Int oper2 ) { Int disjunction; mpz_xor( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; }
    109 Int ?^?( Int oper1, long int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
    110 Int ?^?( long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
    111 Int ?^?( Int oper1, unsigned long int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
    112 Int ?^?( unsigned long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
    113 Int ?^=?( Int * lhs, Int rhs ) { return *lhs = *lhs ^ rhs; }
    114 
    115 Int ?+?( Int addend1, Int addend2 ) { Int sum; mpz_add( sum.mpz, addend1.mpz, addend2.mpz ); return sum; }
    116 Int ?+?( Int addend1, long int addend2 ) { Int sum; if ( addend2 >= 0 ) mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); else mpz_sub_ui( sum.mpz, addend1.mpz, -addend2 ); return sum; }
    117 Int ?+?( long int addend2, Int addend1 ) { Int sum; if ( addend2 >= 0 ) mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); else mpz_sub_ui( sum.mpz, addend1.mpz, -addend2 ); return sum; }
    118 Int ?+?( Int addend1, unsigned long int addend2 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; }
    119 Int ?+?( unsigned long int addend2, Int addend1 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; }
    120 Int ?+=?( Int * lhs, Int rhs ) { return *lhs = *lhs + rhs; }
    121 Int ?+=?( Int * lhs, long int rhs ) { return *lhs = *lhs + rhs; }
    122 Int ?+=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs + rhs; }
    123 Int ++?( Int * lhs ) { return *lhs += 1; }
    124 Int ?++( Int * lhs ) { Int ret = *lhs; *lhs += 1; return ret; }
    125 
    126 Int ?-?( Int minuend, Int subtrahend ) { Int diff; mpz_sub( diff.mpz, minuend.mpz, subtrahend.mpz ); return diff; }
    127 Int ?-?( Int minuend, long int subtrahend ) { Int diff; if ( subtrahend >= 0 ) mpz_sub_ui( diff.mpz, minuend.mpz, subtrahend ); else mpz_add_ui( diff.mpz, minuend.mpz, -subtrahend ); return diff; }
    128 Int ?-?( long int minuend, Int subtrahend ) { Int diff; if ( subtrahend >= 0 ) mpz_ui_sub( diff.mpz, minuend, subtrahend.mpz ); else { mpz_add_ui( diff.mpz, subtrahend.mpz, -minuend ); mpz_neg( diff.mpz, diff.mpz ); } return diff; }
    129 Int ?-?( Int minuend, unsigned long int subtrahend ) { Int diff; mpz_sub_ui( diff.mpz, minuend.mpz, subtrahend ); return diff; }
    130 Int ?-?( unsigned long int minuend, Int subtrahend ) { Int diff; mpz_ui_sub( diff.mpz, minuend, subtrahend.mpz ); return diff; }
    131 Int ?-=?( Int * lhs, Int rhs ) { return *lhs = *lhs - rhs; }
    132 Int ?-=?( Int * lhs, long int rhs ) { return *lhs = *lhs - rhs; }
    133 Int ?-=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs - rhs; }
    134 Int --?( Int * lhs ) { return *lhs -= 1; }
    135 Int ?--( Int * lhs ) { Int ret = *lhs; *lhs -= 1; return ret; }
    136 
    137 Int ?*?( Int multiplicator, Int multiplicand ) { Int product; mpz_mul( product.mpz, multiplicator.mpz, multiplicand.mpz ); return product; }
    138 Int ?*?( Int multiplicator, long int multiplicand ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; }
    139 Int ?*?( long int multiplicand, Int multiplicator ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; }
    140 Int ?*?( Int multiplicator, unsigned long int multiplicand ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; }
    141 Int ?*?( unsigned long int multiplicand, Int multiplicator ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; }
    142 Int ?*=?( Int * lhs, Int rhs ) { return *lhs = *lhs * rhs; }
    143 Int ?*=?( Int * lhs, long int rhs ) { return *lhs = *lhs * rhs; }
    144 Int ?*=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs * rhs; }
     90static inline Int +?( Int oper ) { Int pos; mpz_set( pos.mpz, oper.mpz ); return pos; }
     91static inline Int -?( Int oper ) { Int neg; mpz_neg( neg.mpz, oper.mpz ); return neg; }
     92static inline Int ~?( Int oper ) { Int comp; mpz_com( comp.mpz, oper.mpz ); return comp; }
     93
     94static inline Int ?&?( Int oper1, Int oper2 ) { Int conjunction; mpz_and( conjunction.mpz, oper1.mpz, oper2.mpz ); return conjunction; }
     95static inline Int ?&?( Int oper1, long int oper2 ) { Int conjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_and( conjunction.mpz, oper1.mpz, temp.mpz ); return conjunction; }
     96static inline Int ?&?( long int oper1, Int oper2 ) { Int conjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_and( conjunction.mpz, temp.mpz, oper2.mpz ); return conjunction; }
     97static inline Int ?&?( Int oper1, unsigned long int oper2 ) { Int conjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_and( conjunction.mpz, oper1.mpz, temp.mpz ); return conjunction; }
     98static inline Int ?&?( unsigned long int oper1, Int oper2 ) { Int conjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_and( conjunction.mpz, temp.mpz, oper2.mpz ); return conjunction; }
     99static inline Int ?&=?( Int * lhs, Int rhs ) { return *lhs = *lhs & rhs; }
     100
     101static inline Int ?|?( Int oper1, Int oper2 ) { Int disjunction; mpz_ior( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; }
     102static inline Int ?|?( Int oper1, long int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
     103static inline Int ?|?( long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
     104static inline Int ?|?( Int oper1, unsigned long int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
     105static inline Int ?|?( unsigned long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
     106static inline Int ?|=?( Int * lhs, Int rhs ) { return *lhs = *lhs | rhs; }
     107
     108static inline Int ?^?( Int oper1, Int oper2 ) { Int disjunction; mpz_xor( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; }
     109static inline Int ?^?( Int oper1, long int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
     110static inline Int ?^?( long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_si( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
     111static inline Int ?^?( Int oper1, unsigned long int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper2 ); mpz_ior( disjunction.mpz, oper1.mpz, temp.mpz ); return disjunction; }
     112static inline Int ?^?( unsigned long int oper1, Int oper2 ) { Int disjunction, temp; mpz_set_ui( temp.mpz, oper1 ); mpz_ior( disjunction.mpz, temp.mpz, oper2.mpz ); return disjunction; }
     113static inline Int ?^=?( Int * lhs, Int rhs ) { return *lhs = *lhs ^ rhs; }
     114
     115static inline Int ?+?( Int addend1, Int addend2 ) { Int sum; mpz_add( sum.mpz, addend1.mpz, addend2.mpz ); return sum; }
     116static inline Int ?+?( Int addend1, long int addend2 ) { Int sum; if ( addend2 >= 0 ) mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); else mpz_sub_ui( sum.mpz, addend1.mpz, -addend2 ); return sum; }
     117static inline Int ?+?( long int addend2, Int addend1 ) { Int sum; if ( addend2 >= 0 ) mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); else mpz_sub_ui( sum.mpz, addend1.mpz, -addend2 ); return sum; }
     118static inline Int ?+?( Int addend1, unsigned long int addend2 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; }
     119static inline Int ?+?( unsigned long int addend2, Int addend1 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; }
     120static inline Int ?+=?( Int * lhs, Int rhs ) { return *lhs = *lhs + rhs; }
     121static inline Int ?+=?( Int * lhs, long int rhs ) { return *lhs = *lhs + rhs; }
     122static inline Int ?+=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs + rhs; }
     123static inline Int ++?( Int * lhs ) { return *lhs += 1; }
     124static inline Int ?++( Int * lhs ) { Int ret = *lhs; *lhs += 1; return ret; }
     125
     126static inline Int ?-?( Int minuend, Int subtrahend ) { Int diff; mpz_sub( diff.mpz, minuend.mpz, subtrahend.mpz ); return diff; }
     127static inline Int ?-?( Int minuend, long int subtrahend ) { Int diff; if ( subtrahend >= 0 ) mpz_sub_ui( diff.mpz, minuend.mpz, subtrahend ); else mpz_add_ui( diff.mpz, minuend.mpz, -subtrahend ); return diff; }
     128static inline Int ?-?( long int minuend, Int subtrahend ) { Int diff; if ( subtrahend >= 0 ) mpz_ui_sub( diff.mpz, minuend, subtrahend.mpz ); else { mpz_add_ui( diff.mpz, subtrahend.mpz, -minuend ); mpz_neg( diff.mpz, diff.mpz ); } return diff; }
     129static inline Int ?-?( Int minuend, unsigned long int subtrahend ) { Int diff; mpz_sub_ui( diff.mpz, minuend.mpz, subtrahend ); return diff; }
     130static inline Int ?-?( unsigned long int minuend, Int subtrahend ) { Int diff; mpz_ui_sub( diff.mpz, minuend, subtrahend.mpz ); return diff; }
     131static inline Int ?-=?( Int * lhs, Int rhs ) { return *lhs = *lhs - rhs; }
     132static inline Int ?-=?( Int * lhs, long int rhs ) { return *lhs = *lhs - rhs; }
     133static inline Int ?-=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs - rhs; }
     134static inline Int --?( Int * lhs ) { return *lhs -= 1; }
     135static inline Int ?--( Int * lhs ) { Int ret = *lhs; *lhs -= 1; return ret; }
     136
     137static inline Int ?*?( Int multiplicator, Int multiplicand ) { Int product; mpz_mul( product.mpz, multiplicator.mpz, multiplicand.mpz ); return product; }
     138static inline Int ?*?( Int multiplicator, long int multiplicand ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; }
     139static inline Int ?*?( long int multiplicand, Int multiplicator ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; }
     140static inline Int ?*?( Int multiplicator, unsigned long int multiplicand ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; }
     141static inline Int ?*?( unsigned long int multiplicand, Int multiplicator ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; }
     142static inline Int ?*=?( Int * lhs, Int rhs ) { return *lhs = *lhs * rhs; }
     143static inline Int ?*=?( Int * lhs, long int rhs ) { return *lhs = *lhs * rhs; }
     144static inline Int ?*=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs * rhs; }
    145145
    146146// some code for operators "/" and "%" taken from g++ gmpxx.h
    147 Int ?/?( Int dividend, Int divisor ) { Int quotient; mpz_tdiv_q( quotient.mpz, dividend.mpz, divisor.mpz ); return quotient; }
    148 Int ?/?( Int dividend, unsigned long int divisor ) { Int quotient; mpz_tdiv_q_ui( quotient.mpz, dividend.mpz, divisor ); return quotient; }
    149 Int ?/?( unsigned long int dividend, Int divisor ) {
     147static inline Int ?/?( Int dividend, Int divisor ) { Int quotient; mpz_tdiv_q( quotient.mpz, dividend.mpz, divisor.mpz ); return quotient; }
     148static inline Int ?/?( Int dividend, unsigned long int divisor ) { Int quotient; mpz_tdiv_q_ui( quotient.mpz, dividend.mpz, divisor ); return quotient; }
     149static inline Int ?/?( unsigned long int dividend, Int divisor ) {
    150150        Int quotient;
    151151    if ( mpz_sgn( divisor.mpz ) >= 0 ) {
     
    164164        return quotient;
    165165} // ?/?
    166 Int ?/?( Int dividend, long int divisor ) {
     166static inline Int ?/?( Int dividend, long int divisor ) {
    167167        Int quotient;
    168168    if ( divisor >= 0 )
     
    174174        return quotient;
    175175} // ?/?
    176 Int ?/?( long int dividend, Int divisor ) {
     176static inline Int ?/?( long int dividend, Int divisor ) {
    177177        Int quotient;
    178178    if ( mpz_fits_slong_p( divisor.mpz ) )
     
    185185        return quotient;
    186186} // ?/?
    187 Int ?/=?( Int * lhs, Int rhs ) { return *lhs = *lhs / rhs; }
    188 Int ?/=?( Int * lhs, long int rhs ) { return *lhs = *lhs / rhs; }
    189 Int ?/=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs / rhs; }
    190 
    191 [ Int, Int ] div( Int dividend, Int divisor ) { Int quotient, remainder; mpz_fdiv_qr( quotient.mpz, remainder.mpz, dividend.mpz, divisor.mpz ); return [ quotient, remainder ]; }
    192 [ Int, Int ] div( Int dividend, unsigned long int divisor ) { Int quotient, remainder; mpz_fdiv_qr_ui( quotient.mpz, remainder.mpz, dividend.mpz, divisor ); return [ quotient, remainder ]; }
    193 
    194 Int ?%?( Int dividend, Int divisor ) { Int remainder; mpz_tdiv_r( remainder.mpz, dividend.mpz, divisor.mpz ); return remainder; }
    195 Int ?%?( Int dividend, unsigned long int divisor ) { Int remainder; mpz_tdiv_r_ui( remainder.mpz, dividend.mpz, divisor ); return remainder; }
    196 Int ?%?( unsigned long int dividend, Int divisor ) {
     187static inline Int ?/=?( Int * lhs, Int rhs ) { return *lhs = *lhs / rhs; }
     188static inline Int ?/=?( Int * lhs, long int rhs ) { return *lhs = *lhs / rhs; }
     189static inline Int ?/=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs / rhs; }
     190
     191static inline [ Int, Int ] div( Int dividend, Int divisor ) { Int quotient, remainder; mpz_fdiv_qr( quotient.mpz, remainder.mpz, dividend.mpz, divisor.mpz ); return [ quotient, remainder ]; }
     192static inline [ Int, Int ] div( Int dividend, unsigned long int divisor ) { Int quotient, remainder; mpz_fdiv_qr_ui( quotient.mpz, remainder.mpz, dividend.mpz, divisor ); return [ quotient, remainder ]; }
     193
     194static inline Int ?%?( Int dividend, Int divisor ) { Int remainder; mpz_tdiv_r( remainder.mpz, dividend.mpz, divisor.mpz ); return remainder; }
     195static inline Int ?%?( Int dividend, unsigned long int divisor ) { Int remainder; mpz_tdiv_r_ui( remainder.mpz, dividend.mpz, divisor ); return remainder; }
     196static inline Int ?%?( unsigned long int dividend, Int divisor ) {
    197197        Int remainder;
    198198    if ( mpz_sgn( divisor.mpz ) >= 0 ) {
     
    210210        return remainder;
    211211} // ?%?
    212 Int ?%?( Int dividend, long int divisor ) {
     212static inline Int ?%?( Int dividend, long int divisor ) {
    213213        Int remainder;
    214214    mpz_tdiv_r_ui( remainder.mpz, dividend.mpz, (divisor >= 0 ? divisor : -divisor));
    215215        return remainder;
    216216} // ?%?
    217 Int ?%?( long int dividend, Int divisor ) {
     217static inline Int ?%?( long int dividend, Int divisor ) {
    218218        Int remainder;
    219219    if ( mpz_fits_slong_p( divisor.mpz ) )
     
    226226        return remainder;
    227227} // ?%?
    228 Int ?%=?( Int * lhs, Int rhs ) { return *lhs = *lhs % rhs; }
    229 Int ?%=?( Int * lhs, long int rhs ) { return *lhs = *lhs % rhs; }
    230 Int ?%=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs % rhs; }
    231 
    232 Int ?<<?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_mul_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; }
    233 Int ?<<=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs << shift; }
    234 Int ?>>?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_fdiv_q_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; }
    235 Int ?>>=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs >> shift; }
     228static inline Int ?%=?( Int * lhs, Int rhs ) { return *lhs = *lhs % rhs; }
     229static inline Int ?%=?( Int * lhs, long int rhs ) { return *lhs = *lhs % rhs; }
     230static inline Int ?%=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs % rhs; }
     231
     232static inline Int ?<<?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_mul_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; }
     233static inline Int ?<<=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs << shift; }
     234static inline Int ?>>?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_fdiv_q_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; }
     235static inline Int ?>>=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs >> shift; }
    236236
    237237// number functions
    238 Int abs( Int oper ) { Int positive; mpz_abs( positive.mpz, oper.mpz ); return positive; }
    239 Int fact( unsigned long int N ) { Int factorial; mpz_fac_ui( factorial.mpz, N ); return factorial; }
    240 Int gcd( Int oper1, Int oper2 ) { Int gcdret; mpz_gcd( gcdret.mpz, oper1.mpz, oper2.mpz ); return gcdret; }
    241 Int pow( Int base, unsigned long int exponent ) { Int power; mpz_pow_ui( power.mpz, base.mpz, exponent ); return power; }
    242 Int pow( unsigned long int base, unsigned long int exponent ) { Int power; mpz_ui_pow_ui( power.mpz, base, exponent ); return power; }
    243 void srandom( gmp_randstate_t state ) { gmp_randinit_default( state ); }
    244 Int random( gmp_randstate_t state, mp_bitcnt_t n ) { Int rand; mpz_urandomb( rand.mpz, state, n ); return rand; }
    245 Int random( gmp_randstate_t state, Int n ) { Int rand; mpz_urandomm( rand.mpz, state, n.mpz ); return rand; }
    246 Int random( gmp_randstate_t state, mp_size_t max_size ) { Int rand; mpz_random( rand.mpz, max_size ); return rand; }
    247 int sgn( Int oper ) { return mpz_sgn( oper.mpz ); }
    248 Int sqrt( Int oper ) { Int root; mpz_sqrt( root.mpz, oper.mpz ); return root; }
     238static inline Int abs( Int oper ) { Int positive; mpz_abs( positive.mpz, oper.mpz ); return positive; }
     239static inline Int fact( unsigned long int N ) { Int factorial; mpz_fac_ui( factorial.mpz, N ); return factorial; }
     240static inline Int gcd( Int oper1, Int oper2 ) { Int gcdret; mpz_gcd( gcdret.mpz, oper1.mpz, oper2.mpz ); return gcdret; }
     241static inline Int pow( Int base, unsigned long int exponent ) { Int power; mpz_pow_ui( power.mpz, base.mpz, exponent ); return power; }
     242static inline Int pow( unsigned long int base, unsigned long int exponent ) { Int power; mpz_ui_pow_ui( power.mpz, base, exponent ); return power; }
     243static inline void srandom( gmp_randstate_t state ) { gmp_randinit_default( state ); }
     244static inline Int random( gmp_randstate_t state, mp_bitcnt_t n ) { Int rand; mpz_urandomb( rand.mpz, state, n ); return rand; }
     245static inline Int random( gmp_randstate_t state, Int n ) { Int rand; mpz_urandomm( rand.mpz, state, n.mpz ); return rand; }
     246static inline Int random( gmp_randstate_t state, mp_size_t max_size ) { Int rand; mpz_random( rand.mpz, max_size ); return rand; }
     247static inline int sgn( Int oper ) { return mpz_sgn( oper.mpz ); }
     248static inline Int sqrt( Int oper ) { Int root; mpz_sqrt( root.mpz, oper.mpz ); return root; }
    249249
    250250// I/O
    251 forall( dtype istype | istream( istype ) )
     251static inline forall( dtype istype | istream( istype ) )
    252252istype * ?|?( istype * is, Int * mp ) {
    253253        gmp_scanf( "%Zd", mp );
     
    255255} // ?|?
    256256
    257 forall( dtype ostype | ostream( ostype ) )
     257static inline forall( dtype ostype | ostream( ostype ) )
    258258ostype * ?|?( ostype * os, Int mp ) {
    259259        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
  • src/libcfa/libhdr/libdebug.h

    r9c951e3 rb1e63ac5  
    1818
    1919#ifdef __CFA_DEBUG__
    20       #define LIB_DEBUG_DO(x) x
    21       #define LIB_NO_DEBUG_DO(x) ((void)0)
     20        #define LIB_DEBUG_DO(x) x
     21        #define LIB_NO_DEBUG_DO(x) ((void)0)
    2222#else
    23       #define LIB_DEBUG_DO(x) ((void)0)
    24       #define LIB_NO_DEBUG_DO(x) x     
     23        #define LIB_DEBUG_DO(x) ((void)0)
     24        #define LIB_NO_DEBUG_DO(x) x     
    2525#endif
     26
     27#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
     28        #define verify(x) assert(x)
     29        #define verifyf(x, ...) assertf(x, __VA_ARGS__)
     30#else
     31        #define verify(x)
     32        #define verifyf(x, ...)
     33#endif
     34
    2635
    2736#ifdef __cforall
  • src/libcfa/math

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 24 12:45:02 2016
    13 // Update Count     : 59
     12// Last Modified On : Wed May 24 17:40:39 2017
     13// Update Count     : 60
    1414//
    1515
     
    2020#include <math.h>                                                                               // fpclassify, isfinite, isnormal, isnan, isinf
    2121} // extern "C"
    22 
    23 float fabs( float );
    24 // extern "C" { double fabs( double ); }
    25 long double fabs( long double );
    26 float cabs( float _Complex );
    27 // extern "C" { double cabs( double _Complex ); }
    28 long double cabs( long double _Complex );
    2922
    3023float ?%?( float, float );
  • src/libcfa/math.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Tue Apr 19 22:23:08 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 24 08:52:31 2016
    13 // Update Count     : 75
     12// Last Modified On : Tue May 23 22:52:13 2017
     13// Update Count     : 76
    1414//
    1515
     
    1919#include <complex.h>
    2020} // extern "C"
    21 
    22 float fabs( float x ) { return fabsf( x ); }
    23 long double fabs( long double x ) { return fabsl( x ); }
    24 float cabs( float _Complex x ) { return cabsf( x ); }
    25 long double cabs( long double _Complex x ) { return cabsl( x ); }
    2621
    2722float ?%?( float x, float y ) { return fmodf( x, y ); }
  • src/libcfa/stdlib

    r9c951e3 rb1e63ac5  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  9 08:42:44 2017
    13 // Update Count     : 107
     12// Last Modified On : Fri Jun  2 15:51:03 2017
     13// Update Count     : 218
    1414//
    1515
     
    2828//---------------------------------------
    2929
    30 extern "C" { void * malloc( size_t ); }                                 // use default C routine for void *
    31 forall( dtype T | sized(T) ) T * malloc( void );
    32 forall( dtype T | sized(T) ) T * malloc( char fill );
    33 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size );
    34 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill );
    35 extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void *
    36 forall( dtype T | sized(T) ) T * calloc( size_t nmemb );
    37 extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void *
    38 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size );
    39 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill );
    40 
    41 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment );
    42 forall( dtype T | sized(T) ) T * memalign( size_t alignment );          // deprecated
    43 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment );
    44 
    45 extern "C" {
    46 void * memset( void * ptr, int fill, size_t size );
    47 void free( void * ptr );
    48 } // extern "C"
    49 
    50 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p );
    51 forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr );
    52 forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) void delete( T * ptr, Params rest );
     30// allocation, non-array types
     31static inline forall( dtype T | sized(T) ) T * malloc( void ) {
     32        //printf( "X1\n" );
     33        return (T *)(void *)malloc( (size_t)sizeof(T) );        // C malloc
     34} // malloc
     35
     36extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine
     37static inline forall( dtype T | sized(T) ) T * calloc( size_t dim ) {
     38        //printf( "X2\n" );
     39        return (T *)(void *)calloc( dim, sizeof(T) );           // C cmalloc
     40}
     41
     42extern "C" { void * realloc( void * ptr, size_t size ); } // default C routine for void *
     43static inline forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) {
     44        //printf( "X3\n" );
     45        return (T *)(void *)realloc( (void *)ptr, size );
     46}
     47
     48extern "C" { void * memalign( size_t align, size_t size ); } // use default C routine for void *
     49static inline forall( dtype T | sized(T) ) T * memalign( size_t align ) {
     50        //printf( "X4\n" );
     51        return (T *)memalign( align, sizeof(T) );
     52} // memalign
     53
     54static inline forall( dtype T | sized(T) ) T * aligned_alloc( size_t align ) {
     55        //printf( "X5\n" );
     56        return (T *)memalign( align, sizeof(T) );
     57} // aligned_alloc
     58
     59extern "C" { int posix_memalign( void ** ptr, size_t align, size_t size ); } // use default C routine for void *
     60static inline forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t align ) {
     61        //printf( "X6\n" );
     62        return posix_memalign( (void **)ptr, align, sizeof(T) );
     63} // posix_memalign
     64
     65
     66extern "C" { void * memset( void * dest, int c, size_t size ); } // use default C routine for void *
     67
     68static inline forall( dtype T | sized(T) ) T * alloc( void ) {
     69        //printf( "X7\n" );
     70        return (T *)(void *)malloc( (size_t)sizeof(T) );        // C malloc
     71} // alloc
     72static inline forall( dtype T | sized(T) ) T * alloc( char fill ) {
     73        //printf( "X8\n" );
     74        T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );     // C malloc
     75    return memset( ptr, (int)fill, sizeof(T) );                 // initial with fill value
     76} // alloc
     77
     78static inline forall( dtype T | sized(T) ) T * alloc( size_t dim ) {
     79        //printf( "X9\n" );
     80        return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
     81} // alloc
     82static inline forall( dtype T | sized(T) ) T * alloc( size_t dim, char fill ) {
     83        //printf( "X10\n" );
     84        T * ptr = (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
     85    return memset( ptr, (int)fill, dim * sizeof(T) );
     86} // alloc
     87
     88static inline forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim ) {
     89        //printf( "X11\n" );
     90        return (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
     91} // alloc
     92forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
     93
     94static inline forall( dtype T | sized(T) ) T * align_alloc( size_t align ) {
     95        //printf( "X13\n" );
     96        return (T *)memalign( align, sizeof(T) );
     97} // align_alloc
     98static inline forall( dtype T | sized(T) ) T * align_alloc( size_t align, char fill ) {
     99        //printf( "X14\n" );
     100    T * ptr = (T *)memalign( align, sizeof(T) );
     101    return memset( ptr, (int)fill, sizeof(T) );
     102} // align_alloc
     103
     104static inline forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim ) {
     105        //printf( "X15\n" );
     106        return (T *)memalign( align, dim * sizeof(T) );
     107} // align_alloc
     108static inline forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim, char fill ) {
     109        //printf( "X16\n" );
     110    T * ptr = (T *)memalign( align, dim * sizeof(T) );
     111    return memset( ptr, (int)fill, dim * sizeof(T) );
     112} // align_alloc
     113
     114
     115// data, non-array types
     116static inline forall( dtype T | sized(T) ) T * memset( T * dest, char c ) {
     117        //printf( "X17\n" );
     118        return memset( dest, c, sizeof(T) );
     119} // memset
     120extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } // use default C routine for void *
     121static inline forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src ) {
     122        //printf( "X18\n" );
     123        return memcpy( dest, src, sizeof(T) );
     124} // memcpy
     125
     126// data, array types
     127static inline forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ) {
     128        //printf( "X19\n" );
     129        return (void *)memset( dest, c, dim * sizeof(T) );      // C memset
     130} // memset
     131static inline forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ) {
     132        //printf( "X20\n" );
     133        return (void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy
     134} // memcpy
     135
     136// allocation/deallocation and constructor/destructor, non-array types
     137forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p );
     138forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr );
     139forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } ) void delete( T * ptr, Params rest );
     140
     141// allocation/deallocation and constructor/destructor, array types
     142forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p );
     143forall( dtype T | sized(T) | { void ^?{}( T * ); } ) void adelete( size_t dim, T arr[] );
     144forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } ) void adelete( size_t dim, T arr[], Params rest );
    53145
    54146//---------------------------------------
     
    83175
    84176forall( otype T | { int ?<?( T, T ); } )
    85 T * bsearch( T key, const T * arr, size_t dimension );
    86 
    87 forall( otype T | { int ?<?( T, T ); } )
    88 unsigned int bsearch( T key, const T * arr, size_t dimension );
    89 
    90 
    91 forall( otype T | { int ?<?( T, T ); } )
    92 void qsort( const T * arr, size_t dimension );
     177T * bsearch( T key, const T * arr, size_t dim );
     178
     179forall( otype T | { int ?<?( T, T ); } )
     180unsigned int bsearch( T key, const T * arr, size_t dim );
     181
     182
     183forall( otype T | { int ?<?( T, T ); } )
     184void qsort( const T * arr, size_t dim );
    93185
    94186//---------------------------------------
     
    109201double abs( double _Complex );
    110202long double abs( long double _Complex );
    111 forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
     203forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
    112204T abs( T );
    113205
     
    115207
    116208void rand48seed( long int s );
    117 char rand48();
    118 int rand48();
    119 unsigned int rand48();
    120 long int rand48();
    121 unsigned long int rand48();
    122 float rand48();
    123 double rand48();
    124 float _Complex rand48();
    125 double _Complex rand48();
    126 long double _Complex rand48();
     209char rand48( void );
     210int rand48( void );
     211unsigned int rand48( void );
     212long int rand48( void );
     213unsigned long int rand48( void );
     214float rand48( void );
     215double rand48( void );
     216float _Complex rand48( void );
     217double _Complex rand48( void );
     218long double _Complex rand48( void );
    127219
    128220//---------------------------------------
  • src/libcfa/stdlib.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  9 08:43:00 2017
    13 // Update Count     : 191
     12// Last Modified On : Thu Jun  1 21:52:57 2017
     13// Update Count     : 280
    1414//
    1515
     
    2121#define _XOPEN_SOURCE 600                                                               // posix_memalign, *rand48
    2222#include <stdlib.h>                                                                             // malloc, free, calloc, realloc, memalign, posix_memalign, bsearch
    23 #include <string.h>                                                                             // memset
     23#include <string.h>                                                                             // memcpy, memset
    2424#include <malloc.h>                                                                             // malloc_usable_size
    2525#include <math.h>                                                                               // fabsf, fabs, fabsl
     
    2727} // extern "C"
    2828
    29 forall( dtype T | sized(T) ) T * malloc( void ) {               // type-safe
    30     return (T *)(void *)malloc( (size_t)sizeof(T) );
    31 } // malloc
    32 
    33 forall( dtype T | sized(T) ) T * malloc( char fill ) {  // initial with fill value (like calloc)
    34         T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );
    35     return memset( ptr, (int)fill, sizeof(T) );
    36 } // malloc
    37 
    38 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) { // alternative realloc
    39     return (T *)realloc( ptr, size );
    40 } // malloc
    41 
    42 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
    43     return (T *)realloc( ptr, size, fill );
    44 } // malloc
    45 
    46 
    47 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { // type-safe array initialization with fill 0
    48     return (T *)calloc( nmemb, sizeof(T) );
    49 } // calloc
    50 
    51 
    52 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe
    53     return (T *)(void *)realloc( (void *)ptr, size );
    54 } // realloc
    55 
    56 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
    57     char * nptr = (T *)(void *)realloc( (void *)ptr, size );
    58     size_t unused = malloc_usable_size( nptr );
    59     memset( nptr + size - unused, (int)fill, unused );  // initialize any new storage
    60     return nptr;
    61 } // realloc
    62 
    63 
    64 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation
    65     return (T *)memalign( alignment, sizeof(T) );
    66 } // aligned_alloc
    67 
    68 forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
    69     return (T *)memalign( alignment, sizeof(T) );
    70 } // memalign
    71 
    72 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
    73     return posix_memalign( (void **)ptr, alignment, sizeof(T) );
    74 } // posix_memalign
    75 
    76 
    77 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) //  new
     29// resize, non-array types
     30forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) {
     31        size_t olen = malloc_usable_size( ptr );                        // current allocation
     32    char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
     33        size_t nlen = malloc_usable_size( nptr );                       // new allocation
     34        if ( nlen > olen ) {                                                            // larger ?
     35                memset( nptr + olen, (int)fill, nlen - olen );  // initialize added storage
     36        } //
     37    return (T *)nptr;
     38} // alloc
     39
     40// allocation/deallocation and constructor/destructor, non-array types
     41forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )
    7842T * new( Params p ) {
    79         return ((T *)malloc()){ p };
     43        return (malloc()){ p };                                                         // run constructor
    8044} // new
    8145
    82 forall( dtype T | { void ^?{}(T *); } )                                 // delete
     46forall( dtype T | { void ^?{}( T * ); } )
    8347void delete( T * ptr ) {
    84         if ( ptr ) {
    85                 ^ptr{};
     48        if ( ptr ) {                                                                            // ignore null
     49                ^ptr{};                                                                                 // run destructor
    8650                free( ptr );
    87         }
     51        } // if
    8852} // delete
    8953
    90 forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } )
     54forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } )
    9155void delete( T * ptr, Params rest ) {
    92         if ( ptr ) {
    93                 ^ptr{};
     56        if ( ptr ) {                                                                            // ignore null
     57                ^ptr{};                                                                                 // run destructor
    9458                free( ptr );
    95         }
     59        } // if
    9660        delete( rest );
    9761} // delete
     62
     63
     64// allocation/deallocation and constructor/destructor, array types
     65forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )
     66T * anew( size_t dim, Params p ) {
     67        T *arr = alloc( dim );
     68        for ( unsigned int i = 0; i < dim; i += 1 ) {
     69                (&arr[i]){ p };                                                                 // run constructor
     70        } // for
     71        return arr;
     72} // anew
     73
     74forall( dtype T | sized(T) | { void ^?{}( T * ); } )
     75void adelete( size_t dim, T arr[] ) {
     76        if ( arr ) {                                                                            // ignore null
     77                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
     78                        ^(&arr[i]){};                                                           // run destructor
     79                } // for
     80                free( arr );
     81        } // if
     82} // adelete
     83
     84forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } )
     85void adelete( size_t dim, T arr[], Params rest ) {
     86        if ( arr ) {                                                                            // ignore null
     87                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
     88                        ^(&arr[i]){};                                                           // run destructor
     89                } // for
     90                free( arr );
     91        } // if
     92        adelete( rest );
     93} // adelete
    9894
    9995//---------------------------------------
     
    242238
    243239forall( otype T | { int ?<?( T, T ); } )
    244 T * bsearch( T key, const T * arr, size_t dimension ) {
     240T * bsearch( T key, const T * arr, size_t dim ) {
    245241        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
    246         return (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
     242        return (T *)bsearch( &key, arr, dim, sizeof(T), comp );
    247243} // bsearch
    248244
    249245forall( otype T | { int ?<?( T, T ); } )
    250 unsigned int bsearch( T key, const T * arr, size_t dimension ) {
    251         T *result = bsearch( key, arr, dimension );
    252         return result ? result - arr : dimension;                       // pointer subtraction includes sizeof(T)
     246unsigned int bsearch( T key, const T * arr, size_t dim ) {
     247        T *result = bsearch( key, arr, dim );
     248        return result ? result - arr : dim;                                     // pointer subtraction includes sizeof(T)
    253249} // bsearch
    254250
    255251forall( otype T | { int ?<?( T, T ); } )
    256 void qsort( const T * arr, size_t dimension ) {
     252void qsort( const T * arr, size_t dim ) {
    257253        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
    258         qsort( arr, dimension, sizeof(T), comp );
     254        qsort( arr, dim, sizeof(T), comp );
    259255} // qsort
    260256
     
    279275
    280276void rand48seed( long int s ) { srand48( s ); }
    281 char rand48() { return mrand48(); }
    282 int rand48() { return mrand48(); }
    283 unsigned int rand48() { return lrand48(); }
    284 long int rand48() { return mrand48(); }
    285 unsigned long int rand48() { return lrand48(); }
    286 float rand48() { return (float)drand48(); }                             // otherwise float uses lrand48
    287 double rand48() { return drand48(); }
    288 float _Complex rand48() { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
    289 double _Complex rand48() { return drand48() + (double _Complex)(drand48() * _Complex_I); }
    290 long double _Complex rand48() { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
     277char rand48( void ) { return mrand48(); }
     278int rand48( void ) { return mrand48(); }
     279unsigned int rand48( void ) { return lrand48(); }
     280long int rand48( void ) { return mrand48(); }
     281unsigned long int rand48( void ) { return lrand48(); }
     282float rand48( void ) { return (float)drand48(); }               // otherwise float uses lrand48
     283double rand48( void ) { return drand48(); }
     284float _Complex rand48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
     285double _Complex rand48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }
     286long double _Complex rand48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
    291287
    292288//---------------------------------------
  • src/main.cc

    r9c951e3 rb1e63ac5  
    1010// Author           : Richard C. Bilson
    1111// Created On       : Fri May 15 23:12:02 2015
    12 // Last Modified By : Andrew Beach
    13 // Last Modified On : Wed May 10 14:45:00 2017
    14 // Update Count     : 437
     12// Last Modified By : Peter A. Buhr
     13// Last Modified On : Thu Jun 29 12:46:50 2017
     14// Update Count     : 441
    1515//
    1616
     
    2525using namespace std;
    2626
    27 #include "Parser/lex.h"
    28 #include "Parser/parser.h"
     27#include "Parser/parser.hh"
    2928#include "Parser/TypedefTable.h"
    3029#include "GenPoly/Lvalue.h"
     
    6463        bresolvep = false,
    6564        bboxp = false,
     65        bcodegenp = false,
    6666        ctorinitp = false,
    6767        declstatsp = false,
     
    145145} // sigSegvBusHandler
    146146
    147 void sigAbortHandler( int sig_num ) {
     147void sigAbortHandler( __attribute__((unused)) int sig_num ) {
    148148        backtrace( 6 );                                                                         // skip first 6 stack frames
    149149        signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
     
    185185                if ( ! nopreludep ) {                                                   // include gcc builtins
    186186                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
    187                         FILE * builtins = fopen( libcfap | treep ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
    188                         assertf( builtins, "cannot open builtins.cf\n" );
    189                         parse( builtins, LinkageSpec::Compiler );
     187
     188                        // Read to gcc builtins, if not generating the cfa library
     189                        FILE * gcc_builtins = fopen( libcfap | treep ? "../prelude/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" );
     190                        assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" );
     191                        parse( gcc_builtins, LinkageSpec::Compiler );
    190192
    191193                        // read the extra prelude in, if not generating the cfa library
     
    199201                                assertf( prelude, "cannot open prelude.cf\n" );
    200202                                parse( prelude, LinkageSpec::Intrinsic );
     203
     204                                // Read to cfa builtins, if not generating the cfa library
     205                                FILE * builtins = fopen( libcfap | treep ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
     206                                assertf( builtins, "cannot open builtins.cf\n" );
     207                                parse( builtins, LinkageSpec::Builtin );
    201208                        } // if
    202209                } // if
     
    306313                OPTPRINT( "box" )
    307314                GenPoly::box( translationUnit );
     315
     316                if ( bcodegenp ) {
     317                        dump( translationUnit );
     318                        return 0;
     319                }
    308320
    309321                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     
    377389
    378390        int c;
    379         while ( (c = getopt_long( argc, argv, "abBcdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
     391        while ( (c = getopt_long( argc, argv, "abBcCdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
    380392                switch ( c ) {
    381393                  case Ast:
     
    394406                        ctorinitp = true;
    395407                        break;
     408                  case 'C':                                                                             // print before code generation
     409                        bcodegenp = true;
     410                        break;
    396411                  case DeclStats:
    397412                  case 'd':
     
    466481                        break;
    467482                  case '?':
    468                         assertf( false, "Unknown option: '%c'\n", (char)optopt );
     483                        if ( optopt ) {                                                         // short option ?
     484                                assertf( false, "Unknown option: -%c\n", (char)optopt );
     485                        } else {
     486                                assertf( false, "Unknown option: %s\n", argv[optind - 1] );
     487                        } // if
    469488                  default:
    470489                        abort();
  • src/prelude/Makefile.am

    r9c951e3 rb1e63ac5  
    2020# put into lib for now
    2121cfalibdir = ${CFA_LIBDIR}
    22 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c
     22cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c
    2323noinst_DATA = ../libcfa/libcfa-prelude.c
     24
     25$(DEPDIR) :
     26        mkdir $(DEPDIR)
     27
     28$(DEPDIR)/builtins.Po : $(DEPDIR)
     29        touch ${@}
    2430
    2531# create extra forward types/declarations to reduce inclusion of library files
     
    2834
    2935# create forward declarations for gcc builtins
    30 builtins.cf : builtins.c prototypes.sed
     36gcc-builtins.cf : gcc-builtins.c prototypes.sed
    3137        ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@
    3238
    33 builtins.c : builtins.def prototypes.awk
     39gcc-builtins.c : builtins.def prototypes.awk
    3440        ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@
    3541
     
    3844prototypes.awk :
    3945
    40 ../libcfa/libcfa-prelude.c : prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
     46# create forward declarations for cfa builtins
     47builtins.cf : builtins.c
     48        ${AM_V_GEN}@BACKEND_CC@ -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
     49        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     50
     51include $(DEPDIR)/builtins.Po
     52
     53../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
    4154        ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
    4255
    43 bootloader.c : bootloader.cf prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
     56bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
    4457        ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -tpmL bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
    4558
    46 MAINTAINERCLEANFILES = builtins.c builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
     59maintainer-clean-local :
     60        rm -rf $(DEPDIR)
     61
     62MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
  • src/prelude/Makefile.in

    r9c951e3 rb1e63ac5  
    211211# put into lib for now
    212212cfalibdir = ${CFA_LIBDIR}
    213 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c
     213cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c
    214214noinst_DATA = ../libcfa/libcfa-prelude.c
    215 MAINTAINERCLEANFILES = builtins.c builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
     215MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
    216216all: all-am
    217217
     
    390390maintainer-clean: maintainer-clean-am
    391391        -rm -f Makefile
    392 maintainer-clean-am: distclean-am maintainer-clean-generic
     392maintainer-clean-am: distclean-am maintainer-clean-generic \
     393        maintainer-clean-local
    393394
    394395mostlyclean: mostlyclean-am
     
    416417        install-ps install-ps-am install-strip installcheck \
    417418        installcheck-am installdirs maintainer-clean \
    418         maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
    419         pdf-am ps ps-am uninstall uninstall-am uninstall-cfalibDATA
    420 
     419        maintainer-clean-generic maintainer-clean-local mostlyclean \
     420        mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
     421        uninstall-cfalibDATA
     422
     423
     424$(DEPDIR) :
     425        mkdir $(DEPDIR)
     426
     427$(DEPDIR)/builtins.Po : $(DEPDIR)
     428        touch ${@}
    421429
    422430# create extra forward types/declarations to reduce inclusion of library files
     
    425433
    426434# create forward declarations for gcc builtins
    427 builtins.cf : builtins.c prototypes.sed
     435gcc-builtins.cf : gcc-builtins.c prototypes.sed
    428436        ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@
    429437
    430 builtins.c : builtins.def prototypes.awk
     438gcc-builtins.c : builtins.def prototypes.awk
    431439        ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@
    432440
     
    435443prototypes.awk :
    436444
    437 ../libcfa/libcfa-prelude.c : prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
     445# create forward declarations for cfa builtins
     446builtins.cf : builtins.c
     447        ${AM_V_GEN}@BACKEND_CC@ -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
     448        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     449
     450include $(DEPDIR)/builtins.Po
     451
     452../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
    438453        ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
    439454
    440 bootloader.c : bootloader.cf prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
     455bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
    441456        ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -tpmL bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
     457
     458maintainer-clean-local :
     459        rm -rf $(DEPDIR)
    442460
    443461# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • src/prelude/prelude.cf

    r9c951e3 rb1e63ac5  
    309309// forall( dtype DT ) signed int ?!=?( const volatile void *, const volatile DT * );
    310310
    311 // forall( dtype DT ) signed int ?==?( const volatile DT *, forall( dtype DT2 )const DT2 * );
    312 // forall( dtype DT ) signed int ?==?( forall( dtype DT2 )const DT2 *, const volatile DT * );
    313 // forall( ftype FT ) signed int ?==?( FT *, forall( ftype FT2 )FT2 * );
    314 // forall( ftype FT ) signed int ?==?( forall( ftype FT2 )FT2 *, FT * );
    315 // forall( dtype DT ) signed int ?!=?( const volatile DT *, forall( dtype DT2 )const DT2 * );
    316 // forall( dtype DT ) signed int ?!=?( forall( dtype DT2 )const DT2 *, const volatile DT * );
    317 // forall( ftype FT ) signed int ?!=?( FT *, forall( ftype FT2 )FT2 * );
    318 // forall( ftype FT ) signed int ?!=?( forall( ftype FT2 )FT2 *, FT * );
     311// forall( dtype DT ) signed int ?==?( const volatile DT *, zero_t );
     312// forall( dtype DT ) signed int ?==?( zero_t, const volatile DT * );
     313// forall( ftype FT ) signed int ?==?( FT *, zero_t );
     314// forall( ftype FT ) signed int ?==?( zero_t, FT * );
     315// forall( dtype DT ) signed int ?!=?( const volatile DT *, zero_t );
     316// forall( dtype DT ) signed int ?!=?( zero_t, const volatile DT * );
     317// forall( ftype FT ) signed int ?!=?( FT *, zero_t );
     318// forall( ftype FT ) signed int ?!=?( zero_t, FT * );
    319319
    320320// ------------------------------------------------------------
     
    447447const volatile void *   ?=?( const volatile void * volatile *, const volatile void * );
    448448
    449 //forall( dtype DT ) DT *                       ?=?(                DT *          *, forall( dtype DT2 ) const DT2 * );
    450 //forall( dtype DT ) DT *                       ?=?(                DT * volatile *, forall( dtype DT2 ) const DT2 * );
    451 forall( dtype DT ) const DT *           ?=?( const          DT *          *, forall( dtype DT2 ) const DT2 * );
    452 forall( dtype DT ) const DT *           ?=?( const          DT * volatile *, forall( dtype DT2 ) const DT2 * );
    453 //forall( dtype DT ) volatile DT *      ?=?( volatile       DT *          *, forall( dtype DT2 ) const DT2 * );
    454 //forall( dtype DT ) volatile DT *      ?=?( volatile       DT * volatile *, forall( dtype DT2 ) const DT2 * );
    455 forall( dtype DT ) const volatile DT *  ?=?( const volatile DT *          *, forall( dtype DT2 ) const DT2 * );
    456 forall( dtype DT ) const volatile DT *  ?=?( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );
    457 
    458 forall( ftype FT ) FT *                 ?=?( FT *          *, forall( ftype FT2 ) FT2 * );
    459 forall( ftype FT ) FT *                 ?=?( FT * volatile *, forall( ftype FT2 ) FT2 * );
     449// //forall( dtype DT ) DT *                    ?=?(                DT *          *, zero_t );
     450// //forall( dtype DT ) DT *                    ?=?(                DT * volatile *, zero_t );
     451// forall( dtype DT ) const DT *                ?=?( const          DT *          *, zero_t );
     452// forall( dtype DT ) const DT *                ?=?( const          DT * volatile *, zero_t );
     453// //forall( dtype DT ) volatile DT *   ?=?( volatile       DT *          *, zero_t );
     454// //forall( dtype DT ) volatile DT *   ?=?( volatile       DT * volatile *, );
     455// forall( dtype DT ) const volatile DT *       ?=?( const volatile DT *          *, zero_t );
     456// forall( dtype DT ) const volatile DT *       ?=?( const volatile DT * volatile *, zero_t );
     457
     458// forall( ftype FT ) FT *                      ?=?( FT *          *, zero_t );
     459// forall( ftype FT ) FT *                      ?=?( FT * volatile *, zero_t );
    460460
    461461forall( dtype T | sized(T) ) T *                        ?+=?(                T *          *, ptrdiff_t );
     
    799799void    ?{}( const volatile void *          *, const volatile void * );
    800800
    801 //forall( dtype DT ) void ?{}(              DT *          *, forall( dtype DT2 ) const DT2 * );
    802 //forall( dtype DT ) void ?{}(              DT * volatile *, forall( dtype DT2 ) const DT2 * );
    803 forall( dtype DT ) void ?{}( const          DT *          *, forall( dtype DT2 ) const DT2 * );
    804 //forall( dtype DT ) void ?{}( volatile     DT *          *, forall( dtype DT2 ) const DT2 * );
    805 //forall( dtype DT ) void ?{}( volatile     DT * volatile *, forall( dtype DT2 ) const DT2 * );
    806 forall( dtype DT ) void ?{}( const volatile DT *          *, forall( dtype DT2 ) const DT2 * );
    807 
    808 forall( ftype FT ) void ?{}( FT *          *, forall( ftype FT2 ) FT2 * );
     801// //forall( dtype DT ) void ?{}(                   DT *          *, zero_t );
     802// //forall( dtype DT ) void ?{}(                   DT * volatile *, zero_t );
     803// forall( dtype DT ) void ?{}( const       DT *          *, zero_t );
     804// //forall( dtype DT ) void ?{}( volatile          DT *          *, zero_t );
     805// //forall( dtype DT ) void ?{}( volatile          DT * volatile *, zero_t );
     806// forall( dtype DT ) void ?{}( const volatile DT *       *, zero_t );
     807
     808// forall( ftype FT ) void      ?{}( FT *          *, zero_t );
    809809
    810810// default ctors
  • src/tests/.expect/32/KRfunctions.txt

    r9c951e3 rb1e63ac5  
    66extern int printf(const char *__restrict __format, ...);
    77int __f0__Fi_iPCii__1(int __a__i_1, const int *__b__PCi_1, int __c__i_1){
    8     int ___retval_f0__i_1;
     8    __attribute__ ((unused)) int ___retval_f0__i_1;
    99}
    1010int __f1__Fi_PiiPi__1(int *__a__Pi_1, __attribute__ ((unused)) int __b__i_1, int *__c__Pi_1){
    11     int ___retval_f1__i_1;
     11    __attribute__ ((unused)) int ___retval_f1__i_1;
    1212}
    1313int __f2__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    14     int ___retval_f2__i_1;
     14    __attribute__ ((unused)) int ___retval_f2__i_1;
    1515}
    1616struct S {
     
    4040}
    4141int __f3__Fi_2sS2sSPi__1(struct S __a__2sS_1, struct S __b__2sS_1, int *__c__Pi_1){
    42     int ___retval_f3__i_1;
     42    __attribute__ ((unused)) int ___retval_f3__i_1;
    4343    struct S __s__2sS_2;
    4444}
    4545int __f4__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    46     int ___retval_f4__i_1;
     46    __attribute__ ((unused)) int ___retval_f4__i_1;
    4747}
    4848int __f5__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    49     int ___retval_f5__i_1;
     49    __attribute__ ((unused)) int ___retval_f5__i_1;
    5050}
    5151int (*__f6__FPFi_i__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __anonymous_object0){
    52     int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
     52    __attribute__ ((unused)) int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
    5353}
    5454int (*__f7__FPFi_ii__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __a__i_1, int __b__i_1){
    55     int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
     55    __attribute__ ((unused)) int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
    5656}
    5757int *__f8__FPi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    58     int *___retval_f8__Pi_1;
     58    __attribute__ ((unused)) int *___retval_f8__Pi_1;
    5959}
    6060int *const __f9__FCPi_PiiPi__1(int *__a__Pi_1, int __b__i_1, int *__c__Pi_1){
    61     int *const ___retval_f9__CPi_1;
     61    __attribute__ ((unused)) int *const ___retval_f9__CPi_1;
    6262}
    6363int *(*__f10__FPFPi_ii__iPiPid__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1, double __y__d_1))(int __x__i_1, int __y__i_1){
    64     int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
     64    __attribute__ ((unused)) int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
    6565    int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3);
    6666    ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */);
     
    6868}
    6969int (*__f11__FPA0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[]{
    70     int (*___retval_f11__PA0i_1)[];
     70    __attribute__ ((unused)) int (*___retval_f11__PA0i_1)[];
    7171}
    7272int (*__f12__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    73     int (*___retval_f12__PA0A0i_1)[][((unsigned int )10)];
     73    __attribute__ ((unused)) int (*___retval_f12__PA0A0i_1)[][((unsigned int )10)];
    7474}
    7575int (*__f13__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    76     int (*___retval_f13__PA0A0i_1)[][((unsigned int )10)];
     76    __attribute__ ((unused)) int (*___retval_f13__PA0A0i_1)[][((unsigned int )10)];
    7777}
    7878int (*__f14__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    79     int (*___retval_f14__PA0A0i_1)[][((unsigned int )10)];
     79    __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((unsigned int )10)];
    8080}
    8181const int __fred__FCi___1(){
    82     const int ___retval_fred__Ci_1;
     82    __attribute__ ((unused)) const int ___retval_fred__Ci_1;
    8383    int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5);
    8484    int __a__i_2;
     
    8888    ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */);
    8989    const int __f1__FCi_iPiPi__2(int __a__i_2, int *__b__Pi_2, int *__c__Pi_2){
    90         const int ___retval_f1__Ci_2;
     90        __attribute__ ((unused)) const int ___retval_f1__Ci_2;
    9191    }
    9292    const int __f2__FCi_iii__2(int __a__i_2, int __b__i_2, int __c__i_2){
    93         const int ___retval_f2__Ci_2;
     93        __attribute__ ((unused)) const int ___retval_f2__Ci_2;
    9494    }
    9595}
  • src/tests/.expect/32/attributes.txt

    r9c951e3 rb1e63ac5  
    66extern int printf(const char *__restrict __format, ...);
    77int __la__Fi___1(){
    8     int ___retval_la__i_1;
     8    __attribute__ ((unused)) int ___retval_la__i_1;
    99    L: __attribute__ ((unused)) ((void)1);
    1010}
     
    226226__attribute__ ((unused,used)) int __f1__Fi___1();
    227227__attribute__ ((unused)) int __f1__Fi___1(){
    228     int ___retval_f1__i_1;
     228    __attribute__ ((unused)) int ___retval_f1__i_1;
    229229}
    230230__attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1();
    231231__attribute__ ((unused,unused,unused)) int **const __f2__FCPPi___1(){
    232     int **const ___retval_f2__CPPi_1;
     232    __attribute__ ((unused)) int **const ___retval_f2__CPPi_1;
    233233}
    234234__attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[];
    235235__attribute__ ((unused,unused)) int (*__f3__FPA0i_i__1(int __p__i_1))[]{
    236     int (*___retval_f3__PA0i_1)[];
     236    __attribute__ ((unused)) int (*___retval_f3__PA0i_1)[];
    237237}
    238238__attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2);
    239239__attribute__ ((unused,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object3){
    240     int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
     240    __attribute__ ((unused)) int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
    241241}
    242242int __vtr__Fi___1(){
    243     int ___retval_vtr__i_1;
     243    __attribute__ ((unused)) int ___retval_vtr__i_1;
    244244    __attribute__ ((unused,unused,used)) int __t1__i_2;
    245245    __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2;
     
    251251int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1);
    252252int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1){
    253     int ___retval_ipd1__i_1;
     253    __attribute__ ((unused)) int ___retval_ipd1__i_1;
    254254}
    255255int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    256256int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    257     int ___retval_ipd2__i_1;
     257    __attribute__ ((unused)) int ___retval_ipd2__i_1;
    258258}
    259259int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    260260int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    261     int ___retval_ipd3__i_1;
     261    __attribute__ ((unused)) int ___retval_ipd3__i_1;
    262262}
    263263int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)());
    264264int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()){
    265     int ___retval_ipd4__i_1;
     265    __attribute__ ((unused)) int ___retval_ipd4__i_1;
    266266}
    267267int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1);
     
    273273int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9)));
    274274int __ad__Fi___1(){
    275     int ___retval_ad__i_1;
     275    __attribute__ ((unused)) int ___retval_ad__i_1;
    276276    __attribute__ ((used,unused)) int __ad1__i_2;
    277277    __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2;
  • src/tests/.expect/32/declarationSpecifier.txt

    r9c951e3 rb1e63ac5  
    670670static inline volatile const short __f48__FCVs___1();
    671671int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    672     int ___retval_main__i_1;
     672    __attribute__ ((unused)) int ___retval_main__i_1;
    673673    ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    674674    return ((int )___retval_main__i_1);
     
    685685static inline int invoke_main(int argc, char **argv, char **envp);
    686686int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    687     int ___retval_main__i_1;
     687    __attribute__ ((unused)) int ___retval_main__i_1;
    688688    int _tmp_cp_ret0;
    689689    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/32/extension.txt

    r9c951e3 rb1e63ac5  
    8585__extension__ int j;
    8686__extension__ int __fred__Fi_i__1(int __p__i_1){
    87     int ___retval_fred__i_1;
     87    __attribute__ ((unused)) int ___retval_fred__i_1;
    8888    __extension__ struct S {
    8989        __extension__ int __a__i_2;
     
    105105    ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */);
    106106    __extension__ int __mary__Fi_i__2(int __p__i_2){
    107         int ___retval_mary__i_2;
     107        __attribute__ ((unused)) int ___retval_mary__i_2;
    108108    }
    109109    ((void)__extension__ sizeof(3));
  • src/tests/.expect/32/gccExtensions.txt

    r9c951e3 rb1e63ac5  
    77extern int __x__i_1 asm ( "xx" );
    88int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    9     int ___retval_main__i_1;
     9    __attribute__ ((unused)) int ___retval_main__i_1;
    1010    asm ( "nop" :  :  :  );
    1111    asm ( "nop" :  :  :  );
     
    2626    const int __i3__Ci_2;
    2727    inline int __f1__Fi___2(){
    28         int ___retval_f1__i_2;
     28        __attribute__ ((unused)) int ___retval_f1__i_2;
    2929    }
    3030    inline int __f2__Fi___2(){
    31         int ___retval_f2__i_2;
     31        __attribute__ ((unused)) int ___retval_f2__i_2;
    3232    }
    3333    int __s1__i_2;
     
    182182static inline int invoke_main(int argc, char **argv, char **envp);
    183183int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    184     int ___retval_main__i_1;
     184    __attribute__ ((unused)) int ___retval_main__i_1;
    185185    int _tmp_cp_ret0;
    186186    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/32/math.txt

    r9c951e3 rb1e63ac5  
    1 fabs: 1 1 1 1.41421 1.41421356237309505 1.41421356237309505
    2 fmod: 1 1 1 1 1 1
    3 remainder: -1 -1 -1
    4 remquo: 7 0.0999999 7 0.1 7 0.0999999999999999999
    5 div: 7 0.0999999 7 0.1 7 0.0999999999999999999
    6 fma: -2 -2 -2
    7 fdim: 2 2 2
    8 nan: nan nan nan
    9 exp: 2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i
    10 exp2: 2 2 2
    11 expm1: 1.71828 1.71828182845905 1.71828182845904524
    12 log: 0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    13 log2: 3 3 3
    14 log10: 2 2 2
    15 log1p: 0.693147 0.693147180559945 0.693147180559945309
    16 ilogb: 0 0 0
    17 logb: 3 3 3
    18 sqrt: 1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
    19 cbrt: 3 3 3
    20 hypot: 1.41421 1.4142135623731 1.41421356237309505
    21 pow: 1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
    22 sin: 0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
    23 cos: 0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
    24 tan: 1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
    25 asin: 1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
    26 acos: 0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
    27 atan: 0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
    28 atan2: 0.785398 0.785398163397448 0.78539816339744831 atan: 0.785398 0.785398163397448 0.78539816339744831 sinh: 1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i
    29 cosh: 1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
    30 tanh: 0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
    31 acosh: 0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
    32 asinh: 0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
    33 atanh: inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
    34 erf: 0.842701 0.842700792949715 0.842700792949714869
    35 erfc: 0.157299 0.157299207050285 0.157299207050285131
    36 lgamma: 1.79176 1.79175946922805 1.791759469228055
    37 lgamma: 1.79176 1 1.79175946922805 1 1.791759469228055 1
    38 tgamma: 6 6 6
    39 floor: 1 1 1
    40 ceil: 2 2 2
    41 trunc: 3 3 3
    42 rint: 2 2 2
    43 rint: 2 2 2
    44 rint: 2 2 2
    45 lrint: 2 2 2
    46 llrint: 2 2 2
    47 nearbyint: 4 4 4
    48 round: 2 2 2
    49 round: 2 2 2
    50 round: 2 2 2
    51 lround: 2 2 2
    52 llround: 2 2 2
    53 copysign: -1 -1 -1
    54 frexp: 0.5 3 0.5 3 0.5 3
    55 ldexp: 8 8 8
    56 modf: 2 0.3 2 0.3 2 0.3 nextafter: 2 2 2
    57 nexttoward: 2 2 2
    58 scalbn: 16 16 16
    59 scalbln: 16 16 16
     1fmod:1 1 1 1 1 1
     2remainder:-1 -1 -1
     3remquo:7 0.0999999 7 0.1 7 0.0999999999999999999
     4div:7 0.0999999 7 0.1 7 0.0999999999999999999
     5fma:-2 -2 -2
     6fdim:2 2 2
     7nan:nan nan nan
     8exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i
     9exp2:2 2 2
     10expm1:1.71828 1.71828182845905 1.71828182845904524
     11log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
     12log2:3 3 3
     13log10:2 2 2
     14log1p:0.693147 0.693147180559945 0.693147180559945309
     15ilogb:0 0 0
     16logb:3 3 3
     17sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
     18cbrt:3 3 3
     19hypot:1.41421 1.4142135623731 1.41421356237309505
     20pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
     21sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
     22cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
     23tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
     24asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
     25acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
     26atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
     27atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i
     28cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
     29tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
     30acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
     31asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
     32atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
     33erf:0.842701 0.842700792949715 0.842700792949714869
     34erfc:0.157299 0.157299207050285 0.157299207050285131
     35lgamma:1.79176 1.79175946922805 1.791759469228055
     36lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1
     37tgamma:6 6 6
     38floor:1 1 1
     39ceil:2 2 2
     40trunc:3 3 3
     41rint:2 2 2
     42rint:2 2 2
     43rint:2 2 2
     44lrint:2 2 2
     45llrint:2 2 2
     46nearbyint:4 4 4
     47round:2 2 2
     48round:2 2 2
     49round:2 2 2
     50lround:2 2 2
     51llround:2 2 2
     52copysign:-1 -1 -1
     53frexp:0.5 3 0.5 3 0.5 3
     54ldexp:8 8 8
     55modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2
     56nexttoward:2 2 2
     57scalbn:16 16 16
     58scalbln:16 16 16
  • src/tests/.expect/64/KRfunctions.txt

    r9c951e3 rb1e63ac5  
    66extern int printf(const char *__restrict __format, ...);
    77int __f0__Fi_iPCii__1(int __a__i_1, const int *__b__PCi_1, int __c__i_1){
    8     int ___retval_f0__i_1;
     8    __attribute__ ((unused)) int ___retval_f0__i_1;
    99}
    1010int __f1__Fi_PiiPi__1(int *__a__Pi_1, __attribute__ ((unused)) int __b__i_1, int *__c__Pi_1){
    11     int ___retval_f1__i_1;
     11    __attribute__ ((unused)) int ___retval_f1__i_1;
    1212}
    1313int __f2__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    14     int ___retval_f2__i_1;
     14    __attribute__ ((unused)) int ___retval_f2__i_1;
    1515}
    1616struct S {
     
    4040}
    4141int __f3__Fi_2sS2sSPi__1(struct S __a__2sS_1, struct S __b__2sS_1, int *__c__Pi_1){
    42     int ___retval_f3__i_1;
     42    __attribute__ ((unused)) int ___retval_f3__i_1;
    4343    struct S __s__2sS_2;
    4444}
    4545int __f4__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    46     int ___retval_f4__i_1;
     46    __attribute__ ((unused)) int ___retval_f4__i_1;
    4747}
    4848int __f5__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    49     int ___retval_f5__i_1;
     49    __attribute__ ((unused)) int ___retval_f5__i_1;
    5050}
    5151int (*__f6__FPFi_i__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __anonymous_object0){
    52     int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
     52    __attribute__ ((unused)) int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
    5353}
    5454int (*__f7__FPFi_ii__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __a__i_1, int __b__i_1){
    55     int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
     55    __attribute__ ((unused)) int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
    5656}
    5757int *__f8__FPi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    58     int *___retval_f8__Pi_1;
     58    __attribute__ ((unused)) int *___retval_f8__Pi_1;
    5959}
    6060int *const __f9__FCPi_PiiPi__1(int *__a__Pi_1, int __b__i_1, int *__c__Pi_1){
    61     int *const ___retval_f9__CPi_1;
     61    __attribute__ ((unused)) int *const ___retval_f9__CPi_1;
    6262}
    6363int *(*__f10__FPFPi_ii__iPiPid__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1, double __y__d_1))(int __x__i_1, int __y__i_1){
    64     int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
     64    __attribute__ ((unused)) int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
    6565    int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3);
    6666    ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */);
     
    6868}
    6969int (*__f11__FPA0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[]{
    70     int (*___retval_f11__PA0i_1)[];
     70    __attribute__ ((unused)) int (*___retval_f11__PA0i_1)[];
    7171}
    7272int (*__f12__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    73     int (*___retval_f12__PA0A0i_1)[][((long unsigned int )10)];
     73    __attribute__ ((unused)) int (*___retval_f12__PA0A0i_1)[][((long unsigned int )10)];
    7474}
    7575int (*__f13__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    76     int (*___retval_f13__PA0A0i_1)[][((long unsigned int )10)];
     76    __attribute__ ((unused)) int (*___retval_f13__PA0A0i_1)[][((long unsigned int )10)];
    7777}
    7878int (*__f14__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    79     int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)];
     79    __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)];
    8080}
    8181const int __fred__FCi___1(){
    82     const int ___retval_fred__Ci_1;
     82    __attribute__ ((unused)) const int ___retval_fred__Ci_1;
    8383    int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5);
    8484    int __a__i_2;
     
    8888    ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */);
    8989    const int __f1__FCi_iPiPi__2(int __a__i_2, int *__b__Pi_2, int *__c__Pi_2){
    90         const int ___retval_f1__Ci_2;
     90        __attribute__ ((unused)) const int ___retval_f1__Ci_2;
    9191    }
    9292    const int __f2__FCi_iii__2(int __a__i_2, int __b__i_2, int __c__i_2){
    93         const int ___retval_f2__Ci_2;
     93        __attribute__ ((unused)) const int ___retval_f2__Ci_2;
    9494    }
    9595}
  • src/tests/.expect/64/attributes.txt

    r9c951e3 rb1e63ac5  
    66extern int printf(const char *__restrict __format, ...);
    77int __la__Fi___1(){
    8     int ___retval_la__i_1;
     8    __attribute__ ((unused)) int ___retval_la__i_1;
    99    L: __attribute__ ((unused)) ((void)1);
    1010}
     
    226226__attribute__ ((unused,used)) int __f1__Fi___1();
    227227__attribute__ ((unused)) int __f1__Fi___1(){
    228     int ___retval_f1__i_1;
     228    __attribute__ ((unused)) int ___retval_f1__i_1;
    229229}
    230230__attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1();
    231231__attribute__ ((unused,unused,unused)) int **const __f2__FCPPi___1(){
    232     int **const ___retval_f2__CPPi_1;
     232    __attribute__ ((unused)) int **const ___retval_f2__CPPi_1;
    233233}
    234234__attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[];
    235235__attribute__ ((unused,unused)) int (*__f3__FPA0i_i__1(int __p__i_1))[]{
    236     int (*___retval_f3__PA0i_1)[];
     236    __attribute__ ((unused)) int (*___retval_f3__PA0i_1)[];
    237237}
    238238__attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2);
    239239__attribute__ ((unused,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object3){
    240     int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
     240    __attribute__ ((unused)) int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
    241241}
    242242int __vtr__Fi___1(){
    243     int ___retval_vtr__i_1;
     243    __attribute__ ((unused)) int ___retval_vtr__i_1;
    244244    __attribute__ ((unused,unused,used)) int __t1__i_2;
    245245    __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2;
     
    251251int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1);
    252252int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1){
    253     int ___retval_ipd1__i_1;
     253    __attribute__ ((unused)) int ___retval_ipd1__i_1;
    254254}
    255255int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    256256int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    257     int ___retval_ipd2__i_1;
     257    __attribute__ ((unused)) int ___retval_ipd2__i_1;
    258258}
    259259int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    260260int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    261     int ___retval_ipd3__i_1;
     261    __attribute__ ((unused)) int ___retval_ipd3__i_1;
    262262}
    263263int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)());
    264264int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()){
    265     int ___retval_ipd4__i_1;
     265    __attribute__ ((unused)) int ___retval_ipd4__i_1;
    266266}
    267267int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1);
     
    273273int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9)));
    274274int __ad__Fi___1(){
    275     int ___retval_ad__i_1;
     275    __attribute__ ((unused)) int ___retval_ad__i_1;
    276276    __attribute__ ((used,unused)) int __ad1__i_2;
    277277    __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2;
  • src/tests/.expect/64/declarationSpecifier.txt

    r9c951e3 rb1e63ac5  
    670670static inline volatile const short __f48__FCVs___1();
    671671int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    672     int ___retval_main__i_1;
     672    __attribute__ ((unused)) int ___retval_main__i_1;
    673673    ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    674674    return ((int )___retval_main__i_1);
     
    685685static inline int invoke_main(int argc, char **argv, char **envp);
    686686int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    687     int ___retval_main__i_1;
     687    __attribute__ ((unused)) int ___retval_main__i_1;
    688688    int _tmp_cp_ret0;
    689689    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/64/extension.txt

    r9c951e3 rb1e63ac5  
    8585__extension__ int j;
    8686__extension__ int __fred__Fi_i__1(int __p__i_1){
    87     int ___retval_fred__i_1;
     87    __attribute__ ((unused)) int ___retval_fred__i_1;
    8888    __extension__ struct S {
    8989        __extension__ int __a__i_2;
     
    105105    ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */);
    106106    __extension__ int __mary__Fi_i__2(int __p__i_2){
    107         int ___retval_mary__i_2;
     107        __attribute__ ((unused)) int ___retval_mary__i_2;
    108108    }
    109109    ((void)__extension__ sizeof(3));
  • src/tests/.expect/64/gccExtensions.txt

    r9c951e3 rb1e63ac5  
    77extern int __x__i_1 asm ( "xx" );
    88int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    9     int ___retval_main__i_1;
     9    __attribute__ ((unused)) int ___retval_main__i_1;
    1010    asm ( "nop" :  :  :  );
    1111    asm ( "nop" :  :  :  );
     
    2626    const int __i3__Ci_2;
    2727    inline int __f1__Fi___2(){
    28         int ___retval_f1__i_2;
     28        __attribute__ ((unused)) int ___retval_f1__i_2;
    2929    }
    3030    inline int __f2__Fi___2(){
    31         int ___retval_f2__i_2;
     31        __attribute__ ((unused)) int ___retval_f2__i_2;
    3232    }
    3333    int __s1__i_2;
     
    182182static inline int invoke_main(int argc, char **argv, char **envp);
    183183int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    184     int ___retval_main__i_1;
     184    __attribute__ ((unused)) int ___retval_main__i_1;
    185185    int _tmp_cp_ret0;
    186186    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/64/gmp.txt

    r9c951e3 rb1e63ac5  
    44conversions
    55y:97
     6y:12345678901234567890123456789
    67y:3
    78y:-3
     
    2425z:150000000000000000000
    2526z:16666666666666666666
     2716666666666666666666, 2 16666666666666666666, 2
    2628x:16666666666666666666 y:2
    2729
  • src/tests/.expect/64/math.txt

    r9c951e3 rb1e63ac5  
    1 fabs: 1 1 1 1.41421 1.41421356237309505 1.41421356237309505
    2 fmod: 1 1 1 1 1 1
    3 remainder: -1 -1 -1
    4 remquo: 7 0.0999999 7 0.1 7 0.0999999999999999999
    5 div: 7 0.0999999 7 0.1 7 0.0999999999999999999
    6 fma: -2 -2 -2
    7 fdim: 2 2 2
    8 nan: nan nan nan
    9 exp: 2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i
    10 exp2: 2 2 2
    11 expm1: 1.71828 1.71828182845905 1.71828182845904524
    12 log: 0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    13 log2: 3 3 3
    14 log10: 2 2 2
    15 log1p: 0.693147 0.693147180559945 0.693147180559945309
    16 ilogb: 0 0 0
    17 logb: 3 3 3
    18 sqrt: 1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
    19 cbrt: 3 3 3
    20 hypot: 1.41421 1.4142135623731 1.41421356237309505
    21 pow: 1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
    22 sin: 0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
    23 cos: 0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
    24 tan: 1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
    25 asin: 1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
    26 acos: 0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
    27 atan: 0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
    28 atan2: 0.785398 0.785398163397448 0.78539816339744831 atan: 0.785398 0.785398163397448 0.78539816339744831 sinh: 1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i
    29 cosh: 1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
    30 tanh: 0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
    31 acosh: 0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
    32 asinh: 0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
    33 atanh: inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
    34 erf: 0.842701 0.842700792949715 0.842700792949714869
    35 erfc: 0.157299 0.157299207050285 0.157299207050285131
    36 lgamma: 1.79176 1.79175946922805 1.791759469228055
    37 lgamma: 1.79176 1 1.79175946922805 1 1.791759469228055 1
    38 tgamma: 6 6 6
    39 floor: 1 1 1
    40 ceil: 2 2 2
    41 trunc: 3 3 3
    42 rint: 2 2 2
    43 rint: 2 2 2
    44 rint: 2 2 2
    45 lrint: 2 2 2
    46 llrint: 2 2 2
    47 nearbyint: 4 4 4
    48 round: 2 2 2
    49 round: 2 2 2
    50 round: 2 2 2
    51 lround: 2 2 2
    52 llround: 2 2 2
    53 copysign: -1 -1 -1
    54 frexp: 0.5 3 0.5 3 0.5 3
    55 ldexp: 8 8 8
    56 modf: 2 0.3 2 0.3 2 0.3 nextafter: 2 2 2
    57 nexttoward: 2 2 2
    58 scalbn: 16 16 16
    59 scalbln: 16 16 16
     1fmod:1 1 1 1 1 1
     2remainder:-1 -1 -1
     3remquo:7 0.0999999 7 0.1 7 0.0999999999999999999
     4div:7 0.0999999 7 0.1 7 0.0999999999999999999
     5fma:-2 -2 -2
     6fdim:2 2 2
     7nan:nan nan nan
     8exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i
     9exp2:2 2 2
     10expm1:1.71828 1.71828182845905 1.71828182845904524
     11log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
     12log2:3 3 3
     13log10:2 2 2
     14log1p:0.693147 0.693147180559945 0.693147180559945309
     15ilogb:0 0 0
     16logb:3 3 3
     17sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
     18cbrt:3 3 3
     19hypot:1.41421 1.4142135623731 1.41421356237309505
     20pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
     21sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
     22cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
     23tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
     24asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
     25acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
     26atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
     27atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i
     28cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
     29tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
     30acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
     31asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
     32atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
     33erf:0.842701 0.842700792949715 0.842700792949714869
     34erfc:0.157299 0.157299207050285 0.157299207050285131
     35lgamma:1.79176 1.79175946922805 1.791759469228055
     36lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1
     37tgamma:6 6 6
     38floor:1 1 1
     39ceil:2 2 2
     40trunc:3 3 3
     41rint:2 2 2
     42rint:2 2 2
     43rint:2 2 2
     44lrint:2 2 2
     45llrint:2 2 2
     46nearbyint:4 4 4
     47round:2 2 2
     48round:2 2 2
     49round:2 2 2
     50lround:2 2 2
     51llround:2 2 2
     52copysign:-1 -1 -1
     53frexp:0.5 3 0.5 3 0.5 3
     54ldexp:8 8 8
     55modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2
     56nexttoward:2 2 2
     57scalbn:16 16 16
     58scalbln:16 16 16
  • src/tests/.expect/io.txt

    r9c951e3 rb1e63ac5  
    44123
    55
     6x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
     71, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
     8x`1`x'2'x"3"x:4:x 5 x   6       x
     97
     10x
     118
     12x
     139
     14x
     1510
     16x
     17x ( 1 ) x 2 , x 3 :x: 4
    618A
    7191 2 3 4 5 6 7 8
     
    1830abc, $xyz
    1931
    20 v(27 v[27 v{27 $27 =27 £27 ¥27 ¡27 ¿27 «27
    21 25, 25. 25: 25; 25! 25? 25% 25¢ 25» 25) 25] 25}
    22 25'27 25`27 25"27 25 27 25
    23 27 25
    24 27 25
    25 27 25   27 25
    26 27
     321, 2, 3, 4
     331, $2, $3 ", $"
     341 2 3 " "
     35 1 2 3
     3612 3
     37123
     381 23
     391 2 3
     401 2 3 4 " "
     411, 2, 3, 4 ", "
     421, 2, 3, 4
    27433, 4, a, 7.2
    28443, 4, a, 7.2
    29453 4 a 7.2
    30  3 4 a 7.234a7.2 3 4 a 7.2
     46 3 4 a 7.234a7.23 4 a 7.2
    31473-4-a-7.2^3^4-3-4-a-7.2
  • src/tests/.expect/scopeErrors.txt

    r9c951e3 rb1e63ac5  
    33  with parameters
    44    double
    5   returning
    6     _retval_butThisIsAnError: double
    7   with body
     5  returning
     6    _retval_butThisIsAnError:       Attribute with name: unused
     7double
     8  with body
    89    CompoundStmt
  • src/tests/KRfunctions.c

    r9c951e3 rb1e63ac5  
    1 //                               -*- Mode: C -*-
    21//
    32// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     
    1110// Created On       : Thu Feb 16 15:23:17 2017
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Feb 16 15:25:52 2017
    14 // Update Count     : 2
     12// Last Modified On : Wed May 24 22:05:00 2017
     13// Update Count     : 3
    1514//
    1615
  • src/tests/Makefile.am

    r9c951e3 rb1e63ac5  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sun May 14 14:43:48 2017
    14 ## Update Count     : 42
     13## Last Modified On : Thu Jun  8 07:41:43 2017
     14## Update Count     : 44
    1515###############################################################################
    1616
     
    2020
    2121if BUILD_CONCURRENCY
    22 concurrent=yes
    23 quick_test+= coroutine thread monitor
    24 concurrent_test=coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
     22concurrent = yes
     23quick_test += coroutine thread monitor
     24concurrent_test = coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
    2525else
    2626concurrent=no
     
    3636
    3737.PHONY : list
    38 EXTRA_PROGRAMS = fstream_test vector_test avl_test constant0-1DP constant0-1ND constant0-1NDDP # build but do not install
     38EXTRA_PROGRAMS = fstream_test vector_test avl_test # build but do not install
    3939
    4040fstream_test_SOURCES = fstream_test.c
     
    5757        @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test}
    5858
    59 .dummy : .dummy.c
     59.dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@
    6060        ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@}                              #don't use CFLAGS, this rule is not a real test
    6161
    62 constant0-1DP : constant0-1.c
    63         ${CC} ${CFLAGS} -DDUPS ${<} -o ${@}
    6462
    65 constant0-1ND : constant0-1.c
    66         ${CC} ${CFLAGS} -DNEWDECL ${<} -o ${@}
     63% : %.c @CFA_BINDIR@/@CFA_NAME@
     64        ${CC} ${CFLAGS} ${<} -o ${@}
    6765
    68 constant0-1NDDP : constant0-1.c
    69         ${CC} ${CFLAGS} -DNEWDECL -DDUPS ${<} -o ${@}
    70 
    71 dtor-early-exit-ERR1: dtor-early-exit.c
     66dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
    7267        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    7368
    74 dtor-early-exit-ERR2: dtor-early-exit.c
     69dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
    7570        ${CC} ${CFLAGS} -DERR2 ${<} -o ${@}
    7671
    77 declarationSpecifier: declarationSpecifier.c
     72declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@
    7873        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    7974
    80 gccExtensions : gccExtensions.c
     75gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@
    8176        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    8277
    83 extension : extension.c
     78extension : extension.c @CFA_BINDIR@/@CFA_NAME@
    8479        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    8580
    86 attributes : attributes.c
     81attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@
    8782        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    8883
    89 KRfunctions : KRfunctions.c
     84KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
    9085        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    9186
    92 gmp : gmp.c
     87gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
    9388        ${CC} ${CFLAGS} -lgmp ${<} -o ${@}
    9489
    95 memberCtors-ERR1: memberCtors.c
     90memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@
    9691        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    9792
    98 completeTypeError : completeTypeError.c
     93completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@
    9994        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/Makefile.in

    r9c951e3 rb1e63ac5  
    3939@BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor
    4040EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    41         avl_test$(EXEEXT) constant0-1DP$(EXEEXT) \
    42         constant0-1ND$(EXEEXT) constant0-1NDDP$(EXEEXT)
     41        avl_test$(EXEEXT)
    4342subdir = src/tests
    4443DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
     
    5655avl_test_OBJECTS = $(am_avl_test_OBJECTS)
    5756avl_test_LDADD = $(LDADD)
    58 constant0_1DP_SOURCES = constant0-1DP.c
    59 constant0_1DP_OBJECTS = constant0-1DP.$(OBJEXT)
    60 constant0_1DP_LDADD = $(LDADD)
    61 constant0_1ND_SOURCES = constant0-1ND.c
    62 constant0_1ND_OBJECTS = constant0-1ND.$(OBJEXT)
    63 constant0_1ND_LDADD = $(LDADD)
    64 constant0_1NDDP_SOURCES = constant0-1NDDP.c
    65 constant0_1NDDP_OBJECTS = constant0-1NDDP.$(OBJEXT)
    66 constant0_1NDDP_LDADD = $(LDADD)
    6757am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)
    6858fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
     
    9585am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
    9686am__v_GEN_0 = @echo "  GEN   " $@;
    97 SOURCES = $(avl_test_SOURCES) constant0-1DP.c constant0-1ND.c \
    98         constant0-1NDDP.c $(fstream_test_SOURCES) \
     87SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    9988        $(vector_test_SOURCES)
    100 DIST_SOURCES = $(avl_test_SOURCES) constant0-1DP.c constant0-1ND.c \
    101         constant0-1NDDP.c $(fstream_test_SOURCES) \
     89DIST_SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    10290        $(vector_test_SOURCES)
    10391ETAGS = etags
     
    230218@BUILD_CONCURRENCY_TRUE@concurrent = yes
    231219@BUILD_CONCURRENCY_FALSE@concurrent_test =
    232 @BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
     220@BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
    233221
    234222# applies to both programs
     
    297285@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avl4.Po@am__quote@
    298286@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avl_test.Po@am__quote@
    299 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constant0-1DP.Po@am__quote@
    300 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constant0-1ND.Po@am__quote@
    301 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constant0-1NDDP.Po@am__quote@
    302287@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    303288@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@
     
    676661        @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test}
    677662
    678 .dummy : .dummy.c
     663.dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@
    679664        ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@}                              #don't use CFLAGS, this rule is not a real test
    680665
    681 constant0-1DP : constant0-1.c
    682         ${CC} ${CFLAGS} -DDUPS ${<} -o ${@}
    683 
    684 constant0-1ND : constant0-1.c
    685         ${CC} ${CFLAGS} -DNEWDECL ${<} -o ${@}
    686 
    687 constant0-1NDDP : constant0-1.c
    688         ${CC} ${CFLAGS} -DNEWDECL -DDUPS ${<} -o ${@}
    689 
    690 dtor-early-exit-ERR1: dtor-early-exit.c
     666% : %.c @CFA_BINDIR@/@CFA_NAME@
     667        ${CC} ${CFLAGS} ${<} -o ${@}
     668
     669dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
    691670        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    692671
    693 dtor-early-exit-ERR2: dtor-early-exit.c
     672dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
    694673        ${CC} ${CFLAGS} -DERR2 ${<} -o ${@}
    695674
    696 declarationSpecifier: declarationSpecifier.c
     675declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@
    697676        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    698677
    699 gccExtensions : gccExtensions.c
     678gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@
    700679        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    701680
    702 extension : extension.c
     681extension : extension.c @CFA_BINDIR@/@CFA_NAME@
    703682        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    704683
    705 attributes : attributes.c
     684attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@
    706685        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    707686
    708 KRfunctions : KRfunctions.c
     687KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
    709688        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    710689
    711 gmp : gmp.c
     690gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
    712691        ${CC} ${CFLAGS} -lgmp ${<} -o ${@}
    713692
    714 memberCtors-ERR1: memberCtors.c
     693memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@
    715694        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    716695
    717 completeTypeError : completeTypeError.c
     696completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@
    718697        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    719698
  • src/tests/coroutine.c

    r9c951e3 rb1e63ac5  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// fibonacci.c --
     8//
     9// Author           : Thierry Delisle
     10// Created On       : Thu Jun  8 07:29:37 2017
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jun  8 07:37:12 2017
     13// Update Count     : 5
     14//
     15
    116#include <fstream>
    217#include <coroutine>
    318
    419coroutine Fibonacci {
    5       int fn; // used for communication
     20        int fn;                                         // used for communication
    621};
    722
    8 void ?{}(Fibonacci* this) {
    9       this->fn = 0;
     23void ?{}( Fibonacci * this ) {
     24        this->fn = 0;
    1025}
    1126
    12 void main(Fibonacci* this) {
    13       int fn1, fn2;             // retained between resumes
    14       this->fn = 0;
    15       fn1 = this->fn;
    16       suspend();                // return to last resume
     27void main( Fibonacci * this ) {
     28        int fn1, fn2;                                   // retained between resumes
     29        this->fn = 0;                                   // case 0
     30        fn1 = this->fn;
     31        suspend();                                              // return to last resume
    1732
    18       this->fn = 1;
    19       fn2 = fn1;
    20       fn1 = this->fn;
    21       suspend();                // return to last resume
     33        this->fn = 1;                                   // case 1
     34        fn2 = fn1;
     35        fn1 = this->fn;
     36        suspend();                                              // return to last resume
    2237
    23       for ( ;; ) {
    24             this->fn = fn1 + fn2;
    25             fn2 = fn1;
    26             fn1 = this->fn;
    27             suspend(); // return to last resume
    28       }
     38        for ( ;; ) {                                    // general case
     39                this->fn = fn1 + fn2;
     40                fn2 = fn1;
     41                fn1 = this->fn;
     42                suspend();                                      // return to last resume
     43        } // for
    2944}
    3045
    31 int next(Fibonacci* this) {
    32       resume(this); // transfer to last suspend
    33       return this->fn;
     46int next( Fibonacci * this ) {
     47        resume( this );                                 // transfer to last suspend
     48        return this->fn;
    3449}
    3550
    3651int main() {
    37       Fibonacci f1, f2;
    38       for ( int i = 1; i <= 10; i += 1 ) {
    39             sout | next(&f1) | ' ' | next(&f2) | endl;
    40       }
     52        Fibonacci f1, f2;
     53        for ( int i = 1; i <= 10; i += 1 ) {
     54                sout | next( &f1 ) | ' ' | next( &f2 ) | endl;
     55        } // for
     56}
    4157
    42       return 0;
    43 }
     58// Local Variables: //
     59// tab-width: 4 //
     60// compile-command: "cfa fibonacci.c" //
     61// End: //
  • src/tests/gmp.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 14:46:50 2017
    13 // Update Count     : 530
     12// Last Modified On : Wed May 24 22:05:38 2017
     13// Update Count     : 540
    1414//
    1515
    1616#include <gmp>
    1717
    18 int main() {
     18int main( void ) {
    1919        sout | "constructors" | endl;
    2020        short int si = 3;
     
    2525        sout | "conversions" | endl;
    2626        y = 'a';
     27        sout | "y:" | y | endl;
     28        y = "12345678901234567890123456789";
    2729        sout | "y:" | y | endl;
    2830        y = si;
     
    6264        z = x / 3;
    6365        sout | "z:" | z | endl;
     66        sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6467        [ x, y ] = div( x, 3 );
    6568        sout | "x:" | x | "y:" | y | endl;
    66 //      sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
    6769
    6870        sout | endl;
     
    7274        fn = (Int){0}; fn1 = fn;                                                        // 1st case
    7375        sout | (int)0 | fn | endl;
    74         fn = (Int){1}; fn2 = fn1; fn1 = fn;                                     // 2nd case
     76        fn = 1; fn2 = fn1; fn1 = fn;                                            // 2nd case
    7577        sout | 1 | fn | endl;
    76         for ( int i = 2; i <= 200; i += 1 ) {
     78        for ( unsigned int i = 2; i <= 200; i += 1 ) {
    7779                fn = fn1 + fn2; fn2 = fn1; fn1 = fn;                    // general case
    7880                sout | i | fn | endl;
     
    8385        sout | "Factorial Numbers" | endl;
    8486        Int fact;
    85         fact = (Int){1};                                                                        // 1st case
     87        fact = 1;                                                                                       // 1st case
    8688        sout | (int)0 | fact | endl;
    87         for ( int i = 1; i <= 40; i += 1 ) {
    88                 fact = fact * i;                                                                // general case
     89        for ( unsigned int i = 1; i <= 40; i += 1 ) {
     90                fact *= i;                                                                              // general case
    8991                sout | i | fact | endl;
    9092        } // for
     
    9294
    9395// Local Variables: //
    94 // mode: c //
    9596// tab-width: 4 //
     97// compile-command: "cfa gmp.c -l gmp" //
    9698// End: //
  • src/tests/identity.c

    r9c951e3 rb1e63ac5  
    77// identity.c --
    88//
    9 // Author           : Richard C. Bilson
     9// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  8 22:15:08 2016
    13 // Update Count     : 13
     12// Last Modified On : Thu Jun  8 08:21:32 2017
     13// Update Count     : 18
    1414//
    1515
     
    3232        sout | "double\t\t\t"                           | identity( 4.1 ) | endl;
    3333        sout | "long double\t\t"                        | identity( 4.1l ) | endl;
     34        sout | "float _Complex\t\t"                     | identity( -4.1F-2.0iF ) | endl;
     35        sout | "double _Complex\t\t"            | identity( -4.1D-2.0iD ) | endl;
     36        sout | "long double _Complex\t"         | identity( -4.1L-2.0iL ) | endl;
    3437}
    3538
  • src/tests/io.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 21 22:36:06 2017
    13 // Update Count     : 48
     12// Last Modified On : Thu Jun  8 09:52:10 2017
     13// Update Count     : 51
    1414//
    1515
     
    1717
    1818int main() {
    19         char c;                                                                                                         // basic types
     19        char c;                                                                                         // basic types
    2020        short int si;
    2121        unsigned short int usi;
     
    3232        double _Complex dc;
    3333        long double _Complex ldc;
    34         char s1[10], s2[10];
     34        enum { size = 10 };
     35        char s1[size], s2[size];
    3536
    3637        int x = 3, y = 5, z = 7;
     
    4142        sout | endl;
    4243
    43         ifstream in;                                                                                            // create / open file
     44        sout
     45                // opening delimiters
     46                | "x (" | 1
     47                | "x [" | 2
     48                | "x {" | 3
     49                | "x =" | 4
     50                | "x $" | 5
     51                | "x £" | 6
     52                | "x ¥" | 7
     53                | "x ¡" | 8
     54                | "x ¿" | 9
     55                | "x «" | 10
     56                | endl;
     57        sout
     58                // closing delimiters
     59                | 1 | ", x"
     60                | 2 | ". x"
     61                | 3 | "; x"
     62                | 4 | "! x"
     63                | 5 | "? x"
     64                | 6 | "% x"
     65                | 7 | "¢ x"
     66                | 8 | "» x"
     67                | 9 | ") x"
     68                | 10 | "] x"
     69                | 11 | "} x"
     70                | endl;
     71        sout
     72                // opening-closing delimiters
     73                | "x`" | 1 | "`x'" | 2
     74                | "'x\"" | 3 | "\"x:" | 4
     75                | ":x " | 5 | " x\t" | 6
     76                | "\tx\f" | 7 | "\fx\v" | 8
     77                | "\vx\n" | 9 | "\nx\r" | 10
     78                | "\rx" |
     79                endl;
     80        sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;
     81
     82        ifstream in;                                                                            // create / open file
    4483        open( &in, "io.data", "r" );
    4584
    46         &in | &c                                                                                                        // character
    47                 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli             // integral
    48                 | &f | &d | &ld                                                                                 // floating point
    49                 | &fc | &dc | &ldc                                                                              // floating-point complex
    50                 | cstr( s1 ) | cstr( s2, 10 );                                                  // C string, length unchecked and checked
     85        &in | &c                                                                                        // character
     86                | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli     // integral
     87                | &f | &d | &ld                                                                 // floating point
     88                | &fc | &dc | &ldc                                                              // floating-point complex
     89                | cstr( s1 ) | cstr( s2, size );                                // C string, length unchecked and checked
    5190
    52         sout | c | ' ' | endl                                                                           // character
    53                  | si | usi | i | ui | li | uli | lli | ulli | endl             // integral
    54                  | f | d | ld | endl                                                                    // floating point
    55                  | fc | dc | ldc | endl;                                                                // complex
     91        sout | c | ' ' | endl                                                           // character
     92                | si | usi | i | ui | li | uli | lli | ulli | endl // integral
     93                | f | d | ld | endl                                                             // floating point
     94                | fc | dc | ldc | endl;                                                 // complex
    5695        sout | endl;
    57         sout | f | "" | d | "" | ld | endl                                                      // floating point without separator
    58                  | sepDisable | fc | dc | ldc | sepEnable | endl                // complex without separator
    59                  | sepOn | s1 | sepOff | s2 | endl                                              // local separator removal
    60                  | s1 | "" | s2 | endl;                                                                 // C string without separator
     96        sout | f | "" | d | "" | ld | endl                                      // floating point without separator
     97                | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator
     98                | sepOn | s1 | sepOff | s2 | endl                               // local separator removal
     99                | s1 | "" | s2 | endl;                                                  // C string without separator
    61100        sout | endl;
    62101
    63         sepSet( sout, ", $" );                                                                          // change separator, maximum of 15 characters
     102        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    64103        sout | f | d | ld | endl
    65                  | fc | dc | ldc | endl
    66                  | s1 | s2 | endl;
     104                | fc | dc | ldc | endl
     105                | s1 | s2 | endl;
    67106        sout | endl;
     107
     108        [int, int] t1 = [1, 2], t2 = [3, 4];
     109        sout | t1 | t2 | endl;                                                          // print tuple
     110
    68111        sepSet( sout, " " );
     112        sepSet( sout, ", $" );                                                          // set separator from " " to ", $"
     113        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
     114        sepSet( sout, " " );                                                            // reset separator to " "
     115        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    69116
    70         sout
    71                 // opening delimiters
    72                 | "v(" | 27
    73                 | "v[" | 27
    74                 | "v{" | 27
    75                 | "$" | 27
    76                 | "=" | 27
    77                 | "£" | 27
    78                 | "¥" | 27
    79                 | "¡" | 27
    80                 | "¿" | 27
    81                 | "«" | 27
    82                 | endl
    83                 // closing delimiters
    84                 | 25 | ","
    85                 | 25 | "."
    86                 | 25 | ":"
    87                 | 25 | ";"
    88                 | 25 | "!"
    89                 | 25 | "?"
    90                 | 25 | "%"
    91                 | 25 | "¢"
    92                 | 25 | "»"
    93                 | 25 | ")"
    94                 | 25 | "]"
    95                 | 25 | "}"
    96                 | endl
    97                 // opening-closing delimiters
    98                 | 25 | "'" | 27
    99                 | 25 | "`" | 27
    100                 | 25 | "\"" | 27
    101                 | 25 | " " | 27
    102                 | 25 | "\f" | 27
    103                 | 25 | "\n" | 27
    104                 | 25 | "\r" | 27
    105                 | 25 | "\t" | 27
    106                 | 25 | "\v" | 27
    107                 | endl;
     117        sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // separator at start of line
     118        sout | 1 | sepOff | 2 | 3 | endl;                                       // locally turn off implicit separator
    108119
    109         [int, int, const char *, double] t = { 3, 4, "a", 7.2 };
     120        sout | sepDisable | 1 | 2 | 3 | endl;                           // globally turn off implicit separation
     121        sout | 1 | sepOn | 2 | 3 | endl;                                        // locally turn on implicit separator
     122        sout | sepEnable | 1 | 2 | 3 | endl;                            // globally turn on implicit separation
     123
     124        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
     125        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     126        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
     127        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     128
     129        sout | t1 | t2 | endl;                                                          // print tuple
     130
     131        [int, int, const char *, double] t3 = { 3, 4, "a", 7.2 };
    110132        sout | [ 3, 4, "a", 7.2 ] | endl;
    111         sout | t | endl;
     133        sout | t3 | endl;
    112134        sepSetTuple( sout, " " );
    113         sout | t | endl;
    114         sout | sepOn | t | sepDisable | t | sepEnable | t | endl;
     135        sout | t3 | endl;
     136        sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3 | endl;
    115137        sepSet( sout, "^" );
    116138        sepSetTuple( sout, "-" );
    117         sout | t | 3 | 4 | t | endl;
     139        sout | t3 | 3 | 4 | t3 | endl;
    118140}
    119141
  • src/tests/libcfa_vector.c

    r9c951e3 rb1e63ac5  
    2727
    2828int main() {
    29         vector( int, heap_allocator(int) ) iv;
     29        vector( int ) iv;
    3030
    3131        assert( empty( &iv ) );
  • src/tests/math.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Fri Apr 22 14:59:21 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 24 13:24:20 2016
    13 // Update Count     : 70
     12// Last Modified On : Wed May 24 13:04:33 2017
     13// Update Count     : 71
    1414//
    1515
     
    2222        long double l;
    2323
    24         sout | "fabs:" | fabs( -1.0F ) | fabs( -1.0D ) | fabs( -1.0L ) | cabs( -1.0F+1.0FI ) | cabs( -1.0D+1.0DI ) | cabs( -1.0DL+1.0LI ) | endl;
    2524        sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ) | endl;
    2625        sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ) | endl;
  • src/tests/numericConstants.c

    r9c951e3 rb1e63ac5  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// numericConstants.c --
     8//
     9// Author           : Peter A. Buhr
     10// Created On       : Wed May 24 22:10:36 2017
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed May 24 22:11:36 2017
     13// Update Count     : 2
     14//
     15
    116int main() {
    217        1;                                                      // decimal
     
    4863        0x_ff.ffp0;                                     // hex real
    4964        0x_1.ffff_ffff_p_128_l;
    50 }
     65} // main
     66
     67// Local Variables: //
     68// tab-width: 4 //
     69// compile-command: "cfa minmax.c" //
     70// End: //
  • src/tests/rational.c

    r9c951e3 rb1e63ac5  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 15 21:32:22 2017
    13 // Update Count     : 64
     12// Last Modified On : Wed May 17 15:46:35 2017
     13// Update Count     : 65
    1414//
    1515
  • src/tests/sched-int-disjoint.c

    r9c951e3 rb1e63ac5  
    44#include <thread>
    55
     6#ifndef N
    67#define N 100_000
     8#endif
    79
    810enum state_t { WAIT, SIGNAL, BARGE };
     
    7880        signal( &cond, a, &data );
    7981
    80         int pauses = (unsigned)rand48() % 10;
    81         for(int i = 0; i < pauses; i++) {
    82                 yield();
    83         }
     82        yield( (unsigned)rand48() % 10 );
    8483
    8584        //This is technically a mutual exclusion violation but the mutex monitor protects us
  • src/tests/sched-int-wait.c

    r9c951e3 rb1e63ac5  
    55#include <thread>
    66
    7 static const int N = 10_000;
     7#ifndef N
     8#define N 10_000
     9#endif
    810
    911monitor global_t {};
  • src/tests/test.py

    r9c951e3 rb1e63ac5  
    197197                        # fetch return code and error from the diff command
    198198                        retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run)
     199
     200        else:
     201                with open (out_file, "r") as myfile:
     202                        error = myfile.read()
     203
     204               
    199205        # clean the executable
    200206        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
     
    253259        # for each test to run
    254260        try :
    255                 results = pool.map_async(partial(run_test_worker, generate=generate, dry_run=dry_run, debug=debug), tests ).get(3600)
     261                results = pool.map_async(partial(run_test_worker, generate=generate, dry_run=dry_run, debug=debug), tests, chunksize = 1 ).get(7200)
    256262        except KeyboardInterrupt:
    257263                pool.terminate()
  • src/tests/tuplePolymorphism.c

    r9c951e3 rb1e63ac5  
    99// Author           : Rob Schluntz
    1010// Created On       : Tue Nov 16 10:38:00 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Nov 16 10:39:18 2016
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu May 18 18:05:12 2017
     13// Update Count     : 4
    1414//
    1515
    1616// packed is needed so that structs are not passed with the same alignment as function arguments
    1717__attribute__((packed)) struct A {
    18   double x;
    19   char y;
    20   double z;
     18        double x;
     19        char y;
     20        double z;
    2121};
    2222
    2323__attribute__((packed)) struct B {
    24   long long x;
    25   char y;
    26   long long z;
     24        long long x;
     25        char y;
     26        long long z;
    2727};
    2828
     
    3939
    4040int main() {
    41   int x1 = 123, x3 = 456;
    42   double x2 = 999.123;
     41        int x1 = 123, x3 = 456;
     42        double x2 = 999.123;
    4343
    44   int i1 = 111, i3 = 222;
    45   double i2 = 333;
     44        int i1 = 111, i3 = 222;
     45        double i2 = 333;
    4646
    47   int d1 = 555, d3 = 444;
    48   double d2 = 666;
     47        int d1 = 555, d3 = 444;
     48        double d2 = 666;
    4949
    5050
    51   [i1, i2, i3] = ([x1, (int)x2, x3]) + ([9, 2, 3]);
    52   [d1, d2, d3] = ([x1, x2, x3]) + ([9, 2, 3]);
    53   printf("%d %g %d\n", i1, i2, i3);
    54   printf("%d %g %d\n", d1, d2, d3);
     51        [i1, i2, i3] = ([x1, (int)x2, x3]) + ([9, 2, 3]);
     52        [d1, d2, d3] = ([x1, x2, x3]) + ([9, 2, 3]);
     53        printf("%d %g %d\n", i1, i2, i3);
     54        printf("%d %g %d\n", d1, d2, d3);
    5555
    56   [double, double, double] zzz;
    57   zzz = [x1, x2, x3];
    58   printf("%g %g %g\n", zzz);
    59   [x1, x2, x3] = zzz+zzz;
    60   printf("%d %g %d\n", x1, x2, x3);
     56        [double, double, double] zzz;
     57        zzz = [x1, x2, x3];
     58        printf("%g %g %g\n", zzz);
     59        [x1, x2, x3] = zzz+zzz;
     60        printf("%d %g %d\n", x1, x2, x3);
    6161
    62   // ensure non-matching assertions are specialized correctly
    63   g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL });
     62        // ensure non-matching assertions are specialized correctly
     63        g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL });
    6464}
    6565
     
    7373// tab-width: 4 //
    7474// End: //
    75 
  • tools/cfa.nanorc

    r9c951e3 rb1e63ac5  
    22## WIP
    33
    4 syntax "cfa" "\.cfa$"
    5 ## No magic
     4syntax "cfa" "\.cfa"
    65
    76# Macros
     
    1211color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto)\>"
    1312color green "\<(static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
    14 color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
     13color green "\<((s?size)|one|zero|((u_?)?int(8|16|32|64|ptr)))_t\>"
    1514
    1615# Declarations
     
    1918# Control Flow Structures
    2019color brightyellow "\<(if|else|while|do|for|switch|choose|case|default)\>"
    21 ##color brightyellow "\<(try|catch|catchResume|finally)\>"
     20color brightyellow "\<(try|catch|catchResume|finally)\>"
    2221
    2322# Control Flow Statements
    24 color magenta "\<(return|break|continue|fallthru|throw)\>"
     23color magenta "\<(return|break|continue|fallthru|throw|throwResume)\>"
    2524
    2625# Operator Names
     
    3332## Update/Redistribute
    3433# GCC builtins
    35 ##color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
     34color cyan "__attribute__[[:space:]]*\(\([^()]*(\([^()]*\)[^()]*)*\)\)"
     35##color cyan "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
    3636
    3737# Preprocesser Directives
     
    3939
    4040# Values
     41# Booleans
     42color blue "\<(true|false)\>"
    4143# Characters
    4244color brightmagenta "'([^'\]|(\\")|(\\['abfnrtv\\]))'"
    4345color brightmagenta "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
    4446# Strings and Angle Strings
    45 color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
     47color yellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
    4648# Multiline Strings: This regex is VERY expencive and often too strong.
    4749###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
Note: See TracChangeset for help on using the changeset viewer.