Changeset b1e63ac5
- Timestamp:
- Jul 4, 2017, 9:40:16 AM (8 years ago)
- 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. - Files:
-
- 79 added
- 12 deleted
- 159 edited
- 19 moved
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r9c951e3 rb1e63ac5 13 13 libcfa/Makefile 14 14 src/Makefile 15 version15 /version 16 16 17 17 # genereted by premake … … 31 31 32 32 src/prelude/builtins.cf 33 src/prelude/builtins.c 33 src/prelude/gcc-builtins.cf 34 src/prelude/gcc-builtins.c 34 35 src/prelude/extras.cf 35 36 src/prelude/bootloader.c 36 37 src/libcfa/libcfa-prelude.c 37 38 38 # generated by bison and lex from cfa.yy and lex.ll, respectively39 # generated by bison and lex from parser.yy and lex.ll 39 40 src/Parser/parser.output 40 41 src/Parser/lex.cc … … 42 43 src/Parser/parser.h 43 44 45 tools/prettyprinter/parser.output 46 tools/prettyprinter/lex.cc 47 tools/prettyprinter/parser.cc 48 tools/prettyprinter/parser.h 49 tools/prettyprinter/pretty 50 tools/pretty 51 44 52 # generated by xfig for user manual 45 53 doc/user/Cdecl.tex -
Jenkins/FullBuild
r9c951e3 rb1e63ac5 161 161 """ 162 162 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" 164 164 165 165 //send email notification -
Jenkinsfile
r9c951e3 rb1e63ac5 28 28 wrap([$class: 'TimestamperBuildWrapper']) { 29 29 30 notify_server( )30 notify_server(0) 31 31 32 32 prepare_build() … … 34 34 checkout() 35 35 36 notify_server(0) 37 36 38 build() 37 39 … … 46 48 publish() 47 49 48 notify_server( )50 notify_server(45) 49 51 } 50 52 } … … 171 173 } 172 174 173 def notify_server( ) {174 sh 'curl --silent -X POST http://plg2:8082/jenkins/notify > /dev/null || true'175 def notify_server(int wait) { 176 sh """curl --silent --data "wait=${wait}" -X POST http://plg2:8082/jenkins/notify > /dev/null || true""" 175 177 return 176 178 } … … 374 376 """ 375 377 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" 377 379 378 380 //send email notification -
configure
r9c951e3 rb1e63ac5 2496 2496 2497 2497 2498 if test "x${CXXFLAGS}" = "x"; then2499 export CXXFLAGS="-std=c++11 -g ${CXXFLAGS}" # defaults, no -O2 for debugging and failures2500 else2501 export CXXFLAGS="-std=c++11 ${CXXFLAGS}" # flags from configure command2502 fi2503 2504 2498 am__api_version='1.11' 2505 2499 … … 6257 6251 6258 6252 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"6253 ac_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" 6260 6254 6261 6255 … … 7025 7019 "src/examples/Makefile") CONFIG_FILES="$CONFIG_FILES src/examples/Makefile" ;; 7026 7020 "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" ;; 7027 7022 "src/prelude/Makefile") CONFIG_FILES="$CONFIG_FILES src/prelude/Makefile" ;; 7028 7023 "src/libcfa/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcfa/Makefile" ;; 7024 "tools/prettyprinter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/prettyprinter/Makefile" ;; 7029 7025 7030 7026 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -
configure.ac
r9c951e3 rb1e63ac5 8 8 AC_CONFIG_HEADERS([config.h]) 9 9 AM_SILENT_RULES([no]) 10 11 if test "x${CXXFLAGS}" = "x"; then12 export CXXFLAGS="-std=c++11 -g ${CXXFLAGS}" # defaults, no -O2 for debugging and failures13 else14 export CXXFLAGS="-std=c++11 ${CXXFLAGS}" # flags from configure command15 fi16 10 17 11 AM_INIT_AUTOMAKE … … 241 235 src/examples/Makefile 242 236 src/tests/Makefile 237 src/tests/preempt_longrun/Makefile 243 238 src/prelude/Makefile 244 239 src/libcfa/Makefile 240 tools/prettyprinter/Makefile 245 241 ]) 246 242 -
doc/LaTeXmacros/common.tex
r9c951e3 rb1e63ac5 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon May 15 18:03:29201714 %% Update Count : 3 0213 %% Last Modified On : Sun Jun 18 20:32:32 2017 14 %% Update Count : 319 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 36 36 % Names used in the document. 37 37 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 39 40 \newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name 40 41 \newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name … … 241 242 belowskip=3pt, 242 243 % 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\,$}}1244 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1 244 245 {~}{\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, 247 247 moredelim=**[is][\color{red}]{®}{®}, % red highlighting ®...® (registered trademark symbol) emacs: C-q M-. 248 248 moredelim=**[is][\color{blue}]{ß}{ß}, % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_ -
doc/LaTeXmacros/lstlang.sty
r9c951e3 rb1e63ac5 8 8 %% Created On : Sat May 13 16:34:42 2017 9 9 %% Last Modified By : Peter A. Buhr 10 %% Last Modified On : Sat May 13 16:49:09 201711 %% Update Count : 410 %% Last Modified On : Fri May 26 12:47:09 2017 11 %% Update Count : 8 12 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 13 … … 107 107 \lstdefinelanguage{CFA}[ANSI]{C}{ 108 108 morekeywords={ 109 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, _ Atomic, __attribute,109 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute, 110 110 __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}, 115 126 } 116 127 -
doc/bibliography/cfa.bib
r9c951e3 rb1e63ac5 862 862 } 863 863 864 @techreport{C11, 865 type = {International Standard}, 864 @manual{C11, 866 865 keywords = {ISO/IEC C 11}, 867 866 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}}, 872 872 year = 2012, 873 873 } … … 877 877 keywords = {ISO/IEC TS 19217:2015}, 878 878 contributer = {a3moss@uwaterloo.ca}, 879 key = {{ISO/IEC} {TS} 19217},880 879 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}}, 884 883 year = 2015 885 884 } … … 1096 1095 keywords = {ISO/IEC Cobol 14}, 1097 1096 contributer = {pabuhr@plg}, 1098 key= {Cobol14},1099 title = {Programming Languages -- {Cobol} },1097 author = {Cobol14}, 1098 title = {Programming Languages -- {Cobol} ISO/IEC 1989:2014}, 1100 1099 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}}, 1104 1102 year = 2014, 1105 1103 } … … 2836 2834 keywords = {ISO/IEC Fortran 08}, 2837 2835 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}, 2841 2839 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}}, 2843 2841 year = 2010, 2844 2842 } … … 3037 3035 year = 1992, 3038 3036 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}}, 3039 3047 } 3040 3048 … … 4416 4424 keywords = {Plan 9}, 4417 4425 contributer = {pabuhr@plg}, 4418 title = {A New CCompiler},4426 title = {A New {C} Compiler}, 4419 4427 author = {Ken Thompson}, 4420 4428 booktitle = {Proceedings of the Summer 1990 UKUUG Conference}, 4421 4429 year = 1990, 4422 4430 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}}, 4424 4432 } 4425 4433 … … 5359 5367 } 5360 5368 5361 @manual{ ANSI14:C++,5369 @manual{C++14, 5362 5370 keywords = {ISO/IEC C++ 14}, 5363 5371 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}, 5366 5374 edition = {4th}, 5367 organization= {International Standard ISO/IEC 14882:2014 (E)},5368 5375 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}}, 5370 5377 year = 2014, 5371 5378 } … … 5706 5713 5707 5714 @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}, 5711 5719 edition = {3rd}, 5712 organization= {International Standard ISO/IEC 1989:2014},5713 5720 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}}, 5715 5722 year = 2012, 5716 5723 } -
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 1 build/*.aux 2 build/*.acn 3 build/*.acr 4 build/*.alg 5 build/*.bbl 6 build/*.blg 7 build/*.brf 8 build/*.dvi 9 build/*.glg 10 build/*.glo 11 build/*.gls 12 build/*.idx 13 build/*.ind 14 build/*.ist 15 build/*.log 16 build/*.out 17 build/*.ps 18 build/*.tex 19 build/*.toc 20 *.pdf 21 22 examples -
doc/proposals/concurrency/Makefile
r9c951e3 rb1e63ac5 1 1 ## Define the appropriate configuration variables. 2 2 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 3 TeXLIB = .:./style:./text:./annex:./build:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies: 4 LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=build -interaction=nonstopmode 5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex -terse 6 6 7 7 ## Define the text source files. 8 8 9 9 SOURCES = ${addsuffix .tex, \ 10 concurrency \ 11 style \ 12 cfa-format \ 13 glossary \ 10 thesis \ 11 style/style \ 12 style/cfa-format \ 13 annex/glossary \ 14 text/intro \ 15 text/cforall \ 16 text/basics \ 17 text/concurrency \ 18 text/parallelism \ 14 19 } 15 20 16 FIGURES = ${add suffix .tex, \21 FIGURES = ${addprefix build/, ${addsuffix .tex, \ 17 22 monitor \ 18 23 ext_monitor \ 19 } 24 }} 20 25 21 26 PICTURES = ${addsuffix .pstex, \ … … 30 35 ## Define the documents that need to be made. 31 36 32 DOCUMENT = concurrency.pdf37 DOCUMENT = thesis.pdf 33 38 34 39 # Directives # … … 37 42 38 43 clean : 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 41 68 42 69 # File Dependencies # 43 70 44 ${DOCUMENT} : ${basename ${DOCUMENT}}.ps71 ${DOCUMENT} : build/${basename ${DOCUMENT}}.ps 45 72 ps2pdf $< 46 73 47 ${basename ${DOCUMENT}}.ps :${basename ${DOCUMENT}}.dvi74 build/${basename ${DOCUMENT}}.ps : build/${basename ${DOCUMENT}}.dvi 48 75 dvips $< -o $@ 49 76 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 77 build/${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 67 92 68 93 … … 72 97 ## Define the default recipes. 73 98 74 %.tex :%.fig99 build/%.tex : figures/%.fig 75 100 fig2dev -L eepic $< > $@ 76 101 77 %.ps :%.fig102 build/%.ps : figures/%.fig 78 103 fig2dev -L ps $< > $@ 79 104 80 %.pstex :%.fig105 build/%.pstex : figures/%.fig 81 106 fig2dev -L pstex $< > $@ 82 107 fig2dev -L pstex_t -p $@ $< > $@_t -
doc/proposals/concurrency/style/cfa-format.tex
r9c951e3 rb1e63ac5 1 \usepackage {xcolor}1 \usepackage[usenames,dvipsnames]{xcolor} 2 2 \usepackage{listings} 3 3 \usepackage{inconsolata} … … 144 144 % moredelim=** allows cumulative application 145 145 } 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 151 171 \lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@ % single-character for \lstinline 152 172 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 } 160 187 }{} 161 188 … … 169 196 170 197 \lstnewenvironment{cppcode}[1][]{ 198 \lstset{ 199 language = c++, 200 style=defaultStyle, 201 #1 202 } 203 }{} 204 205 \lstnewenvironment{ucppcode}[1][]{ 171 206 \lstset{ 172 207 language = c++, … … 219 254 \newcommand{\one}{\lstinline{one_t}\xspace} 220 255 \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.21 0.9.119 -
doc/refrat/Makefile
r9c951e3 rb1e63ac5 44 44 45 45 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 46 ../LaTeXmacros/common.tex ../LaTeXmacros/ indexstyle ../bibliography/cfa.bib46 ../LaTeXmacros/common.tex ../LaTeXmacros/lstlang.sty ../LaTeXmacros/indexstyle ../bibliography/cfa.bib 47 47 # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 48 48 if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi … … 70 70 fig2dev -L ps $< > $@ 71 71 72 %.pstex : %.fig 73 fig2dev -L pstex $< > $@ 74 fig2dev -L pstex_t -p $@ $< > $@_t 75 72 76 # Local Variables: # 73 77 # compile-command: "make" # -
doc/refrat/refrat.bib
r9c951e3 rb1e63ac5 2 2 3 3 @manual{ANS:C, 4 keywords 5 contributer 6 title 4 keywords = {ANSI C}, 5 contributer = {gjditchfield@msg}, 6 title = {American National Standard for Information Systems -- 7 7 Programming Language -- {C}}, 8 organization 9 address 10 month = dec, year= 1989,11 note 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} 12 12 } 13 13 14 14 @manual{ANS:C11, 15 keywords 16 contributer 17 title 15 keywords = {ANS:C11}, 16 contributer = {gjditchfield@acm.org}, 17 title = {American National Standard Information Systems -- 18 18 Programming languages -- {C}}, 19 organization 20 address 21 month = may, year= 2012,22 note 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]} 23 23 } 24 24 25 25 @book{c++, 26 keywords 27 author 28 title 29 publisher 30 year 31 edition 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} 32 32 } 33 33 34 34 @Unpublished{Ditchfield96:Overview, 35 author ="Glen Ditchfield",36 title ="An Overview of Cforall",37 note ="in preparation",38 year =199635 author = "Glen Ditchfield", 36 title = "An Overview of Cforall", 37 note = "in preparation", 38 year = 1996 39 39 } 40 40 41 41 @article{Bak:overload, 42 keywords 43 contributer 44 author 45 title 46 journal 47 year 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 = { 50 50 A simple method is presented for detecting ambiguities and finding 51 51 the correct interpretations of expressions in the programming … … 56 56 approach is demonstrated by a brief formal argument. 57 57 }, 58 comment 58 comment = { 59 59 See also \cite{D:overload}. 60 60 } … … 77 77 78 78 @book{clu, 79 keywords 80 contributer 81 author 79 keywords = {CLU}, 80 contributer = {gjditchfield@msg}, 81 author = {Barbara Liskov and Russell Atkinson and Toby Bloom and Eliot 82 82 Moss and J. Craig Schaffert and Robert Scheifler and Alan Snyder}, 83 title 84 publisher 85 year 86 volume 87 series 83 title = {CLU Reference Manual}, 84 publisher = {Springer-Verlag}, 85 year = 1981, 86 volume = 114, 87 series = {Lecture Notes in Computer Science} 88 88 } 89 89 90 90 @manual{SIMULA87, 91 keywords 92 contributer 93 title 94 organization 95 note 96 year 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 = { 98 98 Standard for the programming language SIMULA. Written in English. 99 99 } … … 112 112 113 113 @inproceedings{Thompson90new, 114 title = {A New CCompiler},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} 119 119 } -
doc/refrat/refrat.tex
r9c951e3 rb1e63ac5 11 11 %% Created On : Wed Apr 6 14:52:25 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Apr 5 23:23:28201714 %% Update Count : 7913 %% Last Modified On : Fri Jun 2 10:43:14 2017 14 %% Update Count : 83 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 29 29 \usepackage{epic,eepic} 30 30 \usepackage{upquote} % switch curled `'" to straight 31 \usepackage{calc} 31 32 \usepackage{xspace} 32 33 \usepackage{varioref} % extended references … … 62 63 % Names used in the document. 63 64 \newcommand{\Version}{\input{../../version}} 64 65 65 \newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}} 66 66 \newcommand{\Emph}[2][red]{{\color{#1}\textbf{\emph{#2}}}} … … 97 97 \renewcommand{\chaptermark}[1]{\markboth{\thechapter\quad #1}{\thechapter\quad #1}} 98 98 \renewcommand{\sectionmark}[1]{\markboth{\thesection\quad #1}{\thesection\quad #1}} 99 \renewcommand{\subsectionmark}[1]{\markboth{\thesubsection\quad #1}{\thesubsection\quad #1}} 99 100 \pagenumbering{roman} 100 101 \linenumbers % comment out to turn off line numbering … … 121 122 122 123 This 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. 124 It 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. 125 It makes frequent reference to the \Celeven standard~\cite{C11}, and occasionally compares \CFA to \CC~\cite{C++}. 126 Changes to the syntax and additional features are expected to be included in later revisions. 127 128 The manual deliberately imitates the ordering of the \Celeven standard (although the section numbering differs). 129 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 \Celeven standard. 127 130 For a simple introduction to \CFA, see the companion document ``An Overview of \CFA'' 128 131 \cite{Ditchfield96:Overview}. … … 139 142 \chapter{Terms, definitions, and symbols} 140 143 141 Terms from the {\c11} standard used in this document have the same meaning as in the {\c11}standard.144 Terms from the \Celeven standard used in this document have the same meaning as in the \Celeven standard. 142 145 143 146 % No ``Conformance'' or ``Environment'' chapters yet. … … 149 152 150 153 \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.154 The 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. 152 155 153 156 … … 162 165 \begin{rationale} 163 166 Hence, a \CFA program can declare an ©int v© and a ©float v© in the same scope; 164 a {\CC}program can not.167 a \CC program can not. 165 168 \end{rationale} 166 169 … … 285 288 286 289 \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.290 Note 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. 288 291 \end{rationale} 289 292 … … 370 373 \begin{rationale} 371 374 As 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.375 This is clearly dangerous, and \CC does not have this implicit conversion. 373 376 \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. 374 377 \end{rationale} … … 608 611 609 612 There 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++}. 611 614 First, 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.615 In \CC, a function call must be completely resolved based on the arguments to the call in most circumstances. 613 616 In \CFA, a function call may have several interpretations, each with a different result type, and the interpretations of the containing context choose among them. 614 617 Second, 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.618 in \CC, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators. 616 619 \end{rationale} 617 620 … … 637 640 638 641 \begin{rationale} 639 Expression syntax is quoted from the {\c11}standard.642 Expression syntax is quoted from the \Celeven standard. 640 643 The syntax itself defines the precedence and associativity of operators. 641 644 The sections are arranged in decreasing order of precedence, with all operators in a section having the same precedence. … … 665 668 The \Index{valid interpretation} of an \nonterm{identifier} are given by the visible\index{visible} declarations of the identifier. 666 669 667 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by {\c11}.670 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by \Celeven. 668 671 The predefined integer identifiers ``©1©'' and ``©0©'' have the integer values 1 and 0, respectively. 669 672 The 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. … … 1113 1116 forall( otype T ) T restrict * ?++( T restrict *restrict volatile * ); 1114 1117 \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.1118 This 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. 1116 1119 \end{enumerate} 1117 1120 \end{rationale} … … 1477 1480 1478 1481 \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. 1480 1483 \end{rationale} 1481 1484 … … 1506 1509 1507 1510 \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©. 1509 1512 If ©s© is a ©short int©, ``©s *s©'' does not have type ©short int©; 1510 1513 it is treated as ``©( (int)s ) * ( (int)s )©'', and has type ©int©. \CFA matches that pattern; … … 1519 1522 \end{lstlisting} 1520 1523 Since \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.1524 This is mildly surprising, but it follows the \Celeven operator pattern. 1522 1525 1523 1526 A more troubling example is … … 1617 1620 ©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. 1618 1621 It 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.1622 The \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. 1620 1623 \end{rationale} 1621 1624 … … 1930 1933 \end{lstlisting} 1931 1934 The 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.1935 In contrast, \CC would apply a programmer-defined ©Rational©-to-©int© conversion to ©*rp© in the equivalent situation. 1933 1936 The 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. 1934 1937 \end{rationale} … … 2626 2629 \begin{itemize} 2627 2630 \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. 2629 2632 \end{itemize} 2630 2633 \begin{rationale} 2631 This constraint adds the phrase ``with compatible types'' to the {\c11}constraint, to allow overloading.2634 This constraint adds the phrase ``with compatible types'' to the \Celeven constraint, to allow overloading. 2632 2635 \end{rationale} 2633 2636 2634 2637 An identifier declared by a type declaration shall not be redeclared as a parameter in a function definition whose declarator includes an identifier list. 2635 2638 \begin{rationale} 2636 This restriction echos {\c11}'s ban on the redeclaration of typedef names as parameters.2639 This restriction echos \Celeven's ban on the redeclaration of typedef names as parameters. 2637 2640 This avoids an ambiguity between old-style function declarations and new-style function prototypes: 2638 2641 \begin{lstlisting} … … 2661 2664 2662 2665 \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. 2664 2667 \begin{rationale} 2665 2668 This extension imitates an extension in the Plan 9 C compiler \cite{Thompson90new}. … … 2854 2857 2855 2858 \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. 2860 Reference types have four uses in \CC. 2858 2861 \begin{itemize} 2859 2862 \item … … 2862 2865 \item 2863 2866 A 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.2867 The following \CC code gives an example. 2865 2868 \begin{lstlisting} 2866 2869 { … … 2874 2877 A reference parameter can be used to allow a function to modify an argument without forcing the caller to pass the address of the argument. 2875 2878 This is most useful for user-defined assignment operators. 2876 In {\CC}, plain assignment is done by a function called ``©operator=©'', and the two expressions2879 In \CC, plain assignment is done by a function called ``©operator=©'', and the two expressions 2877 2880 \begin{lstlisting} 2878 2881 a = b; … … 2887 2890 \item 2888 2891 References 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© is2892 \CC function call ``©fiddle( a_thing )©'', where the type of ©a_thing© is 2890 2893 ©Thing©, the type of ©fiddle© could be either of 2891 2894 \begin{lstlisting} … … 3216 3219 The Simula class \cite{SIMULA87} is essentially a record type. 3217 3220 Since 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}3221 In \CC 3219 3222 \cite{C++}, operations on class instances include assignment and ``©&©'', which can be overloaded. 3220 3223 A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used. … … 3548 3551 \subsection{Predefined macro names} 3549 3552 3550 The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the {\c11}standard.3553 The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the \Celeven standard. 3551 3554 It shall not define the macro name ©__STDC__©. 3552 3555 … … 3634 3637 \subsection{Pointer and array types} 3635 3638 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 )))©''.3639 Array 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 )))©''. 3637 3640 Technically, 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. 3638 3641 Consequently, there is no need for a separate ``array type'' specification. … … 3712 3715 Different operators often have related meanings; 3713 3716 for 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.3717 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. 3715 3718 Completeness and consistency is left to the good taste and discretion of the programmer. 3716 3719 It 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. … … 3823 3826 \end{theindex} 3824 3827 3828 3825 3829 \end{document} 3826 3830 -
doc/rob_thesis/intro.tex
r9c951e3 rb1e63ac5 3 3 %====================================================================== 4 4 5 \section{\ CFA Background}5 \section{\protect\CFA Background} 6 6 \label{s:background} 7 7 \CFA \footnote{Pronounced ``C-for-all'', and written \CFA or Cforall.} is a modern non-object-oriented extension to the C programming language. … … 370 370 \end{tabular} 371 371 \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} 373 373 \end{table} 374 374 -
doc/rob_thesis/thesis.tex
r9c951e3 rb1e63ac5 66 66 % ,monochrome % toggle black and white mode 67 67 }{xcolor} 68 \PassOptionsToPackage{pdftex}{graphicx} 68 69 \documentclass[letterpaper,12pt,titlepage,oneside,final]{book} 69 70 -
doc/user/pointer2.fig
r9c951e3 rb1e63ac5 8 8 -2 9 9 1200 2 10 6 1125 2100 3525 2400 10 11 2 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 13 2 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 15 4 2 0 100 0 4 10 0.0000 2 120 270 1425 2400 104\001 16 4 2 0 100 0 4 10 0.0000 2 120 90 1425 2225 y\001 17 4 0 0 100 0 4 10 0.0000 2 120 165 2025 2300 int\001 18 4 2 0 100 0 4 10 0.0000 2 120 270 2625 2400 112\001 19 4 2 0 100 0 4 10 0.0000 2 150 180 2625 2225 p2\001 20 4 1 0 100 0 4 10 0.0000 2 120 90 1725 2300 3\001 21 4 0 0 100 0 4 10 0.0000 2 120 270 3225 2300 int *\001 22 4 1 0 100 0 4 10 0.0000 2 120 270 2925 2300 100\001 23 -6 12 24 2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 13 25 1500 1500 1950 1500 1950 1800 1500 1800 1500 1500 14 26 2 1 0 1 4 7 100 -1 -1 0.000 0 0 -1 1 0 2 15 27 1 1 1.00 45.00 90.00 16 2700 1800 1950 195028 2700 1800 1950 2100 17 29 2 1 0 1 4 7 50 -1 -1 0.000 0 0 -1 1 0 2 18 30 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 22 32 2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 23 33 2700 1500 3150 1500 3150 1800 2700 1800 2700 1500 24 34 2 1 0 1 4 7 100 -1 -1 0.000 0 0 -1 1 0 2 25 35 1 1 1.00 45.00 90.00 26 3900 1800 3150 195036 3900 1800 3150 2100 27 37 2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5 28 38 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\00130 39 4 2 0 100 0 4 10 0.0000 2 120 270 1425 1800 100\001 31 40 4 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\00133 4 0 0 100 0 4 10 0.0000 2 120 165 2025 2150 int\00134 41 4 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\00136 4 2 0 100 0 4 10 0.0000 2 150 180 2625 2075 p2\00137 42 4 2 0 100 0 4 10 0.0000 2 120 270 2625 1800 108\001 38 43 4 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\00140 44 4 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 *\00142 45 4 0 0 100 0 4 10 0.0000 2 120 270 3225 1700 int *\001 43 46 4 2 0 100 0 4 10 0.0000 2 120 270 3825 1800 116\001 44 47 4 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\00146 48 4 1 0 100 0 4 10 0.0000 2 120 270 2925 1700 104\001 47 49 4 1 0 100 0 4 10 0.0000 2 120 270 4125 1700 112\001 -
doc/user/user.tex
r9c951e3 rb1e63ac5 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon May 15 18:29:58201714 %% Update Count : 159813 %% Last Modified On : Fri Jun 16 12:00:01 2017 14 %% Update Count : 2433 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 43 43 \usepackage[pagewise]{lineno} 44 44 \renewcommand{\linenumberfont}{\scriptsize\sffamily} 45 \input{common} % bespoke macros used in the document45 \input{common} % common CFA document macros 46 46 \usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref} 47 47 \usepackage{breakurl} … … 94 94 \author{ 95 95 \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 \\ 97 97 \Large Glen Ditchfield, Rodolfo G. Esteves, Aaron Moss, Rob Schluntz 98 98 }% author … … 110 110 \renewcommand{\subsectionmark}[1]{\markboth{\thesubsection\quad #1}{\thesubsection\quad #1}} 111 111 \pagenumbering{roman} 112 \linenumbers % comment out to turn off line numbering112 %\linenumbers % comment out to turn off line numbering 113 113 114 114 \maketitle … … 135 135 136 136 \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 C11syntax.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 \Celeven syntax. 139 139 \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 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. 141 141 The primary new features include parametric-polymorphic routines and types, exceptions, concurrency, and modules. 142 142 … … 147 147 instead, a programmer evolves an existing C program into \CFA by incrementally incorporating \CFA features. 148 148 New 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. 150 150 In contrast, \CFA has 30 years of hindsight and a clean starting point. 151 151 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.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, C, and \CC I/O mechanisms, where the programs output the same result. 154 154 \begin{quote2} 155 155 \begin{tabular}{@{}l@{\hspace{1.5em}}l@{\hspace{1.5em}}l@{}} 156 156 \multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CC}} \\ 157 157 \begin{cfa} 158 #include <fstream> 158 #include <fstream>§\indexc{fstream}§ 159 159 160 160 int main( void ) { … … 165 165 & 166 166 \begin{lstlisting} 167 #include <stdio.h> 167 #include <stdio.h>§\indexc{stdio.h}§ 168 168 169 169 int main( void ) { … … 174 174 & 175 175 \begin{lstlisting} 176 #include <iostream> 176 #include <iostream>§\indexc{iostream}§ 177 177 using namespace std; 178 178 int main() { … … 183 183 \end{tabular} 184 184 \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. 185 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}). 186 187 This document is a programmer reference-manual for the \CFA programming language. 188 The manual covers the core features of the language and runtime-system, with simple examples illustrating syntax and semantics of each feature. 189 The manual does not teach programming, i.e., how to combine the new constructs to build complex programs. 190 A 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. 189 191 Implementers 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.191 192 Changes to the syntax and additional features are expected to be included in later revisions. 192 193 … … 198 199 Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction. 199 200 For 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.201 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. 201 202 As well, for 30 years, C has been the number 1 and 2 most popular programming language: 202 203 \begin{center} … … 217 218 218 219 As 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; 220 221 however, it largely extended the language, and did not address many existing problems.\footnote{% 221 222 Two 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.} … … 226 227 These 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. 227 228 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.229 The 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. 229 230 Without significant extension to the C programming language, it is becoming unable to cope with the needs of modern programming problems and programmers; 230 231 as a result, it will fade into disuse. 231 232 Considering 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.233 While \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. 233 234 While 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. 234 235 … … 244 245 int forty_two = identity( 42 ); §\C{// T is bound to int, forty\_two == 42}§ 245 246 \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. 247 248 \CFA{}\hspace{1pt}'s polymorphism was originally formalized by Ditchfiled~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}. 248 249 However, at that time, there was little interesting in extending C, so work did not continue. … … 263 264 A simple example is leveraging the existing type-unsafe (©void *©) C ©bsearch© to binary search a sorted floating-point array: 264 265 \begin{lstlisting} 265 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size,266 void * bsearch( const void * key, const void * base, size_t dim, size_t size, 266 267 int (* compar)( const void *, const void * )); 267 268 … … 341 342 The 1999 C standard plus GNU extensions. 342 343 \item 344 {\lstset{deletekeywords={inline}} 343 345 \Indexc{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{©-fgnu89-inline©}} 344 346 Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files. 347 }% 345 348 \end{description} 346 349 The following new \CFA options are available: … … 413 416 \begin{cfa} 414 417 #ifndef __CFORALL__ 415 #include <stdio.h> 418 #include <stdio.h>§\indexc{stdio.h}§ §\C{// C header file}§ 416 419 #else 417 #include <fstream> 420 #include <fstream>§\indexc{fstream}§ §\C{// \CFA header file}§ 418 421 #endif 419 422 \end{cfa} … … 451 454 the type suffixes ©U©, ©L©, etc. may start with an underscore ©1_U©, ©1_ll© or ©1.0E10_f©. 452 455 \end{enumerate} 453 It is significantly easier to read and enter long constants when they are broken up into smaller groupings (m ost cultures use commaor period among digits for the same purpose).456 It 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). 454 457 This extension is backwards compatible, matches with the use of underscore in variable names, and appears in \Index*{Ada} and \Index*{Java} 8. 455 458 … … 461 464 \begin{cfa} 462 465 int ®`®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 anon-keyword name.466 double ®`®forall®`® = 3.5; 467 \end{cfa} 468 Existing 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. 466 469 \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©: 467 470 … … 470 473 // include file uses the CFA keyword "otype". 471 474 #if ! defined( otype ) §\C{// nesting ?}§ 472 #define otype `otype`475 #define otype ®`®otype®`® §\C{// make keyword an identifier}§ 473 476 #define __CFA_BFD_H__ 474 477 #endif // ! otype … … 494 497 \begin{tabular}{@{}ll@{}} 495 498 \begin{cfa} 496 int * x[5]499 int * x[5] 497 500 \end{cfa} 498 501 & … … 505 508 For example, a routine returning a \Index{pointer} to an array of integers is defined and used in the following way: 506 509 \begin{cfa} 507 int (*f())[5] {...}; §\C{}§508 ... (*f())[3] += 1; 510 int ®(*®f®())[®5®]® {...}; §\C{definition}§ 511 ... ®(*®f®())[®3®]® += 1; §\C{usage}§ 509 512 \end{cfa} 510 513 Essentially, the return type is wrapped around the routine name in successive layers (like an \Index{onion}). … … 513 516 \CFA provides its own type, variable and routine declarations, using a different syntax. 514 517 The 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 thequalifiers.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.518 In the following example, \R{red} is the base type and \B{blue} is qualifiers. 519 The \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. 517 520 \begin{quote2} 518 521 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} … … 531 534 \end{tabular} 532 535 \end{quote2} 533 The only exception is bit fieldspecification, which always appear to the right of the base type.536 The only exception is \Index{bit field} specification, which always appear to the right of the base type. 534 537 % 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. 535 538 However, unlike C, \CFA type declaration tokens are distributed across all variables in the declaration list. … … 580 583 \begin{cfa} 581 584 int z[ 5 ]; 582 char * w[ 5 ];583 double (* v)[ 5 ];585 char * w[ 5 ]; 586 double (* v)[ 5 ]; 584 587 struct s { 585 588 int f0:3; 586 int * f1;587 int * f2[ 5 ]589 int * f1; 590 int * f2[ 5 ] 588 591 }; 589 592 \end{cfa} … … 634 637 \begin{cfa} 635 638 int extern x[ 5 ]; 636 const int static * y;639 const int static * y; 637 640 \end{cfa} 638 641 & … … 644 647 \end{quote2} 645 648 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} 649 The 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} 654 y = (®* int®)x; 655 i = sizeof(®[ 5 ] * int®); 656 \end{cfa} 657 & 658 \begin{cfa} 659 y = (®int *®)x; 660 i = sizeof(®int * [ 5 ]®); 661 \end{cfa} 662 \end{tabular} 663 \end{quote2} 655 664 656 665 Finally, new \CFA declarations may appear together with C declarations in the same program block, but cannot be mixed within a specific declaration. … … 659 668 660 669 661 \section{Pointer /Reference}670 \section{Pointer/Reference} 662 671 663 672 C provides a \newterm{pointer type}; 664 673 \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: 674 These types may be derived from an object or routine type, called the \newterm{referenced type}. 675 Objects of these types contain an \newterm{address}, which is normally a location in memory, but may also address memory-mapped registers in hardware devices. 676 An integer constant expression with the value 0, or such an expression cast to type ©void *©, is called a \newterm{null-pointer constant}.\footnote{ 677 One 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.} 679 An 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. 680 Dereferencing an \newterm{unsound} address, including the null pointer, is \Index{undefined}, often resulting in a \Index{memory fault}. 681 682 A program \newterm{object} is a region of data storage in the execution environment, the contents of which can represent values. 683 In 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: 673 684 \begin{quote2} 674 \begin{tabular}{@{}ll l@{}}685 \begin{tabular}{@{}ll@{\hspace{2em}}l@{}} 675 686 \begin{cfa} 676 687 int x; … … 691 702 \end{quote2} 692 703 where 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. 704 Since a variable name only points to one address during its lifetime, it is an \Index{immutable} \Index{pointer}; 705 hence, the implicit type of pointer variables ©x© and ©y© are constant pointers in the compiler interpretation. 706 In general, variable addresses are stored in instructions instead of loaded from memory, and hence may not occupy storage. 707 These approaches are contrasted in the following: 696 708 \begin{quote2} 697 709 \begin{tabular}{@{}l|l@{}} 710 \multicolumn{1}{c|}{explicit variable address} & \multicolumn{1}{c}{implicit variable address} \\ 711 \hline 698 712 \begin{cfa} 699 713 lda r1,100 // load address of x 700 ld r2,(r1)// load value of x714 ld r2,(r1) // load value of x 701 715 lda r3,104 // load address of y 702 st r2,(r3)// store x into y716 st r2,(r3) // store x into y 703 717 \end{cfa} 704 718 & … … 711 725 \end{tabular} 712 726 \end{quote2} 713 Finally, the immutable nature of a variable's address and the fact that there is no storage for a variable addressmeans 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 asthe literal is embedded directly into instructions.)727 Finally, 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. 728 Therefore, 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 730 A \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.) 718 732 Hence, a pointer occupies memory to store its current address, and the pointer's value is loaded by dereferencing, \eg: 719 733 \begin{quote2} 720 \begin{tabular}{@{}l l@{}}734 \begin{tabular}{@{}l@{\hspace{2em}}l@{}} 721 735 \begin{cfa} 722 736 int x, y, ®*® p1, ®*® p2, ®**® p3; … … 727 741 \end{cfa} 728 742 & 729 \raisebox{-0. 45\totalheight}{\input{pointer2.pstex_t}}743 \raisebox{-0.5\totalheight}{\input{pointer2.pstex_t}} 730 744 \end{tabular} 731 745 \end{quote2} 732 746 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: 747 Notice, an address has a \Index{duality}\index{address!duality}: a location in memory or the value at that location. 748 In many cases, a compiler might be able to infer the best meaning for these two cases. 749 For example, \Index*{Algol68}~\cite{Algol68} infers pointer dereferencing to select the best meaning for each pointer usage 735 750 \begin{cfa} 736 751 p2 = p1 + x; §\C{// compiler infers *p2 = *p1 + x;}§ 737 752 \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 ©*©. 753 Algol68 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. 754 Unfortunately, automatic dereferencing does not work in all cases, and so some mechanism is necessary to fix incorrect choices. 755 756 Rather than inferring dereference, most programming languages pick one implicit dereferencing semantics, and the programmer explicitly indicates the other to resolve address-duality. 757 In C, objects of pointer type always manipulate the pointer object's address: 758 \begin{cfa} 759 p1 = p2; §\C{// p1 = p2\ \ rather than\ \ *p1 = *p2}§ 760 p2 = p1 + x; §\C{// p2 = p1 + x\ \ rather than\ \ *p2 = *p1 + x}§ 761 \end{cfa} 762 even though the assignment to ©p2© is likely incorrect, and the programmer probably meant: 748 763 \begin{cfa} 749 764 p1 = p2; §\C{// pointer address assignment}§ 750 *p1 = *p1 + 1;§\C{// pointed-to value assignment / operation}§751 \end{cfa} 752 which workswell 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} 767 The 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©). 753 768 754 769 However, in most other situations, the pointed-to value is requested more often than the pointer address. … … 762 777 \end{cfa} 763 778 764 To s witch the default meaning for an address requires a new kind of pointer, called a \newterm{reference} denoted by ©&©.779 To 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). 765 780 \begin{cfa} 766 781 int x, y, ®&® r1, ®&® r2, ®&&® r3; … … 773 788 Except for auto-dereferencing by the compiler, this reference example is the same as the previous pointer example. 774 789 Hence, 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: 790 One 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: 780 791 \begin{cfa} 781 792 ®*®r2 = ((®*®r1 + ®*®r2) ®*® (®**®r3 - ®*®r1)) / (®**®r3 - 15); 782 793 \end{cfa} 783 When a reference operation appears beside a dereference operation, \eg ©&*©, they cancel out.\footnote{ 794 When a reference operation appears beside a dereference operation, \eg ©&*©, they cancel out. 795 However, in C, the cancellation always yields a value (\Index{rvalue}).\footnote{ 784 796 The unary ©&© operator yields the address of its operand. 785 797 If the operand has type ``type'', the result has type ``pointer to type''. 786 798 If 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 variabler1 not variable pointed-to by r1}§799 For 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}§ 790 802 \end{cfa} 791 803 Similarly, the address of a reference can be obtained for assignment or computation (\Index{rvalue}): 792 804 \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} 807 Cancellation\index{cancellation!pointer/reference}\index{pointer!cancellation} works to arbitrary depth. 808 809 Fundamentally, pointer and reference objects are functionally interchangeable because both contain addresses. 796 810 \begin{cfa} 797 811 int x, *p1 = &x, **p2 = &p1, ***p3 = &p2, … … 805 819 &&&r3 = p3; §\C{// change r3 to p3, (\&(\&(\&*)*)*)r3, 3 cancellations}§ 806 820 \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. 821 Furthermore, both types are equally performant, as the same amount of dereferencing occurs for both types. 822 Therefore, 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 824 As for a pointer type, a reference type may have qualifiers: 825 \begin{cfa} 826 const int cx = 5; §\C{// cannot change cx;}§ 827 const int & cr = cx; §\C{// cannot change what cr points to}§ 828 ®&®cr = &cx; §\C{// can change cr}§ 829 cr = 7; §\C{// error, cannot change cx}§ 830 int & const rc = x; §\C{// must be initialized}§ 831 ®&®rc = &x; §\C{// error, cannot change rc}§ 832 const int & const crc = cx; §\C{// must be initialized}§ 833 crc = 7; §\C{// error, cannot change cx}§ 834 ®&®crc = &cx; §\C{// error, cannot change crc}§ 835 \end{cfa} 836 Hence, 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} 838 int & const cr = *0; §\C{// where 0 is the int * zero}§ 839 \end{cfa} 840 Note, constant reference-types do not prevent \Index{addressing errors} because of explicit storage-management: 841 \begin{cfa} 842 int & const cr = *malloc(); 843 cr = 5; 844 free( &cr ); 845 cr = 7; §\C{// unsound pointer dereference}§ 846 \end{cfa} 847 848 The position of the ©const© qualifier \emph{after} the pointer/reference qualifier causes confuse for C programmers. 833 849 The ©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: 835 851 \begin{quote2} 836 852 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} … … 847 863 \end{tabular} 848 864 \end{quote2} 849 where the \CFA declaration is read left-to-right (see \VRef{s:Declarations}). 865 where the \CFA declaration is read left-to-right. 866 867 Finally, like pointers, references are usable and composable with other type operators and generators. 868 \begin{cfa} 869 int w, x, y, z, & ar[3] = { x, y, z }; §\C{// initialize array of references}§ 870 &ar[1] = &w; §\C{// change reference array element}§ 871 typeof( ar[1] ) p; §\C{// (gcc) is int, i.e., the type of referenced object}§ 872 typeof( &ar[1] ) q; §\C{// (gcc) is int \&, i.e., the type of reference}§ 873 sizeof( ar[1] ) == sizeof( int ); §\C{// is true, i.e., the size of referenced object}§ 874 sizeof( &ar[1] ) == sizeof( int *) §\C{// is true, i.e., the size of a reference}§ 875 \end{cfa} 876 877 In 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}. 878 Also, \CC does not allow \Index{array}s\index{array!reference} of reference\footnote{ 879 The 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} 850 884 851 885 \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. 852 886 There 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. 887 Because 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. 888 In contrast, the left-hand side of assignment has an address that has a duality. 889 Therefore, for pointer/reference initialization, the initializing value must be an address not a value. 890 \begin{cfa} 891 int * p = &x; §\C{// assign address of x}§ 892 ®int * p = x;® §\C{// assign value of x}§ 893 int & r = x; §\C{// must have address of x}§ 894 \end{cfa} 895 Like 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). 896 Therefore, 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. 897 Note, this is strictly a convenience and safety feature for a programmer. 898 Hence, \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. 899 Unfortunately, C allows ©p© to be assigned with ©&x© (address) or ©x© (value), but most compilers warn about the latter assignment as being potentially incorrect. 900 Similarly, 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} 902 int & f( int & r ); §\C{// reference parameter and return}§ 903 z = f( x ) + f( y ); §\C{// reference operator added, temporaries needed for call results}§ 904 \end{cfa} 905 Within routine ©f©, it is possible to change the argument by changing the corresponding parameter, and parameter ©r© can be locally reassigned within ©f©. 906 Since 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} 908 int temp1 = f( x ), temp2 = f( y ); 909 z = temp1 + temp2; 910 \end{cfa} 911 This \Index{implicit referencing} is crucial for reducing the syntactic burden for programmers when using references; 912 otherwise references have the same syntactic burden as pointers in these contexts. 866 913 867 914 When a pointer/reference parameter has a ©const© value (immutable), it is possible to pass literals and expressions. 868 915 \begin{cfa} 869 void f( ®const® int & cr p);870 void g( ®const® int * cp p);871 f( 3 ); g( &3 );872 f( x + y ); g( &(x + y) );916 void f( ®const® int & cr ); 917 void g( ®const® int * cp ); 918 f( 3 ); g( ®&®3 ); 919 f( x + y ); g( ®&®(x + y) ); 873 920 \end{cfa} 874 921 Here, 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}§ 922 The ©&© 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©). 923 Importantly, ©&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{ 926 If whole program analysis is possible, and shows the parameter is not assigned, \ie it is ©const©, the temporary is unnecessary.} 927 \begin{cfa} 928 void f( int & r ); 929 void g( int * p ); 930 f( 3 ); g( ®&®3 ); §\C{// compiler implicit generates temporaries}§ 931 f( x + y ); g( ®&®(x + y) ); §\C{// compiler implicit generates temporaries}§ 882 932 \end{cfa} 883 933 Essentially, there is an implicit \Index{rvalue} to \Index{lvalue} conversion in this case.\footnote{ … … 885 935 The implicit conversion allows seamless calls to any routine without having to explicitly name/copy the literal/expression to allow the call. 886 936 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. 938 Finally, C handles \Index{routine object}s in an inconsistent way. 939 A routine object is both a pointer and a reference (\Index{particle and wave}). 940 \begin{cfa} 941 void f( int i ); 942 void (*fp)( int ); §\C{// routine pointer}§ 943 fp = f; §\C{// reference initialization}§ 944 fp = &f; §\C{// pointer initialization}§ 945 fp = *f; §\C{// reference initialization}§ 946 fp(3); §\C{// reference invocation}§ 947 (*fp)(3); §\C{// pointer invocation}§ 948 \end{cfa} 949 While 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. 950 Instead, a routine object should be referenced by a ©const© reference: 951 \begin{cfa} 952 ®const® void (®&® fr)( int ) = f; §\C{// routine reference}§ 953 fr = ... §\C{// error, cannot change code}§ 954 &fr = ...; §\C{// changing routine reference}§ 955 fr( 3 ); §\C{// reference call to f}§ 956 (*fr)(3); §\C{// error, incorrect type}§ 957 \end{cfa} 958 because the value of the routine object is a routine literal, \ie the routine code is normally immutable during execution.\footnote{ 903 959 Dynamic 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 965 In C, ©&E© is an rvalue for any expression ©E©. 966 \CFA extends the ©&© (address-of) operator as follows: 967 \begin{itemize} 968 \item 969 if ©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 972 if ©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} 974 The following example shows the first rule applied to different \Index{rvalue} contexts: 975 \begin{cfa} 976 int x, * px, ** ppx, *** pppx, **** ppppx; 977 int & rx = x, && rrx = rx, &&& rrrx = rrx ; 978 x = rrrx; // rrrx is an lvalue with type int &&& (equivalent to x) 979 px = &rrrx; // starting from rrrx, &rrrx is an rvalue with type int *&&& (&x) 980 ppx = &&rrrx; // starting from &rrrx, &&rrrx is an rvalue with type int **&& (&rx) 981 pppx = &&&rrrx; // starting from &&rrrx, &&&rrrx is an rvalue with type int ***& (&rrx) 982 ppppx = &&&&rrrx; // starting from &&&rrrx, &&&&rrrx is an rvalue with type int **** (&rrrx) 983 \end{cfa} 984 The following example shows the second rule applied to different \Index{lvalue} contexts: 985 \begin{cfa} 986 int x, * px, ** ppx, *** pppx; 987 int & rx = x, && rrx = rx, &&& rrrx = rrx ; 988 rrrx = 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 997 C provides a basic implicit conversion to simplify variable usage: 998 \begin{enumerate} 999 \setcounter{enumi}{-1} 1000 \item 1001 lvalue to rvalue conversion: ©cv T© converts to ©T©, which allows implicit variable dereferencing. 1002 \begin{cfa} 1003 int x; 1004 x + 1; // lvalue variable (int) converts to rvalue for expression 1005 \end{cfa} 1006 An 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 1011 reference to rvalue conversion: ©cv T &© converts to ©T©, which allows implicit reference dereferencing. 1012 \begin{cfa} 1013 int x, &r = x, f( int p ); 1014 x = ®r® + f( ®r® ); // lvalue reference converts to rvalue 1015 \end{cfa} 1016 An rvalue has no type qualifiers (©cv©), so the reference qualifiers are dropped. 1017 1018 \item 1019 lvalue to reference conversion: \lstinline[deletekeywords={lvalue}]@lvalue-type cv1 T@ converts to ©cv2 T &©, which allows implicitly converting variables to references. 1020 \begin{cfa} 1021 int x, &r = ®x®, f( int & p ); // lvalue variable (int) convert to reference (int &) 1022 f( ®x® ); // lvalue variable (int) convert to reference (int &) 1023 \end{cfa} 1024 Conversion can restrict a type, where ©cv1© $\le$ ©cv2©, \eg passing an ©int© to a ©const volatile int &©, which has low cost. 1025 Conversion can expand a type, where ©cv1© $>$ ©cv2©, \eg passing a ©const volatile int© to an ©int &©, which has high cost (\Index{warning}); 1026 furthermore, if ©cv1© has ©const© but not ©cv2©, a temporary variable is created to preserve the immutable lvalue. 1027 1028 \item 1029 rvalue to reference conversion: ©T© converts to ©cv T &©, which allows binding references to temporaries. 1030 \begin{cfa} 1031 int x, & f( int & p ); 1032 f( ®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} 1035 In both case, modifications to the temporary are inaccessible (\Index{warning}). 1036 Conversion expands the temporary-type with ©cv©, which is low cost since the temporary is inaccessible. 1037 \end{enumerate} 1038 1039 1040 \begin{comment} 1041 From: Richard Bilson <rcbilson@gmail.com> 1042 Date: Wed, 13 Jul 2016 01:58:58 +0000 1043 Subject: Re: pointers / references 1044 To: "Peter A. Buhr" <pabuhr@plg2.cs.uwaterloo.ca> 1045 1046 As a general comment I would say that I found the section confusing, as you move back and forth 1047 between various real and imagined programming languages. If it were me I would rewrite into two 1048 subsections, one that specifies precisely the syntax and semantics of reference variables and 1049 another that provides the rationale. 1050 1051 I don't see any obvious problems with the syntax or semantics so far as I understand them. It's not 1052 obvious that the description you're giving is complete, but I'm sure you'll find the special cases 1053 as you do the implementation. 1054 1055 My big gripes are mostly that you're not being as precise as you need to be in your terminology, and 1056 that you say a few things that aren't actually true even though I generally know what you mean. 1057 1058 20 C provides a pointer type; CFA adds a reference type. Both types contain an address, which is normally a 1059 21 location in memory. 1060 1061 An address is not a location in memory; an address refers to a location in memory. Furthermore it 1062 seems weird to me to say that a type "contains" an address; rather, objects of that type do. 1063 1064 21 Special addresses are used to denote certain states or access co-processor memory. By 1065 22 convention, no variable is placed at address 0, so addresses like 0, 1, 2, 3 are often used to denote no-value 1066 23 or other special states. 1067 1068 This isn't standard C at all. There has to be one null pointer representation, but it doesn't have 1069 to be a literal zero representation and there doesn't have to be more than one such representation. 1070 1071 23 Often dereferencing a special state causes a memory fault, so checking is necessary 1072 24 during execution. 1073 1074 I don't see the connection between the two clauses here. I feel like if a bad pointer will not cause 1075 a memory fault then I need to do more checking, not less. 1076 1077 24 If the programming language assigns addresses, a program's execution is sound, \ie all 1078 25 addresses are to valid memory locations. 1079 1080 You haven't said what it means to "assign" an address, but if I use my intuitive understanding of 1081 the term I don't see how this can be true unless you're assuming automatic storage management. 1082 1083 1 Program variables are implicit pointers to memory locations generated by the compiler and automatically 1084 2 dereferenced, as in: 1085 1086 There is no reason why a variable needs to have a location in memory, and indeed in a typical 1087 program many variables will not. In standard terminology an object identifier refers to data in the 1088 execution environment, but not necessarily in memory. 1089 1090 13 A pointer/reference is a generalization of a variable name, \ie a mutable address that can point to more 1091 14 than one memory location during its lifetime. 1092 1093 I feel like you're off the reservation here. In my world there are objects of pointer type, which 1094 seem to be what you're describing here, but also pointer values, which can be stored in an object of 1095 pointer type but don't necessarily have to be. For example, how would you describe the value denoted 1096 by "&main" in a C program? I would call it a (function) pointer, but that doesn't satisfy your 1097 definition. 1098 1099 16 not occupy storage as the literal is embedded directly into instructions.) Hence, a pointer occupies memory 1100 17 to store its current address, and the pointer's value is loaded by dereferencing, e.g.: 1101 1102 As with my general objection regarding your definition of variables, there is no reason why a 1103 pointer variable (object of pointer type) needs to occupy memory. 1104 1105 21 p2 = p1 + x; // compiler infers *p2 = *p1 + x; 1106 1107 What language are we in now? 1108 1109 24 pointer usage. However, in C, the following cases are ambiguous, especially with pointer arithmetic: 1110 25 p1 = p2; // p1 = p2 or *p1 = *p2 1111 1112 This isn't ambiguous. it's defined to be the first option. 1113 1114 26 p1 = p1 + 1; // p1 = p1 + 1 or *p1 = *p1 + 1 1115 1116 Again, this statement is not ambiguous. 1117 1118 13 example. Hence, a reference behaves like the variable name for the current variable it is pointing-to. The 1119 14 simplest way to understand a reference is to imagine the compiler inserting a dereference operator before 1120 15 the reference variable for each reference qualifier in a declaration, e.g.: 1121 1122 It's hard for me to understand who the audience for this part is. I think a practical programmer is 1123 likely to be satisfied with "a reference behaves like the variable name for the current variable it 1124 is pointing-to," maybe with some examples. Your "simplest way" doesn't strike me as simpler than 1125 that. It feels like you're trying to provide a more precise definition for the semantics of 1126 references, but it isn't actually precise enough to be a formal specification. If you want to 1127 express the semantics of references using rewrite rules that's a great way to do it, but lay the 1128 rules out clearly, and when you're showing an example of rewriting keep your 1129 references/pointers/values separate (right now, you use \eg "r3" to mean a reference, a pointer, 1130 and a value). 1131 1132 24 Cancellation works to arbitrary depth, and pointer and reference values are interchangeable because both 1133 25 contain addresses. 1134 1135 Except they're not interchangeable, because they have different and incompatible types. 1136 1137 40 Interestingly, C++ deals with the address duality by making the pointed-to value the default, and prevent- 1138 41 ing changes to the reference address, which eliminates half of the duality. Java deals with the address duality 1139 42 by making address assignment the default and requiring field assignment (direct or indirect via methods), 1140 43 \ie there is no builtin bit-wise or method-wise assignment, which eliminates half of the duality. 1141 1142 I can follow this but I think that's mostly because I already understand what you're trying to 1143 say. I don't think I've ever heard the term "method-wise assignment" and I don't see you defining 1144 it. Furthermore Java does have value assignment of basic (non-class) types, so your summary here 1145 feels incomplete. (If it were me I'd drop this paragraph rather than try to save it.) 1146 1147 11 Hence, for type & const, there is no pointer assignment, so &rc = &x is disallowed, and the address value 1148 12 cannot be 0 unless an arbitrary pointer is assigned to the reference. 1149 1150 Given the pains you've taken to motivate every little bit of the semantics up until now, this last 1151 clause ("the address value cannot be 0") comes out of the blue. It seems like you could have 1152 perfectly reasonable semantics that allowed the initialization of null references. 1153 1154 12 In effect, the compiler is managing the 1155 13 addresses for type & const not the programmer, and by a programming discipline of only using references 1156 14 with references, address errors can be prevented. 1157 1158 Again, is this assuming automatic storage management? 1159 1160 18 rary binding. For reference initialization (like pointer), the initializing value must be an address (lvalue) not 1161 19 a value (rvalue). 1162 1163 This sentence appears to suggest that an address and an lvalue are the same thing. 1164 1165 20 int * p = &x; // both &x and x are possible interpretations 1166 1167 Are 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 1170 21 int & r = x; // x unlikely interpretation, because of auto-dereferencing 1171 1172 You mean, we can initialize a reference using an integer value? Surely we would need some sort of 1173 cast to induce that interpretation, no? 1174 1175 22 Hence, the compiler implicitly inserts a reference operator, &, before the initialization expression. 1176 1177 But then the expression would have pointer type, which wouldn't be compatible with the type of r. 1178 1179 22 Similarly, 1180 23 when a reference is used for a parameter/return type, the call-site argument does not require a reference 1181 24 operator. 1182 1183 Furthermore, it would not be correct to use a reference operator. 1184 1185 45 The implicit conversion allows 1186 1 seamless calls to any routine without having to explicitly name/copy the literal/expression to allow the call. 1187 2 While C' attempts to handle pointers and references in a uniform, symmetric manner, C handles routine 1188 3 variables in an inconsistent way: a routine variable is both a pointer and a reference (particle and wave). 1189 1190 After all this talk of how expressions can have both pointer and value interpretations, you're 1191 disparaging C because it has expressions that have both pointer and value interpretations? 1192 1193 On 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} 924 1198 925 1199 926 1200 \section{Routine Definition} 927 1201 928 \CFA also supports a new syntax for routine definition, as well as ISO Cand K\&R routine syntax.1202 \CFA also supports a new syntax for routine definition, as well as \Celeven and K\&R routine syntax. 929 1203 The point of the new syntax is to allow returning multiple values from a routine~\cite{Galletly96,CLU}, \eg: 930 1204 \begin{cfa} … … 946 1220 in 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: 947 1221 \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}§ 950 1224 \end{cfa} 951 1225 … … 965 1239 \begin{cfa} 966 1240 typedef int foo; 967 int f( int (* foo) ); §\C{// foo is redefined as a parameter name}§1241 int f( int (* foo) ); §\C{// foo is redefined as a parameter name}§ 968 1242 \end{cfa} 969 1243 The 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. … … 973 1247 C-style declarations can be used to declare parameters for \CFA style routine definitions, \eg: 974 1248 \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}§ 977 1251 \end{cfa} 978 1252 The 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: 979 1253 \begin{cfa} 980 1254 #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 ] )}§1255 int 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 ] )}§ 983 1257 \end{cfa} 984 1258 Again, programmers are highly encouraged to use one declaration form or the other, rather than mixing the forms. … … 1002 1276 int z; 1003 1277 ... x = 0; ... y = z; ... 1004 ®return;® 1278 ®return;® §\C{// implicitly return x, y}§ 1005 1279 } 1006 1280 \end{cfa} … … 1012 1286 [ int x, int y ] f() { 1013 1287 ... 1014 } 1288 } §\C{// implicitly return x, y}§ 1015 1289 \end{cfa} 1016 1290 In this case, the current values of ©x© and ©y© are returned to the calling routine just as if a ©return© had been encountered. 1291 1292 Named return values may be used in conjunction with named parameter values; 1293 specifically, 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} 1299 This 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}§ 1302 int a, b; 1303 [a, b] = f( f( f( a, b ) ) ); 1304 \end{cfa} 1305 While 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. 1306 Hence, even without the body of routine ©f© (separate compilation), it is possible to perform a global optimization across routine calls. 1307 The compiler warns about naming inconsistencies between routine prototype and definition in this case, and behaviour is \Index{undefined} if the programmer is inconsistent. 1017 1308 1018 1309 … … 1022 1313 as well, parameter names are optional, \eg: 1023 1314 \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}§ 1028 1319 \end{cfa} 1029 1320 This syntax allows a prototype declaration to be created by cutting and pasting source text from the routine definition header (or vice versa). … … 1033 1324 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1034 1325 \begin{cfa} 1035 [ int ] f( int), g;1326 [ int ] f( int ), g; 1036 1327 \end{cfa} 1037 1328 & 1038 1329 \begin{cfa} 1039 int f( int), g(int);1330 int f( int ), g( int ); 1040 1331 \end{cfa} 1041 1332 \end{tabular} … … 1043 1334 Declaration qualifiers can only appear at the start of a \CFA routine declaration,\footref{StorageClassSpecifier} \eg: 1044 1335 \begin{cfa} 1045 extern [ int ] f ( int);1046 static [ int ] g ( int);1336 extern [ int ] f ( int ); 1337 static [ int ] g ( int ); 1047 1338 \end{cfa} 1048 1339 … … 1052 1343 The syntax for pointers to \CFA routines specifies the pointer name on the right, \eg: 1053 1344 \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}§ 1058 1349 \end{cfa} 1059 1350 While parameter names are optional, \emph{a routine name cannot be specified}; 1060 1351 for example, the following is incorrect: 1061 1352 \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}§ 1063 1354 \end{cfa} 1064 1355 … … 1066 1357 \section{Named and Default Arguments} 1067 1358 1068 Named and defaultarguments~\cite{Hardgrave76}\footnote{1359 Named\index{named arguments}\index{arguments!named} and default\index{default arguments}\index{arguments!default} arguments~\cite{Hardgrave76}\footnote{ 1069 1360 Francez~\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.} 1070 1361 are two mechanisms to simplify routine call. … … 1233 1524 1234 1525 Given 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; 1236 1527 \Index*{Ada} supports both named and default arguments. 1237 1528 1238 1529 1239 \section{Type/Routine Nesting} 1530 \section{Unnamed Structure Fields} 1531 1532 C requires each field of a structure to have a name, except for a bit field associated with a basic type, \eg: 1533 \begin{cfa} 1534 struct { 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} 1543 This requirement is relaxed by making the field name optional for all field declarations; therefore, all the field declarations in the example are allowed. 1544 As for unnamed bit fields, an unnamed field is used for padding a structure to a particular size. 1545 A list of unnamed fields is also supported, \eg: 1546 \begin{cfa} 1547 struct { 1548 int , , ; §\C{// 3 unnamed fields}§ 1549 } 1550 \end{cfa} 1551 1552 1553 \section{Nesting} 1240 1554 1241 1555 Nesting of types and routines is useful for controlling name visibility (\newterm{name hiding}). … … 1244 1558 \subsection{Type Nesting} 1245 1559 1246 \CFA allows \Index{type nesting}, and type qualification of the nested typ res (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. 1247 1561 \begin{figure} 1248 1562 \centering … … 1347 1661 } 1348 1662 int main() { 1349 * [int]( int) fp = foo(); §\C{// int (*fp)(int)}§1350 1663 * [int]( int ) fp = foo(); §\C{// int (*fp)( int )}§ 1664 sout | fp( 3 ) | endl; 1351 1665 } 1352 1666 \end{cfa} 1353 1667 because 1354 1668 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}1669 Currently, 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} 1359 1673 1360 1674 In C and \CFA, lists of elements appear in several contexts, such as the parameter list for a routine call. … … 1373 1687 [ v+w, x*y, 3.14159, f() ] 1374 1688 \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.1689 Tuples 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. 1376 1690 Note, a tuple is not a record (structure); 1377 1691 a record denotes a single value with substructure, whereas a tuple is multiple values with no substructure (see flattening coercion in Section 12.1). … … 1429 1743 tuple does not have structure like a record; a tuple is simply converted into a list of components. 1430 1744 \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.1745 The 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. 1432 1746 Using a temporary variable to store the results of the inner routine and then passing this variable to the outer routine works, however. 1433 1747 \end{rationale} … … 1442 1756 This requirement is the same as for comma expressions in argument lists. 1443 1757 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:1758 Type qualifiers, \ie const and volatile, may modify a tuple type. 1759 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)], \ie the qualifier is distributed across all of the types in the tuple, \eg: 1446 1760 \begin{cfa} 1447 1761 const volatile [ int, float, const int ] x; … … 1481 1795 ©w© is implicitly opened to yield a tuple of four values, which are then assigned individually. 1482 1796 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:1797 A \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: 1484 1798 \begin{cfa} 1485 1799 [ a, b, c, d ] = [ 1, [ 2, 3 ], 4 ]; … … 1516 1830 \end{cfa} 1517 1831 \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.1832 The 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. 1519 1833 ©$\emph{expr}$© is any standard arithmetic expression. 1520 1834 Clearly, the types of the entities being assigned must be type compatible with the value of the expression. … … 1557 1871 \index{lvalue} 1558 1872 The 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 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.1873 Each \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. 1560 1874 An example of multiple assignment is: 1561 1875 \begin{cfa} … … 1604 1918 [ x1, y1 ] = z = 0; 1605 1919 \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} 1920 As in C, the rightmost assignment is performed first, \ie assignment parses right to left. 1630 1921 1631 1922 … … 1669 1960 1670 1961 1671 \section{Labelled Continue /Break}1962 \section{Labelled Continue/Break} 1672 1963 1673 1964 While 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}.1965 Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting. 1966 To 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}. 1676 1967 For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement; 1677 1968 for ©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©. 1970 The 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:® { 1716 1977 ... §declarations§ ... 1717 ®L 2:® switch ( ... ) {1978 ®LS:® switch ( ... ) { 1718 1979 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 1725 1991 } // for 1726 1992 } else { 1727 ... break ®L 3®; ... // exitif1993 ... break ®LIF®; ... // terminate if 1728 1994 } // if 1729 1995 } // switch … … 1736 2002 switch ( ... ) { 1737 2003 case 3: 1738 2004 if ( ... ) { 1739 2005 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:® ; 1745 2016 } else { 1746 ... goto L3; ...1747 } L3:;1748 } L2:;1749 } L1:;2017 ... goto ®LIF®; ... 2018 } ®L3:® ; 2019 } ®LS:® ; 2020 } ®LC:® ; 1750 2021 \end{cfa} 1751 2022 \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} 2028 int 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 2077 Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline $goto$!restricted} restricted in the following ways: 1756 2078 \begin{itemize} 1757 2079 \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.2080 They cannot create a loop, which means only the looping constructs cause looping. 2081 This restriction means all situations resulting in repeated execution are clearly delineated. 2082 \item 2083 They cannot branch into a control structure. 2084 This restriction prevents missing initialization at the start of a control structure resulting in undefined behaviour. 1763 2085 \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.2086 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. 1765 2087 Furthermore, 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. 1766 2088 With ©goto©, the label is at the end of the control structure, which fails to convey this important clue early enough to the reader. 1767 2089 Finally, 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.2090 The implicit targets of the current ©continue© and ©break©, \ie the closest enclosing loop or ©switch©, change as certain constructs are added or removed. 1769 2091 1770 2092 … … 1903 2225 Furthermore, 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. 1904 2226 As 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.2227 The key observation is that the ©switch© statement branches into control structure, \ie there are multiple entry points into its statement body. 1906 2228 \end{enumerate} 1907 2229 … … 1911 2233 the number of ©switch© statements is small, 1912 2234 \item 1913 most ©switch© statements are well formed ( i.e.,no \Index*{Duff's device}),2235 most ©switch© statements are well formed (\ie no \Index*{Duff's device}), 1914 2236 \item 1915 2237 the ©default© clause is usually written as the last case-clause, … … 1921 2243 \item 1922 2244 Eliminating 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:2245 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, \ie a list of ©case© clauses executing common code, \eg: 1924 2246 \begin{cfa} 1925 2247 case 1: case 2: case 3: ... … … 1964 2286 ®int j = 0;® §\C{// disallowed}§ 1965 2287 case 1: 1966 2288 { 1967 2289 ®int k = 0;® §\C{// allowed at different nesting levels}§ 1968 2290 ... … … 2079 2401 \index{input/output library} 2080 2402 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. 2403 The 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. 2404 The \CFA header file for the I/O library is \Indexc{fstream}. 2405 2082 2406 The common case is printing out a sequence of variables separated by whitespace. 2083 2407 \begin{quote2} … … 2085 2409 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{\CC}} \\ 2086 2410 \begin{cfa} 2087 int x = 0, y = 1, z = 2;2411 int x = 1, y = 2, z = 3; 2088 2412 sout | x ®|® y ®|® z | endl; 2089 2413 \end{cfa} … … 2092 2416 2093 2417 cout << x ®<< " "® << y ®<< " "® << z << endl; 2418 \end{cfa} 2419 \\ 2420 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2421 1 2 3 2422 \end{cfa} 2423 & 2424 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2425 1 2 3 2094 2426 \end{cfa} 2095 2427 \end{tabular} 2096 2428 \end{quote2} 2097 2429 The \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. 2430 A 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]; 2433 sout | t1 | t2 | endl; §\C{// print tuples}§ 2434 \end{cfa} 2435 \begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt] 2436 1, 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. 2100 2439 Therefore, fewer output expressions require parenthesis. 2101 2440 \begin{quote2} … … 2110 2449 & 2111 2450 \begin{cfa} 2112 cout << x * 3 << y + 1 << (z << 2) << (x == y) << (x | y) << (x || y) << (x > z ? 1 : 2) << endl; 2451 cout << 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] 2456 3 3 12 0 3 1 2 2113 2457 \end{cfa} 2114 2458 \end{tabular} … … 2116 2460 Finally, 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. 2117 2461 2118 The implicit separator\index{I/O separator} character (space/blank) is a separator not a terminator. 2462 2463 The implicit separator\index{I/O!separator} character (space/blank) is a separator not a terminator. 2119 2464 The rules for implicitly adding the separator are: 2120 2465 \begin{enumerate} … … 2127 2472 1 2 3 2128 2473 \end{cfa} 2474 2129 2475 \item 2130 2476 A separator does not appear before or after a character literal or variable. … … 2133 2479 123 2134 2480 \end{cfa} 2135 \item 2136 A separator does not appear before or after a null (empty) C string 2481 2482 \item 2483 A separator does not appear before or after a null (empty) C string. 2137 2484 \begin{cfa} 2138 2485 sout | 1 | "" | 2 | "" | 3 | endl; … … 2140 2487 \end{cfa} 2141 2488 which 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 2491 A separator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$£¥¡¿«@ 2144 2492 %$ 2145 2493 \begin{cfa}[mathescape=off] … … 2148 2496 \end{cfa} 2149 2497 %$ 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 «102498 \begin{cfa}[mathescape=off,basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt] 2499 x ®(®1 x ®[®2 x ®{®3 x ®=®4 x ®$®5 x ®£®6 x ®¥®7 x ®¡®8 x ®¿®9 x ®«®10 2152 2500 \end{cfa} 2153 2501 %$ 2502 where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark. 2503 2154 2504 \item 2155 2505 {\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: ©,.;!?)]}%¢»©2506 A seperator does not appear after a C string ending with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@ 2157 2507 \begin{cfa}[belowskip=0pt] 2158 2508 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" 2159 2509 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl; 2160 2510 \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}x2511 \begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt] 2512 1®,® x 2®.® x 3®;® x 4®!® x 5®?® x 6®%® x 7§\color{red}\textcent§ x 8®»® x 9®)® x 10®]® x 11®}® x 2163 2513 \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@ 2514 where \lstinline[basicstyle=\tt]@»@ is a closing citation mark. 2515 2516 \item 2517 A seperator does not appear before or after a C string begining/ending with the \Index*{ASCII} quote or whitespace characters: \lstinline[basicstyle=\tt,showspaces=true]@`'": \t\v\f\r\n@ 2166 2518 \begin{cfa}[belowskip=0pt] 2167 2519 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl; 2168 2520 \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] 2522 x®`®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 2526 If a space is desired before or after one of the special string start/end characters, simply insert a space. 2527 \begin{cfa}[belowskip=0pt] 2528 sout | "x (§\color{red}\texttt{\textvisiblespace}§" | 1 | "§\color{red}\texttt{\textvisiblespace}§) x" | 2 | "§\color{red}\texttt{\textvisiblespace}§, x" | 3 | "§\color{red}\texttt{\textvisiblespace}§:x:§\color{red}\texttt{\textvisiblespace}§" | 4 | endl; 2529 \end{cfa} 2530 \begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] 2531 x (® ®1® ®) x 2® ®, x 3® ®:x:® ®4 2171 2532 \end{cfa} 2172 2533 \end{enumerate} 2173 2534 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. 2535 The following routines and \CC-style \Index{manipulator}s control implicit seperation. 2536 \begin{enumerate} 2537 \item 2538 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string. 2539 The 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] 2541 sepSet( sout, ", $" ); §\C{// set separator from " " to ", \$"}§ 2542 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl; 2543 \end{cfa} 2544 %$ 2545 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt] 2546 1, $2, $3 ®", $"® 2547 \end{cfa} 2548 %$ 2549 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2550 sepSet( sout, " " ); §\C{// reset separator to " "}§ 2551 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl; 2552 \end{cfa} 2553 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt] 2554 1 2 3 ®" "® 2555 \end{cfa} 2556 2557 \item 2558 Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, \ie the seperator is adjusted only with respect to the next printed item. 2176 2559 \begin{cfa}[mathescape=off,belowskip=0pt] 2177 2560 sout | sepOn | 1 | 2 | 3 | sepOn | endl; §\C{// separator at start of line}§ … … 2186 2569 12 3 2187 2570 \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 2573 Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, \ie the seperator is adjusted with respect to all subsequent printed items, unless locally adjusted. 2189 2574 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2190 2575 sout | sepDisable | 1 | 2 | 3 | endl; §\C{// globally turn off implicit separation}§ … … 2205 2590 1 2 3 2206 2591 \end{cfa} 2207 Printing a tuple outputs all the tuple's values separated by ©", "©: 2592 2593 \item 2594 Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string. 2595 The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters). 2208 2596 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2209 sout | [2, 3] | [4, 5] | endl; §\C{// print tuple}§ 2597 sepSetTuple( sout, " " ); §\C{// set tuple separator from ", " to " "}§ 2598 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl; 2599 \end{cfa} 2600 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt] 2601 1 2 3 4 ®" "® 2602 \end{cfa} 2603 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2604 sepSetTuple( sout, ", " ); §\C{// reset tuple separator to ", "}§ 2605 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl; 2606 \end{cfa} 2607 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt] 2608 1, 2, 3, 4 ®", "® 2609 \end{cfa} 2610 2611 \item 2612 The tuple separator can also be turned on and off. 2613 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2614 sout | sepOn | t1 | sepOff | t2 | endl; §\C{// locally turn on/off implicit separation}§ 2210 2615 \end{cfa} 2211 2616 \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 2220 2618 \end{cfa} 2221 2619 Notice 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} 2254 2621 2255 2622 \begin{comment} … … 2257 2624 2258 2625 int 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; 2261 2631 sout | 1 | 2 | 3 | endl; 2262 2632 sout | '1' | '2' | '3' | endl; … … 2267 2637 | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl; 2268 2638 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; 2278 2640 2279 2641 sepSet( sout, ", $" ); // set separator from " " to ", $" … … 2282 2644 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 2283 2645 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 2284 2653 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 2285 sout | [2, 3] | [4, 5]| " \"" | sepGetTuple( sout ) | "\"" | endl;2654 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 2286 2655 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 2288 2660 } 2289 2661 2290 2662 // Local Variables: // 2291 2663 // tab-width: 4 // 2664 // fill-column: 100 // 2292 2665 // End: // 2293 2666 \end{comment} … … 2409 2782 2410 2783 2411 \s ubsection{Constructors and Destructors}2784 \section{Constructors and Destructors} 2412 2785 2413 2786 \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).2787 Additionally, \CFA adds destructors that are called when a variable is deallocated (variable goes out of scope or object is deleted). 2415 2788 These functions take a reference to the structure as a parameter (see References for more information). 2416 2789 … … 2461 2834 \caption{Constructors and Destructors} 2462 2835 \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}2478 2836 2479 2837 … … 2755 3113 2756 3114 3115 \begin{comment} 2757 3116 \section{Generics} 2758 3117 … … 2760 3119 Generics allow programmers to use type variables in place of concrete types so that the code can be reused with multiple types. 2761 3120 The 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.3121 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. 2763 3122 2764 3123 2765 3124 \subsection{Generic Functions} 2766 3125 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.3126 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. 2768 3127 The 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. 2769 3128 This means that compiled libraries can contain generic functions that can be used by programs linked with them (statically or dynamically). … … 2798 3157 generic (type T | bool ?<?(T, T) ) 2799 3158 2800 T min( T a, T b) {3159 T min( T a, T b ) { 2801 3160 return a < b ? a : b; 2802 3161 } … … 2837 3196 2838 3197 generic (type T | Orderable(T)) 2839 T min( T a, T b) {3198 T min( T a, T b ) { 2840 3199 return a < b ? a : b; 2841 3200 } … … 2884 3243 2885 3244 Generic 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 }.3245 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{}}. 2887 3246 For 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. 2888 3247 In C, something like this would have to be done using void pointers and unsafe casting. … … 2936 3295 Throwing 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. 2937 3296 The 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. 2939 3298 An exception is thrown using a throw statement, which accepts one argument. 2940 3299 … … 2961 3320 } 2962 3321 \end{cfa} 3322 \end{comment} 2963 3323 2964 3324 … … 3020 3380 Complex *p3 = new(0.5, 1.0); // allocate + 2 param constructor 3021 3381 } 3022 3023 3382 \end{cfa} 3024 3383 … … 3032 3391 3033 3392 3393 \begin{comment} 3034 3394 \subsection{Unsafe C Constructs} 3035 3395 … … 3042 3402 The 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. 3043 3403 Once the full set is decided, the rules will be listed here. 3404 \end{comment} 3044 3405 3045 3406 3046 3407 \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.3051 3408 3052 3409 Concurrency support in \CFA is implemented on top of a highly efficient runtime system of light-weight, M:N, user level threads. … … 3055 3412 This enables a very familiar interface to all programmers, even those with no parallel programming experience. 3056 3413 It 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. 3414 This 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. 3059 3415 Mutex objects, monitors, are used to contain mutual exclusion within an object and synchronization across concurrent threads. 3060 3416 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 3422 coroutine Fibonacci { 3423 int fn; §\C{// used for communication}§ 3424 }; 3425 void ?{}( Fibonacci * this ) { 3426 this->fn = 0; 3427 } 3428 void 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 } 3446 int next( Fibonacci * this ) { 3447 resume( this ); §\C{// transfer to last suspend}§ 3448 return this->fn; 3449 } 3450 int 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. 3068 3466 3069 3467 … … 3080 3478 \end{cfa} 3081 3479 3480 \begin{figure} 3481 \begin{cfa} 3482 #include <fstream> 3483 #include <kernel> 3484 #include <monitor> 3485 #include <thread> 3486 3487 monitor global_t { 3488 int value; 3489 }; 3490 3491 void ?{}(global_t * this) { 3492 this->value = 0; 3493 } 3494 3495 static global_t global; 3496 3497 void increment3( global_t * mutex this ) { 3498 this->value += 1; 3499 } 3500 void increment2( global_t * mutex this ) { 3501 increment3( this ); 3502 } 3503 void increment( global_t * mutex this ) { 3504 increment2( this ); 3505 } 3506 3507 thread MyThread {}; 3508 3509 void main( MyThread* this ) { 3510 for(int i = 0; i < 1_000_000; i++) { 3511 increment( &global ); 3512 } 3513 } 3514 int 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} 3082 3527 Since a monitor structure includes an implicit locking mechanism, it does not make sense to copy a monitor; 3083 3528 it is always passed by reference. … … 3126 3571 } 3127 3572 \end{cfa} 3573 \end{comment} 3128 3574 3129 3575 … … 3133 3579 A task provides mutual exclusion like a monitor, and also has its own execution state and a thread of control. 3134 3580 Similar 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 3589 thread First { signal_once * lock; }; 3590 thread Second { signal_once * lock; }; 3591 3592 void ?{}( First * this, signal_once* lock ) { this->lock = lock; } 3593 void ?{}( Second * this, signal_once* lock ) { this->lock = lock; } 3594 3595 void 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 3603 void 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 3611 int 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} 3135 3630 \begin{cfa} 3136 3631 type Adder = task { … … 3142 3637 3143 3638 A 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).3639 A 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). 3145 3640 After a task is allocated and initialized, its thread is spawned implicitly and begins executing in its function call method. 3146 3641 All tasks must define this function call method, with a void return value and no additional parameters, or the compiler will report an error. … … 3186 3681 \end{cfa} 3187 3682 3188 3189 3683 \subsection{Cooperative Scheduling} 3190 3684 … … 3299 3793 } 3300 3794 \end{cfa} 3301 3302 3795 \end{comment} 3796 3797 3798 \begin{comment} 3303 3799 \section{Modules and Packages } 3304 3800 3305 \begin{comment}3306 3801 High-level encapsulation is useful for organizing code into reusable units, and accelerating compilation speed. 3307 3802 \CFA provides a convenient mechanism for creating, building and sharing groups of functionality that enhances productivity and improves compile time. … … 3319 3814 \subsection{No Declarations, No Header Files} 3320 3815 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.3816 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. 3322 3817 Header files and a preprocessor are normally used to avoid repeating code. 3323 3818 Thus, many variables, functions, and types are described twice, which exposes an opportunity for errors and causes additional maintenance work. … … 3964 4459 In developing \CFA, many other languages were consulted for ideas, constructs, and syntax. 3965 4460 Therefore, 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 4461 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}. 4462 4463 4464 \begin{comment} 3969 4465 \subsection[Comparing Key Features of CFA]{Comparing Key Features of \CFA} 3970 4466 … … 4344 4840 4345 4841 4346 \begin{comment}4347 4842 \subsubsection{Modules / Packages} 4348 4843 … … 4424 4919 } 4425 4920 \end{cfa} 4426 \end{comment}4427 4921 4428 4922 … … 4585 5079 4586 5080 \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. 4592 5087 It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation. (Wikipedia) 4593 5088 … … 4608 5103 4609 5104 4610 \subs ubsection{Go}5105 \subsection{Go} 4611 5106 4612 5107 \Index*{Go}, also commonly referred to as golang, is a programming language developed at Google in 2007 [.]. … … 4624 5119 4625 5120 4626 \subs ubsection{Rust}5121 \subsection{Rust} 4627 5122 4628 5123 \Index*{Rust} is a general-purpose, multi-paradigm, compiled programming language developed by Mozilla Research. … … 4638 5133 4639 5134 4640 \subs ubsection{D}5135 \subsection{D} 4641 5136 4642 5137 The \Index*{D} programming language is an object-oriented, imperative, multi-paradigm system programming … … 4655 5150 4656 5151 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 5154 C has a number of syntax ambiguities, which are resolved by taking the longest sequence of overlapping characters that constitute a token. 5155 For example, the program fragment ©x+++++y© is parsed as \lstinline[showspaces=true]@x ++ ++ + y@ because operator tokens ©++© and ©+© overlap. 5156 Unfortunately, the longest sequence violates a constraint on increment operators, even though the parse \lstinline[showspaces=true]@x ++ + ++ y@ might yield a correct expression. 5157 Hence, C programmers are aware that spaces have to added to disambiguate certain syntactic cases. 5158 5159 In \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} 5164 By default, the first interpretation is selected, which does not yield a meaningful parse. 5165 Therefore, \CFA does a lexical look-ahead for the second case, and backtracks to return the leading unary operator and reparses the trailing operator identifier. 5166 Otherwise a space is needed between the unary operator and operator identifier to disambiguate this common case. 5167 5168 A similar issue occurs with the dereference, ©*?(...)©, and routine-call, ©?()(...)© identifiers. 5169 The ambiguity occurs when the deference operator has no parameters: 5170 \begin{cfa} 5171 *?()§\color{red}\textvisiblespace...§ ; 5172 *?()§\color{red}\textvisiblespace...§(...) ; 5173 \end{cfa} 5174 requiring arbitrary whitespace look-ahead for the routine-call parameter-list to disambiguate. 5175 However, the dereference operator \emph{must} have a parameter/argument to dereference ©*?(...)©. 5176 Hence, always interpreting the string ©*?()© as \lstinline[showspaces=true]@* ?()@ does not preclude any meaningful program. 5177 5178 The remaining cases are with the increment/decrement operators and conditional expression, \eg: 5179 \begin{cfa} 5180 i++?§\color{red}\textvisiblespace...§(...); 5181 i?++§\color{red}\textvisiblespace...§(...); 5182 \end{cfa} 5183 requiring arbitrary whitespace look-ahead for the operator parameter-list, even though that interpretation is an incorrect expression (juxtaposed identifiers). 5184 Therefore, it is necessary to disambiguate these cases with a space: 5185 \begin{cfa} 5186 i++§\color{red}\textvisiblespace§? i : 0; 5187 i?§\color{red}\textvisiblespace§++i : 0; 5188 \end{cfa} 4817 5189 4818 5190 … … 4821 5193 4822 5194 \begin{quote2} 4823 \begin{tabular}{lll }5195 \begin{tabular}{llll} 4824 5196 \begin{tabular}{@{}l@{}} 4825 5197 ©_AT© \\ … … 4829 5201 ©coroutine© \\ 4830 5202 ©disable© \\ 4831 ©dtype© \\4832 ©enable© \\4833 5203 \end{tabular} 4834 5204 & 4835 5205 \begin{tabular}{@{}l@{}} 5206 ©dtype© \\ 5207 ©enable© \\ 4836 5208 ©fallthrough© \\ 4837 5209 ©fallthru© \\ 4838 5210 ©finally© \\ 4839 5211 ©forall© \\ 5212 \end{tabular} 5213 & 5214 \begin{tabular}{@{}l@{}} 4840 5215 ©ftype© \\ 4841 5216 ©lvalue© \\ 4842 5217 ©monitor© \\ 4843 5218 ©mutex© \\ 5219 ©one_t© \\ 5220 ©otype© \\ 4844 5221 \end{tabular} 4845 5222 & 4846 5223 \begin{tabular}{@{}l@{}} 4847 ©one_t© \\4848 ©otype© \\4849 5224 ©throw© \\ 4850 5225 ©throwResume© \\ … … 4858 5233 4859 5234 5235 \section{Incompatible} 5236 5237 The 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 \\ 5244 New 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. \\ 5247 Any \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 \\ 5255 K\&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} 5258 x; §\C{// int x}§ 5259 *y; §\C{// int *y}§ 5260 f( p1, p2 ); §\C{// int f( int p1, int p2 );}§ 5261 g( 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} 5265 f( 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{ 5272 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}} 5273 \item[Effect on original feature:] original feature is deprecated. \\ 5274 Any 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} 5283 int rtn( int i ); 5284 int rtn( char c ); 5285 rtn( '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. 5288 In particular, output of ©char© variable now print a character rather than the decimal ASCII value of the character. 5289 \begin{cfa} 5290 sout | 'x' | " " | (int)'x' | endl; 5291 x 120 5292 \end{cfa} 5293 Having 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} 5296 sizeof( 'x' ) == sizeof( int ) 5297 \end{cfa} 5298 no 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} 5307 char * p = "abc"; §\C{// valid in C, deprecated in \CFA}§ 5308 char * q = expr ? "abc" : "de"; §\C{// valid in C, invalid in \CFA}§ 5309 \end{cfa} 5310 The type of a string literal is changed from ©[] char© to ©const [] char©. 5311 Similarly, 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} 5314 char * p = "abc"; 5315 p[0] = 'w'; §\C{// segment fault or change constant literal}§ 5316 \end{cfa} 5317 The 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} 5327 int i; §\C{// forward definition}§ 5328 int *j = ®&i®; §\C{// forward reference, valid in C, invalid in \CFA}§ 5329 int i = 0; §\C{// definition}§ 5330 \end{cfa} 5331 is valid in C, and invalid in \CFA because duplicate overloaded object definitions at the same scope level are disallowed. 5332 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, 5333 \begin{cfa} 5334 struct X { int i; struct X *next; }; 5335 static struct X a; §\C{// forward definition}§ 5336 static struct X b = { 0, ®&a® }; §\C{// forward reference, valid in C, invalid in \CFA}§ 5337 static 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} 5349 enum ®Colour® { R, G, B, Y, C, M }; 5350 struct 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}§ 5360 Person®.Colour® pc = Person®.®R; §\C{// type/enum defined inside}§ 5361 Person®.®Face pretty; §\C{// type defined inside}§ 5362 \end{cfa} 5363 In 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{}}. 5365 Nested 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} 5378 struct Y; §\C{// struct Y and struct X are at the same scope}§ 5379 struct X { 5380 struct Y { /* ... */ } y; 5381 }; 5382 \end{cfa} 5383 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. 5384 Note: 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 4860 5399 \section{Standard Headers} 4861 5400 \label{s:StandardHeaders} 4862 5401 4863 C11prescribes 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: 4864 5403 \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} \\ 4867 5407 \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} 4878 5462 \end{tabular} 4879 5463 \end{quote2} 4880 For the prescribed head-files, \CFA implicitly wraps theirincludes in an ©extern "C"©;5464 For the prescribed head-files, \CFA uses header interposition to wraps these includes in an ©extern "C"©; 4881 5465 hence, names in these include files are not mangled\index{mangling!name} (see~\VRef{s:Interoperability}). 4882 5466 All other C header files must be explicitly wrapped in ©extern "C"© to prevent name mangling. 5467 For \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. 4883 5468 4884 5469 … … 4886 5471 \label{s:StandardLibrary} 4887 5472 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} 5473 The \CFA standard-library wraps explicitly-polymorphic C routines into implicitly-polymorphic versions. 5474 5475 5476 \subsection{Storage Management} 5477 5478 The 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 5480 Storage management provides the following capabilities: 5481 \begin{description} 5482 \item[fill] 5483 after allocation the storage is filled with a specified character. 5484 \item[resize] 5485 an existing allocation is decreased or increased in size. 5486 In 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. 5487 For an increase in storage size, new storage after the copied data may be filled. 5488 \item[alignment] 5489 an allocation starts on a specified memory boundary, e.g., an address multiple of 64 or 128 for cache-line purposes. 5490 \item[array] 5491 the allocation size is scaled to the specified number of array elements. 5492 An array may be filled, resized, or aligned. 5493 \end{description} 5494 The 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 5499 C & ©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 \\ 5504 C11 & ©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} 5509 It 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. 4892 5510 4893 5511 \leavevmode 4894 5512 \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 5514 extern "C" { 5515 void * mallac( size_t size );§\indexc{memset}§ 5516 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 5517 void * realloc( void * ptr, size_t size );§\indexc{realloc}§ 5518 void * memalign( size_t align, size_t size );§\indexc{memalign}§ 5519 int posix_memalign( void ** ptr, size_t align, size_t size );§\indexc{posix_memalign}§ 5520 } 5521 5522 // §\CFA§ safe equivalents, i.e., implicit size specification 5523 forall( dtype T | sized(T) ) T * malloc( void ); 5524 forall( dtype T | sized(T) ) T * calloc( size_t dim ); 5525 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ); 5526 forall( dtype T | sized(T) ) T * memalign( size_t align ); 5527 forall( dtype T | sized(T) ) T * aligned_alloc( size_t align ); 5528 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t align ); 5529 5530 // §\CFA§ safe general allocation, fill, resize, array 5531 forall( dtype T | sized(T) ) T * alloc( void );§\indexc{alloc}§ 5532 forall( dtype T | sized(T) ) T * alloc( char fill ); 5533 forall( dtype T | sized(T) ) T * alloc( size_t dim ); 5534 forall( dtype T | sized(T) ) T * alloc( size_t dim, char fill ); 5535 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim ); 5536 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ); 5537 5538 // §\CFA§ safe general allocation, align, fill, array 5539 forall( dtype T | sized(T) ) T * align_alloc( size_t align ); 5540 forall( dtype T | sized(T) ) T * align_alloc( size_t align, char fill ); 5541 forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim ); 5542 forall( dtype T | sized(T) ) T * align_alloc( size_t align, size_t dim, char fill ); 5543 5544 // C unsafe initialization/copy 5545 extern "C" { 5546 void * memset( void * dest, int c, size_t size ); 5547 void * memcpy( void * dest, const void * src, size_t size ); 5548 } 5549 5550 // §\CFA§ safe initialization/copy, i.e., implicit size specification 5551 forall( dtype T | sized(T) ) T * memset( T * dest, char c );§\indexc{memset}§ 5552 forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src );§\indexc{memcpy}§ 5553 5554 // §\CFA§ safe initialization/copy array 5555 forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ); 5556 forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ); 5557 5558 // §\CFA§ allocation/deallocation and constructor/destructor 5559 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p );§\indexc{new}§ 5560 forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr );§\indexc{delete}§ 5561 forall( 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 5565 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p );§\indexc{anew}§ 5566 forall( dtype T | sized(T) | { void ^?{}( T * ); } ) void adelete( size_t dim, T arr[] );§\indexc{adelete}§ 5567 forall( 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} 4913 5573 4914 5574 \leavevmode … … 4942 5602 4943 5603 4944 \subsection{ bsearch / qsort}5604 \subsection{Search / Sort} 4945 5605 4946 5606 \leavevmode 4947 5607 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 5608 forall( otype T | { int ?<?( T, T ); } ) §\C{// location}§ 5609 T * bsearch( T key, const T * arr, size_t dim );§\indexc{bsearch}§ 5610 5611 forall( otype T | { int ?<?( T, T ); } ) §\C{// position}§ 5612 unsigned int bsearch( T key, const T * arr, size_t dim ); 5613 4948 5614 forall( 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} 5615 void qsort( const T * arr, size_t dim );§\indexc{qsort}§ 5616 \end{cfa} 5617 5618 5619 \subsection{Absolute Value} 4957 5620 4958 5621 \leavevmode 4959 5622 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 4960 char abs(char );§\indexc{abs}§5623 unsigned char abs( signed char );§\indexc{abs}§ 4961 5624 int abs( int ); 4962 long int abs( long int );4963 long long int abs( long long int );5625 unsigned long int abs( long int ); 5626 unsigned long long int abs( long long int ); 4964 5627 float abs( float ); 4965 5628 double abs( double ); … … 4968 5631 double abs( double _Complex ); 4969 5632 long double abs( long double _Complex ); 4970 \end{cfa} 4971 4972 4973 \subsection{random} 5633 forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } ) 5634 T abs( T ); 5635 \end{cfa} 5636 5637 5638 \subsection{Random Numbers} 4974 5639 4975 5640 \leavevmode … … 4989 5654 4990 5655 4991 \subsection{ min / max / clamp / swap}5656 \subsection{Algorithms} 4992 5657 4993 5658 \leavevmode 4994 5659 \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}§ 5660 forall( otype T | { int ?<?( T, T ); } ) T min( T t1, T t2 );§\indexc{min}§ 5661 forall( otype T | { int ?>?( T, T ); } ) T max( T t1, T t2 );§\indexc{max}§ 5662 forall( otype T | { T min( T, T ); T max( T, T ); } ) T clamp( T value, T min_val, T max_val );§\indexc{clamp}§ 5663 forall( otype T ) void swap( T * t1, T * t2 );§\indexc{swap}§ 5006 5664 \end{cfa} 5007 5665 … … 5010 5668 \label{s:Math Library} 5011 5669 5012 The goal of the \CFA math-library is to wrap many of the existing C math library-routines that are explicitly polymorphic into implicitlypolymorphic versions.5670 The \CFA math-library wraps explicitly-polymorphic C math-routines into implicitly-polymorphic versions. 5013 5671 5014 5672 … … 5017 5675 \leavevmode 5018 5676 \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 5026 5677 float ?%?( float, float );§\indexc{fmod}§ 5027 5678 float fmod( float, float ); … … 5378 6029 5379 6030 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. 6035 The \CFA interface wraps GMP routines into operator routines to make programming with multi-precision integers identical to using fixed-sized integers. 6036 The \CFA type name for multi-precision signed-integers is \Indexc{Int} and the header file is \Indexc{gmp}. 6037 6038 \begin{cfa} 6039 void ?{}( Int * this ); §\C{// constructor}§ 6040 void ?{}( Int * this, Int init ); 6041 void ?{}( Int * this, zero_t ); 6042 void ?{}( Int * this, one_t ); 6043 void ?{}( Int * this, signed long int init ); 6044 void ?{}( Int * this, unsigned long int init ); 6045 void ?{}( Int * this, const char * val ); 6046 void ^?{}( Int * this ); 6047 6048 Int ?=?( Int * lhs, Int rhs ); §\C{// assignment}§ 6049 Int ?=?( Int * lhs, long int rhs ); 6050 Int ?=?( Int * lhs, unsigned long int rhs ); 6051 Int ?=?( Int * lhs, const char * rhs ); 6052 6053 char ?=?( char * lhs, Int rhs ); 6054 short int ?=?( short int * lhs, Int rhs ); 6055 int ?=?( int * lhs, Int rhs ); 6056 long int ?=?( long int * lhs, Int rhs ); 6057 unsigned char ?=?( unsigned char * lhs, Int rhs ); 6058 unsigned short int ?=?( unsigned short int * lhs, Int rhs ); 6059 unsigned int ?=?( unsigned int * lhs, Int rhs ); 6060 unsigned long int ?=?( unsigned long int * lhs, Int rhs ); 6061 6062 long int narrow( Int val ); 6063 unsigned long int narrow( Int val ); 6064 6065 int ?==?( Int oper1, Int oper2 ); §\C{// comparison}§ 6066 int ?==?( Int oper1, long int oper2 ); 6067 int ?==?( long int oper2, Int oper1 ); 6068 int ?==?( Int oper1, unsigned long int oper2 ); 6069 int ?==?( unsigned long int oper2, Int oper1 ); 6070 6071 int ?!=?( Int oper1, Int oper2 ); 6072 int ?!=?( Int oper1, long int oper2 ); 6073 int ?!=?( long int oper1, Int oper2 ); 6074 int ?!=?( Int oper1, unsigned long int oper2 ); 6075 int ?!=?( unsigned long int oper1, Int oper2 ); 6076 6077 int ?<?( Int oper1, Int oper2 ); 6078 int ?<?( Int oper1, long int oper2 ); 6079 int ?<?( long int oper2, Int oper1 ); 6080 int ?<?( Int oper1, unsigned long int oper2 ); 6081 int ?<?( unsigned long int oper2, Int oper1 ); 6082 6083 int ?<=?( Int oper1, Int oper2 ); 6084 int ?<=?( Int oper1, long int oper2 ); 6085 int ?<=?( long int oper2, Int oper1 ); 6086 int ?<=?( Int oper1, unsigned long int oper2 ); 6087 int ?<=?( unsigned long int oper2, Int oper1 ); 6088 6089 int ?>?( Int oper1, Int oper2 ); 6090 int ?>?( Int oper1, long int oper2 ); 6091 int ?>?( long int oper1, Int oper2 ); 6092 int ?>?( Int oper1, unsigned long int oper2 ); 6093 int ?>?( unsigned long int oper1, Int oper2 ); 6094 6095 int ?>=?( Int oper1, Int oper2 ); 6096 int ?>=?( Int oper1, long int oper2 ); 6097 int ?>=?( long int oper1, Int oper2 ); 6098 int ?>=?( Int oper1, unsigned long int oper2 ); 6099 int ?>=?( unsigned long int oper1, Int oper2 ); 6100 6101 Int +?( Int oper ); §\C{// arithmetic}§ 6102 Int -?( Int oper ); 6103 Int ~?( Int oper ); 6104 6105 Int ?&?( Int oper1, Int oper2 ); 6106 Int ?&?( Int oper1, long int oper2 ); 6107 Int ?&?( long int oper1, Int oper2 ); 6108 Int ?&?( Int oper1, unsigned long int oper2 ); 6109 Int ?&?( unsigned long int oper1, Int oper2 ); 6110 Int ?&=?( Int * lhs, Int rhs ); 6111 6112 Int ?|?( Int oper1, Int oper2 ); 6113 Int ?|?( Int oper1, long int oper2 ); 6114 Int ?|?( long int oper1, Int oper2 ); 6115 Int ?|?( Int oper1, unsigned long int oper2 ); 6116 Int ?|?( unsigned long int oper1, Int oper2 ); 6117 Int ?|=?( Int * lhs, Int rhs ); 6118 6119 Int ?^?( Int oper1, Int oper2 ); 6120 Int ?^?( Int oper1, long int oper2 ); 6121 Int ?^?( long int oper1, Int oper2 ); 6122 Int ?^?( Int oper1, unsigned long int oper2 ); 6123 Int ?^?( unsigned long int oper1, Int oper2 ); 6124 Int ?^=?( Int * lhs, Int rhs ); 6125 6126 Int ?+?( Int addend1, Int addend2 ); 6127 Int ?+?( Int addend1, long int addend2 ); 6128 Int ?+?( long int addend2, Int addend1 ); 6129 Int ?+?( Int addend1, unsigned long int addend2 ); 6130 Int ?+?( unsigned long int addend2, Int addend1 ); 6131 Int ?+=?( Int * lhs, Int rhs ); 6132 Int ?+=?( Int * lhs, long int rhs ); 6133 Int ?+=?( Int * lhs, unsigned long int rhs ); 6134 Int ++?( Int * lhs ); 6135 Int ?++( Int * lhs ); 6136 6137 Int ?-?( Int minuend, Int subtrahend ); 6138 Int ?-?( Int minuend, long int subtrahend ); 6139 Int ?-?( long int minuend, Int subtrahend ); 6140 Int ?-?( Int minuend, unsigned long int subtrahend ); 6141 Int ?-?( unsigned long int minuend, Int subtrahend ); 6142 Int ?-=?( Int * lhs, Int rhs ); 6143 Int ?-=?( Int * lhs, long int rhs ); 6144 Int ?-=?( Int * lhs, unsigned long int rhs ); 6145 Int --?( Int * lhs ); 6146 Int ?--( Int * lhs ); 6147 6148 Int ?*?( Int multiplicator, Int multiplicand ); 6149 Int ?*?( Int multiplicator, long int multiplicand ); 6150 Int ?*?( long int multiplicand, Int multiplicator ); 6151 Int ?*?( Int multiplicator, unsigned long int multiplicand ); 6152 Int ?*?( unsigned long int multiplicand, Int multiplicator ); 6153 Int ?*=?( Int * lhs, Int rhs ); 6154 Int ?*=?( Int * lhs, long int rhs ); 6155 Int ?*=?( Int * lhs, unsigned long int rhs ); 6156 6157 Int ?/?( Int dividend, Int divisor ); 6158 Int ?/?( Int dividend, unsigned long int divisor ); 6159 Int ?/?( unsigned long int dividend, Int divisor ); 6160 Int ?/?( Int dividend, long int divisor ); 6161 Int ?/?( long int dividend, Int divisor ); 6162 Int ?/=?( Int * lhs, Int rhs ); 6163 Int ?/=?( Int * lhs, long int rhs ); 6164 Int ?/=?( 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 6169 Int ?%?( Int dividend, Int divisor ); 6170 Int ?%?( Int dividend, unsigned long int divisor ); 6171 Int ?%?( unsigned long int dividend, Int divisor ); 6172 Int ?%?( Int dividend, long int divisor ); 6173 Int ?%?( long int dividend, Int divisor ); 6174 Int ?%=?( Int * lhs, Int rhs ); 6175 Int ?%=?( Int * lhs, long int rhs ); 6176 Int ?%=?( Int * lhs, unsigned long int rhs ); 6177 6178 Int ?<<?( Int shiften, mp_bitcnt_t shift ); 6179 Int ?<<=?( Int * lhs, mp_bitcnt_t shift ); 6180 Int ?>>?( Int shiften, mp_bitcnt_t shift ); 6181 Int ?>>=?( Int * lhs, mp_bitcnt_t shift ); 6182 6183 Int abs( Int oper ); §\C{// number functions}§ 6184 Int fact( unsigned long int N ); 6185 Int gcd( Int oper1, Int oper2 ); 6186 Int pow( Int base, unsigned long int exponent ); 6187 Int pow( unsigned long int base, unsigned long int exponent ); 6188 void srandom( gmp_randstate_t state ); 6189 Int random( gmp_randstate_t state, mp_bitcnt_t n ); 6190 Int random( gmp_randstate_t state, Int n ); 6191 Int random( gmp_randstate_t state, mp_size_t max_size ); 6192 int sgn( Int oper ); 6193 Int sqrt( Int oper ); 6194 6195 forall( dtype istype | istream( istype ) ) istype * ?|?( istype * is, Int * mp ); §\C{// I/O}§ 6196 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype * os, Int mp ); 6197 \end{cfa} 6198 6199 The 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}§ 6207 int 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}§ 6221 int 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} 6237 Factorial Numbers 6238 0 1 6239 1 1 6240 2 2 6241 3 6 6242 4 24 6243 5 120 6244 6 720 6245 7 5040 6246 8 40320 6247 9 362880 6248 10 3628800 6249 11 39916800 6250 12 479001600 6251 13 6227020800 6252 14 87178291200 6253 15 1307674368000 6254 16 20922789888000 6255 17 355687428096000 6256 18 6402373705728000 6257 19 121645100408832000 6258 20 2432902008176640000 6259 21 51090942171709440000 6260 22 1124000727777607680000 6261 23 25852016738884976640000 6262 24 620448401733239439360000 6263 25 15511210043330985984000000 6264 26 403291461126605635584000000 6265 27 10888869450418352160768000000 6266 28 304888344611713860501504000000 6267 29 8841761993739701954543616000000 6268 30 265252859812191058636308480000000 6269 31 8222838654177922817725562880000000 6270 32 263130836933693530167218012160000000 6271 33 8683317618811886495518194401280000000 6272 34 295232799039604140847618609643520000000 6273 35 10333147966386144929666651337523200000000 6274 36 371993326789901217467999448150835200000000 6275 37 13763753091226345046315979581580902400000000 6276 38 523022617466601111760007224100074291200000000 6277 39 20397882081197443358640281739902897356800000000 6278 40 815915283247897734345611269596115894272000000000 6279 \end{cfa} 6280 \caption{Multi-precision Factorials} 6281 \label{f:MultiPrecisionFactorials} 6282 \end{figure} 6283 6284 5380 6285 \section{Rational Numbers} 5381 6286 \label{s:RationalNumbers} … … 5390 6295 }; // Rational 5391 6296 5392 // constants 5393 extern struct Rational 0; 5394 extern struct Rational 1; 5395 5396 // constructors 5397 Rational rational(); 6297 Rational rational(); §\C{// constructors}§ 5398 6298 Rational rational( long int n ); 5399 6299 Rational rational( long int n, long int d ); 5400 5401 // getter/setter for numerator/denominator 5402 long int numerator( Rational r ); 6300 void ?{}( Rational * r, zero_t ); 6301 void ?{}( Rational * r, one_t ); 6302 6303 long int numerator( Rational r ); §\C{// numerator/denominator getter/setter}§ 5403 6304 long int numerator( Rational r, long int n ); 5404 6305 long int denominator( Rational r ); 5405 6306 long int denominator( Rational r, long int d ); 5406 6307 5407 // comparison 5408 int ?==?( Rational l, Rational r ); 6308 int ?==?( Rational l, Rational r ); §\C{// comparison}§ 5409 6309 int ?!=?( Rational l, Rational r ); 5410 6310 int ?<?( Rational l, Rational r ); … … 5413 6313 int ?>=?( Rational l, Rational r ); 5414 6314 5415 // arithmetic 5416 Rational -?( Rational r ); 6315 Rational -?( Rational r ); §\C{// arithmetic}§ 5417 6316 Rational ?+?( Rational l, Rational r ); 5418 6317 Rational ?-?( Rational l, Rational r ); … … 5420 6319 Rational ?/?( Rational l, Rational r ); 5421 6320 5422 // conversion 5423 double widen( Rational r ); 6321 double widen( Rational r ); §\C{// conversion}§ 5424 6322 Rational narrow( double f, long int md ); 5425 6323 5426 // I/O 5427 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); 6324 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); // I/O 5428 6325 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational ); 5429 6326 \end{cfa} -
doc/working/resolver_design.md
r9c951e3 rb1e63ac5 41 41 ensure that they are two-arg functions (this restriction may be valuable 42 42 regardless). 43 44 Regardless of syntax, there should be a type assertion that expresses `From` 45 is convertable to `To`. 46 If user-defined conversions are not added to the language, 47 `void ?{} ( To*, From )` may be a suitable representation, relying on 48 conversions on the argument types to account for transitivity. 49 On the other hand, `To*` should perhaps match its target type exactly, so 50 another assertion syntax specific to conversions may be required, e.g. 51 `From -> To`. 43 52 44 53 ### Constructor Idiom ### -
src/CodeGen/CodeGenerator.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 10 14:45:00 201713 // Update Count : 48 412 // Last Modified On : Thu Jun 8 16:00:00 2017 13 // Update Count : 485 14 14 // 15 15 … … 65 65 } // if 66 66 } // 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 }75 67 76 68 CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) { … … 111 103 } 112 104 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 ) {} 124 106 125 107 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 212 194 output << " {" << endl; 213 195 214 cur_indent += CodeGenerator::tabsize;196 ++indent; 215 197 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) { 216 198 output << lineDirective( *i ) << indent; … … 219 201 } // for 220 202 221 cur_indent -= CodeGenerator::tabsize;203 --indent; 222 204 223 205 output << indent << "}"; … … 249 231 output << " {" << endl; 250 232 251 cur_indent += CodeGenerator::tabsize;233 ++indent; 252 234 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 253 235 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); … … 261 243 } // for 262 244 263 cur_indent -= CodeGenerator::tabsize;245 --indent; 264 246 265 247 output << indent << "}"; … … 267 249 } 268 250 269 void CodeGenerator::visit( TraitDecl * traitDecl ) {}251 void CodeGenerator::visit( __attribute__((unused)) TraitDecl * traitDecl ) {} 270 252 271 253 void CodeGenerator::visit( TypedefDecl * typeDecl ) { … … 298 280 } 299 281 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(); 302 284 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 member285 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 306 288 output << "."; 307 (*iter)->accept( *this );289 des->accept( *this ); 308 290 } else { 309 // if not a simple name, it has to be a constant expression, i.e. an array designator291 // otherwise, it has to be a ConstantExpr or CastExpr, initializing array eleemnt 310 292 output << "["; 311 (*iter)->accept( *this );293 des->accept( *this ); 312 294 output << "]"; 313 295 } // if … … 317 299 318 300 void CodeGenerator::visit( SingleInit * init ) { 319 printDesignators( init->get_designators() );320 301 init->get_value()->accept( *this ); 321 302 } 322 303 323 304 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 325 310 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 } 332 319 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 ){ 336 324 assertf( ! genC, "ConstructorInit nodes should not reach code generation." ); 337 325 // xxx - generate something reasonable for constructor/destructor pairs … … 731 719 732 720 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 } 735 726 } 736 727 … … 756 747 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 757 748 output << lineDirective( stmtExpr) << "({" << std::endl; 758 cur_indent += CodeGenerator::tabsize;749 ++indent; 759 750 unsigned int numStmts = stmts.size(); 760 751 unsigned int i = 0; … … 779 770 ++i; 780 771 } 781 cur_indent -= CodeGenerator::tabsize;772 --indent; 782 773 output << indent << "})"; 783 774 } … … 788 779 output << "{" << endl; 789 780 790 cur_indent += CodeGenerator::tabsize;781 ++indent; 791 782 792 783 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++ ) { … … 799 790 } // if 800 791 } // for 801 cur_indent -= CodeGenerator::tabsize;792 --indent; 802 793 803 794 output << indent << "}"; … … 867 858 868 859 output << "{" << std::endl; 869 cur_indent += CodeGenerator::tabsize;860 ++indent; 870 861 acceptAll( switchStmt->get_statements(), *this ); 871 cur_indent -= CodeGenerator::tabsize;862 --indent; 872 863 output << indent << "}"; 873 864 } … … 886 877 std::list<Statement *> sts = caseStmt->get_statements(); 887 878 888 cur_indent += CodeGenerator::tabsize;879 ++indent; 889 880 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 890 881 output << indent << printLabels( (*i)->get_labels() ) ; … … 892 883 output << endl; 893 884 } // for 894 cur_indent -= CodeGenerator::tabsize;885 --indent; 895 886 } 896 887 … … 923 914 } 924 915 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 925 932 void CodeGenerator::visit( WhileStmt * whileStmt ) { 926 933 if ( whileStmt->get_isDoWhile() ) { … … 967 974 } 968 975 969 void CodeGenerator::visit( NullStmt * nullStmt ) {976 void CodeGenerator::visit( __attribute__((unused)) NullStmt * nullStmt ) { 970 977 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 971 978 output << "/* null statement */ ;"; -
src/CodeGen/CodeGenerator.h
r9c951e3 rb1e63ac5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 10 10:57:00 201713 // Update Count : 5 112 // Last Modified On : Thu Jun 8 15:48:00 2017 13 // Update Count : 52 14 14 // 15 15 … … 25 25 #include "SymTab/Indexer.h" 26 26 27 #include "Common/Indenter.h" 27 28 #include "Common/utility.h" 28 29 … … 47 48 48 49 //*** Initializer 50 virtual void visit( Designation * ); 49 51 virtual void visit( SingleInit * ); 50 52 virtual void visit( ListInit * ); … … 91 93 virtual void visit( BranchStmt * ); 92 94 virtual void visit( ReturnStmt * ); 95 virtual void visit( ThrowStmt * ); 93 96 virtual void visit( WhileStmt * ); 94 97 virtual void visit( ForStmt * ); … … 99 102 100 103 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 };107 104 108 105 struct LabelPrinter { … … 128 125 private: 129 126 Indenter indent; 130 int cur_indent;131 127 bool insideFunction; 132 128 std::ostream &output; … … 136 132 bool lineMarks = false; 137 133 138 void printDesignators( std::list< Expression * > & );139 134 void handleStorageClass( DeclarationWithType *decl ); 140 135 void handleAggregate( AggregateDecl *aggDecl, const std::string & kind ); -
src/CodeGen/FixNames.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 16 07:50:30 201713 // Update Count : 1611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:26:00 2017 13 // Update Count : 20 14 14 // 15 15 … … 93 93 void FixNames::fixDWT( DeclarationWithType *dwt ) { 94 94 if ( dwt->get_name() != "" ) { 95 if ( LinkageSpec::is Decoratable( dwt->get_linkage() ) ) {95 if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) { 96 96 dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) ); 97 97 dwt->set_scopeLevel( scopeLevel ); … … 114 114 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 115 115 } 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 ) ) ) ); 117 117 CodeGen::FixMain::registerMain( functionDecl ); 118 118 } -
src/CodeTools/TrackLoc.cc
r9c951e3 rb1e63ac5 16 16 #include "TrackLoc.h" 17 17 18 #include <cstdlib> 19 18 20 #include <iostream> 19 21 #include <sstream> 22 #include <stack> 20 23 #include <string> 21 #include < cstdlib>24 #include <typeindex> 22 25 23 26 #include "Common/utility.h" 27 #include "Common/PassVisitor.h" 24 28 #include "Common/VectorMap.h" 25 29 #include "GenPoly/GenPoly.h" … … 27 31 #include "SynTree/Declaration.h" 28 32 #include "SynTree/Initializer.h" 29 #include "SynTree/Visitor.h"30 33 31 34 namespace CodeTools { 32 35 33 34 35 36 std::ostream & operator<<(std::ostream & out, CodeLocation const & loc) { 37 return out << loc.filename << '[' << loc.linenumber << ']'; 38 } 36 39 37 class LocationPrinter : public Visitor { 38 unsigned int printLevel; 39 unsigned int currentLevel; 40 class LocationPrinter { 41 size_t printLevel; 40 42 41 CodeLocation *parent;42 43 CodeLocation *lastNode; 43 44 44 public: 45 LocationPrinter(unsigned int printLevel):46 Visitor(), printLevel(printLevel), currentLevel(0), 47 p arent(nullptr), lastNode(nullptr)48 45 std::stack< CodeLocation * > parents; 46 public: 47 LocationPrinter(size_t printLevel) : 48 printLevel(printLevel), lastNode(nullptr) 49 {} 49 50 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) { 52 53 std::cout << " "; 53 54 } 54 55 if (2 <= printLevel) { 55 56 std::cout << name << '@'; 56 57 } 57 58 std::cout << node->location << std::endl; 58 59 } 59 60 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 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; 71 72 exit(EXIT_FAILURE); 72 73 } 73 74 } 75 74 76 if (0 < printLevel) { 75 print( name, node);77 print( name, node ); 76 78 } 77 79 lastNode = &node->location; 78 80 } 79 81 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 ); 89 85 } 90 86 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 } 176 90 177 91 }; // LocationPrinter 178 92 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); 182 95 acceptAll( translationUnit, printer ); 183 96 } -
src/CodeTools/TrackLoc.h
r9c951e3 rb1e63ac5 24 24 // printLevel: how much printing while filling in the node locations. 25 25 // 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 ); 28 27 29 28 } // namespace CodeTools -
src/Common/Assert.cc
r9c951e3 rb1e63ac5 21 21 extern const char * __progname; // global name of running executable (argv[0]) 22 22 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\"" 24 24 25 25 // called by macro assert in assert.h 26 26 void __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 ); 28 28 abort(); 29 29 } … … 31 31 // called by macro assertf 32 32 void __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 ); 34 34 va_list args; 35 35 va_start( args, fmt ); -
src/Common/utility.h
r9c951e3 rb1e63ac5 246 246 }; 247 247 248 template< typename T > 249 struct 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 257 template< typename T > 258 struct 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 248 268 // ----------------------------------------------------------------------------- 249 269 // Helper struct and function to support … … 285 305 // for ( val : group_iterate( container1, container2, ... ) ) {} 286 306 // 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 288 308 289 309 template< typename T1, typename T2 > … … 334 354 {} 335 355 356 CodeLocation( const CodeLocation& rhs ) = default; 357 336 358 bool isSet () const { 337 359 return -1 != linenumber; -
src/Concurrency/Keywords.cc
r9c951e3 rb1e63ac5 65 65 FunctionDecl * forwardDeclare( StructDecl * ); 66 66 ObjectDecl * addField( StructDecl * ); 67 void addRoutines( StructDecl *,ObjectDecl *, FunctionDecl * );67 void addRoutines( ObjectDecl *, FunctionDecl * ); 68 68 69 69 virtual bool is_target( StructDecl * decl ) = 0; … … 247 247 void ConcurrentSueKeyword::visit(StructDecl * decl) { 248 248 Visitor::visit(decl); 249 if( decl->get_name() == type_name ) {249 if( decl->get_name() == type_name && decl->has_body() ) { 250 250 assert( !type_decl ); 251 251 type_decl = decl; … … 264 264 FunctionDecl * func = forwardDeclare( decl ); 265 265 ObjectDecl * field = addField( decl ); 266 addRoutines( decl,field, func );266 addRoutines( field, func ); 267 267 } 268 268 … … 359 359 } 360 360 361 void ConcurrentSueKeyword::addRoutines( StructDecl * decl,ObjectDecl * field, FunctionDecl * func ) {361 void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) { 362 362 CompoundStmt * statement = new CompoundStmt( noLabels ); 363 363 statement->push_back( -
src/ControlStruct/ForExprMutator.cc
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ForExprMutator.cc -- 7 // ForExprMutator.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 19 19 20 20 namespace 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(); 26 24 if ( init.size() == 0 ) { 27 25 return forStmt; … … 39 37 forStmt->set_initialization( std::list<Statement *>() ); 40 38 return block; 41 42 return forStmt;43 39 } 44 40 } // namespace ControlStruct -
src/ControlStruct/ForExprMutator.h
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ForExprMutator.h -- 7 // ForExprMutator.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 21 21 22 22 namespace ControlStruct { 23 class ForExprMutator : public Mutator{23 class ForExprMutator { 24 24 public: 25 virtual Statement *mutate( ForStmt * );25 Statement *postmutate( ForStmt * ); 26 26 }; 27 27 } // namespace ControlStruct -
src/ControlStruct/Mutate.cc
r9c951e3 rb1e63ac5 26 26 27 27 #include "Common/utility.h" 28 #include "Common/PassVisitor.h" 28 29 29 30 #include "SynTree/Visitor.h" … … 34 35 void mutate( std::list< Declaration * > translationUnit ) { 35 36 // hoist initialization out of for statements 36 ForExprMutatorformut;37 PassVisitor<ForExprMutator> formut; 37 38 38 39 // normalizes label definitions and generates multi-level exit labels -
src/ControlStruct/module.mk
r9c951e3 rb1e63ac5 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Thu Aug 4 11:38:06 201614 ## Update Count : 312 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Wed Jun 28 16:15:00 2017 14 ## Update Count : 4 15 15 ############################################################################### 16 16 17 17 SRC += ControlStruct/LabelGenerator.cc \ 18 18 ControlStruct/LabelFixer.cc \ 19 19 ControlStruct/MLEMutator.cc \ 20 20 ControlStruct/Mutate.cc \ 21 ControlStruct/ForExprMutator.cc 22 21 ControlStruct/ForExprMutator.cc \ 22 ControlStruct/ExceptTranslate.cc -
src/GenPoly/Box.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 13 09:26:38201713 // Update Count : 34 112 // Last Modified On : Wed Jun 21 15:49:59 2017 13 // Update Count : 346 14 14 // 15 15 … … 62 62 namespace GenPoly { 63 63 namespace { 64 const std::list<Label> noLabels;65 66 64 FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars ); 67 65 … … 103 101 void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 104 102 /// 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 ); 106 104 /// Replaces all the type parameters of a generic type with their concrete equivalents under the current environment 107 105 void replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params ); … … 110 108 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 111 109 /// 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 ); 113 111 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 114 112 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 136 134 public: 137 135 template< typename DeclClass > 138 DeclClass *handleDecl( DeclClass *decl , Type *type);136 DeclClass *handleDecl( DeclClass *decl ); 139 137 template< typename AggDecl > 140 138 AggDecl * handleAggDecl( AggDecl * aggDecl ); … … 343 341 Statement *makeAlignTo( Expression *lhs, Expression *rhs ) { 344 342 // 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 ) ) ) ); 346 344 // if not aligned, increment to alignment 347 345 Expression *ifExpr = makeOp( "?+=?", lhs->clone(), makeOp( "?-?", rhs->clone(), ifCond->clone() ) ); … … 386 384 387 385 // 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 ) ) ) ); 390 388 unsigned long n_members = 0; 391 389 bool firstMember = true; … … 443 441 444 442 // 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 ) ) ) ); 447 445 for ( std::list< Declaration* >::const_iterator member = unionDecl->get_members().begin(); member != unionDecl->get_members().end(); ++member ) { 448 446 DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ); … … 506 504 DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) { 507 505 if ( functionDecl->get_statements() ) { // empty routine body ? 506 // std::cerr << "mutating function: " << functionDecl->get_mangleName() << std::endl; 508 507 doBeginScope(); 509 508 scopeTyVars.beginScope(); … … 550 549 retval = oldRetval; 551 550 doEndScope(); 551 // std::cerr << "end function: " << functionDecl->get_mangleName() << std::endl; 552 552 } // if 553 553 return functionDecl; … … 665 665 } 666 666 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 ) { 668 668 // Create temporary to hold return value of polymorphic function and produce that temporary as a result 669 669 // using a comma expression. … … 728 728 } 729 729 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 ) { 731 731 assert( env ); 732 732 Type *concrete = replaceWithConcrete( appExpr, dynType ); 733 733 // add out-parameter for return value 734 return addRetParam( appExpr, function,concrete, arg );734 return addRetParam( appExpr, concrete, arg ); 735 735 } 736 736 … … 739 739 // if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) { 740 740 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 ); 742 742 } // if 743 743 std::string mangleName = mangleAdapterName( function, tyVars ); … … 1118 1118 1119 1119 Expression *Pass1::mutate( ApplicationExpr *appExpr ) { 1120 // std::cerr << "mutate appExpr: " ;1120 // std::cerr << "mutate appExpr: " << InitTweak::getFunctionName( appExpr ) << std::endl; 1121 1121 // for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) { 1122 1122 // std::cerr << i->first << " "; … … 1143 1143 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); 1144 1144 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 1145 1153 // 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 1146 1154 // passTypeVars needs to know the program-text return type (i.e. the distinction between _conc_T30 and T3(int)) 1147 1155 // concRetType may not be a good name in one or both of these places. A more appropriate name change is welcome. 1148 1156 if ( dynRetType ) { 1157 // std::cerr << "dynRetType: " << dynRetType << std::endl; 1149 1158 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result(); 1150 ret = addDynRetParam( appExpr, function,concRetType, arg ); // xxx - used to use dynRetType instead of concRetType1159 ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1151 1160 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? 1152 1161 // 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. … … 1282 1291 1283 1292 template< typename DeclClass > 1284 DeclClass * Pass2::handleDecl( DeclClass *decl , Type *type) {1293 DeclClass * Pass2::handleDecl( DeclClass *decl ) { 1285 1294 DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) ); 1286 1295 … … 1296 1305 1297 1306 DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) { 1298 functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl , functionDecl->get_functionType()) );1307 functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl ) ); 1299 1308 FunctionType * ftype = functionDecl->get_functionType(); 1300 1309 if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) { … … 1321 1330 1322 1331 ObjectDecl * Pass2::mutate( ObjectDecl *objectDecl ) { 1323 return handleDecl( objectDecl , objectDecl->get_type());1332 return handleDecl( objectDecl ); 1324 1333 } 1325 1334 … … 1344 1353 addToTyVarMap( typeDecl, scopeTyVars ); 1345 1354 if ( typeDecl->get_base() ) { 1346 return handleDecl( typeDecl , typeDecl->get_base());1355 return handleDecl( typeDecl ); 1347 1356 } else { 1348 1357 return Parent::mutate( typeDecl ); … … 1351 1360 1352 1361 TypedefDecl * Pass2::mutate( TypedefDecl *typedefDecl ) { 1353 return handleDecl( typedefDecl , typedefDecl->get_base());1362 return handleDecl( typedefDecl ); 1354 1363 } 1355 1364 … … 1566 1575 /// Returns an index expression into the offset array for a type 1567 1576 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 ) ); 1571 1578 UntypedExpr *fieldOffset = new UntypedExpr( new NameExpr( "?[?]" ) ); 1572 1579 fieldOffset->get_args().push_back( new NameExpr( offsetofName( mangleType( objectType ) ) ) ); … … 1781 1788 // all union members are at offset zero 1782 1789 delete offsetofExpr; 1783 return new ConstantExpr( Constant ( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0") );1790 return new ConstantExpr( Constant::from_ulong( 0 ) ); 1784 1791 } else return offsetofExpr; 1785 1792 } … … 1806 1813 std::list< Initializer* > inits; 1807 1814 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 ) ) ); 1811 1817 } 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() ); 1813 1819 } 1814 inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) );1815 1820 } 1816 1821 -
src/GenPoly/CopyParams.cc
r9c951e3 rb1e63ac5 45 45 46 46 CopyParams::CopyParams() : namer( "_cp" ) {} 47 48 static const std::list< Label > noLabels;49 47 50 48 void CopyParams::visit( FunctionDecl *funcDecl ) { -
src/GenPoly/DeclMutator.cc
r9c951e3 rb1e63ac5 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 4 11:16:43 201613 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:49:00 2017 13 // Update Count : 4 14 14 // 15 15 … … 20 20 21 21 namespace GenPoly { 22 namespace {23 const std::list<Label> noLabels;24 }25 26 22 DeclMutator::DeclMutator() : Mutator(), declsToAdd(1), declsToAddAfter(1) {} 27 23 28 24 DeclMutator::~DeclMutator() {} 29 25 30 26 void DeclMutator::mutateDeclarationList( std::list< Declaration* > &decls ) { 31 27 for ( std::list< Declaration* >::iterator decl = decls.begin(); ; ++decl ) { … … 34 30 35 31 if ( decl == decls.end() ) break; 36 32 37 33 // run mutator on declaration 38 34 *decl = maybeMutate( *decl, *this ); … … 55 51 newBack->splice( newBack->end(), *back ); 56 52 declsToAdd.pop_back(); 57 53 58 54 back = declsToAddAfter.rbegin(); 59 55 newBack = back + 1; … … 66 62 CompoundStmt *compoundStmt = dynamic_cast< CompoundStmt* >(stmt); 67 63 if ( compoundStmt ) return mutate( compoundStmt ); 68 64 69 65 doBeginScope(); 70 66 71 67 // run mutator on statement 72 68 stmt = maybeMutate( stmt, *this ); … … 102 98 doBeginScope(); 103 99 104 100 105 101 for ( std::list< Statement* >::iterator stmt = stmts.begin(); ; ++stmt ) { 106 102 // add any new declarations after the previous statement … … 112 108 113 109 if ( stmt == stmts.end() ) break; 114 110 115 111 // run mutator on statement 116 112 *stmt = maybeMutate( *stmt, *this ); … … 123 119 declsToAdd.back().clear(); 124 120 } 125 121 126 122 doEndScope(); 127 123 } … … 139 135 return compoundStmt; 140 136 } 141 137 142 138 Statement* DeclMutator::mutate(IfStmt *ifStmt) { 143 139 ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) ); … … 146 142 return ifStmt; 147 143 } 148 144 149 145 Statement* DeclMutator::mutate(WhileStmt *whileStmt) { 150 146 whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) ); … … 152 148 return whileStmt; 153 149 } 154 150 155 151 Statement* DeclMutator::mutate(ForStmt *forStmt) { 156 152 mutateAll( forStmt->get_initialization(), *this ); … … 160 156 return forStmt; 161 157 } 162 158 163 159 Statement* DeclMutator::mutate(SwitchStmt *switchStmt) { 164 160 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); … … 166 162 return switchStmt; 167 163 } 168 164 169 165 Statement* DeclMutator::mutate(CaseStmt *caseStmt) { 170 166 caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) ); … … 172 168 return caseStmt; 173 169 } 174 170 175 171 Statement* DeclMutator::mutate(TryStmt *tryStmt) { 176 172 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); … … 179 175 return tryStmt; 180 176 } 181 177 182 178 Statement* DeclMutator::mutate(CatchStmt *catchStmt) { 183 179 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 180 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) ); 184 181 catchStmt->set_body( mutateStatement( catchStmt->get_body() ) ); 185 182 return catchStmt; -
src/GenPoly/InstantiateGeneric.cc
r9c951e3 rb1e63ac5 22 22 #include "InstantiateGeneric.h" 23 23 24 #include "DeclMutator.h"25 24 #include "GenPoly.h" 26 25 #include "ScopedSet.h" 27 26 #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" 29 32 30 33 #include "ResolvExpr/typeops.h" … … 34 37 #include "SynTree/Type.h" 35 38 36 #include "Common/ScopedMap.h" 37 #include " Common/UniqueName.h"38 #include "Common/utility.h" 39 40 #include "InitTweak/InitTweak.h" 41 39 42 40 43 namespace GenPoly { … … 153 156 } 154 157 155 // collect the environments of each TypeInstType so that type variables can be replaced156 // 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 172 158 /// 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 { 174 160 /// Map of (generic type, parameter list) pairs to concrete type instantiations 175 161 InstantiationMap< AggregateDecl, AggregateDecl > instantiations; … … 178 164 /// Namer for concrete types 179 165 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(); 191 180 private: 192 181 /// Wrap instantiation lookup for structs … … 207 196 208 197 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 ); 213 200 } 214 201 … … 306 293 Type *GenericInstantiator::replaceWithConcrete( Type *type, bool doClone ) { 307 294 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 308 if ( envMap.count( typeInst ) ) { 309 TypeSubstitution * env = envMap.at( typeInst ); 295 if ( env && ! inFunctionType ) { 310 296 Type *concrete = env->lookup( typeInst->get_name() ); 311 297 if ( concrete ) { … … 331 317 332 318 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 ) { 339 320 // exit early if no need for further mutation 340 321 if ( inst->get_parameters().empty() ) return inst; … … 367 348 concDecl->set_body( inst->get_baseStruct()->has_body() ); 368 349 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 members350 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 372 353 } 373 354 StructInstType *newInst = new StructInstType( inst->get_qualifiers(), concDecl->get_name() ); … … 388 369 } 389 370 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 ) { 396 372 // exit early if no need for further mutation 397 373 if ( inst->get_parameters().empty() ) return inst; … … 422 398 concDecl->set_body( inst->get_baseUnion()->has_body() ); 423 399 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 members400 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 427 403 } 428 404 UnionInstType *newInst = new UnionInstType( inst->get_qualifiers(), concDecl->get_name() ); … … 442 418 } 443 419 444 void GenericInstantiator::doBeginScope() { 445 DeclMutator::doBeginScope(); 420 void GenericInstantiator::beginScope() { 446 421 instantiations.beginScope(); 447 422 dtypeStatics.beginScope(); 448 423 } 449 424 450 void GenericInstantiator::doEndScope() { 451 DeclMutator::doEndScope(); 425 void GenericInstantiator::endScope() { 452 426 instantiations.endScope(); 453 427 dtypeStatics.endScope(); -
src/GenPoly/Lvalue.cc
r9c951e3 rb1e63ac5 36 36 namespace GenPoly { 37 37 namespace { 38 const std::list<Label> noLabels;39 40 38 /// Replace uses of lvalue returns with appropriate pointers 41 39 class Pass1 : public Mutator { -
src/GenPoly/PolyMutator.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 4 11:26:22 201613 // Update Count : 1 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:47:00 2017 13 // Update Count : 17 14 14 // 15 15 … … 123 123 124 124 Statement * PolyMutator::mutate(TryStmt *tryStmt) { 125 tryStmt->set_block( 125 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 126 126 mutateAll( tryStmt->get_catchers(), *this ); 127 tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) ); 127 128 return tryStmt; 128 129 } 129 130 130 131 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 ) ); 133 135 return cathStmt; 134 136 } -
src/GenPoly/Specialize.cc
r9c951e3 rb1e63ac5 93 93 } 94 94 95 bool needsTupleSpecialization( Type *formalType, Type *actualType , TypeSubstitution *env) {95 bool needsTupleSpecialization( Type *formalType, Type *actualType ) { 96 96 // Needs tuple specialization if the structure of the formal type and actual type do not match. 97 97 // This is the case if the formal type has ttype polymorphism, or if the structure of tuple types … … 99 99 if ( FunctionType * fftype = getFunctionType( formalType ) ) { 100 100 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; 101 103 FunctionType * aftype = getFunctionType( actualType ); 102 104 assertf( aftype, "formal type is a function type, but actual type is not." ); … … 112 114 113 115 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 ); 115 117 } 116 118 -
src/InitTweak/FixGlobalInit.cc
r9c951e3 rb1e63ac5 26 26 27 27 namespace InitTweak { 28 namespace {29 const std::list<Label> noLabels;30 }31 32 28 class GlobalFixer : public Visitor { 33 29 public: … … 129 125 130 126 // 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 ) {} 137 133 138 134 } // namespace InitTweak -
src/InitTweak/FixInit.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:13:47201713 // Update Count : 7 112 // Last Modified On : Wed Jun 21 17:35:05 2017 13 // Update Count : 74 14 14 // 15 15 … … 20 20 #include <unordered_map> 21 21 #include <unordered_set> 22 22 23 #include "InitTweak.h" 23 24 #include "GenInit.h" 24 25 #include "FixInit.h" 25 26 #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" 26 31 #include "ResolvExpr/Resolver.h" 27 32 #include "ResolvExpr/typeops.h" 33 #include "SymTab/Autogen.h" 34 #include "SymTab/Indexer.h" 35 #include "SynTree/AddStmtVisitor.h" 36 #include "SynTree/Attribute.h" 28 37 #include "SynTree/Declaration.h" 29 #include "SynTree/Type.h"30 38 #include "SynTree/Expression.h" 31 #include "SynTree/Attribute.h"32 #include "SynTree/Statement.h"33 39 #include "SynTree/Initializer.h" 34 40 #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" 41 43 #include "Tuples/Tuples.h" 42 44 … … 54 56 typedef std::unordered_map< int, int > UnqCount; 55 57 56 class InsertImplicitCalls final : public GenPoly::PolyMutator{58 class InsertImplicitCalls : public WithTypeSubstitution { 57 59 public: 58 60 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 61 63 62 64 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 ); 67 68 68 69 // collects environments for relevant nodes … … 103 104 typedef AddStmtVisitor Parent; 104 105 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; 106 108 virtual void visit( CompoundStmt *compoundStmt ) override; 107 109 virtual void visit( DeclStmt *stmt ) override; 108 110 109 111 // don't go into other functions 110 virtual void visit( FunctionDecl *decl ) override {}112 virtual void visit( __attribute__((unused)) FunctionDecl *decl ) override {} 111 113 112 114 protected: … … 115 117 116 118 // 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 ) {} 120 122 const ObjectSet & objs; 121 123 }; 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) { 123 128 out << "{ "; 124 129 for ( ObjectDecl * obj : set.objs ) { … … 190 195 }; 191 196 192 class FixInit final : public GenPoly::PolyMutator{197 class FixInit : public WithStmtsToAdd { 193 198 public: 194 199 /// expand each object declaration to use its constructor after it is declared. 195 200 static void fixInitializers( std::list< Declaration * > &translationUnit ); 196 201 197 typedef GenPoly::PolyMutator Parent; 198 using Parent::mutate; 199 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 202 DeclarationWithType * postmutate( ObjectDecl *objDecl ); 200 203 201 204 std::list< Declaration * > staticDtorDecls; … … 300 303 namespace { 301 304 void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) { 302 InsertImplicitCallsinserter( envMap );305 PassVisitor<InsertImplicitCalls> inserter( envMap ); 303 306 mutateAll( translationUnit, inserter ); 304 307 } … … 310 313 311 314 void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) { 312 FixInitfixer;315 PassVisitor<FixInit> fixer; 313 316 314 317 // can't use mutateAll, because need to insert declarations at top-level … … 318 321 try { 319 322 *i = maybeMutate( *i, fixer ); 320 translationUnit.splice( i, fixer. staticDtorDecls );323 translationUnit.splice( i, fixer.pass.staticDtorDecls ); 321 324 } catch( SemanticError &e ) { 322 325 e.set_location( (*i)->location ); … … 350 353 } 351 354 352 Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) { 353 appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) ); 355 Expression * InsertImplicitCalls::postmutate( ApplicationExpr * appExpr ) { 354 356 assert( appExpr ); 355 357 … … 393 395 } 394 396 395 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) {397 void InsertImplicitCalls::premutate( StmtExpr * stmtExpr ) { 396 398 assert( env ); 397 399 envMap[stmtExpr] = env; 398 return Parent::mutate( stmtExpr );399 400 } 400 401 … … 696 697 } 697 698 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) 702 701 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 703 702 // a decision should have been made by the resolver, so ctor and init are not both non-NULL … … 729 728 // static bool __objName_uninitialized = true 730 729 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 ) ) ); 732 731 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr ); 733 732 isUninitializedVar->fixUniqueId(); … … 736 735 UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) ); 737 736 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 ) ) ); 739 738 740 739 // generate body of if … … 750 749 751 750 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 ); 754 753 ctorInit->set_dtor( nullptr ); 755 754 if ( dtor ) { … … 804 803 } else { 805 804 stmtsToAddAfter.push_back( ctor ); 806 objDecl->set_init( NULL);807 ctorInit->set_ctor( NULL);805 objDecl->set_init( nullptr ); 806 ctorInit->set_ctor( nullptr ); 808 807 } 809 808 } // if 810 809 } else if ( Initializer * init = ctorInit->get_init() ) { 811 810 objDecl->set_init( init ); 812 ctorInit->set_init( NULL);811 ctorInit->set_init( nullptr ); 813 812 } else { 814 813 // no constructor and no initializer, which is okay 815 objDecl->set_init( NULL);814 objDecl->set_init( nullptr ); 816 815 } // if 817 816 delete ctorInit; … … 821 820 822 821 void ObjDeclCollector::visit( CompoundStmt * compoundStmt ) { 823 std::set< ObjectDecl * >prevVars = curVars;822 ObjectSet prevVars = curVars; 824 823 Parent::visit( compoundStmt ); 825 824 curVars = prevVars; … … 829 828 // keep track of all variables currently in scope 830 829 if ( ObjectDecl * objDecl = dynamic_cast< ObjectDecl * > ( stmt->get_decl() ) ) { 831 curVars. insert( objDecl );830 curVars.push_back( objDecl ); 832 831 } // if 833 832 Parent::visit( stmt ); … … 896 895 Parent::visit( compoundStmt ); 897 896 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 899 899 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 } 901 903 reverseDeclOrder.pop_front(); 902 904 } 903 905 904 void InsertDtors::visit( ReturnStmt * returnStmt ) {906 void InsertDtors::visit( __attribute((unused)) ReturnStmt * returnStmt ) { 905 907 // return exits all scopes, so dump destructors for all scopes 906 908 for ( OrderedDecls & od : reverseDeclOrder ) { … … 941 943 ) 942 944 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 943 948 // go through decl ordered list of objectdecl. for each element that occurs in diff, output destructor 944 949 OrderedDecls ordered; 945 950 for ( OrderedDecls & rdo : reverseDeclOrder ) { 946 951 // 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 ); } ); 948 953 } // for 949 954 insertDtors( ordered.begin(), ordered.end(), back_inserter( stmtsToAdd ) ); -
src/InitTweak/GenInit.cc
r9c951e3 rb1e63ac5 16 16 #include <stack> 17 17 #include <list> 18 19 #include "InitTweak.h" 18 20 #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 20 30 #include "SynTree/Declaration.h" 21 #include "SynTree/Type.h"22 31 #include "SynTree/Expression.h" 23 #include "SynTree/Statement.h"24 32 #include "SynTree/Initializer.h" 25 33 #include "SynTree/Mutator.h" 34 #include "SynTree/Statement.h" 35 #include "SynTree/Type.h" 36 26 37 #include "SymTab/Autogen.h" 27 38 #include "SymTab/Mangler.h" 28 #include "GenPoly/PolyMutator.h"29 #include "GenPoly/DeclMutator.h"30 #include "GenPoly/ScopedSet.h"31 #include "ResolvExpr/typeops.h"32 39 33 40 namespace InitTweak { … … 37 44 } 38 45 39 class ReturnFixer final : public GenPoly::PolyMutator { 40 public: 46 struct ReturnFixer : public WithStmtsToAdd, public WithGuards { 41 47 /// consistently allocates a temporary variable for the return value 42 48 /// of a function so that anything which the resolver decides can be constructed … … 44 50 static void makeReturnTemp( std::list< Declaration * > &translationUnit ); 45 51 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 ); 52 54 53 55 protected: … … 56 58 }; 57 59 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 { 62 61 /// create constructor and destructor statements for object declarations. 63 62 /// the actual call statements will be added in after the resolver has run … … 66 65 static void generateCtorDtor( std::list< Declaration * > &translationUnit ); 67 66 68 virtual DeclarationWithType * mutate( ObjectDecl * ) override; 69 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 67 void previsit( ObjectDecl * ); 68 void previsit( FunctionDecl *functionDecl ); 69 70 70 // should not traverse into any of these declarations to find objects 71 71 // that need to be constructed or destructed 72 v irtual Declaration* mutate( StructDecl *aggregateDecl ) override;73 v irtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; }74 v irtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; }75 v irtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; }76 v irtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; }77 v irtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; }78 79 v irtual Type * mutate( FunctionType *funcType ) override { return funcType; }80 81 v irtual 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 ); 82 82 83 83 private: … … 131 131 132 132 void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) { 133 ReturnFixerfixer;133 PassVisitor<ReturnFixer> fixer; 134 134 mutateAll( translationUnit, fixer ); 135 135 } 136 136 137 ReturnFixer::ReturnFixer() {} 138 139 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) { 137 void ReturnFixer::premutate( ReturnStmt *returnStmt ) { 140 138 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 141 139 assert( returnVals.size() == 0 || returnVals.size() == 1 ); … … 148 146 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 149 147 construct->get_args().push_back( returnStmt->get_expr() ); 150 stmtsToAdd .push_back(new ExprStmt(noLabels, construct));148 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 151 149 152 150 // return the retVal object 153 151 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 154 152 } // 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 ); 161 158 162 159 ftype = functionDecl->get_functionType(); 163 160 funcName = functionDecl->get_name(); 164 return Parent::mutate( functionDecl );165 161 } 166 162 … … 212 208 213 209 void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) { 214 CtorDtorctordtor;215 mutateAll( translationUnit, ctordtor );210 PassVisitor<CtorDtor> ctordtor; 211 acceptAll( translationUnit, ctordtor ); 216 212 } 217 213 … … 291 287 } 292 288 293 DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) {289 void CtorDtor::previsit( ObjectDecl * objDecl ) { 294 290 handleDWT( objDecl ); 295 291 // hands off if @=, extern, builtin, etc. … … 303 299 objDecl->set_init( genCtorInit( objDecl ) ); 304 300 } 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 ); 310 305 inFunction = true; 311 306 312 307 handleDWT( functionDecl ); 313 308 314 managedTypes.beginScope();309 GuardScope( managedTypes ); 315 310 // go through assertions and recursively add seen ctor/dtors 316 311 for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) { 317 312 for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) { 318 assertion = assertion->acceptMutator( *this);313 handleDWT( assertion ); 319 314 } 320 315 } 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 329 326 // don't construct members, but need to take note if there is a managed member, 330 327 // because that means that this type is also managed … … 338 335 } 339 336 } 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 } 350 342 } // namespace InitTweak 351 343 -
src/InitTweak/InitTweak.cc
r9c951e3 rb1e63ac5 14 14 public: 15 15 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 } 23 20 }; 24 21 … … 92 89 InitImpl( Initializer * init ) : init( init ) {} 93 90 94 virtual std::list< Expression * > next( std::list< Expression * > & indices ) {91 virtual std::list< Expression * > next( __attribute((unused)) std::list< Expression * > & indices ) { 95 92 // this is wrong, but just a placeholder for now 96 93 // if ( ! flattened ) flatten( indices ); … … 248 245 } 249 246 250 Statement * ExprImpl::buildListInit( UntypedExpr * dst,std::list< Expression * > & indices ) {247 Statement * ExprImpl::buildListInit( __attribute((unused)) UntypedExpr * dst, __attribute((unused)) std::list< Expression * > & indices ) { 251 248 return NULL; 252 249 } … … 477 474 ConstExprChecker() : isConstExpr( true ) {} 478 475 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; } 481 480 virtual void visit( NameExpr *nameExpr ) { 482 481 // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today … … 489 488 if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false; 490 489 } 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; } 495 494 // these might be okay? 496 495 // virtual void visit( SizeofExpr *sizeofExpr ); … … 503 502 // virtual void visit( LogicalExpr *logicalExpr ); 504 503 // 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; } 512 511 513 512 bool isConstExpr; -
src/MakeLibCfa.cc
r9c951e3 rb1e63ac5 75 75 case CodeGen::OT_POSTFIXASSIGN: 76 76 case CodeGen::OT_INFIXASSIGN: 77 case CodeGen::OT_CTOR: 78 case CodeGen::OT_DTOR: 77 79 funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) ); 78 80 break; 79 case CodeGen::OT_CTOR:80 // ctors don't return a value81 if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) {82 // intrinsic default constructors should do nothing83 // 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 assignment88 // 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 nothing96 // delete newExpr;97 break;98 81 case CodeGen::OT_CONSTANT: 99 82 case CodeGen::OT_LABELADDRESS: … … 109 92 assert( ! objDecl->get_init() ); 110 93 std::list< Expression* > noDesignators; 111 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators,false ) ); // cannot be constructed94 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), false ) ); // cannot be constructed 112 95 newDecls.push_back( objDecl ); 113 96 } -
src/Makefile.am
r9c951e3 rb1e63ac5 43 43 driver_cfa_cpp_SOURCES = ${SRC} 44 44 driver_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 45 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14 46 46 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic 47 47 -
src/Makefile.in
r9c951e3 rb1e63ac5 119 119 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 120 120 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ 121 ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT) \ 121 122 GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \ 122 123 GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \ … … 143 144 Parser/driver_cfa_cpp-TypeData.$(OBJEXT) \ 144 145 Parser/driver_cfa_cpp-LinkageSpec.$(OBJEXT) \ 145 Parser/driver_cfa_cpp-parse utility.$(OBJEXT) \146 Parser/driver_cfa_cpp-parserutility.$(OBJEXT) \ 146 147 ResolvExpr/driver_cfa_cpp-AlternativeFinder.$(OBJEXT) \ 147 148 ResolvExpr/driver_cfa_cpp-Alternative.$(OBJEXT) \ … … 161 162 ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT) \ 162 163 ResolvExpr/driver_cfa_cpp-TypeEnvironment.$(OBJEXT) \ 164 ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT) \ 163 165 SymTab/driver_cfa_cpp-Indexer.$(OBJEXT) \ 164 166 SymTab/driver_cfa_cpp-Mangler.$(OBJEXT) \ … … 173 175 SynTree/driver_cfa_cpp-PointerType.$(OBJEXT) \ 174 176 SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT) \ 175 SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT) \176 177 SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT) \ 177 178 SynTree/driver_cfa_cpp-ReferenceToType.$(OBJEXT) \ … … 395 396 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 396 397 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 397 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 398 ControlStruct/ForExprMutator.cc \ 399 ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \ 398 400 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 399 401 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 406 408 Parser/ExpressionNode.cc Parser/StatementNode.cc \ 407 409 Parser/InitializerNode.cc Parser/TypeData.cc \ 408 Parser/LinkageSpec.cc Parser/parse utility.cc \410 Parser/LinkageSpec.cc Parser/parserutility.cc \ 409 411 ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \ 410 412 ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \ … … 415 417 ResolvExpr/RenameVars.cc ResolvExpr/FindOpenVars.cc \ 416 418 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 \ 423 425 SynTree/FunctionType.cc SynTree/ReferenceToType.cc \ 424 426 SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \ … … 448 450 driver_cfa_cpp_SOURCES = ${SRC} 449 451 driver_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 452 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14 451 453 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic 452 454 all: $(BUILT_SOURCES) … … 595 597 ControlStruct/$(am__dirstamp) \ 596 598 ControlStruct/$(DEPDIR)/$(am__dirstamp) 599 ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT): \ 600 ControlStruct/$(am__dirstamp) \ 601 ControlStruct/$(DEPDIR)/$(am__dirstamp) 597 602 GenPoly/$(am__dirstamp): 598 603 @$(MKDIR_P) GenPoly … … 664 669 Parser/driver_cfa_cpp-LinkageSpec.$(OBJEXT): Parser/$(am__dirstamp) \ 665 670 Parser/$(DEPDIR)/$(am__dirstamp) 666 Parser/driver_cfa_cpp-parse utility.$(OBJEXT): Parser/$(am__dirstamp) \671 Parser/driver_cfa_cpp-parserutility.$(OBJEXT): Parser/$(am__dirstamp) \ 667 672 Parser/$(DEPDIR)/$(am__dirstamp) 668 673 ResolvExpr/$(am__dirstamp): … … 722 727 ResolvExpr/$(am__dirstamp) \ 723 728 ResolvExpr/$(DEPDIR)/$(am__dirstamp) 729 ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT): \ 730 ResolvExpr/$(am__dirstamp) \ 731 ResolvExpr/$(DEPDIR)/$(am__dirstamp) 724 732 SymTab/$(am__dirstamp): 725 733 @$(MKDIR_P) SymTab … … 758 766 SynTree/driver_cfa_cpp-ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \ 759 767 SynTree/$(DEPDIR)/$(am__dirstamp) 760 SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT): \761 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)762 768 SynTree/driver_cfa_cpp-FunctionType.$(OBJEXT): \ 763 769 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) … … 856 862 -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT) 857 863 -rm -f Concurrency/driver_cfa_cpp-Keywords.$(OBJEXT) 864 -rm -f ControlStruct/driver_cfa_cpp-ExceptTranslate.$(OBJEXT) 858 865 -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) 859 866 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) … … 885 892 -rm -f Parser/driver_cfa_cpp-lex.$(OBJEXT) 886 893 -rm -f Parser/driver_cfa_cpp-parser.$(OBJEXT) 887 -rm -f Parser/driver_cfa_cpp-parse utility.$(OBJEXT)894 -rm -f Parser/driver_cfa_cpp-parserutility.$(OBJEXT) 888 895 -rm -f ResolvExpr/driver_cfa_cpp-AdjustExprType.$(OBJEXT) 889 896 -rm -f ResolvExpr/driver_cfa_cpp-Alternative.$(OBJEXT) … … 893 900 -rm -f ResolvExpr/driver_cfa_cpp-CommonType.$(OBJEXT) 894 901 -rm -f ResolvExpr/driver_cfa_cpp-ConversionCost.$(OBJEXT) 902 -rm -f ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT) 895 903 -rm -f ResolvExpr/driver_cfa_cpp-FindOpenVars.$(OBJEXT) 896 904 -rm -f ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT) … … 933 941 -rm -f SynTree/driver_cfa_cpp-PointerType.$(OBJEXT) 934 942 -rm -f SynTree/driver_cfa_cpp-ReferenceToType.$(OBJEXT) 935 -rm -f SynTree/driver_cfa_cpp-ReferenceType.$(OBJEXT)936 943 -rm -f SynTree/driver_cfa_cpp-Statement.$(OBJEXT) 937 944 -rm -f SynTree/driver_cfa_cpp-TupleExpr.$(OBJEXT) … … 969 976 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@ 970 977 @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@ 971 979 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@ 972 980 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ … … 998 1006 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-lex.Po@am__quote@ 999 1007 @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-parse utility.Po@am__quote@1008 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-parserutility.Po@am__quote@ 1001 1009 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-AdjustExprType.Po@am__quote@ 1002 1010 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Alternative.Po@am__quote@ … … 1006 1014 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CommonType.Po@am__quote@ 1007 1015 @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@ 1008 1017 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-FindOpenVars.Po@am__quote@ 1009 1018 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Occurs.Po@am__quote@ … … 1046 1055 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-PointerType.Po@am__quote@ 1047 1056 @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@1049 1057 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Statement.Po@am__quote@ 1050 1058 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TupleExpr.Po@am__quote@ … … 1360 1368 @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` 1361 1369 1370 ControlStruct/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 1377 ControlStruct/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 1362 1384 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1363 1385 @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 … … 1696 1718 @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` 1697 1719 1698 Parser/driver_cfa_cpp-parse utility.o: Parser/parseutility.cc1699 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parse utility.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.cc1700 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Parser/$(DEPDIR)/driver_cfa_cpp-parse utility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Po1701 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Parser/parse utility.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-parse utility.o `test -f 'Parser/parseutility.cc' || echo '$(srcdir)/'`Parser/parseutility.cc1704 1705 Parser/driver_cfa_cpp-parse utility.obj: Parser/parseutility.cc1706 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parse utility.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-parse utility.Tpo Parser/$(DEPDIR)/driver_cfa_cpp-parseutility.Po1708 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Parser/parse utility.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-parse utility.obj `if test -f 'Parser/parseutility.cc'; then $(CYGPATH_W) 'Parser/parseutility.cc'; else $(CYGPATH_W) '$(srcdir)/Parser/parseutility.cc'; fi`1720 Parser/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 1727 Parser/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` 1711 1733 1712 1734 ResolvExpr/driver_cfa_cpp-AlternativeFinder.o: ResolvExpr/AlternativeFinder.cc … … 1948 1970 @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` 1949 1971 1972 ResolvExpr/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 1979 ResolvExpr/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 1950 1986 SymTab/driver_cfa_cpp-Indexer.o: SymTab/Indexer.cc 1951 1987 @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 … … 2115 2151 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2116 2152 @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.cc2119 @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.cc2120 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-ReferenceType.Po2121 @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.cc2124 2125 SynTree/driver_cfa_cpp-ReferenceType.obj: SynTree/ReferenceType.cc2126 @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.Po2128 @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`2131 2153 2132 2154 SynTree/driver_cfa_cpp-FunctionType.o: SynTree/FunctionType.cc -
src/Parser/DeclarationNode.cc
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 15:46:33201713 // Update Count : 101 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:27:00 2017 13 // Update Count : 1019 14 14 // 15 15 … … 57 57 variable.tyClass = NoTypeClass; 58 58 variable.assertions = nullptr; 59 variable.initializer = nullptr; 59 60 60 61 // attr.name = nullptr; … … 70 71 // delete variable.name; 71 72 delete variable.assertions; 73 delete variable.initializer; 72 74 73 75 delete type; … … 101 103 newnode->variable.tyClass = variable.tyClass; 102 104 newnode->variable.assertions = maybeClone( variable.assertions ); 105 newnode->variable.initializer = maybeClone( variable.initializer ); 103 106 104 107 // newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr; … … 857 860 } 858 861 862 DeclarationNode * 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 859 868 DeclarationNode * DeclarationNode::cloneType( string * newName ) { 860 869 DeclarationNode * newnode = new DeclarationNode; … … 1014 1023 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1015 1024 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 ); 1017 1026 buildList( variable.assertions, ret->get_assertions() ); 1018 1027 return ret; … … 1054 1063 case TypeData::Enum: 1055 1064 case TypeData::Aggregate: { 1056 ReferenceToType * ret = buildComAggInst( type, attributes );1065 ReferenceToType * ret = buildComAggInst( type, attributes, linkage ); 1057 1066 buildList( type->aggregate.actuals, ret->get_parameters() ); 1058 1067 return ret; -
src/Parser/ExpressionNode.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 30 17:02:46201713 // Update Count : 5 1512 // Last Modified On : Wed Jun 28 21:08:15 2017 13 // Update Count : 542 14 14 // 15 15 … … 27 27 #include "SynTree/Declaration.h" 28 28 #include "Common/UnimplementedError.h" 29 #include "parse utility.h"29 #include "parserutility.h" 30 30 #include "Common/utility.h" 31 31 … … 62 62 bool dec = true, Unsigned = false; // decimal, unsigned constant 63 63 int size; // 0 => int, 1 => long, 2 => long long 64 unsigned long long v; // converted integral value64 unsigned long long int v; // converted integral value 65 65 size_t last = str.length() - 1; // last character of constant 66 66 … … 118 118 } // if 119 119 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 ) ); 121 121 delete &str; // created by lex 122 122 return ret; … … 133 133 // floating-point constant has minimum of 2 characters: 1. or .1 134 134 size_t last = str.length() - 1; 135 double v; 136 137 sscanf( str.c_str(), "%lg", &v ); 135 138 136 139 if ( checkI( str[last] ) ) { // imaginary ? … … 150 153 } // if 151 154 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 ) ); 153 156 delete &str; // created by lex 154 157 return ret; … … 156 159 157 160 Expression *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] ) ); 159 162 delete &str; // created by lex 160 163 return ret; … … 164 167 // string should probably be a primitive type 165 168 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 '"' 168 170 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 ) ); 170 173 delete &str; // created by lex 171 174 return ret; … … 173 176 174 177 Expression *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 ) ); 176 180 delete &str; // created by lex 177 181 return ret; … … 184 188 std::stringstream ss( str ); 185 189 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 ) ) ); 189 191 delete &str; 190 192 return ret; … … 207 209 } // build_field_name_fraction_constants 208 210 211 212 209 213 Expression * 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 ); 211 215 Expression * ret = build_constantInteger( *new std::string( str.substr(1) ) ); 212 216 delete &str; … … 215 219 216 220 Expression * 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 ); 218 222 Expression * ret = build_constantInteger( *new std::string( str.substr( 0, str.size()-1 ) ) ); 219 223 delete &str; … … 221 225 } // build_field_name_REALDECIMALconstant 222 226 223 NameExpr * build_varref( const string *name , bool labelp) {227 NameExpr * build_varref( const string *name ) { 224 228 NameExpr *expr = new NameExpr( *name, nullptr ); 225 229 delete name; … … 344 348 345 349 Expression *build_valexpr( StatementNode *s ) { 346 return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr);350 return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) ); 347 351 } 348 352 Expression *build_typevalue( DeclarationNode *decl ) { -
src/Parser/InitializerNode.cc
r9c951e3 rb1e63ac5 74 74 75 75 InitializerNode *moreInit; 76 if ( get_next() != 0 && ((moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) != 0) )76 if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) { 77 77 moreInit->printOneLine( os ); 78 } 78 79 } 79 80 80 81 Initializer *InitializerNode::build() const { 81 82 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 82 91 std::list< Initializer * > initlist; 83 92 buildList< Initializer, InitializerNode >( next_init(), initlist ); 84 85 std::list< Expression * > designlist;86 87 if ( designator != 0 ) {88 buildList< Expression, ExpressionNode >( designator, designlist );89 } // if90 91 93 return new ListInit( initlist, designlist, maybeConstructed ); 92 94 } 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 } 100 98 } // if 101 102 99 return 0; 103 100 } -
src/Parser/LinkageSpec.cc
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Oct 2 23:16:21 201613 // Update Count : 2 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 11:51:00 2017 13 // Update Count : 24 14 14 // 15 15 … … 28 28 } else if ( *spec == "\"C\"" ) { 29 29 return C; 30 } else if ( *spec == "\"BuiltinC\"" ) { 31 return BuiltinC; 30 32 } else { 31 33 throw SemanticError( "Invalid linkage specifier " + *spec ); … … 36 38 assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs ); 37 39 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", 39 41 }; 40 42 return linkageKinds[linkage]; 41 43 } 42 44 43 bool LinkageSpec::is Decoratable( Spec spec ) {45 bool LinkageSpec::isMangled( Spec spec ) { 44 46 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs ); 45 47 static bool decoratable[LinkageSpec::NoOfSpecs] = { 46 // Intrinsic, Cforall, C, AutoGen, Compiler 48 // Intrinsic, Cforall, C, AutoGen, Compiler, 47 49 true, true, false, true, false, 50 // Builtin, BuiltinC, 51 true, false, 48 52 }; 49 53 return decoratable[spec]; … … 53 57 assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs ); 54 58 static bool generatable[LinkageSpec::NoOfSpecs] = { 55 // Intrinsic, Cforall, C, AutoGen, Compiler 59 // Intrinsic, Cforall, C, AutoGen, Compiler, 56 60 true, true, true, true, false, 61 // Builtin, BuiltinC, 62 true, true, 57 63 }; 58 64 return generatable[spec]; … … 62 68 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs ); 63 69 static bool overridable[LinkageSpec::NoOfSpecs] = { 64 // Intrinsic, Cforall, C, AutoGen, Compiler 70 // Intrinsic, Cforall, C, AutoGen, Compiler, 65 71 true, false, false, true, false, 72 // Builtin, BuiltinC, 73 false, false, 66 74 }; 67 75 return overridable[spec]; … … 71 79 assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs ); 72 80 static bool builtin[LinkageSpec::NoOfSpecs] = { 73 // Intrinsic, Cforall, C, AutoGen, Compiler 81 // Intrinsic, Cforall, C, AutoGen, Compiler, 74 82 true, false, false, false, true, 83 // Builtin, BuiltinC, 84 true, true, 75 85 }; 76 86 return builtin[spec]; -
src/Parser/LinkageSpec.h
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Oct 1 23:03:17 201613 // Update Count : 1 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 11:50:00 2017 13 // Update Count : 12 14 14 // 15 15 … … 26 26 AutoGen, // built by translator (struct assignment) 27 27 Compiler, // gcc internal 28 Builtin, // mangled builtins 29 BuiltinC, // non-mangled builtins 28 30 NoOfSpecs 29 31 }; … … 32 34 static std::string linkageName( Spec ); 33 35 34 static bool is Decoratable( Spec );36 static bool isMangled( Spec ); 35 37 static bool isGeneratable( Spec ); 36 38 static bool isOverridable( Spec ); -
src/Parser/ParseNode.h
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 15:42:18201713 // Update Count : 77 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:00:00 2017 13 // Update Count : 779 14 14 // 15 15 … … 61 61 } 62 62 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 {} 65 65 66 66 static int indent_by; … … 113 113 ExpressionNode * set_extension( bool exten ) { extension = exten; return this; } 114 114 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 {} 117 117 118 118 template<typename T> … … 166 166 Expression * build_field_name_REALDECIMALconstant( const std::string & str ); 167 167 168 NameExpr * build_varref( const std::string * name , bool labelp = false);168 NameExpr * build_varref( const std::string * name ); 169 169 Expression * build_typevalue( DeclarationNode * decl ); 170 170 … … 274 274 DeclarationNode * addIdList( DeclarationNode * list ); // old-style functions 275 275 DeclarationNode * addInitializer( InitializerNode * init ); 276 DeclarationNode * addTypeInitializer( DeclarationNode * init ); 276 277 277 278 DeclarationNode * cloneType( std::string * newName ); … … 282 283 } 283 284 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; 286 287 287 288 Declaration * build() const; … … 301 302 DeclarationNode::TypeClass tyClass; 302 303 DeclarationNode * assertions; 304 DeclarationNode * initializer; 303 305 }; 304 306 Variable_t variable; … … 361 363 virtual StatementNode * append_last_case( StatementNode * ); 362 364 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 {} 365 367 private: 366 368 std::unique_ptr<Statement> stmt; … … 391 393 Statement * build_return( ExpressionNode * ctl ); 392 394 Statement * build_throw( ExpressionNode * ctl ); 395 Statement * build_resume( ExpressionNode * ctl ); 396 Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target ); 393 397 Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ); 394 Statement * build_catch( DeclarationNode * decl, StatementNode * stmt, bool catchAny = false);398 Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ); 395 399 Statement * build_finally( StatementNode * stmt ); 396 400 Statement * build_compound( StatementNode * first ); … … 411 415 result->location = cur->location; 412 416 * out++ = result; 417 } else { 418 assertf(false, "buildList unknown type"); 413 419 } // if 414 420 } catch( SemanticError &e ) { -
src/Parser/StatementNode.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 22:16:40201713 // Update Count : 3 2712 // Last Modified On : Wed Jun 28 21:08:37 2017 13 // Update Count : 330 14 14 // 15 15 … … 21 21 #include "SynTree/Statement.h" 22 22 #include "SynTree/Expression.h" 23 #include "parse utility.h"23 #include "parserutility.h" 24 24 #include "Common/utility.h" 25 25 … … 152 152 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 153 153 } 154 154 155 Statement *build_throw( ExpressionNode *ctl ) { 155 156 std::list< Expression * > exps; 156 157 buildMoveList( ctl, exps ); 157 158 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 162 Statement *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 169 Statement *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," ); 159 173 } 160 174 161 175 Statement *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 ); 164 178 CompoundStmt *tryBlock = safe_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt)); 165 179 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) ); 166 180 return new TryStmt( noLabels, tryBlock, branches, finallyBlock ); 167 181 } 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);182 Statement *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() ); 173 187 } 174 188 Statement *build_finally( StatementNode *stmt ) { -
src/Parser/TypeData.cc
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 15:52:43201713 // Update Count : 56 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:28:00 2017 13 // Update Count : 564 14 14 // 15 15 … … 630 630 } // buildReference 631 631 632 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes ) {632 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 633 633 assert( td->kind == TypeData::Aggregate ); 634 634 AggregateDecl * at; … … 638 638 case DeclarationNode::Monitor: 639 639 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 ); 641 641 buildForall( td->aggregate.params, at->get_parameters() ); 642 642 break; … … 659 659 } // buildAggregate 660 660 661 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes ) {661 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 662 662 switch ( type->kind ) { 663 663 case TypeData::Enum: { … … 672 672 ReferenceToType * ret; 673 673 if ( type->aggregate.body ) { 674 AggregateDecl * typedecl = buildAggregate( type, attributes );674 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 675 675 switch ( type->aggregate.kind ) { 676 676 case DeclarationNode::Struct: … … 776 776 if ( cur->has_enumeratorValue() ) { 777 777 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() ) ) ); 779 779 } // if 780 780 } // for … … 793 793 TupleType * buildTuple( const TypeData * td ) { 794 794 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 ); 797 798 buildForall( td->forall, ret->get_forall() ); 798 799 return ret; … … 818 819 return decl->set_asmName( asmName ); 819 820 } else if ( td->kind == TypeData::Aggregate ) { 820 return buildAggregate( td, attributes );821 return buildAggregate( td, attributes, linkage ); 821 822 } else if ( td->kind == TypeData::Enum ) { 822 823 return buildEnum( td, attributes ); -
src/Parser/TypeData.h
r9c951e3 rb1e63ac5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:18:36 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 16 08:32:39201713 // Update Count : 18 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:29:00 2017 13 // Update Count : 186 14 14 // 15 15 … … 103 103 ReferenceType * buildReference( const TypeData * ); 104 104 AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); 105 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes );105 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ); 106 106 ReferenceToType * buildAggInst( const TypeData * ); 107 107 TypeDecl * buildVariable( const TypeData * ); -
src/Parser/TypedefTable.h
r9c951e3 rb1e63ac5 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 15 18:25:04 201613 // Update Count : 2812 // Last Modified On : Wed Jun 28 21:56:34 2017 13 // Update Count : 33 14 14 // 15 15 … … 22 22 #include <stack> 23 23 24 #include " lex.h"24 #include "parser.hh" 25 25 #include "parser.h" 26 26 -
src/Parser/lex.ll
r9c951e3 rb1e63ac5 5 5 * file "LICENCE" distributed with Cforall. 6 6 * 7 * lex.l --7 * lex.ll -- 8 8 * 9 9 * Author : Peter A. Buhr 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Mon Mar 13 08:36:17201713 * Update Count : 5 0612 * Last Modified On : Wed Jun 28 21:03:45 2017 13 * Update Count : 529 14 14 */ 15 15 … … 27 27 #include <cstdio> // FILENAME_MAX 28 28 29 #include "lex.h"30 #include "parser.h" // YACC generated definitions based on C++ grammar31 29 #include "ParseNode.h" 32 30 #include "TypedefTable.h" … … 77 75 // numeric constants, CFA: '_' in constant 78 76 hex_quad {hex}("_"?{hex}){3} 79 integer_suffix "_"?(([uU] [lL]?)|([uU]("ll"|"LL")?)|([lL][uU]?)|("ll"|"LL")[uU]?)77 integer_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]?))) 80 78 81 79 octal_digits ({octal})|({octal}({octal}|"_")*{octal}) … … 91 89 92 90 decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal}) 93 real_decimal {decimal_digits}"." 94 real_fraction "."{decimal_digits} 95 real_constant {decimal_digits} ?{real_fraction}91 real_decimal {decimal_digits}"."{exponent}?{floating_suffix}? 92 real_fraction "."{decimal_digits}{exponent}?{floating_suffix}? 93 real_constant {decimal_digits}{real_fraction} 96 94 exponent "_"?[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) 96 floating_suffix "_"?([fFdDlL][iI]?|[iI][lLfFdD]?|"DL") 100 97 floating_constant (({real_constant}{exponent}?)|({decimal_digits}{exponent})){floating_suffix}? 101 98 … … 236 233 long { KEYWORD_RETURN(LONG); } 237 234 lvalue { KEYWORD_RETURN(LVALUE); } // CFA 238 monitor { KEYWORD_RETURN(MONITOR); } // CFA235 monitor { KEYWORD_RETURN(MONITOR); } // CFA 239 236 mutex { KEYWORD_RETURN(MUTEX); } // CFA 240 237 _Noreturn { KEYWORD_RETURN(NORETURN); } // C11 … … 378 375 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 379 376 /* 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 juxtaposed382 to an identifier, e.g., "*i", users will be annoyed if they cannot do this with respect to operator383 identifiers. Even with this special hack, there are 5 general cases that cannot be handled. The first384 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 scanning390 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 of403 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; 404 401 */ 405 {op_unary}"?"({op_unary_pre_post}|" [?]"|{op_binary_over}"?") {402 {op_unary}"?"({op_unary_pre_post}|"()"|"[?]"|{op_binary_over}"?") { 406 403 // 1 or 2 character unary operator ? 407 404 int i = yytext[1] == '?' ? 1 : 2; -
src/Parser/module.mk
r9c951e3 rb1e63ac5 11 11 ## Created On : Sat May 16 15:29:09 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Tue Aug 16 17:28:34 201614 ## Update Count : 10 113 ## Last Modified On : Wed Jun 28 21:58:29 2017 14 ## Update Count : 104 15 15 ############################################################################### 16 16 … … 29 29 Parser/TypeData.cc \ 30 30 Parser/LinkageSpec.cc \ 31 Parser/parse utility.cc31 Parser/parserutility.cc 32 32 33 33 MAINTAINERCLEANFILES += Parser/parser.output -
src/Parser/parser.hh
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // lex.h --7 // parser.hh -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 22 08:58:10 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 21 11:28:47 201613 // Update Count : 34 712 // Last Modified On : Wed Jun 28 22:10:17 2017 13 // Update Count : 349 14 14 // 15 15 16 #ifndef PARSER_ LEX_H17 #define PARSER_ LEX_H16 #ifndef PARSER_HH 17 #define PARSER_HH 18 18 19 19 int yylex(); … … 42 42 }; // Token 43 43 44 #endif // PARSER_ LEX_H44 #endif // PARSER_HH 45 45 46 46 // Local Variables: // -
src/Parser/parser.yy
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // cfa.y --7 // parser.yy -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 30 15:42:32 201713 // Update Count : 2 31812 // Last Modified On : Wed Jun 28 22:11:22 2017 13 // Update Count : 2414 14 14 // 15 15 … … 48 48 #include <cstdio> 49 49 #include <stack> 50 #include "lex.h"51 #include "parser.h"52 50 #include "ParseNode.h" 53 51 #include "TypedefTable.h" … … 85 83 } // for 86 84 } // distExt 85 86 bool forall = false; // aggregate have one or more forall qualifiers ? 87 87 %} 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 } 88 107 89 108 //************************* TERMINAL TOKENS ******************************** … … 138 157 %token ATassign // @= 139 158 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 161 161 %type<constant> string_literal 162 162 %type<str> string_literal_list … … 191 191 %type<sn> case_value_list case_label case_label_list 192 192 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 193 %type<sn> handler_listhandler_clause finally_clause193 %type<sn> /* handler_list */ handler_clause finally_clause 194 194 195 195 // declarations … … 205 205 %type<en> bit_subrange_size_opt bit_subrange_size 206 206 207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type _name indirect_type_name207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type 208 208 209 209 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier … … 259 259 %type<decl> type_declarator type_declarator_name type_declaring_list 260 260 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 262 263 263 264 %type<decl> variable_type_redeclarator type_ptr type_array type_function 264 265 265 266 %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 272 272 273 273 %type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list … … 349 349 IDENTIFIER 350 350 | ATTR_IDENTIFIER // CFA 351 | zero_one // CFA352 ;353 354 no_01_identifier:355 IDENTIFIER356 | ATTR_IDENTIFIER // CFA357 351 ; 358 352 359 353 no_attr_identifier: 360 354 IDENTIFIER 361 | zero_one // CFA362 355 ; 363 356 … … 365 358 ZERO 366 359 | ONE 367 ;360 ; 368 361 369 362 string_literal: … … 393 386 | '(' compound_statement ')' // GCC, lambda expression 394 387 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 395 | primary_expression '{' argument_expression_list '}' // CFA 388 | primary_expression '{' argument_expression_list '}' // CFA, constructor call 396 389 { 397 390 Token fn; … … 399 392 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 400 393 } 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 401 398 ; 402 399 … … 429 426 | postfix_expression DECR 430 427 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 431 | '(' type_n ame_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal428 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 432 429 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 433 430 | '^' primary_expression '{' argument_expression_list '}' // CFA … … 481 478 | no_attr_identifier fraction_constants 482 479 { 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 ) ); 488 485 } 489 486 ; … … 533 530 | SIZEOF unary_expression 534 531 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 535 | SIZEOF '(' type_n ame_no_function ')'532 | SIZEOF '(' type_no_function ')' 536 533 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 537 534 | ALIGNOF unary_expression // GCC, variable alignment 538 535 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 539 | ALIGNOF '(' type_n ame_no_function ')' // GCC, type alignment536 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 540 537 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 541 | OFFSETOF '(' type_n ame_no_function ',' no_attr_identifier ')'538 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' 542 539 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 543 540 | ATTR_IDENTIFIER … … 545 542 | ATTR_IDENTIFIER '(' argument_expression ')' 546 543 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 547 | ATTR_IDENTIFIER '(' type _name')'544 | ATTR_IDENTIFIER '(' type ')' 548 545 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 549 546 // | 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 ) ); } 551 548 ; 552 549 … … 567 564 cast_expression: 568 565 unary_expression 569 | '(' type_n ame_no_function ')' cast_expression566 | '(' type_no_function ')' cast_expression 570 567 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 571 // | '(' type_n ame_no_function ')' tuple568 // | '(' type_no_function ')' tuple 572 569 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 570 ; … … 656 653 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 657 654 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 658 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression659 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }660 655 ; 661 656 … … 669 664 | unary_expression assignment_operator assignment_expression 670 665 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 671 // | tuple assignment_opt // CFA, tuple expression672 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }673 666 ; 674 667 … … 936 929 { $$ = new StatementNode( build_throw( $2 ) ); } 937 930 | THROWRESUME assignment_expression_opt ';' // handles reresume 938 { $$ = new StatementNode( build_ throw( $2 ) ); }931 { $$ = new StatementNode( build_resume( $2 ) ); } 939 932 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 940 { $$ = new StatementNode( build_ throw( $2) ); }933 { $$ = new StatementNode( build_resume_at( $2, $4 ) ); } 941 934 ; 942 935 943 936 exception_statement: 944 TRY compound_statement handler_ list937 TRY compound_statement handler_clause 945 938 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 946 939 | TRY compound_statement finally_clause 947 940 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 948 | TRY compound_statement handler_ listfinally_clause941 | TRY compound_statement handler_clause finally_clause 949 942 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 950 943 ; 951 944 952 handler_list:953 handler_clause954 // 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_statement956 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }957 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement958 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }959 | CATCHRESUME '(' ELLIPSIS ')' compound_statement960 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }961 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement962 { $$ = (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 // ; 964 957 965 958 handler_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 ) ); } 968 967 | 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 ) ) ); } 970 969 | 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 ) ); } 972 971 | 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 ) ) ); } 974 973 ; 975 974 … … 1350 1349 basic_declaration_specifier 1351 1350 | sue_declaration_specifier 1352 | typedef_declaration_specifier 1353 | typegen_declaration_specifier 1351 | type_declaration_specifier 1354 1352 ; 1355 1353 … … 1362 1360 basic_declaration_specifier 1363 1361 | sue_declaration_specifier_nobody 1364 | typedef_declaration_specifier 1365 | typegen_declaration_specifier 1362 | type_declaration_specifier 1366 1363 ; 1367 1364 … … 1369 1366 basic_type_specifier 1370 1367 | sue_type_specifier 1371 | typedef_type_specifier 1372 | typegen_type_specifier 1368 | type_type_specifier 1373 1369 ; 1374 1370 … … 1381 1377 basic_type_specifier 1382 1378 | sue_type_specifier_nobody 1383 | typedef_type_specifier 1384 | typegen_type_specifier 1379 | type_type_specifier 1385 1380 ; 1386 1381 … … 1517 1512 1518 1513 basic_type_specifier: 1519 direct_type _name1520 | type_qualifier_list_opt indirect_type _nametype_qualifier_list_opt1514 direct_type 1515 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1521 1516 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 1522 1517 ; 1523 1518 1524 direct_type _name:1519 direct_type: 1525 1520 // A semantic check is necessary for conflicting type qualifiers. 1526 1521 basic_type_name 1527 1522 | type_qualifier_list basic_type_name 1528 1523 { $$ = $2->addQualifiers( $1 ); } 1529 | direct_type _nametype_qualifier1524 | direct_type type_qualifier 1530 1525 { $$ = $1->addQualifiers( $2 ); } 1531 | direct_type _namebasic_type_name1526 | direct_type basic_type_name 1532 1527 { $$ = $1->addType( $2 ); } 1533 1528 ; 1534 1529 1535 indirect_type _name:1536 TYPEOF '(' type _name ')'// GCC: typeof(x) y;1530 indirect_type: 1531 TYPEOF '(' type ')' // GCC: typeof(x) y; 1537 1532 { $$ = $3; } 1538 1533 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1539 1534 { $$ = DeclarationNode::newTypeof( $3 ); } 1540 | ATTR_TYPEGENname '(' type _name ')'// CFA: e.g., @type(x) y;1535 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1541 1536 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1542 1537 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; … … 1556 1551 sue_type_specifier: // struct, union, enum + type specifier 1557 1552 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 ); } 1560 1557 | sue_type_specifier type_qualifier 1561 1558 { $$ = $1->addQualifiers( $2 ); } … … 1580 1577 ; 1581 1578 1582 type def_declaration_specifier:1583 type def_type_specifier1584 | declaration_qualifier_list type def_type_specifier1579 type_declaration_specifier: 1580 type_type_specifier 1581 | declaration_qualifier_list type_type_specifier 1585 1582 { $$ = $2->addQualifiers( $1 ); } 1586 | type def_declaration_specifier storage_class// remaining OBSOLESCENT (see 2)1583 | type_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1587 1584 { $$ = $1->addQualifiers( $2 ); } 1588 | type def_declaration_specifier storage_class type_qualifier_list1585 | type_declaration_specifier storage_class type_qualifier_list 1589 1586 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1590 1587 ; 1591 1588 1592 typedef_type_specifier: // typedef types 1589 type_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 1597 type_name: 1593 1598 TYPEDEFname 1594 1599 { $$ = 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 1611 typegen_name: // CFA 1612 TYPEGENname '(' ')' 1613 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1614 | TYPEGENname '(' type_list ')' 1615 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1599 1616 ; 1600 1617 … … 1613 1630 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1614 1631 | 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 } 1616 1637 '{' field_declaration_list '}' 1617 1638 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1618 | aggregate_key attribute_list_opt '(' type_ name_list ')' '{' field_declaration_list '}' // CFA1639 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list '}' // CFA 1619 1640 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1620 1641 | aggregate_type_nobody … … 1622 1643 1623 1644 aggregate_type_nobody: // struct, union - {...} 1624 aggregate_key attribute_list_opt no_attr_identifier _or_type_name1645 aggregate_key attribute_list_opt no_attr_identifier 1625 1646 { 1626 1647 typedefTable.makeTypedef( *$3 ); 1627 1648 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1628 1649 } 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 1630 1656 { $$ = $3->addQualifiers( $2 ); } 1631 1657 ; … … 1865 1891 ; 1866 1892 1867 no_01_identifier_or_type_name:1868 no_01_identifier1869 | TYPEDEFname1870 | TYPEGENname1871 ;1872 1873 1893 no_attr_identifier_or_type_name: 1874 1894 no_attr_identifier … … 1877 1897 ; 1878 1898 1879 type_n ame_no_function:// sizeof, alignof, cast (constructor)1899 type_no_function: // sizeof, alignof, cast (constructor) 1880 1900 cfa_abstract_declarator_tuple // CFA 1881 1901 | type_specifier … … 1884 1904 ; 1885 1905 1886 type _name:// typeof, assertion1887 type_n ame_no_function1906 type: // typeof, assertion 1907 type_no_function 1888 1908 | cfa_abstract_function // CFA 1889 1909 ; … … 1925 1945 designation: 1926 1946 designator_list ':' // C99, CFA uses ":" instead of "=" 1927 | no_attr_identifier _or_type_name ':'// GCC, field name1947 | no_attr_identifier ':' // GCC, field name 1928 1948 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1929 1949 ; … … 1937 1957 1938 1958 designator: 1939 '.' no_attr_identifier _or_type_name// C99, field name1959 '.' no_attr_identifier // C99, field name 1940 1960 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1941 1961 | '[' push assignment_expression pop ']' // C99, single array element … … 1968 1988 // on type arguments of polymorphic functions. 1969 1989 1970 typegen_declaration_specifier: // CFA1971 typegen_type_specifier1972 | declaration_qualifier_list typegen_type_specifier1973 { $$ = $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_list1977 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }1978 ;1979 1980 typegen_type_specifier: // CFA1981 typegen_name1982 | type_qualifier_list typegen_name1983 { $$ = $2->addQualifiers( $1 ); }1984 | typegen_type_specifier type_qualifier1985 { $$ = $1->addQualifiers( $2 ); }1986 ;1987 1988 typegen_name: // CFA1989 TYPEGENname '(' type_name_list ')'1990 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }1991 ;1992 1993 1990 type_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 1996 1994 { $$ = $1->appendList( $3 ); } 1995 ; 1996 1997 type_initializer_opt: // CFA 1998 // empty 1999 { $$ = nullptr; } 2000 | '=' type 2001 { $$ = $2; } 1997 2002 ; 1998 2003 … … 2000 2005 type_class no_attr_identifier_or_type_name 2001 2006 { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); } 2002 assertion_list_opt2003 { $$ = DeclarationNode::newTypeParam( $1, $2 )->add Assertions( $4); }2007 type_initializer_opt assertion_list_opt 2008 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2004 2009 | type_specifier identifier_parameter_declarator 2005 2010 ; … … 2024 2029 2025 2030 assertion: // CFA 2026 '|' no_attr_identifier_or_type_name '(' type_ name_list ')'2031 '|' no_attr_identifier_or_type_name '(' type_list ')' 2027 2032 { 2028 2033 typedefTable.openTrait( *$2 ); … … 2031 2036 | '|' '{' push trait_declaration_list '}' 2032 2037 { $$ = $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 ')' 2034 2039 { $$ = nullptr; } 2035 2040 ; 2036 2041 2037 type_ name_list:// CFA2038 type _name2042 type_list: // CFA 2043 type 2039 2044 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 2040 2045 | assignment_expression 2041 | type_ name_list ',' type_name2046 | type_list ',' type 2042 2047 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 2043 | type_ name_list ',' assignment_expression2048 | type_list ',' assignment_expression 2044 2049 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 2045 2050 ; … … 2057 2062 type_declarator_name assertion_list_opt 2058 2063 { $$ = $1->addAssertions( $2 ); } 2059 | type_declarator_name assertion_list_opt '=' type _name2064 | type_declarator_name assertion_list_opt '=' type 2060 2065 { $$ = $1->addAssertions( $2 )->addType( $4 ); } 2061 2066 ; … … 2067 2072 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2068 2073 } 2069 | no_ 01_identifier_or_type_name '(' push type_parameter_list pop ')'2074 | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' 2070 2075 { 2071 2076 typedefTable.addToEnclosingScope( *$1, TypedefTable::TG ); … … 2093 2098 ; 2094 2099 2095 trait_declaration_list: // CFA2100 trait_declaration_list: // CFA 2096 2101 trait_declaration 2097 2102 | trait_declaration_list push trait_declaration … … 2099 2104 ; 2100 2105 2101 trait_declaration: // CFA2106 trait_declaration: // CFA 2102 2107 cfa_trait_declaring_list pop ';' 2103 2108 | trait_declaring_list pop ';' -
src/Parser/parserutility.cc
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // parse utility.cc --7 // parserutility.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:30:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 23:45:03 201613 // Update Count : 312 // Last Modified On : Wed Jun 28 22:11:32 2017 13 // Update Count : 7 14 14 // 15 15 16 #include "parse utility.h"16 #include "parserutility.h" 17 17 #include "SynTree/Type.h" 18 18 #include "SynTree/Expression.h" … … 26 26 UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) ); 27 27 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 ) ) ); 29 29 return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 30 30 } -
src/Parser/parserutility.h
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // parse utility.h --7 // parserutility.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:31:46 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 16 15:32:58 201513 // Update Count : 212 // Last Modified On : Wed Jun 28 22:11:40 2017 13 // Update Count : 3 14 14 // 15 15 -
src/ResolvExpr/AlternativeFinder.cc
r9c951e3 rb1e63ac5 97 97 /// Prunes a list of alternatives down to those that have the minimum conversion cost for a given return type; skips ambiguous interpretations 98 98 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 ) { 100 100 // select the alternatives that have the minimum conversion cost for a particular set of result types 101 101 std::map< std::string, PruneStruct > selected; … … 183 183 ) 184 184 AltList::iterator oldBegin = alternatives.begin(); 185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) , indexer);185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) ); 186 186 if ( alternatives.begin() == oldBegin ) { 187 187 std::ostringstream stream; … … 604 604 // ) 605 605 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 // ) 612 612 addToIndexer( have, decls ); 613 613 AssertionSet newNeed; … … 627 627 TypeEnvironment resultEnv; 628 628 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 629 630 AltList instantiatedActuals; // filled by instantiate function 630 631 if ( targetType && ! targetType->isVoid() && ! funcType->get_returnVals().empty() ) { … … 808 809 } 809 810 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 810 837 void AlternativeFinder::visit( CastExpr *castExpr ) { 811 838 Type *& toType = castExpr->get_result(); … … 839 866 thisCost += Cost( 0, 0, discardedValues ); 840 867 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 ) ); 865 869 } // if 866 870 } // for … … 1181 1185 } 1182 1186 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 } 1183 1234 } // namespace ResolvExpr 1184 1235 -
src/ResolvExpr/AlternativeFinder.h
r9c951e3 rb1e63ac5 73 73 virtual void visit( UniqueExpr *unqExpr ); 74 74 virtual void visit( StmtExpr *stmtExpr ); 75 virtual void visit( UntypedInitExpr *initExpr ); 75 76 /// Runs a new alternative finder on each element in [begin, end) 76 77 /// and writes each alternative finder to out. -
src/ResolvExpr/CastCost.cc
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CastCost.cc -- 7 // CastCost.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 public: 27 27 CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 28 28 29 29 virtual void visit( BasicType *basicType ); 30 30 virtual void visit( PointerType *pointerType ); … … 36 36 NamedTypeDecl *namedType; 37 37 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 } 39 43 } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) { 40 44 TypeDecl *type = dynamic_cast< TypeDecl* >( namedType ); -
src/ResolvExpr/CommonType.cc
r9c951e3 rb1e63ac5 43 43 44 44 void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer ); 45 template< typename RefType > void handleRefType( RefType *inst, Type *other );46 45 47 46 Type *result; … … 126 125 } 127 126 128 void CommonType::visit( VoidType *voidType ) { 129 } 127 void CommonType::visit( __attribute((unused)) VoidType *voidType ) {} 130 128 131 129 void CommonType::visit( BasicType *basicType ) { … … 159 157 void CommonType::visit( PointerType *pointerType ) { 160 158 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()) ) { 162 160 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()) ) { 164 162 getCommonWithVoidPointer( pointerType, otherPointer ); 165 163 } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst ) … … 189 187 } 190 188 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 ) {} 205 193 206 194 void CommonType::visit( EnumInstType *enumInstType ) { … … 214 202 } 215 203 216 void CommonType::visit( TraitInstType *aggregateUseType ) {204 void CommonType::visit( __attribute((unused)) TraitInstType *aggregateUseType ) { 217 205 } 218 206 … … 239 227 } 240 228 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 ) {} 246 231 247 232 void CommonType::visit( ZeroType *zeroType ) { -
src/ResolvExpr/ConversionCost.cc
r9c951e3 rb1e63ac5 30 30 /// std::cout << "type inst " << destAsTypeInst->get_name(); 31 31 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 } 33 37 } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) { 34 38 /// std::cout << " found" << std::endl; … … 145 149 }; 146 150 147 void ConversionCost::visit( VoidType *voidType) {151 void ConversionCost::visit( __attribute((unused)) VoidType *voidType ) { 148 152 cost = Cost::infinity; 149 153 } … … 182 186 } 183 187 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) {} 189 190 190 191 void ConversionCost::visit(StructInstType *inst) { … … 204 205 } 205 206 206 void ConversionCost::visit( EnumInstType *inst) {207 void ConversionCost::visit( __attribute((unused)) EnumInstType *inst ) { 207 208 static Type::Qualifiers q; 208 209 static BasicType integer( q, BasicType::SignedInt ); … … 213 214 } 214 215 215 void ConversionCost::visit( TraitInstType *inst) {216 void ConversionCost::visit( __attribute((unused)) TraitInstType *inst) { 216 217 } 217 218 … … 235 236 } 236 237 237 void ConversionCost::visit( TupleType *tupleType) {238 void ConversionCost::visit( __attribute((unused)) TupleType *tupleType) { 238 239 Cost c; 239 240 if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) { … … 255 256 } 256 257 257 void ConversionCost::visit( VarArgsType *varArgsType) {258 void ConversionCost::visit( __attribute((unused)) VarArgsType *varArgsType) { 258 259 if ( dynamic_cast< VarArgsType* >( dest ) ) { 259 260 cost = Cost::zero; … … 261 262 } 262 263 263 void ConversionCost::visit( ZeroType *zeroType) {264 void ConversionCost::visit( __attribute((unused)) ZeroType *zeroType) { 264 265 if ( dynamic_cast< ZeroType* >( dest ) ) { 265 266 cost = Cost::zero; … … 277 278 } 278 279 279 void ConversionCost::visit( OneType *oneType) {280 void ConversionCost::visit( __attribute((unused)) OneType *oneType) { 280 281 if ( dynamic_cast< OneType* >( dest ) ) { 281 282 cost = Cost::zero; -
src/ResolvExpr/PtrsAssignable.cc
r9c951e3 rb1e63ac5 63 63 } 64 64 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 ) {} 67 66 68 void PtrsAssignable::visit( VoidType *voidType ) {67 void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) { 69 68 if ( dynamic_cast< FunctionType* >( dest ) ) { 70 69 result = 0; … … 74 73 } 75 74 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 ) { 86 79 result = -1; 87 80 } 88 81 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 ) {} 96 84 97 85 void PtrsAssignable::visit( EnumInstType *inst ) { … … 103 91 } 104 92 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 ) {} 109 94 void PtrsAssignable::visit( TypeInstType *inst ) { 110 95 EqvClass eqvClass; … … 116 101 } 117 102 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 ) {} 151 107 152 108 } // namespace ResolvExpr -
src/ResolvExpr/PtrsCastable.cc
r9c951e3 rb1e63ac5 92 92 } 93 93 94 void PtrsCastable::visit( VoidType *voidType) {94 void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) { 95 95 result = objectCast( dest, env, indexer ); 96 96 } 97 97 98 void PtrsCastable::visit( BasicType *basicType) {98 void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) { 99 99 result = objectCast( dest, env, indexer ); 100 100 } 101 101 102 void PtrsCastable::visit( PointerType *pointerType) {102 void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) { 103 103 result = objectCast( dest, env, indexer ); 104 104 } 105 105 106 void PtrsCastable::visit( ArrayType *arrayType) {106 void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) { 107 107 result = objectCast( dest, env, indexer ); 108 108 } 109 109 110 void PtrsCastable::visit( FunctionType *functionType) {110 void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) { 111 111 // result = -1; 112 112 result = functionCast( dest, env, indexer ); 113 113 } 114 114 115 void PtrsCastable::visit( StructInstType *inst) {115 void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) { 116 116 result = objectCast( dest, env, indexer ); 117 117 } 118 118 119 void PtrsCastable::visit( UnionInstType *inst) {119 void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) { 120 120 result = objectCast( dest, env, indexer ); 121 121 } 122 122 123 void PtrsCastable::visit( EnumInstType *inst) {123 void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) { 124 124 if ( dynamic_cast< EnumInstType* >( dest ) ) { 125 125 result = 1; … … 135 135 } 136 136 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 ) {} 140 138 141 139 void PtrsCastable::visit(TypeInstType *inst) { … … 144 142 } 145 143 146 void PtrsCastable::visit( TupleType *tupleType) {144 void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) { 147 145 result = objectCast( dest, env, indexer ); 148 146 } 149 147 150 void PtrsCastable::visit( VarArgsType *varArgsType) {148 void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) { 151 149 result = objectCast( dest, env, indexer ); 152 150 } 153 151 154 void PtrsCastable::visit( ZeroType *zeroType) {152 void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) { 155 153 result = objectCast( dest, env, indexer ); 156 154 } 157 155 158 void PtrsCastable::visit( OneType *oneType) {156 void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) { 159 157 result = objectCast( dest, env, indexer ); 160 158 } -
src/ResolvExpr/Resolver.cc
r9c951e3 rb1e63ac5 14 14 // 15 15 16 #include <iostream> 17 18 #include "Alternative.h" 19 #include "AlternativeFinder.h" 20 #include "CurrentObject.h" 21 #include "RenameVars.h" 16 22 #include "Resolver.h" 17 #include "AlternativeFinder.h"18 #include "Alternative.h"19 #include "RenameVars.h"20 23 #include "ResolveTypeof.h" 21 24 #include "typeops.h" 25 26 #include "SynTree/Expression.h" 27 #include "SynTree/Initializer.h" 22 28 #include "SynTree/Statement.h" 23 29 #include "SynTree/Type.h" 24 #include "SynTree/Expression.h" 25 #include "Sy nTree/Initializer.h"30 31 #include "SymTab/Autogen.h" 26 32 #include "SymTab/Indexer.h" 27 #include "SymTab/Autogen.h" 33 28 34 #include "Common/utility.h" 35 29 36 #include "InitTweak/InitTweak.h" 30 37 31 #include <iostream>32 38 using namespace std; 33 39 … … 39 45 if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) { 40 46 functionReturn = res->functionReturn; 41 initContext = res->initContext;47 currentObject = res->currentObject; 42 48 inEnumDecl = res->inEnumDecl; 43 49 } … … 79 85 80 86 Type * functionReturn = nullptr; 81 Type *initContext = nullptr;87 CurrentObject currentObject = nullptr; 82 88 bool inEnumDecl = false; 83 89 }; … … 124 130 } // if 125 131 #endif 126 assert ( finder.get_alternatives().size() == 1);132 assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." ); 127 133 Alternative &choice = finder.get_alternatives().front(); 128 134 Expression *newExpr = choice.expr->clone(); … … 186 192 // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting 187 193 // 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() ) ) { 191 197 // enumerator initializers should not use the enum type to initialize, since 192 198 // 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 ) ); 194 200 } 195 201 Parent::visit( objectDecl ); 196 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext) ) {202 if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) { 197 203 // delete newly created signed int type 198 delete initContext; 199 } 200 initContext = temp; 204 // delete currentObject.getType(); 205 } 201 206 } 202 207 … … 315 320 316 321 void Resolver::visit( SwitchStmt *switchStmt ) { 317 ValueGuard< Type * > oldInitContext( initContext );322 ValueGuard< CurrentObject > oldCurrentObject( currentObject ); 318 323 Expression *newExpr; 319 324 newExpr = findIntegralExpression( switchStmt->get_condition(), *this ); … … 321 326 switchStmt->set_condition( newExpr ); 322 327 323 initContext = newExpr->get_result();328 currentObject = CurrentObject( newExpr->get_result() ); 324 329 Parent::visit( switchStmt ); 325 330 } … … 327 332 void Resolver::visit( CaseStmt *caseStmt ) { 328 333 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() ); 331 337 Expression * newExpr = findSingleExpression( castExpr, *this ); 332 338 castExpr = safe_dynamic_cast< CastExpr * >( newExpr ); … … 370 376 371 377 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; 419 407 } 420 408 } 421 409 } 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(); 486 417 } 487 418 488 419 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 { 573 449 } 574 450 -
src/ResolvExpr/TypeMap.h
r9c951e3 rb1e63ac5 110 110 } 111 111 112 virtual void visit( VoidType *voidType ) {112 virtual void visit( __attribute__((unused)) VoidType *voidType ) { 113 113 findAndReplace( typeMap.voidValue ); 114 114 } … … 138 138 } 139 139 140 virtual void visit( FunctionType *functionType ) {140 virtual void visit( __attribute__((unused)) FunctionType *functionType ) { 141 141 findAndReplace( typeMap.functionPointerValue ); 142 142 } -
src/ResolvExpr/Unify.cc
r9c951e3 rb1e63ac5 115 115 } 116 116 117 bool isFtype( Type *type , const SymTab::Indexer &indexer) {117 bool isFtype( Type *type ) { 118 118 if ( dynamic_cast< FunctionType* >( type ) ) { 119 119 return true; … … 124 124 } 125 125 126 bool tyVarCompatible( const TypeDecl::Data & data, Type *type , const SymTab::Indexer &indexer) {126 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 127 127 switch ( data.kind ) { 128 128 case TypeDecl::Any: … … 132 132 // type must also be complete 133 133 // 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() ); 135 135 case TypeDecl::Ftype: 136 return isFtype( type , indexer);136 return isFtype( type ); 137 137 case TypeDecl::Ttype: 138 138 // ttype unifies with any tuple type … … 145 145 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 146 146 assert( tyvar != openVars.end() ); 147 if ( ! tyVarCompatible( tyvar->second, other , indexer) ) {147 if ( ! tyVarCompatible( tyvar->second, other ) ) { 148 148 return false; 149 149 } // if … … 345 345 std::cerr << "unifyInexact type 1 is "; 346 346 type1->print( std::cerr ); 347 std::cerr << " type 2 is ";347 std::cerr << " type 2 is "; 348 348 type2->print( std::cerr ); 349 349 std::cerr << std::endl; … … 389 389 } 390 390 391 void Unify::visit( VoidType *voidType) {391 void Unify::visit( __attribute__((unused)) VoidType *voidType) { 392 392 result = dynamic_cast< VoidType* >( type2 ); 393 393 } … … 615 615 } else if ( tupleParam ) { 616 616 // bundle other parameters into tuple to match 617 TupleType* binder = new TupleType{ paramTy->get_qualifiers() };617 std::list< Type * > binderTypes; 618 618 619 619 do { 620 binder ->get_types().push_back( otherParam->get_type()->clone() );620 binderTypes.push_back( otherParam->get_type()->clone() ); 621 621 ++jt; 622 622 … … 627 627 } while (true); 628 628 629 otherParamTy = binder;629 otherParamTy = new TupleType{ paramTy->get_qualifiers(), binderTypes }; 630 630 ++it; // skip ttype parameter for break 631 631 } else if ( otherTupleParam ) { 632 632 // bundle parameters into tuple to match other 633 TupleType* binder = new TupleType{ otherParamTy->get_qualifiers() };633 std::list< Type * > binderTypes; 634 634 635 635 do { 636 binder ->get_types().push_back( param->get_type()->clone() );636 binderTypes.push_back( param->get_type()->clone() ); 637 637 ++it; 638 638 … … 643 643 } while (true); 644 644 645 paramTy = binder;645 paramTy = new TupleType{ otherParamTy->get_qualifiers(), binderTypes }; 646 646 ++jt; // skip ttype parameter for break 647 647 } … … 692 692 693 693 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 ) { 695 695 auto get_type = [](Type * t) { return t; }; 696 696 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { … … 742 742 flatten( flat2.get(), back_inserter( types2 ) ); 743 743 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 ) { 749 749 result = dynamic_cast< VarArgsType* >( type2 ); 750 750 } 751 751 752 void Unify::visit( ZeroType *zeroType) {752 void Unify::visit( __attribute__((unused)) ZeroType *zeroType ) { 753 753 result = dynamic_cast< ZeroType* >( type2 ); 754 754 } 755 755 756 void Unify::visit( OneType *oneType) {756 void Unify::visit( __attribute__((unused)) OneType *oneType ) { 757 757 result = dynamic_cast< OneType* >( type2 ); 758 758 } … … 765 765 return function->get_returnVals().front()->get_type()->clone(); 766 766 } else { 767 TupleType * tupleType = new TupleType( Type::Qualifiers() );767 std::list< Type * > types; 768 768 for ( DeclarationWithType * decl : function->get_returnVals() ) { 769 t upleType->get_types().push_back( decl->get_type()->clone() );769 types.push_back( decl->get_type()->clone() ); 770 770 } // for 771 return tupleType;771 return new TupleType( Type::Qualifiers(), types ); 772 772 } 773 773 } -
src/ResolvExpr/module.mk
r9c951e3 rb1e63ac5 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 31 31 ResolvExpr/PolyCost.cc \ 32 32 ResolvExpr/Occurs.cc \ 33 ResolvExpr/TypeEnvironment.cc 33 ResolvExpr/TypeEnvironment.cc \ 34 ResolvExpr/CurrentObject.cc -
src/ResolvExpr/typeops.h
r9c951e3 rb1e63ac5 118 118 119 119 // in Unify.cc 120 bool isFtype( Type *type , const SymTab::Indexer &indexer);120 bool isFtype( Type *type ); 121 121 bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 122 122 bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); … … 130 130 TypeEnvironment env; 131 131 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 } // if142 }143 return ( i1 == c1.end() ) && ( i2 == c2.end() );144 132 } 145 133 -
src/SymTab/Autogen.cc
r9c951e3 rb1e63ac5 9 9 // Author : Rob Schluntz 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 09:41:08201713 // Update Count : 6 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:30:00 2017 13 // Update Count : 61 14 14 // 15 15 … … 263 263 // E ?=?(E volatile*, int), 264 264 // ?=?(E _Atomic volatile*, int); 265 void makeEnumFunctions( Enum Decl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {265 void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 266 266 267 267 // T ?=?(E *, E); … … 401 401 /// generates struct constructors, destructor, and assignment functions 402 402 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 403 409 // Make function polymorphic in same parameters as generic struct, if applicable 404 410 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions … … 487 493 488 494 /// generates the body of a union assignment/copy constructor/field constructor 489 void makeUnionAssignBody( FunctionDecl * funcDecl , bool isDynamicLayout) {495 void makeUnionAssignBody( FunctionDecl * funcDecl ) { 490 496 FunctionType * ftype = funcDecl->get_functionType(); 491 497 assert( ftype->get_parameters().size() == 2 ); … … 507 513 // Make function polymorphic in same parameters as generic union, if applicable 508 514 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 511 516 // default ctor/dtor need only first parameter 512 517 // void ?{}(T *); void ^?{}(T *); … … 534 539 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 535 540 536 makeUnionAssignBody( assignDecl , isDynamicLayout);541 makeUnionAssignBody( assignDecl ); 537 542 538 543 // body of assignment and copy ctor is the same 539 makeUnionAssignBody( copyCtorDecl , isDynamicLayout);544 makeUnionAssignBody( copyCtorDecl ); 540 545 541 546 // create a constructor which takes the first member type as a parameter. … … 552 557 FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting ); 553 558 554 makeUnionAssignBody( ctor , isDynamicLayout);559 makeUnionAssignBody( ctor ); 555 560 memCtors.push_back( ctor ); 556 561 // only generate a ctor for the first field … … 579 584 EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() ); 580 585 // enumInst->set_baseEnum( enumDecl ); 581 makeEnumFunctions( enum Decl, enumInst, functionNesting, declsToAddAfter );586 makeEnumFunctions( enumInst, functionNesting, declsToAddAfter ); 582 587 } 583 588 } -
src/SymTab/Autogen.h
r9c951e3 rb1e63ac5 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:10:41201713 // Update Count : 912 // Last Modified On : Wed Jun 21 17:25:26 2017 13 // Update Count : 14 14 14 // 15 15 … … 43 43 template< typename OutputIterator > 44 44 Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) { 45 46 47 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 ) ); 48 48 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 ); 66 65 67 66 Statement * listInit = srcParam.buildListInit( fExpr ); 68 67 69 70 68 std::list< Expression * > args = *++srcParam; 69 fExpr->get_args().splice( fExpr->get_args().end(), args ); 71 70 72 71 *out++ = new ExprStmt( noLabels, fExpr ); 73 72 74 73 srcParam.clearArrayIndices(); 75 74 76 75 return listInit; 77 76 } 78 77 … … 88 87 Expression * begin, * end, * update, * cmp; 89 88 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 ) ); 92 91 end = array->get_dimension()->clone(); 93 92 cmp = new NameExpr( "?<?" ); … … 97 96 begin = new UntypedExpr( new NameExpr( "?-?" ) ); 98 97 ((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 ) ); 101 100 cmp = new NameExpr( "?>=?" ); 102 101 update = new NameExpr( "--?" ); 103 102 } 104 103 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 ) ); 106 105 107 106 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/FixFunction.cc
r9c951e3 rb1e63ac5 24 24 25 25 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() ); 27 27 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() ); 28 30 delete functionDecl; 29 31 return pointer; -
src/SymTab/ImplementationType.cc
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ImplementationType.cc -- 7 // ImplementationType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 61 61 } 62 62 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 ) {} 68 65 69 66 void ImplementationType::visit(PointerType *pointerType) { … … 79 76 } 80 77 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 ) {} 102 83 103 84 void ImplementationType::visit(TypeInstType *inst) { … … 111 92 112 93 void ImplementationType::visit(TupleType *tupleType) { 113 TupleType *newType = new TupleType( Type::Qualifiers() );94 std::list< Type * > types; 114 95 for ( std::list< Type* >::iterator i = tupleType->get_types().begin(); i != tupleType->get_types().end(); ++i ) { 115 96 Type *implType = implementationType( *i, indexer ); 116 97 implType->get_qualifiers() |= tupleType->get_qualifiers(); 117 newType->get_types().push_back( implType );98 types.push_back( implType ); 118 99 } // for 119 result = new Type;100 result = new TupleType( Type::Qualifiers(), types ); 120 101 } 121 102 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 ) {} 130 106 } // namespace SymTab 131 107 -
src/SymTab/Indexer.cc
r9c951e3 rb1e63ac5 124 124 }; 125 125 // 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 130 131 std::list< DeclBall > decls; 131 132 … … 138 139 bool isCopyFunc = InitTweak::isCopyFunction( function, function->get_name() ); 139 140 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); 144 146 return *this; 145 147 } … … 164 166 } 165 167 166 // if a type contains user defined ctor/dtor s, then special rules trigger, which determine167 // the set of ctor/dtor sthat are seen by the requester. In particular, if the user defines168 // 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 168 170 // a default ctor, then the generated default ctor should never be seen, likewise for copy ctor 169 171 // 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). 171 174 for ( std::pair< const std::string, ValueType > & pair : funcMap ) { 172 175 ValueType & val = pair.second; 173 176 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 ) { 175 183 // decl conforms to the rules described above, so it should be seen by the requester 176 184 out.push_back( ball.decl ); … … 278 286 addType( typeDecl ); 279 287 acceptAll( typeDecl->get_assertions(), *this ); 288 acceptNewScope( typeDecl->get_init(), *this ); 280 289 } 281 290 … … 487 496 } 488 497 489 void Indexer::visit( UntypedValofExpr *valofExpr ) {490 acceptNewScope( valofExpr->get_result(), *this );491 maybeAccept( valofExpr->get_body(), *this );492 }493 494 498 void Indexer::visit( RangeExpr *rangeExpr ) { 495 499 maybeAccept( rangeExpr->get_low(), *this ); … … 510 514 acceptNewScope( tupleExpr->get_result(), *this ); 511 515 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 );518 516 } 519 517 -
src/SymTab/Indexer.h
r9c951e3 rb1e63ac5 69 69 virtual void visit( ConstructorExpr * ctorExpr ); 70 70 virtual void visit( CompoundLiteralExpr *compLitExpr ); 71 virtual void visit( UntypedValofExpr *valofExpr );72 71 virtual void visit( RangeExpr *rangeExpr ); 73 72 virtual void visit( UntypedTupleExpr *tupleExpr ); 74 73 virtual void visit( TupleExpr *tupleExpr ); 75 74 virtual void visit( TupleIndexExpr *tupleExpr ); 76 virtual void visit( MemberTupleExpr *tupleExpr );77 75 virtual void visit( TupleAssignExpr *tupleExpr ); 78 76 virtual void visit( StmtExpr * stmtExpr ); -
src/SymTab/Mangler.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:40:29 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 09:40:01201713 // Update Count : 2 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:31:00 2017 13 // Update Count : 21 14 14 // 15 15 … … 72 72 } else { 73 73 // if we add another kind of overridable function, this has to change 74 assert( false );74 assert( false && "unknown overrideable linkage" ); 75 75 } // if 76 76 } … … 236 236 } 237 237 238 void Mangler::visit( ZeroType *zeroType ) {238 void Mangler::visit( __attribute__((unused)) ZeroType *zeroType ) { 239 239 mangleName << "Z"; 240 240 } 241 241 242 void Mangler::visit( OneType *oneType ) {242 void Mangler::visit( __attribute__((unused)) OneType *oneType ) { 243 243 mangleName << "O"; 244 244 } -
src/SymTab/Validate.cc
r9c951e3 rb1e63ac5 38 38 // definition occurs later in the input. 39 39 40 #include <algorithm> 41 #include <iterator> 40 42 #include <list> 41 #include <iterator> 43 44 #include "CodeGen/CodeGenerator.h" 45 46 #include "Common/PassVisitor.h" 42 47 #include "Common/ScopedMap.h" 48 #include "Common/UniqueName.h" 43 49 #include "Common/utility.h" 44 #include "Common/UniqueName.h" 50 45 51 #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" 54 59 #include "FixFunction.h" 55 60 // #include "ImplementationType.h" 56 #include "GenPoly/DeclMutator.h" 57 #include "AddVisit.h" 61 #include "Indexer.h" 58 62 #include "MakeLibCfa.h" 59 63 #include "TypeEquality.h" 60 #include "Autogen.h" 64 #include "Validate.h" 65 61 66 #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" 65 75 66 76 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 96 106 97 107 /// 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 { 103 109 static void fix( std::list< Declaration * > &translationUnit ); 104 110 105 v irtual voidvisit( FunctionDecl * functionDecl );106 v irtual voidvisit( FunctionType * ftype );111 void postvisit( FunctionDecl * functionDecl ); 112 void postvisit( FunctionType * ftype ); 107 113 }; 108 114 109 115 /// 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 ); 114 119 }; 115 120 … … 119 124 public: 120 125 LinkReferenceToTypes( bool doDebug, const Indexer *indexer ); 121 private:122 126 using Parent::visit; 123 127 void visit( EnumInstType *enumInst ) final; … … 129 133 void visit( UnionDecl *unionDecl ) final; 130 134 void visit( TypeInstType *typeInst ) final; 131 135 private: 132 136 const Indexer *indexer; 133 137 … … 140 144 }; 141 145 142 /// Replaces array and function types in forall lists by appropriate pointer type 143 class Pass3final : 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 { 144 148 typedef Indexer Parent; 145 149 public: 146 150 using Parent::visit; 147 Pass3( const Indexer *indexer );148 private: 151 ForallPointerDecay( const Indexer *indexer ); 152 149 153 virtual void visit( ObjectDecl *object ) override; 150 154 virtual void visit( FunctionDecl *func ) override; … … 153 157 }; 154 158 155 class ReturnChecker : public Visitor { 156 public: 159 struct ReturnChecker : public WithGuards { 157 160 /// Checks that return statements return nothing if their return type is void 158 161 /// and return something if the return type is non-void. 159 162 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; 165 169 }; 166 170 … … 198 202 }; 199 203 200 class VerifyCtorDtorAssign : public Visitor { 201 public: 204 struct VerifyCtorDtorAssign { 202 205 /// ensure that constructors, destructors, and assignment have at least one 203 206 /// parameter, the first of which must be a pointer, and that ctor/dtors have no … … 205 208 static void verify( std::list< Declaration * > &translationUnit ); 206 209 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 { 212 220 /// for array types without an explicit length, compute the length and store it so that it 213 221 /// is known to the rest of the phases. For example, … … 219 227 static void computeLength( std::list< Declaration * > & translationUnit ); 220 228 221 v irtual voidvisit( 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> { 225 233 Type::StorageClasses storageClasses; 226 234 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 ); 230 237 }; 231 238 232 239 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 233 EnumAndPointerDecayPassepc;240 PassVisitor<EnumAndPointerDecay> epc; 234 241 LinkReferenceToTypes lrt( doDebug, 0 ); 235 Pass3 pass3( 0 );236 CompoundLiteralcompoundliteral;237 238 HoistStruct::hoistStruct( translationUnit ); 242 ForallPointerDecay fpd( 0 ); 243 PassVisitor<CompoundLiteral> compoundliteral; 244 PassVisitor<ValidateGenericParameters> genericParams; 245 239 246 EliminateTypedef::eliminateTypedef( translationUnit ); 247 HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order 240 248 ReturnTypeFixer::fix( translationUnit ); // must happen before autogen 241 249 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 242 251 acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist 243 252 VerifyCtorDtorAssign::verify( translationUnit ); // must happen before autogen, because autogen examines existing ctor/dtors 244 253 Concurrency::applyKeywords( translationUnit ); 245 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay Pass254 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay 246 255 Concurrency::implementMutexFuncs( translationUnit ); 247 256 Concurrency::implementThreadStarter( translationUnit ); 248 257 ReturnChecker::checkFunctionReturns( translationUnit ); 249 compoundliteral.mutateDeclarationList( translationUnit);250 acceptAll( translationUnit, pass3);258 mutateAll( translationUnit, compoundliteral ); 259 acceptAll( translationUnit, fpd ); 251 260 ArrayLength::computeLength( translationUnit ); 252 261 } 253 262 254 263 void validateType( Type *type, const Indexer *indexer ) { 255 EnumAndPointerDecayPassepc;264 PassVisitor<EnumAndPointerDecay> epc; 256 265 LinkReferenceToTypes lrt( false, indexer ); 257 Pass3 pass3( indexer );266 ForallPointerDecay fpd( indexer ); 258 267 type->accept( epc ); 259 268 type->accept( lrt ); 260 type->accept( pass3);269 type->accept( fpd ); 261 270 } 262 271 … … 337 346 } 338 347 339 void EnumAndPointerDecay Pass::visit( EnumDecl *enumDecl ) {348 void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) { 340 349 // Set the type of each member of the enumeration to be EnumConstant 341 350 for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) { … … 344 353 obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) ); 345 354 } // for 346 Parent::visit( enumDecl );347 355 } 348 356 … … 351 359 void fixFunctionList( DWTList & dwts, FunctionType * func ) { 352 360 // 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 class361 // entirely. other fix ups are handled by the FixFunction class 354 362 typedef typename DWTList::iterator DWTIterator; 355 363 DWTIterator begin( dwts.begin() ), end( dwts.end() ); … … 370 378 for ( ; i != end; ++i ) { 371 379 FixFunction fixer; 372 *i = (*i 380 *i = (*i)->acceptMutator( fixer ); 373 381 if ( fixer.get_isVoid() ) { 374 382 throw SemanticError( "invalid type void in function type ", func ); … … 379 387 } 380 388 381 void EnumAndPointerDecay Pass::visit( FunctionType *func ) {389 void EnumAndPointerDecay::previsit( FunctionType *func ) { 382 390 // Fix up parameters and return types 383 391 fixFunctionList( func->get_parameters(), func ); 384 392 fixFunctionList( func->get_returnVals(), func ); 385 Visitor::visit( func );386 393 } 387 394 … … 496 503 void LinkReferenceToTypes::visit( StructDecl *structDecl ) { 497 504 // 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) 498 506 Parent::visit( structDecl ); 499 507 if ( ! structDecl->get_members().empty() ) { … … 529 537 } 530 538 531 Pass3::Pass3( const Indexer *other_indexer ) : Indexer( false ) {539 ForallPointerDecay::ForallPointerDecay( const Indexer *other_indexer ) : Indexer( false ) { 532 540 if ( other_indexer ) { 533 541 indexer = other_indexer; … … 567 575 } 568 576 569 void Pass3::visit( ObjectDecl *object ) {577 void ForallPointerDecay::visit( ObjectDecl *object ) { 570 578 forallFixer( object->get_type() ); 571 579 if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) { … … 576 584 } 577 585 578 void Pass3::visit( FunctionDecl *func ) {586 void ForallPointerDecay::visit( FunctionDecl *func ) { 579 587 forallFixer( func->get_type() ); 580 588 Parent::visit( func ); … … 583 591 584 592 void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) { 585 ReturnCheckerchecker;593 PassVisitor<ReturnChecker> checker; 586 594 acceptAll( translationUnit, checker ); 587 595 } 588 596 589 void ReturnChecker:: visit( FunctionDecl * functionDecl ) {590 std::list< DeclarationWithType * > oldReturnVals = returnVals;597 void ReturnChecker::previsit( FunctionDecl * functionDecl ) { 598 GuardValue( returnVals ); 591 599 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 ) { 597 603 // Previously this also checked for the existence of an expr paired with no return values on 598 604 // the function return type. This is incorrect, since you can have an expression attached to … … 804 810 805 811 void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) { 806 VerifyCtorDtorAssignverifier;812 PassVisitor<VerifyCtorDtorAssign> verifier; 807 813 acceptAll( translationUnit, verifier ); 808 814 } 809 815 810 void VerifyCtorDtorAssign:: visit( FunctionDecl * funcDecl ) {816 void VerifyCtorDtorAssign::previsit( FunctionDecl * funcDecl ) { 811 817 FunctionType * funcType = funcDecl->get_functionType(); 812 818 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); … … 826 832 } 827 833 } 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 ) { 833 880 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 ) { 839 884 // transform [storage_class] ... (struct S){ 3, ... }; 840 885 // into [storage_class] struct S temp = { 3, ... }; 841 886 static UniqueName indexName( "_compLit" ); 842 887 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 ); 846 891 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 ); 850 894 } 851 895 852 896 void ReturnTypeFixer::fix( std::list< Declaration * > &translationUnit ) { 853 ReturnTypeFixerfixer;897 PassVisitor<ReturnTypeFixer> fixer; 854 898 acceptAll( translationUnit, fixer ); 855 899 } 856 900 857 void ReturnTypeFixer::visit( FunctionDecl * functionDecl ) { 858 Parent::visit( functionDecl ); 901 void ReturnTypeFixer::postvisit( FunctionDecl * functionDecl ) { 859 902 FunctionType * ftype = functionDecl->get_functionType(); 860 903 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); … … 867 910 ret->set_name( toString( "_retval_", CodeGen::genName( functionDecl ) ) ); 868 911 } 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 ) { 873 917 // xxx - need to handle named return values - this information needs to be saved somehow 874 918 // so that resolution has access to the names. … … 888 932 889 933 void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) { 890 ArrayLengthlen;934 PassVisitor<ArrayLength> len; 891 935 acceptAll( translationUnit, len ); 892 936 } 893 937 894 void ArrayLength:: visit( ObjectDecl * objDecl ) {938 void ArrayLength::previsit( ObjectDecl * objDecl ) { 895 939 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) { 896 940 if ( at->get_dimension() != nullptr ) return; -
src/SynTree/AggregateDecl.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 23:56:39 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Mar 16 07:49:07201713 // Update Count : 2 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jun 27 15:30:00 2017 13 // Update Count : 21 14 14 // 15 15 … … 20 20 21 21 22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall), body( false ), attributes( attributes ) {22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) { 23 23 } 24 24 -
src/SynTree/Attribute.h
r9c951e3 rb1e63ac5 40 40 }; 41 41 42 const std::list< Attribute * > noAttributes; 43 42 44 #endif 43 45 -
src/SynTree/BaseSyntaxNode.h
r9c951e3 rb1e63ac5 24 24 CodeLocation location; 25 25 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; 27 29 }; 28 30 -
src/SynTree/Constant.cc
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Constant.cc -- 7 // Constant.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Th u Jul 30 15:18:38 201513 // Update Count : 1211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jun 22 10:11:00 2017 13 // Update Count : 28 14 14 // 15 15 … … 21 21 #include "Type.h" 22 22 23 Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {} 23 Constant::Constant( Type * type, std::string rep, unsigned long long val ) : type( type ), rep( rep ), val( val ) {} 24 Constant::Constant( Type * type, std::string rep, double val ) : type( type ), rep( rep ), val( val ) {} 24 25 25 Constant::Constant( const Constant &other ) {26 Constant::Constant( const Constant &other ) : rep( other.rep ), val( other.val ) { 26 27 type = other.type->clone(); 27 value = other.value;28 28 } 29 29 30 30 Constant::~Constant() { delete type; } 31 31 32 Constant Constant::from_bool( bool b ) { 33 return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b ); 34 } 35 32 36 Constant 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 ); 34 38 } 35 39 36 40 Constant 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 ); 38 42 } 39 43 40 44 Constant 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 ); 42 46 } 43 47 44 Constant *Constant::clone() const { assert( false ); return 0; } 48 unsigned 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 53 double Constant::get_dval() const { 54 assertf( ! safe_dynamic_cast<BasicType*>(type)->isInteger(), "Attempt to retrieve dval from integer constant." ); 55 return val.dval; 56 } 45 57 46 58 void Constant::print( std::ostream &os ) const { 47 os << "(" << value;59 os << "(" << rep << " " << val.ival; 48 60 if ( type ) { 49 61 os << ": "; -
src/SynTree/Constant.h
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Constant.h -- 7 // Constant.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Th u Jun 30 13:33:17 201613 // Update Count : 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jun 22 10:13:00 2017 13 // Update Count : 15 14 14 // 15 15 … … 23 23 class Constant { 24 24 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 ); 27 28 virtual ~Constant(); 28 29 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; 33 36 37 /// generates a boolean constant of the given bool 38 static Constant from_bool( bool b ); 34 39 /// generates an integer constant of the given int 35 40 static Constant from_int( int i ); … … 39 44 static Constant from_double( double d ); 40 45 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; 45 49 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; 48 58 }; 49 59 -
src/SynTree/Declaration.h
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 16:05:08201713 // Update Count : 12 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jun 27 15:31:00 2017 13 // Update Count : 122 14 14 // 15 15 … … 194 194 }; 195 195 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 ); 197 197 TypeDecl( const TypeDecl &other ); 198 virtual ~TypeDecl(); 198 199 199 200 Kind get_kind() const { return kind; } 201 202 Type * get_init() const { return init; } 203 TypeDecl * set_init( Type * newValue ) { init = newValue; return this; } 200 204 201 205 bool isComplete() const { return kind == Any || sized; } … … 209 213 virtual void accept( Visitor &v ) { v.visit( this ); } 210 214 virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); } 215 virtual void print( std::ostream &os, int indent = 0 ) const; 216 211 217 private: 212 218 Kind kind; 219 Type * init; 213 220 bool sized; 214 221 }; … … 231 238 typedef Declaration Parent; 232 239 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 ); 234 241 AggregateDecl( const AggregateDecl &other ); 235 242 virtual ~AggregateDecl(); … … 259 266 typedef AggregateDecl Parent; 260 267 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 ) {} 262 269 StructDecl( const StructDecl &other ) : Parent( other ) {} 263 270 … … 277 284 typedef AggregateDecl Parent; 278 285 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 ) {} 280 287 UnionDecl( const UnionDecl &other ) : Parent( other ) {} 281 288 … … 290 297 typedef AggregateDecl Parent; 291 298 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 ) {} 293 300 EnumDecl( const EnumDecl &other ) : Parent( other ) {} 294 301 -
src/SynTree/Expression.cc
r9c951e3 rb1e63ac5 21 21 #include <iterator> 22 22 23 #include "Declaration.h" 24 #include "Expression.h" 25 #include "Initializer.h" 26 #include "Statement.h" 23 27 #include "Type.h" 24 #include "Initializer.h"25 #include "Expression.h"26 #include "Declaration.h"27 #include "Statement.h"28 28 #include "TypeSubstitution.h" 29 #include "VarExprReplacer.h" 30 29 31 #include "Common/utility.h" 32 #include "Common/PassVisitor.h" 33 30 34 #include "InitTweak/InitTweak.h" 31 35 … … 92 96 93 97 Declaration *decl = get_var(); 94 // if ( decl != 0) decl->print(os, indent + 2);95 98 if ( decl != 0) decl->printShort(os, indent + 2); 96 99 os << std::endl; … … 287 290 delete arg; 288 291 } 289 290 // CastExpr *CastExpr::clone() const { return 0; }291 292 292 293 void CastExpr::print( std::ostream &os, int indent ) const { … … 355 356 } 356 357 357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...358 358 MemberExpr::MemberExpr( const MemberExpr &other ) : 359 359 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { … … 361 361 362 362 MemberExpr::~MemberExpr() { 363 // d elete member;363 // don't delete the member declaration, since it points somewhere else in the tree 364 364 delete aggregate; 365 365 } … … 591 591 } 592 592 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 603 593 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 604 594 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} … … 670 660 } 671 661 662 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {} 663 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {} 664 InitAlternative::~InitAlternative() { 665 delete type; 666 delete designation; 667 } 668 669 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 670 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 671 UntypedInitExpr::~UntypedInitExpr() { 672 delete expr; 673 } 674 675 void 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 687 InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) { 688 set_result( expr->get_result()->clone() ); 689 } 690 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {} 691 InitExpr::~InitExpr() { 692 delete expr; 693 delete designation; 694 } 695 696 void 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 672 704 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 673 705 if ( expr ) { -
src/SynTree/Expression.h
r9c951e3 rb1e63ac5 226 226 }; 227 227 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. 229 230 class MemberExpr : public Expression { 230 231 public: … … 247 248 }; 248 249 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. 250 252 class VariableExpr : public Expression { 251 253 public: … … 598 600 }; 599 601 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 618 602 /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' 619 603 class RangeExpr : public Expression { … … 688 672 Expression * tuple; 689 673 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 analyzer693 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;711 674 }; 712 675 … … 781 744 }; 782 745 746 struct InitAlternative { 747 public: 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 756 class UntypedInitExpr : public Expression { 757 public: 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; 771 private: 772 Expression * expr; 773 std::list<InitAlternative> initAlts; 774 }; 775 776 class InitExpr : public Expression { 777 public: 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; 792 private: 793 Expression * expr; 794 Designation * designation; 795 }; 796 797 783 798 std::ostream & operator<<( std::ostream & out, const Expression * expr ); 784 799 -
src/SynTree/Initializer.cc
r9c951e3 rb1e63ac5 19 19 #include "Common/utility.h" 20 20 21 Designation::Designation( const std::list< Expression * > & designators ) : designators( designators ) {} 22 Designation::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 28 Designation::~Designation() { 29 // std::cerr << "destroying designation" << std::endl; 30 deleteAll( designators ); 31 // std::cerr << "finished destroying designation" << std::endl; 32 } 33 34 void 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 21 45 Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {} 22 46 Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ), maybeConstructed( other.maybeConstructed ) { 23 47 } 24 25 26 48 Initializer::~Initializer() {} 27 49 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 ) { 50 SingleInit::SingleInit( Expression *v, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ) { 38 51 } 39 52 40 53 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) { 41 cloneAll(other.designators, designators );42 54 } 43 55 44 56 SingleInit::~SingleInit() { 45 57 delete value; 46 deleteAll(designators);47 58 } 48 59 49 void SingleInit::print( std::ostream &os, int indent ) {50 os << std:: endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;60 void SingleInit::print( std::ostream &os, int indent ) const { 61 os << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl; 51 62 os << std::string(indent+4, ' ' ); 52 63 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 } // if61 64 } 62 65 63 ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed ) 64 : Initializer( maybeConstructed ), initializers( _initializers ), designators( _designators ) { 66 67 ListInit::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() ); 65 77 } 66 78 67 79 ListInit::ListInit( const ListInit & other ) : Initializer( other ) { 68 80 cloneAll( other.initializers, initializers ); 69 cloneAll( other.designat ors, designators );81 cloneAll( other.designations, designations ); 70 82 } 71 72 83 73 84 ListInit::~ListInit() { 74 85 deleteAll( initializers ); 75 deleteAll( designat ors );86 deleteAll( designations ); 76 87 } 77 88 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 89 void 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 } 86 94 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 } 92 99 } 93 100 … … 103 110 } 104 111 105 void ConstructorInit::print( std::ostream &os, int indent ) {112 void ConstructorInit::print( std::ostream &os, int indent ) const { 106 113 os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl; 107 114 if ( ctor ) { … … 124 131 } 125 132 126 std::ostream & operator<<( std::ostream & out, Initializer * init ) { 127 init->print( out ); 133 std::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 142 std::ostream & operator<<( std::ostream & out, const Designation * des ) { 143 if ( des ) { 144 des->print( out ); 145 } else { 146 out << "nullptr"; 147 } 128 148 return out; 129 149 } -
src/SynTree/Initializer.h
r9c951e3 rb1e63ac5 25 25 #include "Visitor.h" 26 26 27 const std::list<Expression*> noDesignators; 27 // Designation: list of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an object being initialized. 28 class Designation : public BaseSyntaxNode { 29 public: 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; 40 private: 41 std::list< Expression * > designators; 42 }; 43 44 const std::list<Designation *> noDesignators; 28 45 29 46 // Initializer: base class for object initializers (provide default values) 30 47 class Initializer : public BaseSyntaxNode { 31 48 public: 32 // Initializer( std::string _name = std::string(""), int _pos = 0 );33 49 Initializer( bool maybeConstructed ); 34 50 Initializer( const Initializer & other ); 35 51 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 reached48 }49 52 50 53 bool get_maybeConstructed() { return maybeConstructed; } … … 53 56 virtual void accept( Visitor &v ) = 0; 54 57 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; 56 59 private: 57 // std::string name;58 // int pos;59 60 bool maybeConstructed; 60 61 }; … … 63 64 class SingleInit : public Initializer { 64 65 public: 65 SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(),bool maybeConstructed = false );66 SingleInit( Expression *value, bool maybeConstructed = false ); 66 67 SingleInit( const SingleInit &other ); 67 68 virtual ~SingleInit(); … … 70 71 void set_value( Expression *newValue ) { value = newValue; } 71 72 72 std::list<Expression *> &get_designators() { return designators; }73 void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }74 75 73 virtual SingleInit *clone() const { return new SingleInit( *this); } 76 74 virtual void accept( Visitor &v ) { v.visit( this ); } 77 75 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; 79 77 private: 80 78 //Constant *value; 81 79 Expression *value; // has to be a compile-time constant 82 std::list< Expression * > designators;83 80 }; 84 81 … … 88 85 public: 89 86 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 ); 91 88 ListInit( const ListInit & other ); 92 89 virtual ~ListInit(); 93 90 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; } 98 93 99 94 typedef std::list<Initializer*>::iterator iterator; 95 typedef std::list<Initializer*>::const_iterator const_iterator; 100 96 iterator begin() { return initializers.begin(); } 101 97 iterator end() { return initializers.end(); } 98 const_iterator begin() const { return initializers.begin(); } 99 const_iterator end() const { return initializers.end(); } 102 100 103 101 virtual ListInit *clone() const { return new ListInit( *this ); } 104 102 virtual void accept( Visitor &v ) { v.visit( this ); } 105 103 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; 107 105 private: 108 std::list<Initializer *> initializers; // order *is* important109 std::list< Expression *> designators;106 std::list<Initializer *> initializers; // order *is* important 107 std::list<Designation *> designations; // order/length is consistent with initializers 110 108 }; 111 109 … … 130 128 virtual void accept( Visitor &v ) { v.visit( this ); } 131 129 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; 133 131 134 132 private: … … 140 138 }; 141 139 142 std::ostream & operator<<( std::ostream & out, Initializer * init ); 140 std::ostream & operator<<( std::ostream & out, const Initializer * init ); 141 std::ostream & operator<<( std::ostream & out, const Designation * des ); 143 142 144 143 #endif // INITIALIZER_H -
src/SynTree/Mutator.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 30 16:45:19201713 // Update Count : 2 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:43:00 2017 13 // Update Count : 24 14 14 // 15 15 … … 77 77 TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) { 78 78 handleNamedTypeDecl( typeDecl ); 79 typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) ); 79 80 return typeDecl; 80 81 } … … 152 153 } 153 154 155 Statement *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 154 161 Statement *Mutator::mutate( TryStmt *tryStmt ) { 155 162 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 156 163 mutateAll( tryStmt->get_catchers(), *this ); 164 tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) ); 157 165 return tryStmt; 158 166 } … … 160 168 Statement *Mutator::mutate( CatchStmt *catchStmt ) { 161 169 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 170 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) ); 162 171 catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) ); 163 172 return catchStmt; … … 373 382 } 374 383 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 381 384 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 382 385 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); … … 404 407 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 405 408 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 ) );414 409 return tupleExpr; 415 410 } … … 438 433 } 439 434 435 Expression *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 443 Expression *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 440 451 441 452 Type *Mutator::mutate( VoidType *voidType ) { … … 510 521 mutateAll( tupleType->get_forall(), *this ); 511 522 mutateAll( tupleType->get_types(), *this ); 523 mutateAll( tupleType->get_members(), *this ); 512 524 return tupleType; 513 525 } … … 546 558 547 559 560 Designation *Mutator::mutate( Designation * designation ) { 561 mutateAll( designation->get_designators(), *this ); 562 return designation; 563 } 564 548 565 Initializer *Mutator::mutate( SingleInit *singleInit ) { 549 566 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); … … 552 569 553 570 Initializer *Mutator::mutate( ListInit *listInit ) { 554 mutateAll( listInit->get_designat ors(), *this );571 mutateAll( listInit->get_designations(), *this ); 555 572 mutateAll( listInit->get_initializers(), *this ); 556 573 return listInit; -
src/SynTree/Mutator.h
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 9 14:23:23201713 // Update Count : 1 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 15:45:00 2017 13 // Update Count : 14 14 14 // 15 15 #include <cassert> … … 46 46 virtual Statement* mutate( BranchStmt *branchStmt ); 47 47 virtual Statement* mutate( ReturnStmt *returnStmt ); 48 virtual Statement* mutate( TryStmt *returnStmt ); 48 virtual Statement* mutate( ThrowStmt *throwStmt ); 49 virtual Statement* mutate( TryStmt *tryStmt ); 49 50 virtual Statement* mutate( CatchStmt *catchStmt ); 50 51 virtual Statement* mutate( FinallyStmt *catchStmt ); … … 77 78 virtual Expression* mutate( ConstructorExpr *ctorExpr ); 78 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 79 virtual Expression* mutate( UntypedValofExpr *valofExpr );80 80 virtual Expression* mutate( RangeExpr *rangeExpr ); 81 81 virtual Expression* mutate( UntypedTupleExpr *tupleExpr ); 82 82 virtual Expression* mutate( TupleExpr *tupleExpr ); 83 83 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); 84 virtual Expression* mutate( MemberTupleExpr *tupleExpr );85 84 virtual Expression* mutate( TupleAssignExpr *assignExpr ); 86 85 virtual Expression* mutate( StmtExpr * stmtExpr ); 87 86 virtual Expression* mutate( UniqueExpr * uniqueExpr ); 87 virtual Expression* mutate( UntypedInitExpr * initExpr ); 88 virtual Expression* mutate( InitExpr * initExpr ); 88 89 89 90 virtual Type* mutate( VoidType *basicType ); … … 105 106 virtual Type* mutate( OneType *oneType ); 106 107 108 virtual Designation* mutate( Designation *designation ); 107 109 virtual Initializer* mutate( SingleInit *singleInit ); 108 110 virtual Initializer* mutate( ListInit *listInit ); -
src/SynTree/ObjectDecl.cc
r9c951e3 rb1e63ac5 56 56 57 57 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, ' '); 61 61 os << "maybeConstructed? " << init->get_maybeConstructed(); 62 62 } // if -
src/SynTree/Statement.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Aug 12 13:58:48 201613 // Update Count : 6 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 10:37:00 2017 13 // Update Count : 64 14 14 // 15 15 … … 30 30 Statement::Statement( std::list<Label> _labels ) : labels( _labels ) {} 31 31 32 void Statement::print( std::ostream &,int indent ) const {}32 void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {} 33 33 34 34 Statement::~Statement() {} … … 101 101 } 102 102 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 ){}103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {} 104 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 106 106 107 107 ReturnStmt::~ReturnStmt() { … … 110 110 111 111 void ReturnStmt::print( std::ostream &os, int indent ) const { 112 os << string ( isThrow? "Throw":"Return" ) << "Statement, returning: ";112 os << "Return Statement, returning: "; 113 113 if ( expr != 0 ) { 114 114 os << endl << string( indent+2, ' ' ); … … 287 287 } 288 288 289 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) : 289 ThrowStmt::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 294 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 295 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 296 } 297 298 ThrowStmt::~ThrowStmt() { 299 delete expr; 300 delete target; 301 } 302 303 void 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 315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) : 290 316 Statement( labels ), block( tryBlock ), handlers( _handlers ), finallyBlock( _finallyBlock ) { 291 317 } … … 308 334 // handlers 309 335 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++) 311 337 (*i )->print( os, indent + 4 ); 312 338 … … 318 344 } 319 345 320 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :321 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {346 CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) : 347 Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) { 322 348 } 323 349 324 350 CatchStmt::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 ) ) { 326 352 } 327 353 … … 332 358 333 359 void CatchStmt::print( std::ostream &os, int indent ) const { 334 os << "Catch Statement" << endl;360 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 335 361 336 362 os << string( indent, ' ' ) << "... catching" << endl; … … 338 364 decl->printShort( os, indent + 4 ); 339 365 os << endl; 340 } else if ( catchRest ) 341 os << string( indent + 4 , ' ' ) << "the rest" << endl; 366 } 342 367 else 343 368 os << string( indent + 4 , ' ' ) << ">>> Error: this catch clause must have a declaration <<<" << endl; … … 365 390 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} 366 391 367 void NullStmt::print( std::ostream &os, int indent ) const {392 void NullStmt::print( std::ostream &os, __attribute__((unused)) int indent ) const { 368 393 os << "Null Statement" << endl ; 369 394 } -
src/SynTree/Statement.h
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Aug 12 13:57:46 201613 // Update Count : 6 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:35:00 2017 13 // Update Count : 67 14 14 // 15 15 … … 57 57 private: 58 58 std::list<Statement*> kids; 59 }; 60 61 class 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: 59 72 }; 60 73 … … 261 274 class ReturnStmt : public Statement { 262 275 public: 263 ReturnStmt( std::list<Label> labels, Expression *expr , bool throwP = false);276 ReturnStmt( std::list<Label> labels, Expression *expr ); 264 277 ReturnStmt( const ReturnStmt &other ); 265 278 virtual ~ReturnStmt(); … … 274 287 private: 275 288 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 291 class 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; 291 313 }; 292 314 293 315 class TryStmt : public Statement { 294 316 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 ); 296 318 TryStmt( const TryStmt &other ); 297 319 virtual ~TryStmt(); … … 299 321 CompoundStmt *get_block() const { return block; } 300 322 void set_block( CompoundStmt *newValue ) { block = newValue; } 301 std::list< Statement *>& get_catchers() { return handlers; }323 std::list<CatchStmt *>& get_catchers() { return handlers; } 302 324 303 325 FinallyStmt *get_finally() const { return finallyBlock; } … … 311 333 private: 312 334 CompoundStmt *block; 313 std::list< Statement *> handlers;335 std::list<CatchStmt *> handlers; 314 336 FinallyStmt *finallyBlock; 315 337 }; … … 317 339 class CatchStmt : public Statement { 318 340 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 ); 320 345 CatchStmt( const CatchStmt &other ); 321 346 virtual ~CatchStmt(); 322 347 348 Kind get_kind() { return kind; } 323 349 Declaration *get_decl() { return decl; } 324 350 void set_decl( Declaration *newValue ) { decl = newValue; } 325 351 Expression *get_cond() { return cond; } 352 void set_cond( Expression *newCond ) { cond = newCond; } 326 353 Statement *get_body() { return body; } 327 354 void set_body( Statement *newValue ) { body = newValue; } … … 333 360 334 361 private: 362 Kind kind; 335 363 Declaration *decl; 364 Expression *cond; 336 365 Statement *body; 337 bool catchRest;338 366 }; 339 367 -
src/SynTree/SynTree.h
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 9 14:23:49201713 // Update Count : 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 17:00:00 2017 13 // Update Count : 9 14 14 // 15 15 … … 51 51 class BranchStmt; 52 52 class ReturnStmt; 53 class ThrowStmt; 53 54 class TryStmt; 54 55 class CatchStmt; … … 89 90 class TupleExpr; 90 91 class TupleIndexExpr; 91 class MemberTupleExpr;92 92 class TupleAssignExpr; 93 93 class StmtExpr; 94 94 class UniqueExpr; 95 class UntypedInitExpr; 96 class InitExpr; 95 97 96 98 class Type; … … 114 116 class OneType; 115 117 118 class Designation; 116 119 class Initializer; 117 120 class SingleInit; -
src/SynTree/TupleExpr.cc
r9c951e3 rb1e63ac5 78 78 } 79 79 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 102 80 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) { 103 81 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments -
src/SynTree/TupleType.cc
r9c951e3 rb1e63ac5 14 14 // 15 15 16 #include "Declaration.h" 17 #include "Initializer.h" 16 18 #include "Type.h" 17 19 #include "Common/utility.h" 20 #include "Parser/LinkageSpec.h" 18 21 19 22 TupleType::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 } 20 33 } 21 34 22 35 TupleType::TupleType( const TupleType& other ) : Type( other ) { 23 36 cloneAll( other.types, types ); 37 cloneAll( other.members, members ); 24 38 } 25 39 26 40 TupleType::~TupleType() { 27 41 deleteAll( types ); 42 deleteAll( members ); 28 43 } 29 44 -
src/SynTree/Type.h
r9c951e3 rb1e63ac5 307 307 private: 308 308 Type *base; 309 unsigned int level = 0;310 309 }; 311 310 … … 354 353 virtual void print( std::ostream & os, int indent = 0 ) const; 355 354 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 {} 357 356 protected: 358 357 virtual std::string typeString() const = 0; … … 501 500 class TupleType : public Type { 502 501 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 * >() ); 504 503 TupleType( const TupleType& ); 505 504 virtual ~TupleType(); … … 508 507 typedef value_type::iterator iterator; 509 508 510 std::list<Type *>& get_types() { return types; }509 std::list<Type *> & get_types() { return types; } 511 510 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; } 512 515 513 516 iterator begin() { return types.begin(); } … … 526 529 virtual void print( std::ostream & os, int indent = 0 ) const; 527 530 private: 528 std::list<Type*> types; 531 std::list<Type *> types; 532 std::list<Declaration *> members; 529 533 }; 530 534 -
src/SynTree/TypeDecl.cc
r9c951e3 rb1e63ac5 18 18 #include "Common/utility.h" 19 19 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 ) {20 TypeDecl::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 ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) { 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) { 24 } 25 26 TypeDecl::~TypeDecl() { 27 delete init; 24 28 } 25 29 … … 34 38 } 35 39 40 void 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 36 49 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 37 50 return os << data.kind << ", " << data.isComplete; -
src/SynTree/TypeSubstitution.cc
r9c951e3 rb1e63ac5 166 166 boundVars.insert( (*tyvar )->get_name() ); 167 167 } // for 168 } // if169 // bind type variables from generic type instantiations170 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 } // for168 // 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 175 175 } // if 176 176 Type *ret = Mutator::mutate( type ); -
src/SynTree/VarExprReplacer.cc
r9c951e3 rb1e63ac5 14 14 // 15 15 16 #include "Declaration.h" 16 17 #include "Expression.h" 17 18 #include "VarExprReplacer.h" 18 19 19 VarExprReplacer::VarExprReplacer( const DeclMap & declMap ) : declMap( declMap) {}20 VarExprReplacer::VarExprReplacer( const DeclMap & declMap, bool debug ) : declMap( declMap ), debug( debug ) {} 20 21 21 22 // replace variable with new node from decl map 22 23 void 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 } 27 31 } -
src/SynTree/VarExprReplacer.h
r9c951e3 rb1e63ac5 27 27 private: 28 28 const DeclMap & declMap; 29 bool debug; 29 30 public: 30 VarExprReplacer( const DeclMap & declMap );31 VarExprReplacer( const DeclMap & declMap, bool debug = false ); 31 32 32 33 // replace variable with new node from decl map -
src/SynTree/Visitor.cc
r9c951e3 rb1e63ac5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 30 16:45:25201713 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:41:00 2017 13 // Update Count : 26 14 14 // 15 15 … … 67 67 void Visitor::visit( TypeDecl *typeDecl ) { 68 68 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) ); 69 maybeAccept( typeDecl->get_init(), *this ); 69 70 } 70 71 … … 121 122 } 122 123 123 void Visitor::visit( BranchStmt *branchStmt ) {124 void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) { 124 125 } 125 126 126 127 void Visitor::visit( ReturnStmt *returnStmt ) { 127 128 maybeAccept( returnStmt->get_expr(), *this ); 129 } 130 131 void Visitor::visit( ThrowStmt * throwStmt ) { 132 maybeAccept( throwStmt->get_expr(), *this ); 133 maybeAccept( throwStmt->get_target(), *this ); 128 134 } 129 135 … … 131 137 maybeAccept( tryStmt->get_block(), *this ); 132 138 acceptAll( tryStmt->get_catchers(), *this ); 139 maybeAccept( tryStmt->get_finally(), *this ); 133 140 } 134 141 135 142 void Visitor::visit( CatchStmt *catchStmt ) { 136 143 maybeAccept( catchStmt->get_decl(), *this ); 144 maybeAccept( catchStmt->get_cond(), *this ); 137 145 maybeAccept( catchStmt->get_body(), *this ); 138 146 } … … 142 150 } 143 151 144 void Visitor::visit( NullStmt *nullStmt ) {152 void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) { 145 153 } 146 154 … … 295 303 } 296 304 297 void Visitor::visit( UntypedValofExpr *valofExpr ) {298 maybeAccept( valofExpr->get_result(), *this );299 maybeAccept( valofExpr->get_body(), *this );300 }301 302 305 void Visitor::visit( RangeExpr *rangeExpr ) { 303 306 maybeAccept( rangeExpr->get_low(), *this ); … … 318 321 maybeAccept( tupleExpr->get_result(), *this ); 319 322 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 );326 323 } 327 324 … … 343 340 } 344 341 342 void 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 348 void Visitor::visit( InitExpr * initExpr ) { 349 maybeAccept( initExpr->get_result(), *this ); 350 maybeAccept( initExpr->get_expr(), *this ); 351 maybeAccept( initExpr->get_designation(), *this ); 352 } 353 345 354 346 355 void Visitor::visit( VoidType *voidType ) { … … 404 413 acceptAll( tupleType->get_forall(), *this ); 405 414 acceptAll( tupleType->get_types(), *this ); 415 acceptAll( tupleType->get_members(), *this ); 406 416 } 407 417 … … 433 443 } 434 444 445 void Visitor::visit( Designation * designation ) { 446 acceptAll( designation->get_designators(), *this ); 447 } 435 448 436 449 void Visitor::visit( SingleInit *singleInit ) { … … 439 452 440 453 void Visitor::visit( ListInit *listInit ) { 441 acceptAll( listInit->get_designat ors(), *this );454 acceptAll( listInit->get_designations(), *this ); 442 455 acceptAll( listInit->get_initializers(), *this ); 443 456 } … … 450 463 451 464 452 void Visitor::visit( Subrange *subrange ) {}453 454 455 void Visitor::visit( Constant *constant ) {}465 void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {} 466 467 468 void Visitor::visit( __attribute__((unused)) Constant *constant ) {} 456 469 // Local Variables: // 457 470 // tab-width: 4 // -
src/SynTree/Visitor.h
r9c951e3 rb1e63ac5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 3 08:58:00 201713 // Update Count : 1 012 // Last Modified On : Thr Jun 08 15:45:00 2017 13 // Update Count : 11 14 14 // 15 15 … … 49 49 virtual void visit( BranchStmt *branchStmt ); 50 50 virtual void visit( ReturnStmt *returnStmt ); 51 virtual void visit( ThrowStmt *throwStmt ); 51 52 virtual void visit( TryStmt *tryStmt ); 52 53 virtual void visit( CatchStmt *catchStmt ); … … 80 81 virtual void visit( ConstructorExpr * ctorExpr ); 81 82 virtual void visit( CompoundLiteralExpr *compLitExpr ); 82 virtual void visit( UntypedValofExpr *valofExpr );83 83 virtual void visit( RangeExpr *rangeExpr ); 84 84 virtual void visit( UntypedTupleExpr *tupleExpr ); 85 85 virtual void visit( TupleExpr *tupleExpr ); 86 86 virtual void visit( TupleIndexExpr *tupleExpr ); 87 virtual void visit( MemberTupleExpr *tupleExpr );88 87 virtual void visit( TupleAssignExpr *assignExpr ); 89 88 virtual void visit( StmtExpr * stmtExpr ); 90 89 virtual void visit( UniqueExpr * uniqueExpr ); 90 virtual void visit( UntypedInitExpr * initExpr ); 91 virtual void visit( InitExpr * initExpr ); 91 92 92 93 virtual void visit( VoidType *basicType ); … … 108 109 virtual void visit( OneType *oneType ); 109 110 111 virtual void visit( Designation *designation ); 110 112 virtual void visit( SingleInit *singleInit ); 111 113 virtual void visit( ListInit *listInit ); -
src/SynTree/ZeroOneType.cc
r9c951e3 rb1e63ac5 20 20 ZeroType::ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 21 21 22 void ZeroType::print( std::ostream &os, int indent ) const {22 void ZeroType::print( std::ostream &os, __attribute__((unused)) int indent ) const { 23 23 os << "zero_t"; 24 24 } … … 28 28 OneType::OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 29 29 30 void OneType::print( std::ostream &os, int indent ) const {30 void OneType::print( std::ostream &os, __attribute__((unused)) int indent ) const { 31 31 os << "one_t"; 32 32 } -
src/Tuples/TupleExpansion.cc
r9c951e3 rb1e63ac5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 08:05:17201713 // Update Count : 1 512 // Last Modified On : Wed Jun 21 17:35:04 2017 13 // Update Count : 19 14 14 // 15 15 … … 18 18 #include <cassert> 19 19 #include "Tuples.h" 20 #include "Common/PassVisitor.h" 21 #include "Common/ScopedMap.h" 20 22 #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" 21 30 #include "SynTree/Mutator.h" 22 31 #include "SynTree/Statement.h" 23 #include "SynTree/Declaration.h"24 32 #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"32 33 33 34 namespace Tuples { … … 82 83 }; 83 84 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 ); 90 88 }; 91 89 … … 116 114 replacer.mutateDeclarationList( translationUnit ); 117 115 118 TupleIndexExpanderidxExpander;116 PassVisitor<TupleIndexExpander> idxExpander; 119 117 mutateAll( translationUnit, idxExpander ); 120 118 … … 193 191 commaExpr->set_arg1( nullptr ); 194 192 } 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 ) ) ) ); 197 195 addDeclaration( finished ); 198 196 // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N)) 199 197 // 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 ) ) ); 201 199 ConditionalExpr * condExpr = new ConditionalExpr( new VariableExpr( finished ), var->clone(), 202 200 new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) ); … … 250 248 } 251 249 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(); 254 252 assert( tuple ); 255 253 tupleExpr->set_tuple( nullptr ); … … 312 310 Type * makeTupleType( const std::list< Expression * > & exprs ) { 313 311 // 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 ); 316 314 for ( Expression * expr : exprs ) { 317 315 assert( expr->get_result() ); 318 316 if ( expr->get_result()->isVoid() ) { 319 317 // if the type of any expr is void, the type of the entire tuple is void 320 delete tupleType;321 318 return new VoidType( Type::Qualifiers() ); 322 319 } 323 320 Type * type = expr->get_result()->clone(); 324 t upleType->get_types().push_back( type );321 types.push_back( type ); 325 322 // the qualifiers on the tuple type are the qualifiers that exist on all component types 326 323 qualifiers &= type->get_qualifiers(); 327 324 } // for 328 325 if ( exprs.empty() ) qualifiers = Type::Qualifiers(); 329 return tupleType;326 return new TupleType( qualifiers, types ); 330 327 } 331 328 332 329 TypeInstType * isTtype( Type * type ) { 333 330 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 ) { 335 332 return inst; 336 333 } … … 356 353 maybeImpure = true; 357 354 } 358 virtual void visit( UntypedExpr * untypedExpr ) { maybeImpure = true; }355 virtual void visit( __attribute__((unused)) UntypedExpr * untypedExpr ) { maybeImpure = true; } 359 356 bool maybeImpure = false; 360 357 }; -
src/driver/Makefile.am
r9c951e3 rb1e63ac5 16 16 17 17 # applies to both programs 18 AM_CXXFLAGS = -Wall -O2 18 AM_CXXFLAGS = -Wall -O2 -g -std=c++14 19 19 if BUILD_NO_LIB 20 20 else -
src/driver/Makefile.in
r9c951e3 rb1e63ac5 208 208 209 209 # applies to both programs 210 AM_CXXFLAGS = -Wall -O2 $(am__append_1) $(am__append_2) \210 AM_CXXFLAGS = -Wall -O2 -g -std=c++14 $(am__append_1) $(am__append_2) \ 211 211 $(am__append_3) 212 212 cfa_SOURCES = cfa.cc -
src/driver/cc1.cc
r9c951e3 rb1e63ac5 84 84 85 85 86 void sigTermHandler( int signal ) {86 void sigTermHandler( __attribute__((unused)) int signal ) { 87 87 if ( tmpfilefd != -1 ) { // RACE, file created ? 88 88 rmtmpfile(); // remove … … 469 469 470 470 471 int main( const int argc, const char * const argv[], const char * const env[] ) {471 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 472 472 #ifdef __DEBUG_H__ 473 473 for ( int i = 0; env[i] != NULL; i += 1 ) { -
src/driver/cfa.cc
r9c951e3 rb1e63ac5 271 271 args[nargs] = "-ldl"; 272 272 nargs += 1; 273 args[nargs] = "-lrt"; 274 nargs += 1; 273 275 args[nargs] = "-Xlinker"; 274 276 nargs += 1; -
src/libcfa/Makefile.am
r9c951e3 rb1e63ac5 10 10 ## Author : Peter A. Buhr 11 11 ## Created On : Sun May 31 08:54:01 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Sun May 14 21:04:21201714 ## Update Count : 21 412 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Wed Jun 28 15:36:00 2017 14 ## Update Count : 215 15 15 ############################################################################### 16 16 … … 41 41 CC = ${abs_top_srcdir}/src/driver/cfa 42 42 43 headers = limits stdlib math iostream fstream iterator rational assert containers/pair containers/vector 43 headers = assert fstream iostream iterator limits math rational stdlib \ 44 containers/maybe containers/pair containers/result containers/vector 44 45 45 46 # not all platforms support concurrency, add option do disable it … … 53 54 # not all platforms support concurrency, add option do disable it 54 55 if BUILD_CONCURRENCY 55 libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/ invoke.c56 libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c 56 57 endif 57 58 … … 63 64 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $< 64 65 66 libcfa_a-exception.o : exception.c 67 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $< 68 65 69 concurrency/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 72 libcfa_d_a-exception.o : exception.c 66 73 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $< 67 74 … … 71 78 libcfa_a_CFLAGS = -nodebug -O2 72 79 libcfa_d_a_SOURCES = ${libsrc} 73 libcfa_d_a_CFLAGS = -debug -O0 80 libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug 74 81 75 82 stdhdr = ${shell echo stdhdr/*} -
src/libcfa/Makefile.in
r9c951e3 rb1e63ac5 46 46 47 47 # not all platforms support concurrency, add option do disable it 48 @BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/ invoke.c48 @BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c 49 49 subdir = src/libcfa 50 50 DIST_COMMON = $(am__nobase_cfa_include_HEADERS_DIST) \ … … 98 98 libcfa_d_a_LIBADD = 99 99 am__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 106 107 am__dirstamp = $(am__leading_dot)dirstamp 107 108 @BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \ … … 109 110 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-kernel.$(OBJEXT) \ 110 111 @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) \ 112 am__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) \ 116 118 containers/libcfa_d_a-pair.$(OBJEXT) \ 119 containers/libcfa_d_a-result.$(OBJEXT) \ 117 120 containers/libcfa_d_a-vector.$(OBJEXT) $(am__objects_1) 118 121 @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) 120 125 am__objects_4 = libcfa_d_a-libcfa-prelude.$(OBJEXT) \ 121 126 libcfa_d_a-interpose.$(OBJEXT) \ … … 127 132 libcfa_a_LIBADD = 128 133 am__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 135 141 @BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \ 136 142 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread.$(OBJEXT) \ 137 143 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-kernel.$(OBJEXT) \ 138 144 @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) \ 145 am__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) \ 143 150 containers/libcfa_a-pair.$(OBJEXT) \ 151 containers/libcfa_a-result.$(OBJEXT) \ 144 152 containers/libcfa_a-vector.$(OBJEXT) $(am__objects_5) 145 153 @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) 147 157 am__objects_8 = libcfa_a-libcfa-prelude.$(OBJEXT) \ 148 158 libcfa_a-interpose.$(OBJEXT) \ … … 179 189 DIST_SOURCES = $(am__libcfa_d_a_SOURCES_DIST) \ 180 190 $(am__libcfa_a_SOURCES_DIST) 181 am__nobase_cfa_include_HEADERS_DIST = limits stdlib math iostream\182 fstream iterator rational assertcontainers/pair \183 containers/ vector concurrency/coroutine concurrency/thread\184 concurrency/ kernel concurrency/monitor ${shell echo stdhdr/*}\185 gmp concurrency/invoke.h191 am__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 186 196 HEADERS = $(nobase_cfa_include_HEADERS) 187 197 ETAGS = etags … … 313 323 EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -I${abs_top_srcdir}/src/libcfa/libhdr -imacros libcfa-prelude.c @CFA_FLAGS@ 314 324 AM_CCASFLAGS = @CFA_FLAGS@ 315 headers = limits stdlib math iostream fstream iterator rational assert \ 316 containers/pair containers/vector $(am__append_3) 325 headers = assert fstream iostream iterator limits math rational stdlib \ 326 containers/maybe containers/pair containers/result \ 327 containers/vector $(am__append_3) 317 328 libobjs = ${headers:=.o} 318 329 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \ … … 321 332 libcfa_a_CFLAGS = -nodebug -O2 322 333 libcfa_d_a_SOURCES = ${libsrc} 323 libcfa_d_a_CFLAGS = -debug -O0 334 libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug 324 335 stdhdr = ${shell echo stdhdr/*} 325 336 cfa_includedir = $(CFA_INCDIR) … … 404 415 @$(MKDIR_P) containers/$(DEPDIR) 405 416 @: > containers/$(DEPDIR)/$(am__dirstamp) 417 containers/libcfa_d_a-maybe.$(OBJEXT): containers/$(am__dirstamp) \ 418 containers/$(DEPDIR)/$(am__dirstamp) 406 419 containers/libcfa_d_a-pair.$(OBJEXT): containers/$(am__dirstamp) \ 420 containers/$(DEPDIR)/$(am__dirstamp) 421 containers/libcfa_d_a-result.$(OBJEXT): containers/$(am__dirstamp) \ 407 422 containers/$(DEPDIR)/$(am__dirstamp) 408 423 containers/libcfa_d_a-vector.$(OBJEXT): containers/$(am__dirstamp) \ … … 426 441 concurrency/$(am__dirstamp) \ 427 442 concurrency/$(DEPDIR)/$(am__dirstamp) 443 concurrency/libcfa_d_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \ 444 concurrency/$(DEPDIR)/$(am__dirstamp) 428 445 concurrency/libcfa_d_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \ 446 concurrency/$(DEPDIR)/$(am__dirstamp) 447 concurrency/libcfa_d_a-preemption.$(OBJEXT): \ 448 concurrency/$(am__dirstamp) \ 429 449 concurrency/$(DEPDIR)/$(am__dirstamp) 430 450 libcfa-d.a: $(libcfa_d_a_OBJECTS) $(libcfa_d_a_DEPENDENCIES) $(EXTRA_libcfa_d_a_DEPENDENCIES) … … 434 454 libhdr/libcfa_a-libdebug.$(OBJEXT): libhdr/$(am__dirstamp) \ 435 455 libhdr/$(DEPDIR)/$(am__dirstamp) 456 containers/libcfa_a-maybe.$(OBJEXT): containers/$(am__dirstamp) \ 457 containers/$(DEPDIR)/$(am__dirstamp) 436 458 containers/libcfa_a-pair.$(OBJEXT): containers/$(am__dirstamp) \ 459 containers/$(DEPDIR)/$(am__dirstamp) 460 containers/libcfa_a-result.$(OBJEXT): containers/$(am__dirstamp) \ 437 461 containers/$(DEPDIR)/$(am__dirstamp) 438 462 containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \ … … 446 470 concurrency/libcfa_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \ 447 471 concurrency/$(DEPDIR)/$(am__dirstamp) 472 concurrency/libcfa_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \ 473 concurrency/$(DEPDIR)/$(am__dirstamp) 448 474 concurrency/libcfa_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \ 475 concurrency/$(DEPDIR)/$(am__dirstamp) 476 concurrency/libcfa_a-preemption.$(OBJEXT): \ 477 concurrency/$(am__dirstamp) \ 449 478 concurrency/$(DEPDIR)/$(am__dirstamp) 450 479 libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES) … … 456 485 -rm -f *.$(OBJEXT) 457 486 -rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) 487 -rm -f concurrency/libcfa_a-alarm.$(OBJEXT) 458 488 -rm -f concurrency/libcfa_a-coroutine.$(OBJEXT) 459 489 -rm -f concurrency/libcfa_a-invoke.$(OBJEXT) 460 490 -rm -f concurrency/libcfa_a-kernel.$(OBJEXT) 461 491 -rm -f concurrency/libcfa_a-monitor.$(OBJEXT) 492 -rm -f concurrency/libcfa_a-preemption.$(OBJEXT) 462 493 -rm -f concurrency/libcfa_a-thread.$(OBJEXT) 494 -rm -f concurrency/libcfa_d_a-alarm.$(OBJEXT) 463 495 -rm -f concurrency/libcfa_d_a-coroutine.$(OBJEXT) 464 496 -rm -f concurrency/libcfa_d_a-invoke.$(OBJEXT) 465 497 -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT) 466 498 -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT) 499 -rm -f concurrency/libcfa_d_a-preemption.$(OBJEXT) 467 500 -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT) 501 -rm -f containers/libcfa_a-maybe.$(OBJEXT) 468 502 -rm -f containers/libcfa_a-pair.$(OBJEXT) 503 -rm -f containers/libcfa_a-result.$(OBJEXT) 469 504 -rm -f containers/libcfa_a-vector.$(OBJEXT) 505 -rm -f containers/libcfa_d_a-maybe.$(OBJEXT) 470 506 -rm -f containers/libcfa_d_a-pair.$(OBJEXT) 507 -rm -f containers/libcfa_d_a-result.$(OBJEXT) 471 508 -rm -f containers/libcfa_d_a-vector.$(OBJEXT) 472 509 -rm -f libhdr/libcfa_a-libdebug.$(OBJEXT) … … 497 534 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@ 498 535 @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@ 499 537 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@ 500 538 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@ 501 539 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@ 502 540 @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@ 503 542 @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@ 504 544 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po@am__quote@ 505 545 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-invoke.Po@am__quote@ 506 546 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@ 507 547 @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@ 508 549 @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@ 509 551 @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@ 510 553 @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@ 511 555 @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@ 512 557 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@ 513 558 @AMDEP_TRUE@@am__include@ @am__quote@libhdr/$(DEPDIR)/libcfa_a-libdebug.Po@am__quote@ … … 581 626 @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` 582 627 628 libcfa_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 635 libcfa_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 642 libcfa_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 649 libcfa_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 656 libcfa_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 663 libcfa_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 670 libcfa_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 677 libcfa_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 583 684 libcfa_d_a-limits.o: limits.c 584 685 @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 … … 595 696 @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` 596 697 698 libcfa_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 705 libcfa_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 712 libcfa_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 719 libcfa_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 597 726 libcfa_d_a-stdlib.o: stdlib.c 598 727 @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 … … 609 738 @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` 610 739 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` 740 containers/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 747 containers/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` 694 753 695 754 containers/libcfa_d_a-pair.o: containers/pair.c … … 707 766 @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` 708 767 768 containers/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 775 containers/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 709 782 containers/libcfa_d_a-vector.o: containers/vector.c 710 783 @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 … … 777 850 @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` 778 851 852 concurrency/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 859 concurrency/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 779 866 concurrency/libcfa_d_a-invoke.obj: concurrency/invoke.c 780 867 @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` … … 784 871 @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` 785 872 873 concurrency/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 880 concurrency/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 786 887 libcfa_a-libcfa-prelude.obj: libcfa-prelude.c 787 888 @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` … … 819 920 @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` 820 921 922 libcfa_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 929 libcfa_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 936 libcfa_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 943 libcfa_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 950 libcfa_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 957 libcfa_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 964 libcfa_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 971 libcfa_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 821 978 libcfa_a-limits.o: limits.c 822 979 @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 … … 833 990 @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` 834 991 992 libcfa_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 999 libcfa_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 1006 libcfa_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 1013 libcfa_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 835 1020 libcfa_a-stdlib.o: stdlib.c 836 1021 @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 … … 847 1032 @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` 848 1033 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` 1034 containers/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 1041 containers/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` 932 1047 933 1048 containers/libcfa_a-pair.o: containers/pair.c … … 945 1060 @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` 946 1061 1062 containers/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 1069 containers/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 947 1076 containers/libcfa_a-vector.o: containers/vector.c 948 1077 @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 … … 1015 1144 @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` 1016 1145 1146 concurrency/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 1153 concurrency/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 1017 1160 concurrency/libcfa_a-invoke.obj: concurrency/invoke.c 1018 1161 @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` … … 1021 1164 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1022 1165 @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 1167 concurrency/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 1174 concurrency/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` 1023 1180 install-nobase_cfa_includeHEADERS: $(nobase_cfa_include_HEADERS) 1024 1181 @$(NORMAL_INSTALL) … … 1271 1428 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $< 1272 1429 1430 libcfa_a-exception.o : exception.c 1431 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $< 1432 1273 1433 concurrency/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 1436 libcfa_d_a-exception.o : exception.c 1274 1437 ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $< 1275 1438 -
src/libcfa/concurrency/coroutine
r9c951e3 rb1e63ac5 71 71 // Suspend implementation inlined for performance 72 72 static inline void suspend() { 73 73 coroutine_desc * src = this_coroutine(); // optimization 74 74 75 75 assertf( src->last != 0, … … 91 91 coroutine_desc * dst = get_coroutine(cor); 92 92 93 93 if( unlikely(!dst->stack.base) ) { 94 94 create_stack(&dst->stack, dst->stack.size); 95 95 CtxStart(cor, CtxInvokeCoroutine); 96 96 } 97 97 98 98 // not resuming self ? 99 99 if ( src != dst ) { 100 100 assertf( dst->state != Halted , … … 103 103 src->name, src, dst->name, dst ); 104 104 105 105 // set last resumer 106 106 dst->last = src; 107 107 } // if 108 108 109 109 // always done for performance testing 110 110 CoroutineCtxSwitch( src, dst ); 111 111 } … … 114 114 coroutine_desc * src = this_coroutine(); // optimization 115 115 116 116 // not resuming self ? 117 117 if ( src != dst ) { 118 118 assertf( dst->state != Halted , … … 121 121 src->name, src, dst->name, dst ); 122 122 123 123 // set last resumer 124 124 dst->last = src; 125 125 } // if 126 126 127 127 // always done for performance testing 128 128 CoroutineCtxSwitch( src, dst ); 129 129 } -
src/libcfa/concurrency/kernel
r9c951e3 rb1e63ac5 28 28 //----------------------------------------------------------------------------- 29 29 // Locks 30 bool try_lock( spinlock * ); 30 31 void lock( spinlock * ); 31 32 void unlock( spinlock * ); … … 85 86 86 87 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; 87 95 }; 88 96 … … 94 102 95 103 // Local Variables: // 96 // mode: c//97 // tab-width: 4//104 // mode: CFA // 105 // tab-width: 6 // 98 106 // End: // -
src/libcfa/concurrency/kernel.c
r9c951e3 rb1e63ac5 36 36 //CFA Includes 37 37 #include "libhdr.h" 38 #include "preemption.h" 38 39 39 40 //Private includes … … 47 48 KERNEL_STORAGE(processorCtx_t, systemProcessorCtx); 48 49 KERNEL_STORAGE(cluster, systemCluster); 49 KERNEL_STORAGE( processor, systemProcessor);50 KERNEL_STORAGE(system_proc_t, systemProcessor); 50 51 KERNEL_STORAGE(thread_desc, mainThread); 51 52 KERNEL_STORAGE(machine_context_t, mainThread_context); 52 53 53 54 cluster * systemCluster; 54 processor* systemProcessor;55 system_proc_t * systemProcessor; 55 56 thread_desc * mainThread; 56 57 … … 118 119 // Processor coroutine 119 120 void ?{}(processorCtx_t * this, processor * proc) { 120 (&this->__cor){ };121 (&this->__cor){ "Processor" }; 121 122 this->proc = proc; 122 123 proc->runner = this; … … 139 140 (&this->terminated){}; 140 141 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; 141 146 142 147 start( this ); … … 149 154 (&this->terminated){}; 150 155 this->is_terminated = false; 156 this->disable_preempt_count = 0; 157 this->pending_preemption = false; 151 158 152 159 this->runner = runner; 153 160 LIB_DEBUG_PRINT_SAFE("Kernel : constructing processor context %p\n", runner); 154 161 runner{ this }; 162 } 163 164 void ?{}(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 }; 155 170 } 156 171 … … 178 193 void main(processorCtx_t * runner) { 179 194 processor * this = runner->proc; 195 180 196 LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this); 181 197 182 thread_desc * readyThread = NULL;183 for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )184 198 { 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++ ) 188 206 { 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 203 227 signal( &this->terminated ); 204 228 LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this); … … 287 311 // appropriate stack. 288 312 proc_cor_storage.__cor.state = Active; 289 290 313 main( &proc_cor_storage ); 314 proc_cor_storage.__cor.state = Halted; 291 315 292 316 // Main routine of the core returned, the core is now fully terminated … … 299 323 LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this); 300 324 301 // pthread_attr_t attributes;302 // pthread_attr_init( &attributes );303 304 325 pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this ); 305 306 // pthread_attr_destroy( &attributes );307 326 308 327 LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this); … … 314 333 if( !thrd ) return; 315 334 316 assertf( thrd->next == NULL, "Expected null got %p", thrd->next );335 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 317 336 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 ); 321 340 } 322 341 … … 367 386 } 368 387 388 //============================================================================================= 389 // Kernel Setup logic 390 //============================================================================================= 369 391 //----------------------------------------------------------------------------- 370 392 // Kernel boot procedures … … 379 401 mainThread{ &info }; 380 402 403 LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n"); 404 405 // Enable preemption 406 kernel_start_preemption(); 407 381 408 // Initialize the system cluster 382 409 systemCluster = (cluster *)&systemCluster_storage; 383 410 systemCluster{}; 384 411 412 LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n"); 413 385 414 // Initialize the system processor and the system processor ctx 386 415 // (the coroutine that contains the processing control flow) 387 systemProcessor = ( processor*)&systemProcessor_storage;416 systemProcessor = (system_proc_t *)&systemProcessor_storage; 388 417 systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage }; 389 418 390 419 // Add the main thread to the ready queue 391 // once resume is called on systemProcessor-> ctxthe mainThread needs to be scheduled like any normal thread420 // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread 392 421 ScheduleThread(mainThread); 393 422 394 423 //initialize the global state variables 395 this_processor = systemProcessor;424 this_processor = &systemProcessor->proc; 396 425 this_processor->current_thread = mainThread; 397 426 this_processor->current_coroutine = &mainThread->cor; … … 400 429 // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that 401 430 // mainThread is on the ready queue when this call is made. 402 resume( systemProcessor->runner);431 resume( systemProcessor->proc.runner ); 403 432 404 433 … … 414 443 // When its coroutine terminates, it return control to the mainThread 415 444 // which is currently here 416 systemProcessor-> is_terminated = true;445 systemProcessor->proc.is_terminated = true; 417 446 suspend(); 418 447 … … 421 450 // Destroy the system processor and its context in reverse order of construction 422 451 // These were manually constructed so we need manually destroy them 423 ^(systemProcessor-> runner){};452 ^(systemProcessor->proc.runner){}; 424 453 ^(systemProcessor){}; 425 454 … … 484 513 } 485 514 515 //============================================================================================= 516 // Kernel Utilities 517 //============================================================================================= 486 518 //----------------------------------------------------------------------------- 487 519 // Locks … … 491 523 void ^?{}( spinlock * this ) { 492 524 525 } 526 527 bool try_lock( spinlock * this ) { 528 return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0; 493 529 } 494 530 … … 541 577 542 578 void append( __thread_queue_t * this, thread_desc * t ) { 543 assert(this->tail != NULL);579 verify(this->tail != NULL); 544 580 *this->tail = t; 545 581 this->tail = &t->next; … … 563 599 564 600 void push( __condition_stack_t * this, __condition_criterion_t * t ) { 565 assert( !t->next );601 verify( !t->next ); 566 602 t->next = this->top; 567 603 this->top = t; -
src/libcfa/concurrency/kernel_private.h
r9c951e3 rb1e63ac5 21 21 #include "thread" 22 22 23 #include "alarm.h" 24 25 #include "libhdr.h" 26 23 27 //----------------------------------------------------------------------------- 24 28 // Scheduler … … 35 39 //----------------------------------------------------------------------------- 36 40 // Processor 37 structprocessorCtx_t {41 coroutine processorCtx_t { 38 42 processor * proc; 39 coroutine_desc __cor;40 43 }; 41 42 DECL_COROUTINE(processorCtx_t);43 44 44 45 void main(processorCtx_t *); … … 47 48 void finishRunning(processor * this); 48 49 void spin(processor * this, unsigned int * spin_count); 50 51 struct system_proc_t { 52 processor proc; 53 54 alarm_list_t alarms; 55 spinlock alarm_lock; 56 57 bool pending_alarm; 58 }; 59 60 extern cluster * systemCluster; 61 extern system_proc_t * systemProcessor; 62 extern thread_local processor * this_processor; 63 64 static 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 69 static 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 74 static 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 } 49 82 50 83 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/monitor
r9c951e3 rb1e63ac5 26 26 static inline void ?{}(monitor_desc * this) { 27 27 this->owner = NULL; 28 28 this->stack_owner = NULL; 29 29 this->recursion = 0; 30 30 } … … 33 33 monitor_desc ** m; 34 34 int count; 35 36 35 monitor_desc ** prev_mntrs; 36 unsigned short prev_count; 37 37 }; 38 38 … … 59 59 unsigned short count; //Number of criterions in the criteria 60 60 __condition_node_t * next; //Intrusive linked list Next field 61 uintptr_t user_info; //Custom user info accessible before signalling 61 62 }; 62 63 … … 85 86 } 86 87 87 void wait( condition * this ); 88 void signal( condition * this ); 88 void wait( condition * this, uintptr_t user_info = 0 ); 89 bool signal( condition * this ); 90 bool signal_block( condition * this ); 91 static inline bool is_empty( condition * this ) { return !this->blocked.head; } 92 uintptr_t front( condition * this ); 93 94 struct __acceptable_t { 95 void (*func)(void); 96 unsigned short count; 97 monitor_desc * monitors[1]; 98 }; 99 100 void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ); 101 89 102 #endif //MONITOR_H -
src/libcfa/concurrency/monitor.c
r9c951e3 rb1e63ac5 56 56 else if( this->owner == thrd) { 57 57 //We already have the monitor, just not how many times we took it 58 assert( this->recursion > 0 );58 verify( this->recursion > 0 ); 59 59 this->recursion += 1; 60 60 } … … 62 62 //Some one else has the monitor, wait in line for it 63 63 append( &this->entry_queue, thrd ); 64 LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd); 64 65 ScheduleInternal( &this->lock ); 65 66 … … 77 78 lock( &this->lock ); 78 79 79 thread_desc * thrd = this_thread();80 81 80 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 ); 83 82 84 83 //Leaving a recursion level, decrement the counter … … 97 96 unlock( &this->lock ); 98 97 98 LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner); 99 99 100 //We need to wake-up the thread 100 101 ScheduleThread( new_owner ); … … 134 135 } 135 136 136 void debug_break() __attribute__(( noinline )) 137 { 138 137 void ?{}(__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 144 void ?{}(__condition_criterion_t * this ) { 145 this->ready = false; 146 this->target = NULL; 147 this->owner = NULL; 148 this->next = NULL; 149 } 150 151 void ?{}(__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; 139 156 } 140 157 141 158 //----------------------------------------------------------------------------- 142 159 // Internal scheduling 143 void wait( condition * this ) {160 void wait( condition * this, uintptr_t user_info = 0 ) { 144 161 LIB_DEBUG_PRINT_SAFE("Waiting\n"); 145 162 … … 148 165 //Check that everything is as expected 149 166 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 ); 151 169 152 170 unsigned short count = this->monitor_count; … … 156 174 LIB_DEBUG_PRINT_SAFE("count %i\n", count); 157 175 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 }; 162 177 163 178 __condition_criterion_t criteria[count]; 164 179 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 }; 169 181 LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] ); 170 182 } … … 184 196 } 185 197 186 debug_break();187 188 198 for( int i = 0; i < count; i++) { 189 199 thread_desc * new_owner = next_thread( this->monitors[i] ); 190 200 thread_count = insert_unique( threads, thread_count, new_owner ); 191 201 } 192 193 debug_break();194 202 195 203 LIB_DEBUG_PRINT_SAFE("Will unblock: "); … … 212 220 } 213 221 214 voidsignal( condition * this ) {215 if( !this->blocked.head) {222 bool signal( condition * this ) { 223 if( is_empty( this ) ) { 216 224 LIB_DEBUG_PRINT_SAFE("Nothing to signal\n"); 217 return ;225 return false; 218 226 } 219 227 220 228 //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 ); 223 231 224 232 unsigned short count = this->monitor_count; 225 233 234 //Some more checking in debug 226 235 LIB_DEBUG_DO( 227 236 thread_desc * this_thrd = this_thread(); … … 237 246 ); 238 247 248 //Lock all the monitors 239 249 lock_all( this->monitors, NULL, count ); 240 250 LIB_DEBUG_PRINT_SAFE("Signalling"); 241 251 252 //Pop the head of the waiting queue 242 253 __condition_node_t * node = pop_head( &this->blocked ); 254 255 //Add the thread to the proper AS stack 243 256 for(int i = 0; i < count; i++) { 244 257 __condition_criterion_t * crit = &node->criteria[i]; … … 250 263 LIB_DEBUG_PRINT_SAFE("\n"); 251 264 265 //Release 252 266 unlock_all( this->monitors, count ); 267 268 return true; 269 } 270 271 bool 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 326 uintptr_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 336 void __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 ); 253 360 } 254 361 … … 335 442 336 443 for( int i = 0; i < count; i++ ) { 444 337 445 LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target ); 338 446 if( &criteria[i] == target ) { … … 379 487 380 488 void append( __condition_blocked_queue_t * this, __condition_node_t * c ) { 381 assert(this->tail != NULL);489 verify(this->tail != NULL); 382 490 *this->tail = c; 383 491 this->tail = &c->next; -
src/libcfa/concurrency/thread
r9c951e3 rb1e63ac5 82 82 83 83 void yield(); 84 void yield( unsigned times ); 84 85 85 86 #endif //THREADS_H -
src/libcfa/concurrency/thread.c
r9c951e3 rb1e63ac5 87 87 } 88 88 89 void yield( unsigned times ) { 90 for( unsigned i = 0; i < times; i++ ) { 91 yield(); 92 } 93 } 94 89 95 void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 90 96 // set state of current coroutine to inactive -
src/libcfa/containers/vector
r9c951e3 rb1e63ac5 22 22 23 23 //------------------------------------------------------------------------------ 24 //Allocator 25 forall(otype T) 26 struct heap_allocator 27 { 28 T* storage; 29 size_t capacity; 30 }; 31 32 forall(otype T) 33 void ?{}(heap_allocator(T)* this); 34 35 forall(otype T) 36 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs); 37 38 forall(otype T) 39 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs); 40 41 forall(otype T) 42 void ^?{}(heap_allocator(T)* this); 43 44 forall(otype T) 45 void realloc_storage(heap_allocator(T)* this, size_t size); 46 47 forall(otype T) 48 static inline T* data(heap_allocator(T)* this) 49 { 50 return this->storage; 51 } 52 53 //------------------------------------------------------------------------------ 24 54 //Declaration 25 55 trait allocator_c(otype T, otype allocator_t) … … 29 59 }; 30 60 31 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))61 forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t)) 32 62 struct vector; 33 63 … … 46 76 void ^?{}(vector(T, allocator_t)* this); 47 77 48 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))78 forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t)) 49 79 struct vector 50 80 { … … 136 166 // } 137 167 138 //------------------------------------------------------------------------------139 //Allocator140 forall(otype T)141 struct heap_allocator142 {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 168 168 #endif // VECTOR_H 169 169 -
src/libcfa/gmp
r9c951e3 rb1e63ac5 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un May 14 23:47:36201713 // Update Count : 912 // Last Modified On : Sat May 27 09:55:51 2017 13 // Update Count : 14 14 14 // 15 15 … … 22 22 23 23 // 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 ); }24 static inline void ?{}( Int * this ) { mpz_init( this->mpz ); } 25 static inline void ?{}( Int * this, Int init ) { mpz_init_set( this->mpz, init.mpz ); } 26 static inline void ?{}( Int * this, zero_t ) { mpz_init_set_si( this->mpz, 0 ); } 27 static inline void ?{}( Int * this, one_t ) { mpz_init_set_si( this->mpz, 1 ); } 28 static inline void ?{}( Int * this, signed long int init ) { mpz_init_set_si( this->mpz, init ); } 29 static inline void ?{}( Int * this, unsigned long int init ) { mpz_init_set_ui( this->mpz, init ); } 30 static inline void ?{}( Int * this, const char * val ) { if ( mpz_init_set_str( this->mpz, val, 0 ) ) abort(); } 31 static inline void ^?{}( Int * this ) { mpz_clear( this->mpz ); } 32 32 33 33 // 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 s hort 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; }34 static inline Int ?=?( Int * lhs, Int rhs ) { mpz_set( lhs->mpz, rhs.mpz ); return *lhs; } 35 static inline Int ?=?( Int * lhs, long int rhs ) { mpz_set_si( lhs->mpz, rhs ); return *lhs; } 36 static inline Int ?=?( Int * lhs, unsigned long int rhs ) { mpz_set_ui( lhs->mpz, rhs ); return *lhs; } 37 static inline Int ?=?( Int * lhs, const char * rhs ) { if ( mpz_set_str( lhs->mpz, rhs, 0 ) ) { printf( "invalid string conversion\n" ); abort(); } return *lhs; } 38 39 static inline char ?=?( char * lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); *lhs = val; return val; } 40 static inline short int ?=?( short int * lhs, Int rhs ) { short int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; } 41 static inline int ?=?( int * lhs, Int rhs ) { int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; } 42 static inline long int ?=?( long int * lhs, Int rhs ) { long int val = mpz_get_si( rhs.mpz ); *lhs = val; return val; } 43 static inline unsigned char ?=?( unsigned char * lhs, Int rhs ) { unsigned char val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; } 44 static inline unsigned short int ?=?( unsigned short int * lhs, Int rhs ) { unsigned short int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; } 45 static inline unsigned int ?=?( unsigned int * lhs, Int rhs ) { unsigned int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; } 46 static inline unsigned long int ?=?( unsigned long int * lhs, Int rhs ) { unsigned long int val = mpz_get_ui( rhs.mpz ); *lhs = val; return val; } 47 47 48 48 // 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 ); }49 static inline long int narrow( Int val ) { return mpz_get_si( val.mpz ); } 50 static inline unsigned long int narrow( Int val ) { return mpz_get_ui( val.mpz ); } 51 51 52 52 // 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 ); }53 static inline int ?==?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) == 0; } 54 static inline int ?==?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; } 55 static inline int ?==?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) == 0; } 56 static inline int ?==?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; } 57 static inline int ?==?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) == 0; } 58 59 static inline int ?!=?( Int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); } 60 static inline int ?!=?( Int oper1, long int oper2 ) { return ! ( oper1 == oper2 ); } 61 static inline int ?!=?( long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); } 62 static inline int ?!=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 == oper2 ); } 63 static inline int ?!=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 == oper2 ); } 64 65 static inline int ?<?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) < 0; } 66 static inline int ?<?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; } 67 static inline int ?<?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) < 0; } 68 static inline int ?<?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; } 69 static inline int ?<?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) < 0; } 70 71 static inline int ?<=?( Int oper1, Int oper2 ) { return mpz_cmp( oper1.mpz, oper2.mpz ) <= 0; } 72 static inline int ?<=?( Int oper1, long int oper2 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; } 73 static inline int ?<=?( long int oper2, Int oper1 ) { return mpz_cmp_si( oper1.mpz, oper2 ) <= 0; } 74 static inline int ?<=?( Int oper1, unsigned long int oper2 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; } 75 static inline int ?<=?( unsigned long int oper2, Int oper1 ) { return mpz_cmp_ui( oper1.mpz, oper2 ) <= 0; } 76 77 static inline int ?>?( Int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); } 78 static inline int ?>?( Int oper1, long int oper2 ) { return ! ( oper1 <= oper2 ); } 79 static inline int ?>?( long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); } 80 static inline int ?>?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 <= oper2 ); } 81 static inline int ?>?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 <= oper2 ); } 82 83 static inline int ?>=?( Int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); } 84 static inline int ?>=?( Int oper1, long int oper2 ) { return ! ( oper1 < oper2 ); } 85 static inline int ?>=?( long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); } 86 static inline int ?>=?( Int oper1, unsigned long int oper2 ) { return ! ( oper1 < oper2 ); } 87 static inline int ?>=?( unsigned long int oper1, Int oper2 ) { return ! ( oper1 < oper2 ); } 88 88 89 89 // 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; }90 static inline Int +?( Int oper ) { Int pos; mpz_set( pos.mpz, oper.mpz ); return pos; } 91 static inline Int -?( Int oper ) { Int neg; mpz_neg( neg.mpz, oper.mpz ); return neg; } 92 static inline Int ~?( Int oper ) { Int comp; mpz_com( comp.mpz, oper.mpz ); return comp; } 93 94 static inline Int ?&?( Int oper1, Int oper2 ) { Int conjunction; mpz_and( conjunction.mpz, oper1.mpz, oper2.mpz ); return conjunction; } 95 static 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; } 96 static 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; } 97 static 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; } 98 static 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; } 99 static inline Int ?&=?( Int * lhs, Int rhs ) { return *lhs = *lhs & rhs; } 100 101 static inline Int ?|?( Int oper1, Int oper2 ) { Int disjunction; mpz_ior( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; } 102 static 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; } 103 static 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; } 104 static 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; } 105 static 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; } 106 static inline Int ?|=?( Int * lhs, Int rhs ) { return *lhs = *lhs | rhs; } 107 108 static inline Int ?^?( Int oper1, Int oper2 ) { Int disjunction; mpz_xor( disjunction.mpz, oper1.mpz, oper2.mpz ); return disjunction; } 109 static 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; } 110 static 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; } 111 static 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; } 112 static 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; } 113 static inline Int ?^=?( Int * lhs, Int rhs ) { return *lhs = *lhs ^ rhs; } 114 115 static inline Int ?+?( Int addend1, Int addend2 ) { Int sum; mpz_add( sum.mpz, addend1.mpz, addend2.mpz ); return sum; } 116 static 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; } 117 static 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; } 118 static inline Int ?+?( Int addend1, unsigned long int addend2 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; } 119 static inline Int ?+?( unsigned long int addend2, Int addend1 ) { Int sum; mpz_add_ui( sum.mpz, addend1.mpz, addend2 ); return sum; } 120 static inline Int ?+=?( Int * lhs, Int rhs ) { return *lhs = *lhs + rhs; } 121 static inline Int ?+=?( Int * lhs, long int rhs ) { return *lhs = *lhs + rhs; } 122 static inline Int ?+=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs + rhs; } 123 static inline Int ++?( Int * lhs ) { return *lhs += 1; } 124 static inline Int ?++( Int * lhs ) { Int ret = *lhs; *lhs += 1; return ret; } 125 126 static inline Int ?-?( Int minuend, Int subtrahend ) { Int diff; mpz_sub( diff.mpz, minuend.mpz, subtrahend.mpz ); return diff; } 127 static 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; } 128 static 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; } 129 static inline Int ?-?( Int minuend, unsigned long int subtrahend ) { Int diff; mpz_sub_ui( diff.mpz, minuend.mpz, subtrahend ); return diff; } 130 static inline Int ?-?( unsigned long int minuend, Int subtrahend ) { Int diff; mpz_ui_sub( diff.mpz, minuend, subtrahend.mpz ); return diff; } 131 static inline Int ?-=?( Int * lhs, Int rhs ) { return *lhs = *lhs - rhs; } 132 static inline Int ?-=?( Int * lhs, long int rhs ) { return *lhs = *lhs - rhs; } 133 static inline Int ?-=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs - rhs; } 134 static inline Int --?( Int * lhs ) { return *lhs -= 1; } 135 static inline Int ?--( Int * lhs ) { Int ret = *lhs; *lhs -= 1; return ret; } 136 137 static inline Int ?*?( Int multiplicator, Int multiplicand ) { Int product; mpz_mul( product.mpz, multiplicator.mpz, multiplicand.mpz ); return product; } 138 static inline Int ?*?( Int multiplicator, long int multiplicand ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; } 139 static inline Int ?*?( long int multiplicand, Int multiplicator ) { Int product; mpz_mul_si( product.mpz, multiplicator.mpz, multiplicand ); return product; } 140 static inline Int ?*?( Int multiplicator, unsigned long int multiplicand ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; } 141 static inline Int ?*?( unsigned long int multiplicand, Int multiplicator ) { Int product; mpz_mul_ui( product.mpz, multiplicator.mpz, multiplicand ); return product; } 142 static inline Int ?*=?( Int * lhs, Int rhs ) { return *lhs = *lhs * rhs; } 143 static inline Int ?*=?( Int * lhs, long int rhs ) { return *lhs = *lhs * rhs; } 144 static inline Int ?*=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs * rhs; } 145 145 146 146 // 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 ) {147 static inline Int ?/?( Int dividend, Int divisor ) { Int quotient; mpz_tdiv_q( quotient.mpz, dividend.mpz, divisor.mpz ); return quotient; } 148 static inline Int ?/?( Int dividend, unsigned long int divisor ) { Int quotient; mpz_tdiv_q_ui( quotient.mpz, dividend.mpz, divisor ); return quotient; } 149 static inline Int ?/?( unsigned long int dividend, Int divisor ) { 150 150 Int quotient; 151 151 if ( mpz_sgn( divisor.mpz ) >= 0 ) { … … 164 164 return quotient; 165 165 } // ?/? 166 Int ?/?( Int dividend, long int divisor ) {166 static inline Int ?/?( Int dividend, long int divisor ) { 167 167 Int quotient; 168 168 if ( divisor >= 0 ) … … 174 174 return quotient; 175 175 } // ?/? 176 Int ?/?( long int dividend, Int divisor ) {176 static inline Int ?/?( long int dividend, Int divisor ) { 177 177 Int quotient; 178 178 if ( mpz_fits_slong_p( divisor.mpz ) ) … … 185 185 return quotient; 186 186 } // ?/? 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 ) {187 static inline Int ?/=?( Int * lhs, Int rhs ) { return *lhs = *lhs / rhs; } 188 static inline Int ?/=?( Int * lhs, long int rhs ) { return *lhs = *lhs / rhs; } 189 static inline Int ?/=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs / rhs; } 190 191 static 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 ]; } 192 static 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 194 static inline Int ?%?( Int dividend, Int divisor ) { Int remainder; mpz_tdiv_r( remainder.mpz, dividend.mpz, divisor.mpz ); return remainder; } 195 static inline Int ?%?( Int dividend, unsigned long int divisor ) { Int remainder; mpz_tdiv_r_ui( remainder.mpz, dividend.mpz, divisor ); return remainder; } 196 static inline Int ?%?( unsigned long int dividend, Int divisor ) { 197 197 Int remainder; 198 198 if ( mpz_sgn( divisor.mpz ) >= 0 ) { … … 210 210 return remainder; 211 211 } // ?%? 212 Int ?%?( Int dividend, long int divisor ) {212 static inline Int ?%?( Int dividend, long int divisor ) { 213 213 Int remainder; 214 214 mpz_tdiv_r_ui( remainder.mpz, dividend.mpz, (divisor >= 0 ? divisor : -divisor)); 215 215 return remainder; 216 216 } // ?%? 217 Int ?%?( long int dividend, Int divisor ) {217 static inline Int ?%?( long int dividend, Int divisor ) { 218 218 Int remainder; 219 219 if ( mpz_fits_slong_p( divisor.mpz ) ) … … 226 226 return remainder; 227 227 } // ?%? 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; }228 static inline Int ?%=?( Int * lhs, Int rhs ) { return *lhs = *lhs % rhs; } 229 static inline Int ?%=?( Int * lhs, long int rhs ) { return *lhs = *lhs % rhs; } 230 static inline Int ?%=?( Int * lhs, unsigned long int rhs ) { return *lhs = *lhs % rhs; } 231 232 static inline Int ?<<?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_mul_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; } 233 static inline Int ?<<=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs << shift; } 234 static inline Int ?>>?( Int shiften, mp_bitcnt_t shift ) { Int shifted; mpz_fdiv_q_2exp( shifted.mpz, shiften.mpz, shift ); return shifted; } 235 static inline Int ?>>=?( Int * lhs, mp_bitcnt_t shift ) { return *lhs = *lhs >> shift; } 236 236 237 237 // 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; }238 static inline Int abs( Int oper ) { Int positive; mpz_abs( positive.mpz, oper.mpz ); return positive; } 239 static inline Int fact( unsigned long int N ) { Int factorial; mpz_fac_ui( factorial.mpz, N ); return factorial; } 240 static inline Int gcd( Int oper1, Int oper2 ) { Int gcdret; mpz_gcd( gcdret.mpz, oper1.mpz, oper2.mpz ); return gcdret; } 241 static inline Int pow( Int base, unsigned long int exponent ) { Int power; mpz_pow_ui( power.mpz, base.mpz, exponent ); return power; } 242 static inline Int pow( unsigned long int base, unsigned long int exponent ) { Int power; mpz_ui_pow_ui( power.mpz, base, exponent ); return power; } 243 static inline void srandom( gmp_randstate_t state ) { gmp_randinit_default( state ); } 244 static inline Int random( gmp_randstate_t state, mp_bitcnt_t n ) { Int rand; mpz_urandomb( rand.mpz, state, n ); return rand; } 245 static inline Int random( gmp_randstate_t state, Int n ) { Int rand; mpz_urandomm( rand.mpz, state, n.mpz ); return rand; } 246 static inline Int random( gmp_randstate_t state, mp_size_t max_size ) { Int rand; mpz_random( rand.mpz, max_size ); return rand; } 247 static inline int sgn( Int oper ) { return mpz_sgn( oper.mpz ); } 248 static inline Int sqrt( Int oper ) { Int root; mpz_sqrt( root.mpz, oper.mpz ); return root; } 249 249 250 250 // I/O 251 forall( dtype istype | istream( istype ) )251 static inline forall( dtype istype | istream( istype ) ) 252 252 istype * ?|?( istype * is, Int * mp ) { 253 253 gmp_scanf( "%Zd", mp ); … … 255 255 } // ?|? 256 256 257 forall( dtype ostype | ostream( ostype ) )257 static inline forall( dtype ostype | ostream( ostype ) ) 258 258 ostype * ?|?( ostype * os, Int mp ) { 259 259 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); -
src/libcfa/libhdr/libdebug.h
r9c951e3 rb1e63ac5 18 18 19 19 #ifdef __CFA_DEBUG__ 20 21 20 #define LIB_DEBUG_DO(x) x 21 #define LIB_NO_DEBUG_DO(x) ((void)0) 22 22 #else 23 24 23 #define LIB_DEBUG_DO(x) ((void)0) 24 #define LIB_NO_DEBUG_DO(x) x 25 25 #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 26 35 27 36 #ifdef __cforall -
src/libcfa/math
r9c951e3 rb1e63ac5 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 12:45:02 201613 // Update Count : 5912 // Last Modified On : Wed May 24 17:40:39 2017 13 // Update Count : 60 14 14 // 15 15 … … 20 20 #include <math.h> // fpclassify, isfinite, isnormal, isnan, isinf 21 21 } // 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 );29 22 30 23 float ?%?( float, float ); -
src/libcfa/math.c
r9c951e3 rb1e63ac5 10 10 // Created On : Tue Apr 19 22:23:08 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 08:52:31 201613 // Update Count : 7 512 // Last Modified On : Tue May 23 22:52:13 2017 13 // Update Count : 76 14 14 // 15 15 … … 19 19 #include <complex.h> 20 20 } // 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 ); }26 21 27 22 float ?%?( float x, float y ) { return fmodf( x, y ); } -
src/libcfa/stdlib
r9c951e3 rb1e63ac5 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 9 08:42:44201713 // Update Count : 10712 // Last Modified On : Fri Jun 2 15:51:03 2017 13 // Update Count : 218 14 14 // 15 15 … … 28 28 //--------------------------------------- 29 29 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 31 static 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 36 extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine 37 static 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 42 extern "C" { void * realloc( void * ptr, size_t size ); } // default C routine for void * 43 static 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 48 extern "C" { void * memalign( size_t align, size_t size ); } // use default C routine for void * 49 static 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 54 static 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 59 extern "C" { int posix_memalign( void ** ptr, size_t align, size_t size ); } // use default C routine for void * 60 static 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 66 extern "C" { void * memset( void * dest, int c, size_t size ); } // use default C routine for void * 67 68 static 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 72 static 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 78 static 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 82 static 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 88 static 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 92 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ); 93 94 static 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 98 static 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 104 static 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 108 static 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 116 static 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 120 extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } // use default C routine for void * 121 static 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 127 static 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 131 static 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 137 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p ); 138 forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr ); 139 forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } ) void delete( T * ptr, Params rest ); 140 141 // allocation/deallocation and constructor/destructor, array types 142 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p ); 143 forall( dtype T | sized(T) | { void ^?{}( T * ); } ) void adelete( size_t dim, T arr[] ); 144 forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } ) void adelete( size_t dim, T arr[], Params rest ); 53 145 54 146 //--------------------------------------- … … 83 175 84 176 forall( otype T | { int ?<?( T, T ); } ) 85 T * bsearch( T key, const T * arr, size_t dim ension);86 87 forall( otype T | { int ?<?( T, T ); } ) 88 unsigned int bsearch( T key, const T * arr, size_t dim ension);89 90 91 forall( otype T | { int ?<?( T, T ); } ) 92 void qsort( const T * arr, size_t dim ension);177 T * bsearch( T key, const T * arr, size_t dim ); 178 179 forall( otype T | { int ?<?( T, T ); } ) 180 unsigned int bsearch( T key, const T * arr, size_t dim ); 181 182 183 forall( otype T | { int ?<?( T, T ); } ) 184 void qsort( const T * arr, size_t dim ); 93 185 94 186 //--------------------------------------- … … 109 201 double abs( double _Complex ); 110 202 long double abs( long double _Complex ); 111 forall 203 forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } ) 112 204 T abs( T ); 113 205 … … 115 207 116 208 void 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( );209 char rand48( void ); 210 int rand48( void ); 211 unsigned int rand48( void ); 212 long int rand48( void ); 213 unsigned long int rand48( void ); 214 float rand48( void ); 215 double rand48( void ); 216 float _Complex rand48( void ); 217 double _Complex rand48( void ); 218 long double _Complex rand48( void ); 127 219 128 220 //--------------------------------------- -
src/libcfa/stdlib.c
r9c951e3 rb1e63ac5 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue May 9 08:43:00201713 // Update Count : 19112 // Last Modified On : Thu Jun 1 21:52:57 2017 13 // Update Count : 280 14 14 // 15 15 … … 21 21 #define _XOPEN_SOURCE 600 // posix_memalign, *rand48 22 22 #include <stdlib.h> // malloc, free, calloc, realloc, memalign, posix_memalign, bsearch 23 #include <string.h> // mem set23 #include <string.h> // memcpy, memset 24 24 #include <malloc.h> // malloc_usable_size 25 25 #include <math.h> // fabsf, fabs, fabsl … … 27 27 } // extern "C" 28 28 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 30 forall( 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 41 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) 78 42 T * new( Params p ) { 79 return ( (T *)malloc()){ p };43 return (malloc()){ p }; // run constructor 80 44 } // new 81 45 82 forall( dtype T | { void ^?{}( T *); } ) // delete46 forall( dtype T | { void ^?{}( T * ); } ) 83 47 void delete( T * ptr ) { 84 if ( ptr ) { 85 ^ptr{}; 48 if ( ptr ) { // ignore null 49 ^ptr{}; // run destructor 86 50 free( ptr ); 87 } 51 } // if 88 52 } // delete 89 53 90 forall( dtype T, ttype Params | { void ^?{}( T *); void delete(Params); } )54 forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } ) 91 55 void delete( T * ptr, Params rest ) { 92 if ( ptr ) { 93 ^ptr{}; 56 if ( ptr ) { // ignore null 57 ^ptr{}; // run destructor 94 58 free( ptr ); 95 } 59 } // if 96 60 delete( rest ); 97 61 } // delete 62 63 64 // allocation/deallocation and constructor/destructor, array types 65 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) 66 T * 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 74 forall( dtype T | sized(T) | { void ^?{}( T * ); } ) 75 void 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 84 forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } ) 85 void 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 98 94 99 95 //--------------------------------------- … … 242 238 243 239 forall( otype T | { int ?<?( T, T ); } ) 244 T * bsearch( T key, const T * arr, size_t dim ension) {240 T * bsearch( T key, const T * arr, size_t dim ) { 245 241 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, dim ension, sizeof(T), comp );242 return (T *)bsearch( &key, arr, dim, sizeof(T), comp ); 247 243 } // bsearch 248 244 249 245 forall( otype T | { int ?<?( T, T ); } ) 250 unsigned int bsearch( T key, const T * arr, size_t dim ension) {251 T *result = bsearch( key, arr, dim ension);252 return result ? result - arr : dim ension;// pointer subtraction includes sizeof(T)246 unsigned 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) 253 249 } // bsearch 254 250 255 251 forall( otype T | { int ?<?( T, T ); } ) 256 void qsort( const T * arr, size_t dim ension) {252 void qsort( const T * arr, size_t dim ) { 257 253 int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; } 258 qsort( arr, dim ension, sizeof(T), comp );254 qsort( arr, dim, sizeof(T), comp ); 259 255 } // qsort 260 256 … … 279 275 280 276 void 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 lrand48287 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); }277 char rand48( void ) { return mrand48(); } 278 int rand48( void ) { return mrand48(); } 279 unsigned int rand48( void ) { return lrand48(); } 280 long int rand48( void ) { return mrand48(); } 281 unsigned long int rand48( void ) { return lrand48(); } 282 float rand48( void ) { return (float)drand48(); } // otherwise float uses lrand48 283 double rand48( void ) { return drand48(); } 284 float _Complex rand48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 285 double _Complex rand48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 286 long double _Complex rand48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 291 287 292 288 //--------------------------------------- -
src/main.cc
r9c951e3 rb1e63ac5 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Andrew Beach13 // Last Modified On : Wed May 10 14:45:00 201714 // Update Count : 4 3712 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Jun 29 12:46:50 2017 14 // Update Count : 441 15 15 // 16 16 … … 25 25 using namespace std; 26 26 27 #include "Parser/lex.h" 28 #include "Parser/parser.h" 27 #include "Parser/parser.hh" 29 28 #include "Parser/TypedefTable.h" 30 29 #include "GenPoly/Lvalue.h" … … 64 63 bresolvep = false, 65 64 bboxp = false, 65 bcodegenp = false, 66 66 ctorinitp = false, 67 67 declstatsp = false, … … 145 145 } // sigSegvBusHandler 146 146 147 void sigAbortHandler( int sig_num ) {147 void sigAbortHandler( __attribute__((unused)) int sig_num ) { 148 148 backtrace( 6 ); // skip first 6 stack frames 149 149 signal( SIGABRT, SIG_DFL); // reset default signal handler … … 185 185 if ( ! nopreludep ) { // include gcc builtins 186 186 // -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 ); 190 192 191 193 // read the extra prelude in, if not generating the cfa library … … 199 201 assertf( prelude, "cannot open prelude.cf\n" ); 200 202 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 ); 201 208 } // if 202 209 } // if … … 306 313 OPTPRINT( "box" ) 307 314 GenPoly::box( translationUnit ); 315 316 if ( bcodegenp ) { 317 dump( translationUnit ); 318 return 0; 319 } 308 320 309 321 if ( optind < argc ) { // any commands after the flags and input file ? => output file name … … 377 389 378 390 int c; 379 while ( (c = getopt_long( argc, argv, "abBc defglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {391 while ( (c = getopt_long( argc, argv, "abBcCdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 380 392 switch ( c ) { 381 393 case Ast: … … 394 406 ctorinitp = true; 395 407 break; 408 case 'C': // print before code generation 409 bcodegenp = true; 410 break; 396 411 case DeclStats: 397 412 case 'd': … … 466 481 break; 467 482 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 469 488 default: 470 489 abort(); -
src/prelude/Makefile.am
r9c951e3 rb1e63ac5 20 20 # put into lib for now 21 21 cfalibdir = ${CFA_LIBDIR} 22 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c22 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c 23 23 noinst_DATA = ../libcfa/libcfa-prelude.c 24 25 $(DEPDIR) : 26 mkdir $(DEPDIR) 27 28 $(DEPDIR)/builtins.Po : $(DEPDIR) 29 touch ${@} 24 30 25 31 # create extra forward types/declarations to reduce inclusion of library files … … 28 34 29 35 # create forward declarations for gcc builtins 30 builtins.cf :builtins.c prototypes.sed36 gcc-builtins.cf : gcc-builtins.c prototypes.sed 31 37 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@ 32 38 33 builtins.c : builtins.def prototypes.awk39 gcc-builtins.c : builtins.def prototypes.awk 34 40 ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@ 35 41 … … 38 44 prototypes.awk : 39 45 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 47 builtins.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 51 include $(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 41 54 ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@ # use src/cfa-cpp as not in lib until after install 42 55 43 bootloader.c : bootloader.cf prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp56 bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp 44 57 ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -tpmL bootloader.cf $@ # use src/cfa-cpp as not in lib until after install 45 58 46 MAINTAINERCLEANFILES = builtins.c builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} 59 maintainer-clean-local : 60 rm -rf $(DEPDIR) 61 62 MAINTAINERCLEANFILES = 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 211 211 # put into lib for now 212 212 cfalibdir = ${CFA_LIBDIR} 213 cfalib_DATA = builtins.cf extras.cf prelude.cf bootloader.c213 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c 214 214 noinst_DATA = ../libcfa/libcfa-prelude.c 215 MAINTAINERCLEANFILES = builtins.cbuiltins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}215 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} 216 216 all: all-am 217 217 … … 390 390 maintainer-clean: maintainer-clean-am 391 391 -rm -f Makefile 392 maintainer-clean-am: distclean-am maintainer-clean-generic 392 maintainer-clean-am: distclean-am maintainer-clean-generic \ 393 maintainer-clean-local 393 394 394 395 mostlyclean: mostlyclean-am … … 416 417 install-ps install-ps-am install-strip installcheck \ 417 418 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 ${@} 421 429 422 430 # create extra forward types/declarations to reduce inclusion of library files … … 425 433 426 434 # create forward declarations for gcc builtins 427 builtins.cf :builtins.c prototypes.sed435 gcc-builtins.cf : gcc-builtins.c prototypes.sed 428 436 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@ 429 437 430 builtins.c : builtins.def prototypes.awk438 gcc-builtins.c : builtins.def prototypes.awk 431 439 ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@ 432 440 … … 435 443 prototypes.awk : 436 444 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 446 builtins.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 450 include $(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 438 453 ${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@ # use src/cfa-cpp as not in lib until after install 439 454 440 bootloader.c : bootloader.cf prelude.cf extras.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp455 bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp 441 456 ${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 458 maintainer-clean-local : 459 rm -rf $(DEPDIR) 442 460 443 461 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/prelude/prelude.cf
r9c951e3 rb1e63ac5 309 309 // forall( dtype DT ) signed int ?!=?( const volatile void *, const volatile DT * ); 310 310 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 * ); 319 319 320 320 // ------------------------------------------------------------ … … 447 447 const volatile void * ?=?( const volatile void * volatile *, const volatile void * ); 448 448 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 ); 460 460 461 461 forall( dtype T | sized(T) ) T * ?+=?( T * *, ptrdiff_t ); … … 799 799 void ?{}( const volatile void * *, const volatile void * ); 800 800 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 ); 809 809 810 810 // default ctors -
src/tests/.expect/32/KRfunctions.txt
r9c951e3 rb1e63ac5 6 6 extern int printf(const char *__restrict __format, ...); 7 7 int __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; 9 9 } 10 10 int __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; 12 12 } 13 13 int __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; 15 15 } 16 16 struct S { … … 40 40 } 41 41 int __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; 43 43 struct S __s__2sS_2; 44 44 } 45 45 int __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; 47 47 } 48 48 int __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; 50 50 } 51 51 int (*__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); 53 53 } 54 54 int (*__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); 56 56 } 57 57 int *__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; 59 59 } 60 60 int *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; 62 62 } 63 63 int *(*__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); 65 65 int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3); 66 66 ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */); … … 68 68 } 69 69 int (*__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)[]; 71 71 } 72 72 int (*__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)]; 74 74 } 75 75 int (*__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)]; 77 77 } 78 78 int (*__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)]; 80 80 } 81 81 const int __fred__FCi___1(){ 82 const int ___retval_fred__Ci_1;82 __attribute__ ((unused)) const int ___retval_fred__Ci_1; 83 83 int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5); 84 84 int __a__i_2; … … 88 88 ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */); 89 89 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; 91 91 } 92 92 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; 94 94 } 95 95 } -
src/tests/.expect/32/attributes.txt
r9c951e3 rb1e63ac5 6 6 extern int printf(const char *__restrict __format, ...); 7 7 int __la__Fi___1(){ 8 int ___retval_la__i_1;8 __attribute__ ((unused)) int ___retval_la__i_1; 9 9 L: __attribute__ ((unused)) ((void)1); 10 10 } … … 226 226 __attribute__ ((unused,used)) int __f1__Fi___1(); 227 227 __attribute__ ((unused)) int __f1__Fi___1(){ 228 int ___retval_f1__i_1;228 __attribute__ ((unused)) int ___retval_f1__i_1; 229 229 } 230 230 __attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1(); 231 231 __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; 233 233 } 234 234 __attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[]; 235 235 __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)[]; 237 237 } 238 238 __attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2); 239 239 __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); 241 241 } 242 242 int __vtr__Fi___1(){ 243 int ___retval_vtr__i_1;243 __attribute__ ((unused)) int ___retval_vtr__i_1; 244 244 __attribute__ ((unused,unused,used)) int __t1__i_2; 245 245 __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2; … … 251 251 int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1); 252 252 int __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; 254 254 } 255 255 int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1); 256 256 int __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; 258 258 } 259 259 int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1); 260 260 int __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; 262 262 } 263 263 int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()); 264 264 int __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; 266 266 } 267 267 int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1); … … 273 273 int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9))); 274 274 int __ad__Fi___1(){ 275 int ___retval_ad__i_1;275 __attribute__ ((unused)) int ___retval_ad__i_1; 276 276 __attribute__ ((used,unused)) int __ad1__i_2; 277 277 __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2; -
src/tests/.expect/32/declarationSpecifier.txt
r9c951e3 rb1e63ac5 670 670 static inline volatile const short __f48__FCVs___1(); 671 671 int __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; 673 673 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 674 674 return ((int )___retval_main__i_1); … … 685 685 static inline int invoke_main(int argc, char **argv, char **envp); 686 686 int 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; 688 688 int _tmp_cp_ret0; 689 689 ((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 85 85 __extension__ int j; 86 86 __extension__ int __fred__Fi_i__1(int __p__i_1){ 87 int ___retval_fred__i_1;87 __attribute__ ((unused)) int ___retval_fred__i_1; 88 88 __extension__ struct S { 89 89 __extension__ int __a__i_2; … … 105 105 ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */); 106 106 __extension__ int __mary__Fi_i__2(int __p__i_2){ 107 int ___retval_mary__i_2;107 __attribute__ ((unused)) int ___retval_mary__i_2; 108 108 } 109 109 ((void)__extension__ sizeof(3)); -
src/tests/.expect/32/gccExtensions.txt
r9c951e3 rb1e63ac5 7 7 extern int __x__i_1 asm ( "xx" ); 8 8 int __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; 10 10 asm ( "nop" : : : ); 11 11 asm ( "nop" : : : ); … … 26 26 const int __i3__Ci_2; 27 27 inline int __f1__Fi___2(){ 28 int ___retval_f1__i_2;28 __attribute__ ((unused)) int ___retval_f1__i_2; 29 29 } 30 30 inline int __f2__Fi___2(){ 31 int ___retval_f2__i_2;31 __attribute__ ((unused)) int ___retval_f2__i_2; 32 32 } 33 33 int __s1__i_2; … … 182 182 static inline int invoke_main(int argc, char **argv, char **envp); 183 183 int 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; 185 185 int _tmp_cp_ret0; 186 186 ((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 1 fmod:1 1 1 1 1 1 2 remainder:-1 -1 -1 3 remquo:7 0.0999999 7 0.1 7 0.0999999999999999999 4 div:7 0.0999999 7 0.1 7 0.0999999999999999999 5 fma:-2 -2 -2 6 fdim:2 2 2 7 nan:nan nan nan 8 exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 9 exp2:2 2 2 10 expm1:1.71828 1.71828182845905 1.71828182845904524 11 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 12 log2:3 3 3 13 log10:2 2 2 14 log1p:0.693147 0.693147180559945 0.693147180559945309 15 ilogb:0 0 0 16 logb:3 3 3 17 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 18 cbrt:3 3 3 19 hypot:1.41421 1.4142135623731 1.41421356237309505 20 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 21 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 24 asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 27 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 28 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 29 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 30 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 31 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 32 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 33 erf:0.842701 0.842700792949715 0.842700792949714869 34 erfc:0.157299 0.157299207050285 0.157299207050285131 35 lgamma:1.79176 1.79175946922805 1.791759469228055 36 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1 37 tgamma:6 6 6 38 floor:1 1 1 39 ceil:2 2 2 40 trunc:3 3 3 41 rint:2 2 2 42 rint:2 2 2 43 rint:2 2 2 44 lrint:2 2 2 45 llrint:2 2 2 46 nearbyint:4 4 4 47 round:2 2 2 48 round:2 2 2 49 round:2 2 2 50 lround:2 2 2 51 llround:2 2 2 52 copysign:-1 -1 -1 53 frexp:0.5 3 0.5 3 0.5 3 54 ldexp:8 8 8 55 modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2 56 nexttoward:2 2 2 57 scalbn:16 16 16 58 scalbln:16 16 16 -
src/tests/.expect/64/KRfunctions.txt
r9c951e3 rb1e63ac5 6 6 extern int printf(const char *__restrict __format, ...); 7 7 int __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; 9 9 } 10 10 int __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; 12 12 } 13 13 int __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; 15 15 } 16 16 struct S { … … 40 40 } 41 41 int __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; 43 43 struct S __s__2sS_2; 44 44 } 45 45 int __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; 47 47 } 48 48 int __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; 50 50 } 51 51 int (*__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); 53 53 } 54 54 int (*__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); 56 56 } 57 57 int *__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; 59 59 } 60 60 int *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; 62 62 } 63 63 int *(*__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); 65 65 int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3); 66 66 ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */); … … 68 68 } 69 69 int (*__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)[]; 71 71 } 72 72 int (*__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)]; 74 74 } 75 75 int (*__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)]; 77 77 } 78 78 int (*__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)]; 80 80 } 81 81 const int __fred__FCi___1(){ 82 const int ___retval_fred__Ci_1;82 __attribute__ ((unused)) const int ___retval_fred__Ci_1; 83 83 int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5); 84 84 int __a__i_2; … … 88 88 ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */); 89 89 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; 91 91 } 92 92 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; 94 94 } 95 95 } -
src/tests/.expect/64/attributes.txt
r9c951e3 rb1e63ac5 6 6 extern int printf(const char *__restrict __format, ...); 7 7 int __la__Fi___1(){ 8 int ___retval_la__i_1;8 __attribute__ ((unused)) int ___retval_la__i_1; 9 9 L: __attribute__ ((unused)) ((void)1); 10 10 } … … 226 226 __attribute__ ((unused,used)) int __f1__Fi___1(); 227 227 __attribute__ ((unused)) int __f1__Fi___1(){ 228 int ___retval_f1__i_1;228 __attribute__ ((unused)) int ___retval_f1__i_1; 229 229 } 230 230 __attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1(); 231 231 __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; 233 233 } 234 234 __attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[]; 235 235 __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)[]; 237 237 } 238 238 __attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2); 239 239 __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); 241 241 } 242 242 int __vtr__Fi___1(){ 243 int ___retval_vtr__i_1;243 __attribute__ ((unused)) int ___retval_vtr__i_1; 244 244 __attribute__ ((unused,unused,used)) int __t1__i_2; 245 245 __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2; … … 251 251 int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1); 252 252 int __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; 254 254 } 255 255 int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1); 256 256 int __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; 258 258 } 259 259 int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1); 260 260 int __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; 262 262 } 263 263 int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()); 264 264 int __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; 266 266 } 267 267 int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1); … … 273 273 int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9))); 274 274 int __ad__Fi___1(){ 275 int ___retval_ad__i_1;275 __attribute__ ((unused)) int ___retval_ad__i_1; 276 276 __attribute__ ((used,unused)) int __ad1__i_2; 277 277 __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2; -
src/tests/.expect/64/declarationSpecifier.txt
r9c951e3 rb1e63ac5 670 670 static inline volatile const short __f48__FCVs___1(); 671 671 int __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; 673 673 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 674 674 return ((int )___retval_main__i_1); … … 685 685 static inline int invoke_main(int argc, char **argv, char **envp); 686 686 int 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; 688 688 int _tmp_cp_ret0; 689 689 ((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 85 85 __extension__ int j; 86 86 __extension__ int __fred__Fi_i__1(int __p__i_1){ 87 int ___retval_fred__i_1;87 __attribute__ ((unused)) int ___retval_fred__i_1; 88 88 __extension__ struct S { 89 89 __extension__ int __a__i_2; … … 105 105 ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */); 106 106 __extension__ int __mary__Fi_i__2(int __p__i_2){ 107 int ___retval_mary__i_2;107 __attribute__ ((unused)) int ___retval_mary__i_2; 108 108 } 109 109 ((void)__extension__ sizeof(3)); -
src/tests/.expect/64/gccExtensions.txt
r9c951e3 rb1e63ac5 7 7 extern int __x__i_1 asm ( "xx" ); 8 8 int __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; 10 10 asm ( "nop" : : : ); 11 11 asm ( "nop" : : : ); … … 26 26 const int __i3__Ci_2; 27 27 inline int __f1__Fi___2(){ 28 int ___retval_f1__i_2;28 __attribute__ ((unused)) int ___retval_f1__i_2; 29 29 } 30 30 inline int __f2__Fi___2(){ 31 int ___retval_f2__i_2;31 __attribute__ ((unused)) int ___retval_f2__i_2; 32 32 } 33 33 int __s1__i_2; … … 182 182 static inline int invoke_main(int argc, char **argv, char **envp); 183 183 int 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; 185 185 int _tmp_cp_ret0; 186 186 ((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 4 4 conversions 5 5 y:97 6 y:12345678901234567890123456789 6 7 y:3 7 8 y:-3 … … 24 25 z:150000000000000000000 25 26 z:16666666666666666666 27 16666666666666666666, 2 16666666666666666666, 2 26 28 x:16666666666666666666 y:2 27 29 -
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 1 fmod:1 1 1 1 1 1 2 remainder:-1 -1 -1 3 remquo:7 0.0999999 7 0.1 7 0.0999999999999999999 4 div:7 0.0999999 7 0.1 7 0.0999999999999999999 5 fma:-2 -2 -2 6 fdim:2 2 2 7 nan:nan nan nan 8 exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 9 exp2:2 2 2 10 expm1:1.71828 1.71828182845905 1.71828182845904524 11 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 12 log2:3 3 3 13 log10:2 2 2 14 log1p:0.693147 0.693147180559945 0.693147180559945309 15 ilogb:0 0 0 16 logb:3 3 3 17 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 18 cbrt:3 3 3 19 hypot:1.41421 1.4142135623731 1.41421356237309505 20 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 21 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 24 asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 27 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 28 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 29 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 30 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 31 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 32 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 33 erf:0.842701 0.842700792949715 0.842700792949714869 34 erfc:0.157299 0.157299207050285 0.157299207050285131 35 lgamma:1.79176 1.79175946922805 1.791759469228055 36 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1 37 tgamma:6 6 6 38 floor:1 1 1 39 ceil:2 2 2 40 trunc:3 3 3 41 rint:2 2 2 42 rint:2 2 2 43 rint:2 2 2 44 lrint:2 2 2 45 llrint:2 2 2 46 nearbyint:4 4 4 47 round:2 2 2 48 round:2 2 2 49 round:2 2 2 50 lround:2 2 2 51 llround:2 2 2 52 copysign:-1 -1 -1 53 frexp:0.5 3 0.5 3 0.5 3 54 ldexp:8 8 8 55 modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2 56 nexttoward:2 2 2 57 scalbn:16 16 16 58 scalbln:16 16 16 -
src/tests/.expect/io.txt
r9c951e3 rb1e63ac5 4 4 123 5 5 6 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10 7 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x 8 x`1`x'2'x"3"x:4:x 5 x 6 x 9 7 10 x 11 8 12 x 13 9 14 x 15 10 16 x 17 x ( 1 ) x 2 , x 3 :x: 4 6 18 A 7 19 1 2 3 4 5 6 7 8 … … 18 30 abc, $xyz 19 31 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 32 1, 2, 3, 4 33 1, $2, $3 ", $" 34 1 2 3 " " 35 1 2 3 36 12 3 37 123 38 1 23 39 1 2 3 40 1 2 3 4 " " 41 1, 2, 3, 4 ", " 42 1, 2, 3, 4 27 43 3, 4, a, 7.2 28 44 3, 4, a, 7.2 29 45 3 4 a 7.2 30 3 4 a 7.234a7.2 46 3 4 a 7.234a7.23 4 a 7.2 31 47 3-4-a-7.2^3^4-3-4-a-7.2 -
src/tests/.expect/scopeErrors.txt
r9c951e3 rb1e63ac5 3 3 with parameters 4 4 double 5 returning 6 _retval_butThisIsAnError: double 7 with body 5 returning 6 _retval_butThisIsAnError: Attribute with name: unused 7 double 8 with body 8 9 CompoundStmt -
src/tests/KRfunctions.c
r9c951e3 rb1e63ac5 1 // -*- Mode: C -*-2 1 // 3 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo … … 11 10 // Created On : Thu Feb 16 15:23:17 2017 12 11 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Feb 16 15:25:52201714 // Update Count : 212 // Last Modified On : Wed May 24 22:05:00 2017 13 // Update Count : 3 15 14 // 16 15 -
src/tests/Makefile.am
r9c951e3 rb1e63ac5 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sun May 14 14:43:48201714 ## Update Count : 4 213 ## Last Modified On : Thu Jun 8 07:41:43 2017 14 ## Update Count : 44 15 15 ############################################################################### 16 16 … … 20 20 21 21 if BUILD_CONCURRENCY 22 concurrent =yes23 quick_test += coroutine thread monitor24 concurrent_test =coroutine thread monitor multi-monitor sched-int-disjoint sched-int-bargesched-int-wait sched-ext sched-ext-multi preempt22 concurrent = yes 23 quick_test += coroutine thread monitor 24 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 25 25 else 26 26 concurrent=no … … 36 36 37 37 .PHONY : list 38 EXTRA_PROGRAMS = fstream_test vector_test avl_test constant0-1DP constant0-1ND constant0-1NDDP# build but do not install38 EXTRA_PROGRAMS = fstream_test vector_test avl_test # build but do not install 39 39 40 40 fstream_test_SOURCES = fstream_test.c … … 57 57 @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test} 58 58 59 .dummy : .dummy.c 59 .dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@ 60 60 ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@} #don't use CFLAGS, this rule is not a real test 61 61 62 constant0-1DP : constant0-1.c63 ${CC} ${CFLAGS} -DDUPS ${<} -o ${@}64 62 65 constant0-1ND : constant0-1.c 66 ${CC} ${CFLAGS} -DNEWDECL${<} -o ${@}63 % : %.c @CFA_BINDIR@/@CFA_NAME@ 64 ${CC} ${CFLAGS} ${<} -o ${@} 67 65 68 constant0-1NDDP : constant0-1.c 69 ${CC} ${CFLAGS} -DNEWDECL -DDUPS ${<} -o ${@} 70 71 dtor-early-exit-ERR1: dtor-early-exit.c 66 dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 72 67 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 73 68 74 dtor-early-exit-ERR2: dtor-early-exit.c 69 dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 75 70 ${CC} ${CFLAGS} -DERR2 ${<} -o ${@} 76 71 77 declarationSpecifier: declarationSpecifier.c 72 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@ 78 73 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 79 74 80 gccExtensions : gccExtensions.c 75 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@ 81 76 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 82 77 83 extension : extension.c 78 extension : extension.c @CFA_BINDIR@/@CFA_NAME@ 84 79 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 85 80 86 attributes : attributes.c 81 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@ 87 82 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 88 83 89 KRfunctions : KRfunctions.c 84 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@ 90 85 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 91 86 92 gmp : gmp.c 87 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@ 93 88 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 94 89 95 memberCtors-ERR1: memberCtors.c 90 memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@ 96 91 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 97 92 98 completeTypeError : completeTypeError.c 93 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@ 99 94 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
r9c951e3 rb1e63ac5 39 39 @BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor 40 40 EXTRA_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) 43 42 subdir = src/tests 44 43 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in … … 56 55 avl_test_OBJECTS = $(am_avl_test_OBJECTS) 57 56 avl_test_LDADD = $(LDADD) 58 constant0_1DP_SOURCES = constant0-1DP.c59 constant0_1DP_OBJECTS = constant0-1DP.$(OBJEXT)60 constant0_1DP_LDADD = $(LDADD)61 constant0_1ND_SOURCES = constant0-1ND.c62 constant0_1ND_OBJECTS = constant0-1ND.$(OBJEXT)63 constant0_1ND_LDADD = $(LDADD)64 constant0_1NDDP_SOURCES = constant0-1NDDP.c65 constant0_1NDDP_OBJECTS = constant0-1NDDP.$(OBJEXT)66 constant0_1NDDP_LDADD = $(LDADD)67 57 am_fstream_test_OBJECTS = fstream_test.$(OBJEXT) 68 58 fstream_test_OBJECTS = $(am_fstream_test_OBJECTS) … … 95 85 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 96 86 am__v_GEN_0 = @echo " GEN " $@; 97 SOURCES = $(avl_test_SOURCES) constant0-1DP.c constant0-1ND.c \ 98 constant0-1NDDP.c $(fstream_test_SOURCES) \ 87 SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES) \ 99 88 $(vector_test_SOURCES) 100 DIST_SOURCES = $(avl_test_SOURCES) constant0-1DP.c constant0-1ND.c \ 101 constant0-1NDDP.c $(fstream_test_SOURCES) \ 89 DIST_SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES) \ 102 90 $(vector_test_SOURCES) 103 91 ETAGS = etags … … 230 218 @BUILD_CONCURRENCY_TRUE@concurrent = yes 231 219 @BUILD_CONCURRENCY_FALSE@concurrent_test = 232 @BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int- disjoint sched-int-bargesched-int-wait sched-ext sched-ext-multi preempt220 @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 233 221 234 222 # applies to both programs … … 297 285 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avl4.Po@am__quote@ 298 286 @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@302 287 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@ 303 288 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@ … … 676 661 @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test} 677 662 678 .dummy : .dummy.c 663 .dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@ 679 664 ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@} #don't use CFLAGS, this rule is not a real test 680 665 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 669 dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 691 670 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 692 671 693 dtor-early-exit-ERR2: dtor-early-exit.c 672 dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 694 673 ${CC} ${CFLAGS} -DERR2 ${<} -o ${@} 695 674 696 declarationSpecifier: declarationSpecifier.c 675 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@ 697 676 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 698 677 699 gccExtensions : gccExtensions.c 678 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@ 700 679 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 701 680 702 extension : extension.c 681 extension : extension.c @CFA_BINDIR@/@CFA_NAME@ 703 682 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 704 683 705 attributes : attributes.c 684 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@ 706 685 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 707 686 708 KRfunctions : KRfunctions.c 687 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@ 709 688 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 710 689 711 gmp : gmp.c 690 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@ 712 691 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 713 692 714 memberCtors-ERR1: memberCtors.c 693 memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@ 715 694 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 716 695 717 completeTypeError : completeTypeError.c 696 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@ 718 697 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 719 698 -
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 1 16 #include <fstream> 2 17 #include <coroutine> 3 18 4 19 coroutine Fibonacci { 5 int fn;// used for communication20 int fn; // used for communication 6 21 }; 7 22 8 void ?{}( Fibonacci* this) {9 23 void ?{}( Fibonacci * this ) { 24 this->fn = 0; 10 25 } 11 26 12 void main( Fibonacci* this) {13 int fn1, fn2;// retained between resumes14 this->fn = 0; 15 16 suspend();// return to last resume27 void 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 17 32 18 this->fn = 1; 19 20 21 suspend();// return to last resume33 this->fn = 1; // case 1 34 fn2 = fn1; 35 fn1 = this->fn; 36 suspend(); // return to last resume 22 37 23 for ( ;; ) { 24 25 26 27 suspend();// return to last resume28 } 38 for ( ;; ) { // general case 39 this->fn = fn1 + fn2; 40 fn2 = fn1; 41 fn1 = this->fn; 42 suspend(); // return to last resume 43 } // for 29 44 } 30 45 31 int next( Fibonacci* this) {32 resume(this);// transfer to last suspend33 46 int next( Fibonacci * this ) { 47 resume( this ); // transfer to last suspend 48 return this->fn; 34 49 } 35 50 36 51 int 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 } 41 57 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 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 14 14:46:50201713 // Update Count : 5 3012 // Last Modified On : Wed May 24 22:05:38 2017 13 // Update Count : 540 14 14 // 15 15 16 16 #include <gmp> 17 17 18 int main( ) {18 int main( void ) { 19 19 sout | "constructors" | endl; 20 20 short int si = 3; … … 25 25 sout | "conversions" | endl; 26 26 y = 'a'; 27 sout | "y:" | y | endl; 28 y = "12345678901234567890123456789"; 27 29 sout | "y:" | y | endl; 28 30 y = si; … … 62 64 z = x / 3; 63 65 sout | "z:" | z | endl; 66 sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl; 64 67 [ x, y ] = div( x, 3 ); 65 68 sout | "x:" | x | "y:" | y | endl; 66 // sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;67 69 68 70 sout | endl; … … 72 74 fn = (Int){0}; fn1 = fn; // 1st case 73 75 sout | (int)0 | fn | endl; 74 fn = (Int){1}; fn2 = fn1; fn1 = fn;// 2nd case76 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 75 77 sout | 1 | fn | endl; 76 for ( int i = 2; i <= 200; i += 1 ) {78 for ( unsigned int i = 2; i <= 200; i += 1 ) { 77 79 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 78 80 sout | i | fn | endl; … … 83 85 sout | "Factorial Numbers" | endl; 84 86 Int fact; 85 fact = (Int){1};// 1st case87 fact = 1; // 1st case 86 88 sout | (int)0 | fact | endl; 87 for ( int i = 1; i <= 40; i += 1 ) {88 fact = fact * i;// general case89 for ( unsigned int i = 1; i <= 40; i += 1 ) { 90 fact *= i; // general case 89 91 sout | i | fact | endl; 90 92 } // for … … 92 94 93 95 // Local Variables: // 94 // mode: c //95 96 // tab-width: 4 // 97 // compile-command: "cfa gmp.c -l gmp" // 96 98 // End: // -
src/tests/identity.c
r9c951e3 rb1e63ac5 7 7 // identity.c -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 8 22:15:08 201613 // Update Count : 1 312 // Last Modified On : Thu Jun 8 08:21:32 2017 13 // Update Count : 18 14 14 // 15 15 … … 32 32 sout | "double\t\t\t" | identity( 4.1 ) | endl; 33 33 sout | "long double\t\t" | identity( 4.1l ) | endl; 34 sout | "float _Complex\t\t" | identity( -4.1F-2.0iF ) | endl; 35 sout | "double _Complex\t\t" | identity( -4.1D-2.0iD ) | endl; 36 sout | "long double _Complex\t" | identity( -4.1L-2.0iL ) | endl; 34 37 } 35 38 -
src/tests/io.c
r9c951e3 rb1e63ac5 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 21 22:36:06201713 // Update Count : 4812 // Last Modified On : Thu Jun 8 09:52:10 2017 13 // Update Count : 51 14 14 // 15 15 … … 17 17 18 18 int main() { 19 char c; 19 char c; // basic types 20 20 short int si; 21 21 unsigned short int usi; … … 32 32 double _Complex dc; 33 33 long double _Complex ldc; 34 char s1[10], s2[10]; 34 enum { size = 10 }; 35 char s1[size], s2[size]; 35 36 36 37 int x = 3, y = 5, z = 7; … … 41 42 sout | endl; 42 43 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 44 83 open( &in, "io.data", "r" ); 45 84 46 &in | &c 47 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli 48 | &f | &d | &ld 49 | &fc | &dc | &ldc 50 | cstr( s1 ) | cstr( s2, 10 );// C string, length unchecked and checked85 &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 51 90 52 sout | c | ' ' | endl 53 | si | usi | i | ui | li | uli | lli | ulli | endl// integral54 | f | d | ld | endl// floating point55 | fc | dc | ldc | endl;// complex91 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 56 95 sout | endl; 57 sout | f | "" | d | "" | ld | endl 58 | sepDisable | fc | dc | ldc | sepEnable | endl// complex without separator59 | sepOn | s1 | sepOff | s2 | endl// local separator removal60 | s1 | "" | s2 | endl;// C string without separator96 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 61 100 sout | endl; 62 101 63 sepSet( sout, ", $" ); 102 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 64 103 sout | f | d | ld | endl 65 66 104 | fc | dc | ldc | endl 105 | s1 | s2 | endl; 67 106 sout | endl; 107 108 [int, int] t1 = [1, 2], t2 = [3, 4]; 109 sout | t1 | t2 | endl; // print tuple 110 68 111 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; 69 116 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 108 119 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 }; 110 132 sout | [ 3, 4, "a", 7.2 ] | endl; 111 sout | t | endl;133 sout | t3 | endl; 112 134 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; 115 137 sepSet( sout, "^" ); 116 138 sepSetTuple( sout, "-" ); 117 sout | t | 3 | 4 | t| endl;139 sout | t3 | 3 | 4 | t3 | endl; 118 140 } 119 141 -
src/tests/libcfa_vector.c
r9c951e3 rb1e63ac5 27 27 28 28 int main() { 29 vector( int , heap_allocator(int)) iv;29 vector( int ) iv; 30 30 31 31 assert( empty( &iv ) ); -
src/tests/math.c
r9c951e3 rb1e63ac5 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 24 13:24:20 201613 // Update Count : 7 012 // Last Modified On : Wed May 24 13:04:33 2017 13 // Update Count : 71 14 14 // 15 15 … … 22 22 long double l; 23 23 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;25 24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ) | endl; 26 25 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 1 16 int main() { 2 17 1; // decimal … … 48 63 0x_ff.ffp0; // hex real 49 64 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 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 15 21:32:22201713 // Update Count : 6 412 // Last Modified On : Wed May 17 15:46:35 2017 13 // Update Count : 65 14 14 // 15 15 -
src/tests/sched-int-disjoint.c
r9c951e3 rb1e63ac5 4 4 #include <thread> 5 5 6 #ifndef N 6 7 #define N 100_000 8 #endif 7 9 8 10 enum state_t { WAIT, SIGNAL, BARGE }; … … 78 80 signal( &cond, a, &data ); 79 81 80 int pauses = (unsigned)rand48() % 10; 81 for(int i = 0; i < pauses; i++) { 82 yield(); 83 } 82 yield( (unsigned)rand48() % 10 ); 84 83 85 84 //This is technically a mutual exclusion violation but the mutex monitor protects us -
src/tests/sched-int-wait.c
r9c951e3 rb1e63ac5 5 5 #include <thread> 6 6 7 static const int N = 10_000; 7 #ifndef N 8 #define N 10_000 9 #endif 8 10 9 11 monitor global_t {}; -
src/tests/test.py
r9c951e3 rb1e63ac5 197 197 # fetch return code and error from the diff command 198 198 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 199 205 # clean the executable 200 206 sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run) … … 253 259 # for each test to run 254 260 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) 256 262 except KeyboardInterrupt: 257 263 pool.terminate() -
src/tests/tuplePolymorphism.c
r9c951e3 rb1e63ac5 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Nov 16 10:38:00 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Nov 16 10:39:18 201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 18 18:05:12 2017 13 // Update Count : 4 14 14 // 15 15 16 16 // packed is needed so that structs are not passed with the same alignment as function arguments 17 17 __attribute__((packed)) struct A { 18 19 20 18 double x; 19 char y; 20 double z; 21 21 }; 22 22 23 23 __attribute__((packed)) struct B { 24 25 26 24 long long x; 25 char y; 26 long long z; 27 27 }; 28 28 … … 39 39 40 40 int main() { 41 42 41 int x1 = 123, x3 = 456; 42 double x2 = 999.123; 43 43 44 45 44 int i1 = 111, i3 = 222; 45 double i2 = 333; 46 46 47 48 47 int d1 = 555, d3 = 444; 48 double d2 = 666; 49 49 50 50 51 52 53 54 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); 55 55 56 57 58 59 60 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); 61 61 62 63 62 // ensure non-matching assertions are specialized correctly 63 g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL }); 64 64 } 65 65 … … 73 73 // tab-width: 4 // 74 74 // End: // 75 -
tools/cfa.nanorc
r9c951e3 rb1e63ac5 2 2 ## WIP 3 3 4 syntax "cfa" "\.cfa$" 5 ## No magic 4 syntax "cfa" "\.cfa" 6 5 7 6 # Macros … … 12 11 color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto)\>" 13 12 color green "\<(static|const|struct|union|typedef|extern|(un)?signed|inline)\>" 14 color green "\<((s?size)| ((u_?)?int(8|16|32|64|ptr)))_t\>"13 color green "\<((s?size)|one|zero|((u_?)?int(8|16|32|64|ptr)))_t\>" 15 14 16 15 # Declarations … … 19 18 # Control Flow Structures 20 19 color brightyellow "\<(if|else|while|do|for|switch|choose|case|default)\>" 21 ##color brightyellow "\<(try|catch|catchResume|finally)\>"20 color brightyellow "\<(try|catch|catchResume|finally)\>" 22 21 23 22 # Control Flow Statements 24 color magenta "\<(return|break|continue|fallthru|throw )\>"23 color magenta "\<(return|break|continue|fallthru|throw|throwResume)\>" 25 24 26 25 # Operator Names … … 33 32 ## Update/Redistribute 34 33 # GCC builtins 35 ##color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" 34 color cyan "__attribute__[[:space:]]*\(\([^()]*(\([^()]*\)[^()]*)*\)\)" 35 ##color cyan "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" 36 36 37 37 # Preprocesser Directives … … 39 39 40 40 # Values 41 # Booleans 42 color blue "\<(true|false)\>" 41 43 # Characters 42 44 color brightmagenta "'([^'\]|(\\")|(\\['abfnrtv\\]))'" 43 45 color brightmagenta "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" 44 46 # Strings and Angle Strings 45 color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"47 color yellow ""([^"]|\\")*"" "<[^[:blank:]=]*>" 46 48 # Multiline Strings: This regex is VERY expencive and often too strong. 47 49 ###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
Note:
See TracChangeset
for help on using the changeset viewer.