Changes in / [85034ed:8cbe732]
- Files:
-
- 15 added
- 63 edited
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
r85034ed r8cbe732 25 25 gcc_08_x64_new: { trigger_build( 'gcc-8', 'x64', false ) }, 26 26 gcc_07_x64_new: { trigger_build( 'gcc-7', 'x64', false ) }, 27 // gcc_06_x64_new: { trigger_build( 'gcc-6', 'x64', false ) }, 27 gcc_11_arm64_new: { trigger_build( 'gcc-11', 'arm64', false ) }, 28 gcc_10_arm64_new: { trigger_build( 'gcc-10', 'arm64', false ) }, 29 gcc_09_arm64_new: { trigger_build( 'gcc-9', 'arm64', false ) }, 30 // gcc_06_arm64_new: { trigger_build( 'gcc-6', 'arm64', false ) }, 28 31 clang_x64_new: { trigger_build( 'clang', 'x64', true ) }, 29 32 ) -
Jenkins/TestRegen
r85034ed r8cbe732 24 24 stage('Building x64') { 25 25 regen_tests('x86_64') 26 } 27 28 stage('Building arm64') { 29 regen_tests('arm64') 26 30 } 27 31 -
Jenkinsfile
r85034ed r8cbe732 327 327 case 'x86': 328 328 this.Architecture = new Arch_Desc('x86', '--host=i386', 'x86') 329 break 330 case 'arm64': 331 this.Architecture = new Arch_Desc('arm64', '--host=aarch64', 'arm64') 329 332 break 330 333 default : … … 377 380 description: 'The target architecture', \ 378 381 name: 'Architecture', \ 379 choices: 'x64\nx86 ',\382 choices: 'x64\nx86\narm64', \ 380 383 defaultValue: 'x64', \ 381 384 ], \ -
doc/LaTeXmacros/common.sty
r85034ed r8cbe732 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sun Jul 16 08:28:52202314 %% Update Count : 58 613 %% Last Modified On : Fri Sep 29 16:48:59 2023 14 %% Update Count : 587 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 272 272 \setlength{\gcolumnposn}{2.75in} 273 273 \setlength{\columnposn}{\gcolumnposn} 274 \newcommand{\setgcolumn}[1]{\global\gcolumnposn=#1\global\columnposn=\gcolumnposn} 274 275 \newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@basicstyle{\LstCommentStyle{#2}}}} 275 276 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 302 303 literate= 303 304 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 304 {^}{\raisebox{0.6ex}{$\scripts criptstyle\land\,$}}1305 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 305 306 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 306 307 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/common.tex
r85034ed r8cbe732 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Jul 21 09:02:00202314 %% Update Count : 5 7613 %% Last Modified On : Fri Sep 29 16:49:02 2023 14 %% Update Count : 590 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 275 275 \setlength{\gcolumnposn}{2.75in} 276 276 \setlength{\columnposn}{\gcolumnposn} 277 \newcommand{\setgcolumn}[1]{\global\gcolumnposn=#1\global\columnposn=\gcolumnposn} 277 278 \newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@basicstyle{\LstCommentStyle{#2}}}} 278 279 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 301 302 showlines=true, % show blank lines at end of code 302 303 aboveskip=4pt, % spacing above/below code block 303 belowskip= 0pt,304 belowskip=2pt, 304 305 numberstyle=\footnotesize\sf, % numbering style 305 306 % replace/adjust listing characters that look bad in sanserif 306 307 literate= 307 308 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 308 {^}{\raisebox{0.6ex}{$\scripts criptstyle\land\,$}}1309 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 309 310 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 310 311 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/lstlang.sty
r85034ed r8cbe732 8 8 %% Created On : Sat May 13 16:34:42 2017 9 9 %% Last Modified By : Peter A. Buhr 10 %% Last Modified On : T ue May 2 08:52:35 202311 %% Update Count : 3 010 %% Last Modified On : Thu Sep 21 08:40:05 2023 11 %% Update Count : 31 12 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 13 … … 134 134 morekeywords={ 135 135 _Accept, _AcceptReturn, _AcceptWait, _Actor, _At, _Catch, _CatchResume, _CorActor, _Cormonitor, _Coroutine, 136 _Disable, _Else, _Enable, _Event, _ Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask,136 _Disable, _Else, _Enable, _Event, _Exception, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask, 137 137 _Resume, _ResumeTop, _Select, _SporadicTask, _Task, _Timeout, _When, _With, _Throw}, 138 138 } -
doc/bibliography/pl.bib
r85034ed r8cbe732 4113 4113 title = {High-Performance Extended Actors}, 4114 4114 journal = spe, 4115 year = 2022, 4116 note = {submitted July 2022}, 4115 year = 2023, 4116 month = sep, 4117 note = {\url{https://onlinelibrary.wiley.com/doi/pdf/10.1002/spe.3262}} 4117 4118 } 4118 4119 -
doc/user/user.tex
r85034ed r8cbe732 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Aug 10 21:24:07202314 %% Update Count : 5 57013 %% Last Modified On : Sat Sep 30 22:46:19 2023 14 %% Update Count : 5658 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 65 65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 66 66 67 \setlength{\gcolumnposn}{3in}68 67 \CFAStyle % use default CFA format-style 68 \setgcolumn{2.25in} 69 69 %\lstset{language=CFA} % CFA default lnaguage 70 70 \lstnewenvironment{C++}[1][] % use C++ style … … 224 224 \setlength{\tabcolsep}{10pt} 225 225 \begin{tabular}{@{}rcccccccc@{}} 226 & 202 1 & 2016 & 2011 & 2006 & 2001 & 1996 & 1991 & 1986\\ \hline227 \RB{C} & \RB{1}& \RB{2}& \RB{2}& \RB{1}& \RB{1}& \RB{1}& \RB{1}& \RB{1}\\228 Java & 2 & 1 & 1 & 2 & 3 & 28 & - & -\\229 Python & 3 & 5 & 6 & 7 & 23 & 13 & - & -\\230 \CC & 4 & 3 & 3 & 3 & 2 & 2 & 2 & 8\\226 & 2023 & 2018 & 2013 & 2008 & 2003 & 1998 & 1993 & 1988 \\ \hline 227 Python & 1 & 4 & 8 & 7 & 12 & 25 & 18 & - \\ 228 \RB{C} & \RB{2}& \RB{2}& \RB{1}& \RB{2}& \RB{2}& \RB{1}& \RB{1}& \RB{1}\\ 229 C++ & 3 & 3 & 4 & 4 & 3 & 2 & 2 & 4 \\ 230 Java & 4 & 1 & 2 & 1 & 1 & 18 & - & - \\ 231 231 \end{tabular} 232 232 \end{center} … … 465 465 \Indexc{-h}\index{translator option!-h@{©-h©}}, \Indexc{--help}\index{translator option!--help@{©--help©}} \, print translator help message 466 466 \item 467 \Indexc{-i}\index{translator option!-i@{©-i©}}, \Indexc{--invariant}\index{translator option!--invariant@{©--invariant©}} \, invariant checking during AST passes 468 \item 467 469 \Indexc{-l}\index{translator option!-l@{©-l©}}, \Indexc{--libcfa}\index{translator option!--libcfa@{©--libcfa©}} \, generate ©libcfa.c© 468 470 \item … … 482 484 \begin{description}[topsep=0pt,itemsep=0pt,parsep=0pt] 483 485 \item 484 \Indexc{ascodegen}\index{translator option!-P@{©-P©}!©ascodegen©}\index{translator option!--print@{©-print©}!©ascodegen©} \, as codegen rather than AST485 \item 486 \Indexc{asterr}\index{translator option!-P@{©-P©}!©asterr©}\index{translator option!--print@{©-print©}!©asterr©} \, AST on error487 \item 488 \Indexc{declstats}\index{translator option!-P@{©-P©}!©declstats©}\index{translator option!--print@{©-print©}!©declstats©} \, code property statistics489 \item 490 \Indexc{parse}\index{translator option!-P@{©-P©}!©parse©}\index{translator option!--print@{©-print©}!©parse©} \, yacc (parsing) debug information486 \Indexc{ascodegen}\index{translator option!-P@{©-P©}!©ascodegen©}\index{translator option!--print@{©-print©}!©ascodegen©} \, print AST as codegen rather than AST 487 \item 488 \Indexc{asterr}\index{translator option!-P@{©-P©}!©asterr©}\index{translator option!--print@{©-print©}!©asterr©} \, print AST on error 489 \item 490 \Indexc{declstats}\index{translator option!-P@{©-P©}!©declstats©}\index{translator option!--print@{©-print©}!©declstats©} \, print code property statistics 491 \item 492 \Indexc{parse}\index{translator option!-P@{©-P©}!©parse©}\index{translator option!--print@{©-print©}!©parse©} \, print yacc (parsing) debug information 491 493 \item 492 494 \Indexc{pretty}\index{translator option!-P@{©-P©}!©pretty©}\index{translator option!--print@{©-print©}!©pretty©} \, prettyprint for ©ascodegen© flag … … 494 496 \Indexc{rproto}\index{translator option!-P@{©-P©}!©rproto©}\index{translator option!--print@{©-print©}!©rproto©} \, resolver-proto instance 495 497 \item 496 \Indexc{rsteps}\index{translator option!-P@{©-P©}!©rsteps©}\index{translator option!--print@{©-print©}!©rsteps©} \, resolver steps497 \item 498 \Indexc{ tree}\index{translator option!-P@{©-P©}!©tree©}\index{translator option!--print@{©-print©}!©tree©} \, parse tree499 \item 500 \Indexc{ ast}\index{translator option!-P@{©-P©}!©ast©}\index{translator option!--print@{©-print©}!©ast©} \, AST after parsing501 \item 502 \Indexc{symevt}\index{translator option!-P@{©-P©}!©symevt©}\index{translator option!--print@{©-print©}!©symevt©} \, symbol table events503 \item 504 \Indexc{ altexpr}\index{translator option!-P@{©-P©}!©altexpr©}\index{translator option!--print@{©-print©}!©altexpr©} \, alternatives for expressions505 \item 506 \Indexc{ astdecl}\index{translator option!-P@{©-P©}!©astdecl©}\index{translator option!--print@{©-print©}!©astdecl©} \,AST after declaration validation pass507 \item 508 \Indexc{ resolver}\index{translator option!-P@{©-P©}!©resolver©}\index{translator option!--print@{©-print©}!©resolver©} \,before resolver step509 \item 510 \Indexc{ astexpr}\index{translator option!-P@{©-P©}!©astexpr©}\index{translator option!--print@{©-print©}!©altexpr©} \,AST after expression analysis511 \item 512 \Indexc{ctordtor}\index{translator option!-P@{©-P©}!©ctordtor©}\index{translator option!--print@{©-print©}!©ctordtor©} \, after ctor/dtor are replaced513 \item 514 \Indexc{tuple}\index{translator option!-P@{©-P©}!©tuple©}\index{translator option!--print@{©-print©}!©tuple©} \, after tuple expansion515 \item 516 \Indexc{ astgen}\index{translator option!-P@{©-P©}!©astgen©}\index{translator option!--print@{©-print©}!©astgen©} \,AST after instantiate generics517 \item 518 \Indexc{b ox}\index{translator option!-P@{©-P©}!©box©}\index{translator option!--print@{©-print©}!©box©} \, before box step519 \item 520 \Indexc{ codegen}\index{translator option!-P@{©-P©}!©codegen©}\index{translator option!--print@{©-print©}!©codegen©} \,before code generation498 \Indexc{rsteps}\index{translator option!-P@{©-P©}!©rsteps©}\index{translator option!--print@{©-print©}!©rsteps©} \, print resolver steps 499 \item 500 \Indexc{ast}\index{translator option!-P@{©-P©}!©ast©}\index{translator option!--print@{©-print©}!©ast©} \, print AST after parsing 501 \item 502 \Indexc{excpdecl}\index{translator option!-P@{©-P©}!©excpdecl©}\index{translator option!--print@{©-print©}!©excpdecl©} \, print AST after translating exception decls 503 \item 504 \Indexc{symevt}\index{translator option!-P@{©-P©}!©symevt©}\index{translator option!--print@{©-print©}!©symevt©} \, print AST after symbol table events 505 \item 506 \Indexc{expralt}\index{translator option!-P@{©-P©}!©expralt©}\index{translator option!--print@{©-print©}!©expralt©} \, print AST after expressions alternatives 507 \item 508 \Indexc{valdecl}\index{translator option!-P@{©-P©}!©valdecl©}\index{translator option!--print@{©-print©}!©valdecl©} \, print AST after declaration validation pass 509 \item 510 \Indexc{bresolver}\index{translator option!-P@{©-P©}!©bresolver©}\index{translator option!--print@{©-print©}!©bresolver©} \, print AST before resolver step 511 \item 512 \Indexc{expranly}\index{translator option!-P@{©-P©}!©expranly©}\index{translator option!--print@{©-print©}!©expranly©} \, print AST after expression analysis 513 \item 514 \Indexc{ctordtor}\index{translator option!-P@{©-P©}!©ctordtor©}\index{translator option!--print@{©-print©}!©ctordtor©} \, print AST after ctor/dtor are replaced 515 \item 516 \Indexc{tuple}\index{translator option!-P@{©-P©}!©tuple©}\index{translator option!--print@{©-print©}!©tuple©} \, print AST after tuple expansion 517 \item 518 \Indexc{instgen}\index{translator option!-P@{©-P©}!©instgen©}\index{translator option!--print@{©-print©}!©instgen©} \, print AST after instantiate generics 519 \item 520 \Indexc{bbox}\index{translator option!-P@{©-P©}!©bbox©}\index{translator option!--print@{©-print©}!©bbox©} \, print AST before box pass 521 \item 522 \Indexc{bcodegen}\index{translator option!-P@{©-P©}!©bcodegen©}\index{translator option!--print@{©-print©}!©bcodegen©} \, print AST before code generation 521 523 \end{description} 522 524 \item … … 535 537 Keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism: 536 538 \begin{cfa} 537 int ®``®coroutine = 3; 539 int ®``®coroutine = 3; $\C{// make keyword an identifier}$ 538 540 double ®``®forall = 3.5; 539 541 \end{cfa} … … 545 547 \begin{cfa} 546 548 // include file uses the CFA keyword "with". 547 #if ! defined( with ) 548 #define with ®``®with 549 #if ! defined( with ) $\C{// nesting ?}$ 550 #define with ®``®with $\C{// make keyword an identifier}$ 549 551 #define __CFA_BFD_H__ 550 552 #endif 551 $\R{\#include\_next} <bfdlink.h>$ 553 $\R{\#include\_next} <bfdlink.h>$ $\C{// must have internal check for multiple expansion}$ 552 554 #if defined( with ) && defined( __CFA_BFD_H__ ) $\C{// reset only if set}$ 553 555 #undef with … … 564 566 Numeric constants are extended to allow \Index{underscore}s\index{constant!underscore} as a separator, \eg: 565 567 \begin{cfa} 566 2®_®147®_®483®_®648; 567 56®_®ul; 568 0®_®377; 569 0x®_®ff®_®ff; 570 0x®_®ef3d®_®aa5c; 571 3.141®_®592®_®654; 572 10®_®e®_®+1®_®00; 573 0x®_®ff®_®ff®_®p®_®3; 574 0x®_®1.ffff®_®ffff®_®p®_®128®_®l; 568 2®_®147®_®483®_®648; $\C{// decimal constant}$ 569 56®_®ul; $\C{// decimal unsigned long constant}$ 570 0®_®377; $\C{// octal constant}$ 571 0x®_®ff®_®ff; $\C{// hexadecimal constant}$ 572 0x®_®ef3d®_®aa5c; $\C{// hexadecimal constant}$ 573 3.141®_®592®_®654; $\C{// floating constant}$ 574 10®_®e®_®+1®_®00; $\C{// floating constant}$ 575 0x®_®ff®_®ff®_®p®_®3; $\C{// hexadecimal floating}$ 576 0x®_®1.ffff®_®ffff®_®p®_®128®_®l; $\C{// hexadecimal floating long constant}$ 575 577 L®_®$"\texttt{\textbackslash{x}}$®_®$\texttt{ff}$®_®$\texttt{ee}"$; $\C{// wide character constant}$ 576 578 \end{cfa} … … 602 604 603 605 There are exponentiation operators for integral and floating types, including the builtin \Index{complex} types. 604 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication \footnote{The multiplication computation is $O(\log y)$.} (or shifting if the exponent is 2).606 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication ($O(\log y)$ multiplies or shifting if the exponent is 2). 605 607 Overflow for a large exponent or negative exponent returns zero. 606 608 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the exponent cannot be negative. 607 609 \begin{cfa} 608 sout | 1 ®\® 0 | 1 ®\® 1 | 2 ®\® 8 | -4 ®\® 3 | 5 ®\® 3 | 5 ®\® 32 | 5L ®\® 32 | 5L ®\® 64 | -4 ®\® -3 | -4.0 ®\® -3 | 4.0 ®\® 2.1 609 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 610 sout | 1 ®\® 0 | 1 ®\® 1 | 2 ®\® 8 | -4 ®\® 3 | 5 ®\® 3 | 5 ®\® 32 | 5L ®\® 32 | 5L ®\® 64 | -4 ®\® -3 | -4.0 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 610 611 1 1 256 -64 125 ®0® 3273344365508751233 ®0® ®0® -0.015625 18.3791736799526 0.264715-1.1922i 611 612 \end{cfa} … … 620 621 T ?®\®?( T ep, unsigned long int y ); 621 622 \end{cfa} 622 Theuser type ©T© must define multiplication, one (©1©), and ©*©.623 A user type ©T© must define multiplication, one (©1©), and ©*©. 623 624 624 625 … … 634 635 Declarations in the \Indexc{do}-©while© condition are not useful because they appear after the loop body.} 635 636 \begin{cfa} 636 if ( ®int x = f()® ) ... 637 if ( ®int x = f(), y = g()® ) ... 637 if ( ®int x = f()® ) ... $\C{// x != 0}$ 638 if ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 638 639 if ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ 639 640 if ( ®struct S { int i; } x = { f() }; x.i < 4® ) $\C{// relational expression}$ 640 641 641 while ( ®int x = f()® ) ... 642 while ( ®int x = f()® ) ... $\C{// x != 0}$ 642 643 while ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 643 644 while ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ … … 653 654 \label{s:caseClause} 654 655 655 C restricts the \Indexc{case} clause of a\Indexc{switch} statement to a single value.656 For multiple ©case© clauses associated with the samestatement, it is necessary to have multiple ©case© clauses rather than multiple values.656 C restricts a \Indexc{case} clause in \Indexc{switch} statement to a single value. 657 For multiple ©case© clauses prefixing a statement within the ©switch© statement, it is necessary to have multiple ©case© clauses rather than multiple values. 657 658 Requiring a ©case© clause for each value is not in the spirit of brevity normally associated with C. 658 659 Therefore, the ©case© clause is extended with a list of values. 659 660 \begin{cquote} 660 661 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 661 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 662 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 663 \begin{cfa} 664 switch ( i ) { 665 case 1: case 3 : case 5: 666 ... 667 case 2: case 4 : case 6: 668 ... 669 } 670 \end{cfa} 671 & 662 672 \begin{cfa} 663 673 switch ( i ) { … … 670 680 & 671 681 \begin{cfa} 672 switch ( i ) {673 case 1: case 3 : case 5:674 ...675 case 2: case 4 : case 6:676 ...677 }678 \end{cfa}679 &680 \begin{cfa}681 682 682 683 // odd values … … 688 689 \end{tabular} 689 690 \end{cquote} 690 In addition, subranges are allowed to specify case values.\footnote{ 691 gcc has the same mechanism but awkward syntax, \lstinline{2 ...42}, because a space is required after a number, otherwise the period is a decimal point.} 691 In addition, subranges are allowed to specify case values. 692 \begin{cquote} 693 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{\hspace{2em}}l@{}} 694 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{©gcc©}} \\ 692 695 \begin{cfa} 693 696 switch ( i ) { 694 case ®1~5:® $\C{// 1, 2, 3, 4, 5}$697 case 1: case 2: case 3: case 4: 695 698 ... 696 case ®10~15:® $\C{// 10, 11, 12, 13, 14, 15}$699 case 10: case 11: case 12: case 13: 697 700 ... 698 701 } 699 702 \end{cfa} 700 Lists of subranges are also allowed. 703 & 704 \begin{cfa} 705 switch ( i ) { 706 case ®1~4:® 707 ... 708 case ®10~13:® 709 ... 710 } 711 \end{cfa} 712 & 713 \begin{cfa} 714 switch ( i ) { 715 case 1$\R{\textvisiblespace}$®...®4: 716 ... 717 case 10$\R{\textvisiblespace}$®...®13: 718 ... 719 } 720 \end{cfa} 721 & 722 \begin{cfa} 723 724 // 1, 2, 3, 4 725 726 // 10, 11, 12, 13 727 728 729 \end{cfa} 730 \end{tabular} 731 \end{cquote} 732 While ©gcc© has the same range mechanism, it has an awkward syntax, ©2©\R{\textvisiblespace}©...42©, because a space is required after a number, otherwise the period is a decimal point. 733 734 \CFA also allows lists of subranges. 701 735 \begin{cfa} 702 736 case ®1~5, 12~21, 35~42®: … … 769 803 This situation is better handled by a list of case values \see{\VRef{s:caseClause}}. 770 804 While fall-through itself is not a problem, the problem occurs when fall-through is the default, as this semantics is unintuitive to many programmers and is different from most programming languages with a ©switch© statement. 771 Hence, default fall-through semantics results in a large number ofprogramming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through.805 Hence, default fall-through semantics results in a many programming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through. 772 806 773 807 \item … … 846 880 and there is only a medium amount of fall-through from one ©case© clause to the next, and most of these result from a list of case values executing common code, rather than a sequence of case actions that compound. 847 881 \end{itemize} 848 These observations put into perspective the \CFA changes to the ©switch© .882 These observations put into perspective the \CFA changes to the ©switch© statement. 849 883 \begin{enumerate} 850 884 \item … … 888 922 \begin{cfa} 889 923 switch ( x ) { 890 ®int i = 0;® 924 ®int i = 0;® $\C{// allowed only at start}$ 891 925 case 0: 892 926 ... 893 ®int j = 0;® 927 ®int j = 0;® $\C{// disallowed}$ 894 928 case 1: 895 929 { 896 ®int k = 0;® 930 ®int k = 0;® $\C{// allowed at different nesting levels}$ 897 931 ... 898 ®case 2:® 932 ®case 2:® $\C{// disallow case in nested statements}$ 899 933 } 900 934 ... … … 907 941 908 942 The \Indexc{fallthrough} clause may be non-terminating within a \Indexc{case} clause or have a target label to common code from multiple case clauses. 909 \begin{c enter}943 \begin{cquote} 910 944 \begin{tabular}{@{}lll@{}} 911 945 \begin{cfa} … … 957 991 \end{cfa} 958 992 \end{tabular} 959 \end{c enter}993 \end{cquote} 960 994 The target label must be below the \Indexc{fallthrough} and may not be nested in a control structure, and 961 995 the target label must be at the same or higher level as the containing \Indexc{case} clause and located at … … 964 998 965 999 \begin{figure} 966 \begin{tabular}{@{}l@{\hspace{ 40pt}}|l@{}}967 \multicolumn{1}{@{}c@{\hspace{ 40pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\1000 \begin{tabular}{@{}l@{\hspace{50pt}}|l@{}} 1001 \multicolumn{1}{@{}c@{\hspace{50pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\ 968 1002 \hline 969 1003 \begin{cfa} … … 1083 1117 The \Indexc{for}, \Indexc{while}, and \Indexc{do} loop-control allow an empty conditional, which implies a comparison value of ©1© (true). 1084 1118 \begin{cfa} 1085 while ( ®/* empty*/® )$\C{// while ( true )}$1086 for ( ®/* empty*/® )$\C{// for ( ; true; )}$1087 do ... while ( ®/* empty*/® )$\C{// do ... while ( true )}$1119 while ( ®/* empty */® ) $\C{// while ( true )}$ 1120 for ( ®/* empty */® ) $\C{// for ( ; true; )}$ 1121 do ... while ( ®/* empty */® ) $\C{// do ... while ( true )}$ 1088 1122 \end{cfa} 1089 1123 … … 1115 1149 If no type is specified for the loop index, it is the type of the high value H (when the low value is implicit) or the low value L. 1116 1150 \begin{cfa} 1117 for ( ®5® ) $\C{// typeof(5) anonymous-index; 5 is high value}$1118 for ( i; ®1.5® ~ 5.5 ) $\C{// typeof(1.5) i; 1.5 is low value}$1119 for ( ®int i®; 0 ~ 10 ~ 2 ) $\C{// int i; type is explicit}$1151 for ( ®5® ) $\C{// typeof(5) anonymous-index; 5 is high value}$ 1152 for ( i; ®1.5® ~ 5.5 ) $\C{// typeof(1.5) i; 1.5 is low value}$ 1153 for ( ®int i®; 0 ~ 10 ~ 2 ) $\C{// int i; type is explicit}$ 1120 1154 \end{cfa} 1121 1155 … … 1125 1159 H is implicit up-to exclusive range [0,H\R{)}. 1126 1160 \begin{cfa} 1127 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$1161 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$ 1128 1162 \end{cfa} 1129 1163 \item 1130 1164 ©~=© H is implicit up-to inclusive range [0,H\R{]}. 1131 1165 \begin{cfa} 1132 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$1166 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$ 1133 1167 \end{cfa} 1134 1168 \item 1135 1169 L ©~©\index{~@©~©} H is explicit up-to exclusive range [L,H\R{)}. 1136 1170 \begin{cfa} 1137 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$1171 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$ 1138 1172 \end{cfa} 1139 1173 \item 1140 1174 L ©~=©\index{~=@©~=©} H is explicit up-to inclusive range [L,H\R{]}. 1141 1175 \begin{cfa} 1142 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$1176 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$ 1143 1177 \end{cfa} 1144 1178 \item 1145 1179 L ©-~©\index{-~@©-~©} H is explicit down-to exclusive range [H,L\R{)}, where L and H are implicitly interchanged to make the range down-to. 1146 1180 \begin{cfa} 1147 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$1181 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$ 1148 1182 \end{cfa} 1149 1183 \item 1150 1184 L ©-~=©\index{-~=@©-~=©} H is explicit down-to inclusive range [H,L\R{]}, where L and H are implicitly interchanged to make the range down-to. 1151 1185 \begin{cfa} 1152 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$1186 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$ 1153 1187 \end{cfa} 1154 1188 \item 1155 1189 ©@© means put nothing in this field. 1156 1190 \begin{cfa} 1157 for ( i; 1 ~ ®@® ~ 2 ) $\C{// for ( typeof(1) i = 1; \R{/* empty */}; i += 2 )}$1158 for ( i; 1 ~ 10 ~ ®@® ) $\C{// for ( typeof(1) i = 1; i < 10; \R{/* empty */} )}$1159 for ( i; 1 ~ ®@® ~ ®@® ) $\C{// for ( typeof(1) i = 1; /*empty*/; \R{/* empty */} )}$1191 for ( i; 1 ~ ®@® ~ 2 ) $\C{// for ( typeof(1) i = 1; \R{/* empty */}; i += 2 )}$ 1192 for ( i; 1 ~ 10 ~ ®@® ) $\C{// for ( typeof(1) i = 1; i < 10; \R{/* empty */} )}$ 1193 for ( i; 1 ~ ®@® ~ ®@® ) $\C{// for ( typeof(1) i = 1; /*empty*/; \R{/* empty */} )}$ 1160 1194 \end{cfa} 1161 1195 L cannot be elided for the up-to range, \lstinline{@ ~ 5}, and H for the down-to range, \lstinline{1 -~ @}, because then the loop index is uninitialized. … … 1164 1198 ©:© means low another index. 1165 1199 \begin{cfa} 1166 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$1200 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$ 1167 1201 \end{cfa} 1168 1202 \end{itemize} 1169 1203 \R{Warning}: specifying the down-to range maybe unexpected because the loop control \emph{implicitly} switches the L and H values (and toggles the increment/decrement for I): 1170 1204 \begin{cfa} 1171 for ( i; 1 ~ 10 ) ${\C[1.5in]{// up range}$1172 for ( i; 1 -~ 10 ) ${\C{// down range}$1173 for ( i; ®10 -~ 1® ) ${\C{// \R{WRONG down range!}}\CRT}$1205 for ( i; 1 ~ 10 ) ${\C{// up range}$ 1206 for ( i; 1 -~ 10 ) ${\C{// down range}$ 1207 for ( i; ®10 -~ 1® ) ${\C{// \R{WRONG down range!}}}$ 1174 1208 \end{cfa} 1175 1209 The reason for this semantics is that the range direction can be toggled by adding/removing the minus, ©'-'©, versus interchanging the L and H expressions, which has a greater chance of introducing errors. … … 1188 1222 1189 1223 \begin{figure} 1190 \centering1191 1224 \begin{lrbox}{\myboxA} 1192 \begin{cfa}[tabsize= 3]1225 \begin{cfa}[tabsize=4] 1193 1226 ®Compound:® { 1194 1227 ®Try:® try { … … 1220 1253 1221 1254 \begin{lrbox}{\myboxB} 1222 \begin{cfa}[tabsize= 3]1255 \begin{cfa}[tabsize=4] 1223 1256 { 1224 1257 … … 1249 1282 \end{lrbox} 1250 1283 1251 \subfloat[ \CFA]{\label{f:CFibonacci}\usebox\myboxA}1284 \subfloat[C]{\label{f:CFAFibonacciGen}\usebox\myboxB} 1252 1285 \hspace{3pt} 1253 1286 \vrule 1254 1287 \hspace{3pt} 1255 \subfloat[ C]{\label{f:CFAFibonacciGen}\usebox\myboxB}1288 \subfloat[\CFA]{\label{f:CFibonacci}\usebox\myboxA} 1256 1289 \caption{Multi-level Exit} 1257 1290 \label{f:MultiLevelExit} … … 1287 1320 int a[10]; 1288 1321 \end{cfa} 1289 \begin{tabular}{@{}l ll@{}}1322 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{3em}}l@{}} 1290 1323 \begin{cfa} 1291 1324 … … 1328 1361 Grouping heterogeneous data into an \newterm{aggregate} (structure/union) is a common programming practice, and aggregates may be nested: 1329 1362 \begin{cfa} 1330 struct Person { $\C{// aggregate}$ 1331 struct Name { char first[20], last[20]; } name $\C{// nesting}$ 1332 struct Address { ... } address $\C{// nesting}$ 1363 struct Person { $\C{// aggregate}$ 1364 struct Name { $\C{// nesting}$ 1365 char first[20], last[20]; 1366 } name; 1367 struct Address { $\C{// nesting}$ 1368 ... 1369 } address; 1333 1370 int sex; 1334 1371 }; … … 1337 1374 \begin{cfa} 1338 1375 Person p 1339 ®p.®name; ®p.®address; ®p.®sex; 1376 ®p.®name; ®p.®address; ®p.®sex; $\C{// access containing fields}$ 1340 1377 \end{cfa} 1341 1378 which extends to multiple levels of qualification for nested aggregates and multiple aggregates. … … 1352 1389 \begin{cfa} 1353 1390 struct S { 1354 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) ));1391 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) )); 1355 1392 int tag; 1356 union $\R{\LstCommentStyle{/* unnamed */}}$ {1393 union $\R{\LstCommentStyle{/* unnamed */}}$ { 1357 1394 struct { char c1, c2; } __attribute__(( aligned(128) )); 1358 1395 struct { int i1, i2; }; … … 1368 1405 struct S { 1369 1406 char ®c®; int ®i®; double ®d®; 1370 void f( /* S * this */ ) { 1371 ®c®; ®i®; ®d®; 1407 void f( /* S * this */ ) { $\C{// implicit ``this'' parameter}$ 1408 ®c®; ®i®; ®d®; $\C{// this->c; this->i; this->d;}$ 1372 1409 } 1373 1410 } … … 1377 1414 \begin{cfa} 1378 1415 struct T { 1379 char ®m®; int ®i®; double ®n®; 1416 char ®m®; int ®i®; double ®n®; $\C{// derived class variables}$ 1380 1417 }; 1381 1418 struct S : public T { 1382 char ®c®; int ®i®; double ®d®; 1419 char ®c®; int ®i®; double ®d®; $\C{// class variables}$ 1383 1420 void g( double ®d®, T & t ) { 1384 d; ®t®.m; ®t®.i; ®t®.n; 1385 c; i; ®this->®d; ®S::®d; 1386 m; ®T::®i; n; 1421 d; ®t®.m; ®t®.i; ®t®.n; $\C{// function parameter}$ 1422 c; i; ®this->®d; ®S::®d; $\C{// class S variables}$ 1423 m; ®T::®i; n; $\C{// class T variables}$ 1387 1424 } 1388 1425 }; … … 1394 1431 Hence, the qualified fields become variables with the side-effect that it is simpler to write, easier to read, and optimize field references in a block. 1395 1432 \begin{cfa} 1396 void f( S & this ) ®with ( this )® { 1397 ®c®; ®i®; ®d®; 1433 void f( S & this ) ®with ( this )® { $\C{// with statement}$ 1434 ®c®; ®i®; ®d®; $\C{// this.c, this.i, this.d}$ 1398 1435 } 1399 1436 \end{cfa} 1400 1437 with the generality of opening multiple aggregate-parameters: 1401 1438 \begin{cfa} 1402 void g( S & s, T & t ) ®with ( s, t )® { 1403 c; ®s.®i; d; 1404 m; ®t.®i; n; 1439 void g( S & s, T & t ) ®with ( s, t )® {$\C{// multiple aggregate parameters}$ 1440 c; ®s.®i; d; $\C{// s.c, s.i, s.d}$ 1441 m; ®t.®i; n; $\C{// t.m, t.i, t.n}$ 1405 1442 } 1406 1443 \end{cfa} … … 1425 1462 struct R { int ®i®; int j; double ®m®; } r, w; 1426 1463 with ( r, q ) { 1427 j + k; 1428 m = 5.0; 1429 m = 1; 1430 int a = m; 1431 double b = m; 1432 int c = r.i + q.i; 1433 (double)m; 1464 j + k; $\C{// unambiguous, r.j + q.k}$ 1465 m = 5.0; $\C{// unambiguous, q.m = 5.0}$ 1466 m = 1; $\C{// unambiguous, r.m = 1}$ 1467 int a = m; $\C{// unambiguous, a = r.i }$ 1468 double b = m; $\C{// unambiguous, b = q.m}$ 1469 int c = r.i + q.i; $\C{// disambiguate with qualification}$ 1470 (double)m; $\C{// disambiguate with cast}$ 1434 1471 } 1435 1472 \end{cfa} … … 1439 1476 \begin{cfa} 1440 1477 with ( r ) { 1441 i; 1478 i; $\C{// unambiguous, r.i}$ 1442 1479 with ( q ) { 1443 i; 1480 i; $\C{// unambiguous, q.i}$ 1444 1481 } 1445 1482 } … … 1448 1485 A cast can also be used to disambiguate among overload variables in a ©with© \emph{expression}: 1449 1486 \begin{cfa} 1450 with ( w ) { ... } 1451 with ( (Q)w ) { ... } 1487 with ( w ) { ... } $\C{// ambiguous, same name and no context}$ 1488 with ( (Q)w ) { ... } $\C{// unambiguous, cast}$ 1452 1489 \end{cfa} 1453 1490 Because there is no left-side in the ©with© expression to implicitly disambiguate between the ©w© variables, it is necessary to explicitly disambiguate by casting ©w© to type ©Q© or ©R©. … … 1456 1493 \begin{cfa} 1457 1494 void f( S & s, char c ) with ( s ) { 1458 ®s.c = c;® i = 3; d = 5.5; 1495 ®s.c = c;® i = 3; d = 5.5; $\C{// initialize fields}$ 1459 1496 } 1460 1497 \end{cfa} … … 1462 1499 To solve this problem, parameters \emph{not} explicitly opened are treated like an initialized aggregate: 1463 1500 \begin{cfa} 1464 struct Params { 1501 struct Params { $\C{// s explicitly opened so S \& s elided}$ 1465 1502 char c; 1466 1503 } params; … … 1481 1518 Transfer of control can be local, within a routine, or non-local, among routines. 1482 1519 Non-local transfer can cause stack unwinding, \ie non-local routine termination, depending on the kind of raise. 1520 1521 Currently, \CFA uses macros ©ExceptionDecl© and ©ExceptionInst© to declare and instantiate an exception. 1522 \begin{cfa} 1523 #include <Exception.hfa> 1524 ®ExceptionDecl®( E, // must be global scope 1525 ... // exception fields 1526 ); 1527 try { 1528 ... 1529 if ( ... ) ®throwResume® ®ExceptionInst®( E, /* intialization */ ); 1530 if ( ... ) ®throw® ®ExceptionInst®( E, /* intialization */ ); 1531 ... 1532 } ®catchResume®( E * ) { // must be pointer 1533 ... 1534 } catch( E * ) { 1535 ... 1536 } 1537 \end{cfa} 1538 1483 1539 \begin{cfa} 1484 1540 exception_t E {}; $\C{// exception type}$ … … 1489 1545 try { 1490 1546 f(...); 1491 } catch( E e ; $boolean-predicate$ ) { 1547 } catch( E e ; $boolean-predicate$ ) { $\C{// termination handler}$ 1492 1548 // recover and continue 1493 1549 } catchResume( E e ; $boolean-predicate$ ) { $\C{// resumption handler}$ … … 1501 1557 The ©catch© and ©catchResume© handlers may appear in any oder. 1502 1558 However, the ©finally© clause must appear at the end of the ©try© statement. 1559 1560 1561 \section{Non-local Exception} 1562 1563 \begin{cfa} 1564 void main() { 1565 try { 1566 _Enable { 1567 ... resume(); ... 1568 } 1569 } ®catchResume®( E & ) { // should be reference 1570 ... 1571 } catch( E & ) { 1572 ... 1573 } 1574 } 1575 \end{cfa} 1503 1576 1504 1577 … … 1566 1639 \begin{cquote} 1567 1640 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1568 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1641 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1642 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1643 ®int® #*# x1 #[5]#; 1644 ®int® #(*#x2#)[5]#; 1645 #int (*#f®( int p )®#)[5]#; 1646 \end{cfa} 1647 & 1569 1648 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1570 1649 #[5] *# ®int® x1; 1571 1650 #* [5]# ®int® x2; 1572 1651 #[* [5] int]# f®( int p )®; 1573 \end{cfa}1574 &1575 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}]1576 ®int® #*# x1 #[5]#;1577 ®int® #(*#x2#)[5]#;1578 #int (*#f®( int p )®#)[5]#;1579 1652 \end{cfa} 1580 1653 \end{tabular} … … 1586 1659 \begin{cquote} 1587 1660 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1588 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1661 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1662 \begin{cfa} 1663 int ®*®x, ®*®y; 1664 \end{cfa} 1665 & 1589 1666 \begin{cfa} 1590 1667 ®*® int x, y; 1591 \end{cfa}1592 &1593 \begin{cfa}1594 int ®*®x, ®*®y;1595 1668 \end{cfa} 1596 1669 \end{tabular} … … 1599 1672 \begin{cquote} 1600 1673 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1601 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1674 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1675 \begin{cfa} 1676 int ®*®x, y; 1677 1678 \end{cfa} 1679 & 1602 1680 \begin{cfa} 1603 1681 ®*® int x; 1604 1682 int y; 1605 \end{cfa}1606 &1607 \begin{cfa}1608 int ®*®x, y;1609 1610 1683 \end{cfa} 1611 1684 \end{tabular} … … 1615 1688 \begin{cquote} 1616 1689 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1617 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1690 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1691 \begin{cfa} 1692 int z[ 5 ]; 1693 char * w[ 5 ]; 1694 double (* v)[ 5 ]; 1695 struct s { 1696 int f0:3; 1697 int * f1; 1698 int * f2[ 5 ] 1699 }; 1700 \end{cfa} 1701 & 1618 1702 \begin{cfa} 1619 1703 [ 5 ] int z; … … 1628 1712 & 1629 1713 \begin{cfa} 1630 int z[ 5 ];1631 char * w[ 5 ];1632 double (* v)[ 5 ];1633 struct s {1634 int f0:3;1635 int * f1;1636 int * f2[ 5 ]1637 };1638 \end{cfa}1639 &1640 \begin{cfa}1641 1714 // array of 5 integers 1642 1715 // array of 5 pointers to char … … 1654 1727 \begin{cquote} 1655 1728 \begin{tabular}{@{}l@{\hspace{1em}}l@{\hspace{1em}}l@{}} 1656 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} \\ 1729 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} \\ 1730 \begin{cfa} 1731 int const * const x; 1732 const int (* const y)[ 5 ] 1733 \end{cfa} 1734 & 1657 1735 \begin{cfa} 1658 1736 const * const int x; 1659 1737 const * [ 5 ] const int y; 1660 \end{cfa}1661 &1662 \begin{cfa}1663 int const * const x;1664 const int (* const y)[ 5 ]1665 1738 \end{cfa} 1666 1739 & … … 1675 1748 \begin{cquote} 1676 1749 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1677 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1750 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1751 \begin{cfa} 1752 int extern x[ 5 ]; 1753 const int static * y; 1754 \end{cfa} 1755 & 1678 1756 \begin{cfa} 1679 1757 extern [ 5 ] int x; 1680 1758 static * const int y; 1681 \end{cfa}1682 &1683 \begin{cfa}1684 int extern x[ 5 ];1685 const int static * y;1686 1759 \end{cfa} 1687 1760 & … … 1696 1769 \begin{cquote} 1697 1770 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1698 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1771 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1772 \begin{cfa} 1773 y = (int *)x; 1774 i = sizeof(int * [ 5 ]); 1775 \end{cfa} 1776 & 1699 1777 \begin{cfa} 1700 1778 y = (* int)x; 1701 1779 i = sizeof([ 5 ] * int); 1702 \end{cfa}1703 &1704 \begin{cfa}1705 y = (int *)x;1706 i = sizeof(int * [ 5 ]);1707 1780 \end{cfa} 1708 1781 \end{tabular} … … 1899 1972 \begin{cquote} 1900 1973 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1901 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1974 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{Cy}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1975 \begin{cfa} 1976 const int * ®const® * ®const® ccp; 1977 1978 \end{cfa} 1979 & 1902 1980 \begin{cfa} 1903 1981 ®const® * ®const® * const int ccp; 1904 1982 ®const® & ®const® & const int ccr; 1905 \end{cfa}1906 &1907 \begin{cfa}1908 const int * ®const® * ®const® ccp;1909 1910 1983 \end{cfa} 1911 1984 \end{tabular} … … 2068 2141 \begin{cfa} 2069 2142 int x, &r = ®x®, f( int & p ); $\C{// lvalue variable (int) convert to reference (int \&)}$ 2070 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)} $2143 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)}\CRT$ 2071 2144 \end{cfa} 2072 2145 Conversion can restrict a type, where ©cv1© $\le$ ©cv2©, \eg passing an ©int© to a ©const volatile int &©, which has low cost. … … 4430 4503 \end{cfa} 4431 4504 To match a minus, put it as the first character, ©"-0-9"©. 4432 Note, other complex forms of regular-expression matching isnot supported.4505 Other complex forms of regular-expression matching are not supported. 4433 4506 4434 4507 The following \Index{manipulator}s control scanning of input values (reading), and only affect the format of the argument. … … 8628 8701 \begin{cquote} 8629 8702 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}} 8630 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{ \CFA}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{C}} \\8703 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{C}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{\CFA}} \\ 8631 8704 \hline 8632 \begin{cfa}8633 #include <gmp.hfa>$\indexc{gmp}$8634 int main( void ) {8635 sout | "Factorial Numbers";8636 Int fact = 1;8637 8638 sout | 0 | fact;8639 for ( i; 40 ) {8640 fact *= i;8641 sout | i | fact;8642 }8643 }8644 \end{cfa}8645 &8646 8705 \begin{cfa} 8647 8706 #include <gmp.h>$\indexc{gmp.h}$ … … 8654 8713 ®mpz_mul_ui®( fact, fact, i ); 8655 8714 ®gmp_printf®( "%d %Zd\n", i, fact ); 8715 } 8716 } 8717 \end{cfa} 8718 & 8719 \begin{cfa} 8720 #include <gmp.hfa>$\indexc{gmp}$ 8721 int main( void ) { 8722 sout | "Factorial Numbers"; 8723 Int fact = 1; 8724 8725 sout | 0 | fact; 8726 for ( i; 40 ) { 8727 fact *= i; 8728 sout | i | fact; 8656 8729 } 8657 8730 } -
driver/cc1.cc
r85034ed r8cbe732 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 9 11:36:44202313 // Update Count : 42 312 // Last Modified On : Mon Sep 25 11:07:22 2023 13 // Update Count : 427 14 14 // 15 15 16 16 #include <iostream> 17 using std::cerr;18 using std::endl;19 17 #include <string> 20 using std::string;21 18 #include <algorithm> // find 22 19 #include <cstdio> // stderr, stdout, perror, fprintf 23 20 #include <cstdlib> // getenv, exit, mkstemp 21 using namespace std; 24 22 #include <unistd.h> // execvp, fork, unlink 25 23 #include <sys/wait.h> // wait … … 52 50 if ( dot == string::npos ) return; 53 51 const string * end = suffixes + NumSuffixes; 54 if ( std::find( suffixes, end, arg.substr( dot + 1 ) ) != end ) {52 if ( find( suffixes, end, arg.substr( dot + 1 ) ) != end ) { 55 53 args[nargs++] = "-x"; 56 54 args[nargs++] = "c"; … … 153 151 154 152 #ifdef __DEBUG_H__ 155 cerr << " Stage1" << endl;153 cerr << "#########" << endl << "Stage1 " << string( 100, '#' ) << endl << "#########" << endl; 156 154 #endif // __DEBUG_H__ 157 155 checkEnv1(); // arguments passed via environment variables 158 156 #ifdef __DEBUG_H__ 157 cerr << string( 100, '*' ) << endl; 159 158 for ( int i = 1; i < argc; i += 1 ) { 160 159 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 161 160 } // for 161 cerr << string( 100, '*' ) << endl; 162 162 #endif // __DEBUG_H__ 163 163 … … 260 260 } else { 261 261 args[nargs++] = "-x"; 262 args[nargs++] = ( *new string( lang .c_str()) ).c_str();262 args[nargs++] = ( *new string( lang ) ).c_str(); 263 263 } // if 264 264 args[nargs++] = cpp_in; … … 275 275 } // for 276 276 cerr << endl; 277 cerr << string( 100, '*' ) << endl; 277 278 #endif // __DEBUG_H__ 278 279 … … 298 299 } else { 299 300 args[nargs++] = "-x"; 300 args[nargs++] = ( *new string( lang .c_str()) ).c_str();301 args[nargs++] = ( *new string( lang ) ).c_str(); 301 302 } // if 302 303 args[nargs++] = cpp_in; // input to cpp … … 346 347 347 348 #ifdef __DEBUG_H__ 348 cerr << " Stage2" << endl;349 cerr << "#########" << endl << "Stage2 " << string( 100, '#' ) << endl << "#########" << endl; 349 350 #endif // __DEBUG_H__ 350 351 checkEnv2( cargs, ncargs ); // arguments passed via environment variables 351 352 #ifdef __DEBUG_H__ 353 cerr << string( 100, '*' ) << endl; 352 354 for ( int i = 1; i < argc; i += 1 ) { 353 355 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 354 356 } // for 357 cerr << string( 100, '*' ) << endl; 355 358 #endif // __DEBUG_H__ 356 359 … … 473 476 if ( CFA_flag ) { // run cfa-cpp ? 474 477 if ( o_file.size() != 0 ) { // location for output 475 cargs[ncargs++] = ( *new string( o_file .c_str()) ).c_str();478 cargs[ncargs++] = ( *new string( o_file ) ).c_str(); 476 479 } // if 477 480 } else { … … 571 574 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 572 575 #ifdef __DEBUG_H__ 573 for ( int i = 0; env[i] != nullptr; i += 1 ) { 574 cerr << env[i] << endl; 575 } // for 576 cerr << "#########" << endl << "main cc1 " << string( 100, '#' ) << endl << "#########" << endl; 576 577 #endif // __DEBUG_H__ 577 578 -
driver/cfa.cc
r85034ed r8cbe732 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 30 21:48:48202313 // Update Count : 48 012 // Last Modified On : Thu Sep 28 21:53:54 2023 13 // Update Count : 484 14 14 // 15 15 … … 20 20 #include <string> // STL version 21 21 #include <algorithm> // find 22 using namespace std; 22 23 23 24 #include <unistd.h> // execvp … … 27 28 #include "Common/SemanticError.h" 28 29 #include "config.h" // configure info 29 30 using std::cerr;31 using std::endl;32 using std::string;33 using std::to_string;34 30 35 31 //#define __DEBUG_H__ -
libcfa/src/collections/string_res.cfa
r85034ed r8cbe732 218 218 // Read in chunks. Often, one chunk is enough. Keep the string that accumulates chunks last in the heap, 219 219 // so available room is rest of heap. When a chunk fills the heap, force growth then take the next chunk. 220 for (;;) { 220 for (bool cont = true; cont; ) { 221 cont = false; 222 221 223 // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops) 222 224 // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator … … 228 230 temp.Handle.ulink->EndVbyte -= 2; 229 231 230 // rest of heap , less 1 byte for null terminator,is available to read into231 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte - 1;232 assert (lenReadable >= 1);232 // rest of heap is available to read into 233 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte; 234 assert (lenReadable >= 2); 233 235 234 236 // get bytes 235 in | wdi( lenReadable + 1, lenReadable, temp.Handle.ulink->EndVbyte ); 237 try { 238 in | wdi( lenReadable, temp.Handle.ulink->EndVbyte ); 239 } catch (cstring_length*) { 240 cont = true; 241 } 236 242 int lenWasRead = strlen(temp.Handle.ulink->EndVbyte); 237 243 … … 239 245 temp.Handle.lnth += lenWasRead; 240 246 temp.Handle.ulink->EndVbyte += lenWasRead; 241 242 if (lenWasRead < lenReadable) break;243 247 } 244 248 -
libcfa/src/concurrency/channel.hfa
r85034ed r8cbe732 130 130 static inline void __cons_handoff( channel(T) & chan, T & elem ) with(chan) { 131 131 memcpy( cons`first.extra, (void *)&elem, sizeof(T) ); // do waiting consumer work 132 __atomic_thread_fence( __ATOMIC_SEQ_CST ); 132 133 wake_one( cons ); 133 134 } … … 136 137 static inline void __prods_handoff( channel(T) & chan, T & retval ) with(chan) { 137 138 memcpy( (void *)&retval, prods`first.extra, sizeof(T) ); 139 __atomic_thread_fence( __ATOMIC_SEQ_CST ); 138 140 wake_one( prods ); 139 141 } -
libcfa/src/concurrency/cofor.cfa
r85034ed r8cbe732 4 4 // cofor ( uC++ COFOR ) 5 5 6 thread co _runner {6 thread cofor_runner { 7 7 ssize_t low, high; 8 8 __cofor_body_t loop_body; 9 9 }; 10 10 11 static void ?{}( co _runner & this, ssize_t low, ssize_t high, __cofor_body_t loop_body ) {11 static void ?{}( cofor_runner & this, ssize_t low, ssize_t high, __cofor_body_t loop_body ) { 12 12 this.low = low; 13 13 this.high = high; … … 15 15 } 16 16 17 void main( co _runner & this ) with( this ) {17 void main( cofor_runner & this ) with( this ) { 18 18 for ( ssize_t i = low; i < high; i++ ) 19 19 loop_body(i); 20 20 } 21 21 22 void cofor( ssize_t low, ssize_t high, __cofor_body_t loop_body ) libcfa_public {22 void __Cofor__( ssize_t low, ssize_t high, __cofor_body_t loop_body ) libcfa_public { 23 23 ssize_t range = high - low; 24 24 if ( range <= 0 ) return; … … 29 29 ssize_t i = 0; 30 30 ssize_t stride_iter = low; 31 co _runner * runners[ threads ];31 cofor_runner * runners[ threads ]; 32 32 for ( i; threads ) { 33 33 runners[i] = alloc(); … … 45 45 } 46 46 47 //////////////////////////////////////////////////////////////////////////////////////////48 // parallel (COBEGIN/COEND)49 47 50 thread para_runner {51 parallel_stmt_t body;52 void * arg;53 };54 55 static void ?{}( para_runner & this, parallel_stmt_t body, void * arg ) {56 this.body = body;57 this.arg = arg;58 }59 60 void main( para_runner & this ) with( this ) { body( arg ); }61 62 void parallel( parallel_stmt_t * stmts, void ** args, size_t num ) libcfa_public {63 para_runner * runners[ num ];64 for ( i; num )65 (*(runners[i] = malloc())){ stmts[i], args[i] };66 for ( i; num )67 delete( runners[i] );68 }69 -
libcfa/src/concurrency/cofor.hfa
r85034ed r8cbe732 5 5 typedef void (*__cofor_body_t)( ssize_t ); 6 6 7 void cofor( ssize_t low, ssize_t high, __cofor_body_t loop_body );7 void __Cofor__( ssize_t low, ssize_t high, __cofor_body_t loop_body ); 8 8 9 9 #define COFOR( lidname, low, high, loopbody ) \ … … 12 12 loopbody \ 13 13 } \ 14 cofor( low, high, __CFA_loopLambda__ ); \14 __Cofor__( low, high, __CFA_loopLambda__ ); \ 15 15 } 16 16 17 17 ////////////////////////////////////////////////////////////////////////////////////////// 18 // parallel (COBEGIN/COEND) 19 typedef void (*parallel_stmt_t)( void * ); 18 // corun 20 19 21 void parallel( parallel_stmt_t * stmts, void ** args, size_t num ); 20 // 21 typedef void (*__CFA_corun_lambda_t)( void ); 22 23 // used to run a corun statement in parallel 24 thread co_runner { 25 __CFA_corun_lambda_t body; 26 }; 27 28 // wraps a co_runner to provide RAII deallocation 29 struct runner_block { 30 co_runner * runner; 31 }; 32 static inline void ?{}( co_runner & this, __CFA_corun_lambda_t body ) { this.body = body; } 33 34 void main( co_runner & this ) with( this ) { body(); } 35 36 static inline void ?{}( runner_block & this ) {} 37 static inline void ?{}( runner_block & this, __CFA_corun_lambda_t body ) { 38 (*(this.runner = malloc())){ body }; 39 } 40 41 static inline void ^?{}( runner_block & this ) { 42 delete( this.runner ); 43 } 44 -
libcfa/src/concurrency/coroutine.cfa
r85034ed r8cbe732 343 343 344 344 bool poll() libcfa_public { return poll( active_coroutine() ); } 345 void enable_ehm() libcfa_public { active_coroutine()->ehm_state.ehm_enabled = true; } 346 void disable_ehm() libcfa_public { active_coroutine()->ehm_state.ehm_enabled = false; } 347 bool checked_poll() libcfa_public { return active_coroutine()->ehm_state.ehm_enabled ? poll( active_coroutine() ) : false; } 345 348 coroutine$ * resumer() libcfa_public { return active_coroutine()->last; } 346 349 coroutine$ * first_resumer() libcfa_public { return active_coroutine()->starter; } -
libcfa/src/concurrency/coroutine.hfa
r85034ed r8cbe732 224 224 225 225 // non local ehm and coroutine utility routines 226 void enable_ehm(); 227 void disable_ehm(); 226 228 bool poll( coroutine$ * cor ); 227 229 bool poll(); 230 bool checked_poll(); 228 231 coroutine$ * resumer(); 229 232 coroutine$ * first_resumer(); 230 233 231 234 forall(T & | is_coroutine(T)) { 232 void enable_ehm( T & cor ); 233 void disable_ehm( T & cor ); 235 void enable_ehm( T & cor ); // enable checking non-local exceptions for cor via checked_poll 236 void disable_ehm( T & cor ); // disable checking non-local exceptions for cor via checked_poll 234 237 bool poll( T & cor ); 235 bool checked_poll( T & cor ); 238 bool checked_poll( T & cor ); // check for non-local exceptions while respecting enable/disable 236 239 coroutine$ * resumer( T & cor ); 237 240 coroutine$ * first_resumer( T & cor ); -
libcfa/src/concurrency/kernel/fwd.hfa
r85034ed r8cbe732 118 118 // Yield: yield N times 119 119 static inline void yield( size_t times ) { 120 for ( times ) {120 for ( times ) { 121 121 yield(); 122 122 } … … 136 136 137 137 bool wait(single_sem & this) { 138 for () {138 for () { 139 139 struct thread$ * expected = this.ptr; 140 if (expected == 1p) {141 if (__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {140 if (expected == 1p) { 141 if (__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 142 142 return false; 143 143 } … … 145 145 else { 146 146 /* paranoid */ verify( expected == 0p ); 147 if (__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {147 if (__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 148 148 park(); 149 149 return true; … … 155 155 156 156 bool post(single_sem & this) { 157 for () {157 for () { 158 158 struct thread$ * expected = this.ptr; 159 if (expected == 1p) return false;160 if (expected == 0p) {161 if (__atomic_compare_exchange_n(&this.ptr, &expected, 1p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {159 if (expected == 1p) return false; 160 if (expected == 0p) { 161 if (__atomic_compare_exchange_n(&this.ptr, &expected, 1p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 162 162 return false; 163 163 } 164 164 } 165 165 else { 166 if (__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {166 if (__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 167 167 unpark( expected ); 168 168 return true; … … 195 195 // return true if the thread was parked 196 196 bool wait(oneshot & this) { 197 for () {197 for () { 198 198 struct thread$ * expected = this.ptr; 199 if (expected == oneshot_FULFILLED) return false;200 if (__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {199 if (expected == oneshot_FULFILLED) return false; 200 if (__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 201 201 park(); 202 202 /* paranoid */ verify( this.ptr == oneshot_FULFILLED ); … … 210 210 thread$ * post(oneshot & this, bool do_unpark = true) { 211 211 struct thread$ * got = __atomic_exchange_n( &this.ptr, oneshot_FULFILLED, __ATOMIC_SEQ_CST); 212 if ( got == oneshot_ARMED || got == oneshot_FULFILLED ) return 0p;213 if (do_unpark) unpark( got );212 if ( got == oneshot_ARMED || got == oneshot_FULFILLED ) return 0p; 213 if (do_unpark) unpark( got ); 214 214 return got; 215 215 } … … 255 255 /* paranoid */ verify( wait_ctx.ptr == oneshot_ARMED || wait_ctx.ptr == oneshot_FULFILLED ); 256 256 // The future needs to set the wait context 257 for () {257 for () { 258 258 struct oneshot * expected = this.ptr; 259 259 // Is the future already fulfilled? 260 if (expected == future_FULFILLED) return false; // Yes, just return false (didn't block)260 if (expected == future_FULFILLED) return false; // Yes, just return false (didn't block) 261 261 262 262 // The future is not fulfilled, try to setup the wait context 263 if (__atomic_compare_exchange_n(&this.ptr, &expected, &wait_ctx, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {263 if (__atomic_compare_exchange_n(&this.ptr, &expected, &wait_ctx, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 264 264 return true; 265 265 } … … 276 276 277 277 // attempt to remove the context so it doesn't get consumed. 278 if (__atomic_compare_exchange_n( &this.ptr, &expected, future_ARMED, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {278 if (__atomic_compare_exchange_n( &this.ptr, &expected, future_ARMED, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 279 279 // we still have the original context, then no one else saw it 280 280 return false; … … 282 282 283 283 // expected == ARMED: future was never actually setup, just return 284 if ( expected == future_ARMED ) return false;284 if ( expected == future_ARMED ) return false; 285 285 286 286 // expected == FULFILLED: the future is ready and the context was fully consumed 287 287 // the server won't use the pointer again 288 288 // It is safe to delete (which could happen after the return) 289 if ( expected == future_FULFILLED ) return true;289 if ( expected == future_FULFILLED ) return true; 290 290 291 291 // expected == PROGRESS: the future is ready but the context hasn't fully been consumed 292 292 // spin until it is safe to move on 293 if ( expected == future_PROGRESS ) {293 if ( expected == future_PROGRESS ) { 294 294 while( this.ptr != future_FULFILLED ) Pause(); 295 295 /* paranoid */ verify( this.ptr == future_FULFILLED ); … … 310 310 311 311 // If the future isn't already fulfilled, let the server delete it 312 if ( got == future_ARMED ) return false;312 if ( got == future_ARMED ) return false; 313 313 314 314 // got == PROGRESS: the future is ready but the context hasn't fully been consumed 315 315 // spin until it is safe to move on 316 if ( got == future_PROGRESS ) {316 if ( got == future_PROGRESS ) { 317 317 while( this.ptr != future_FULFILLED ) Pause(); 318 318 got = future_FULFILLED; … … 327 327 // from the server side, mark the future as fulfilled 328 328 // delete it if needed 329 329 330 thread$ * fulfil( future_t & this, bool do_unpark = true ) { 330 for () {331 for () { 331 332 struct oneshot * expected = this.ptr; 332 // was this abandoned? 333 333 334 #if defined(__GNUC__) && __GNUC__ >= 7 334 #pragma GCC diagnostic push 335 #pragma GCC diagnostic ignored "-Wfree-nonheap-object" 335 // SKULLDUGGERY: gcc bug does not handle push/pop for -Wfree-nonheap-object 336 //#pragma GCC diagnostic push 337 #pragma GCC diagnostic ignored "-Wfree-nonheap-object" 336 338 #endif 337 if( expected == future_ABANDONED ) { free( &this ); return 0p; } 339 340 if ( expected == future_ABANDONED ) { free( &this ); return 0p; } 341 338 342 #if defined(__GNUC__) && __GNUC__ >= 7 339 343 //#pragma GCC diagnostic pop 340 344 #endif 341 345 … … 346 350 // If there is no context then we can skip the in progress phase 347 351 struct oneshot * want = expected == future_ARMED ? future_FULFILLED : future_PROGRESS; 348 if (__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {349 if ( expected == future_ARMED ) { return 0p; }352 if (__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 353 if ( expected == future_ARMED ) { return 0p; } 350 354 thread$ * ret = post( *expected, do_unpark ); 351 355 __atomic_store_n( &this.ptr, future_FULFILLED, __ATOMIC_SEQ_CST); … … 359 363 bool wait( future_t & this ) { 360 364 oneshot temp; 361 if ( !setup(this, temp) ) return false;365 if ( !setup(this, temp) ) return false; 362 366 363 367 // Wait context is setup, just wait on it … … 387 391 // if any are already satisfied return 388 392 for ( i; num_futures ) { 389 if ( !setup(futures[i], temp) ) return futures[i];393 if ( !setup(futures[i], temp) ) return futures[i]; 390 394 } 391 395 … … 413 417 414 418 #define __STATS__(in_kernel, ...) { \ 415 if ( !(in_kernel) ) disable_interrupts(); \416 with ( *__tls_stats() ) { \419 if ( !(in_kernel) ) disable_interrupts(); \ 420 with ( *__tls_stats() ) { \ 417 421 __VA_ARGS__ \ 418 422 } \ 419 if ( !(in_kernel) ) enable_interrupts(); \423 if ( !(in_kernel) ) enable_interrupts(); \ 420 424 } 421 425 #if defined(CFA_HAVE_LINUX_IO_URING_H) 422 426 #define __IO_STATS__(in_kernel, ...) { \ 423 if ( !(in_kernel) ) disable_interrupts(); \424 with ( *__tls_stats() ) { \427 if ( !(in_kernel) ) disable_interrupts(); \ 428 with ( *__tls_stats() ) { \ 425 429 __VA_ARGS__ \ 426 430 } \ 427 if ( !(in_kernel) ) enable_interrupts(); \431 if ( !(in_kernel) ) enable_interrupts(); \ 428 432 } 429 433 #else … … 436 440 } 437 441 } 438 #endif 442 #endif // #endif -
libcfa/src/heap.cfa
r85034ed r8cbe732 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 11 11:21:10202313 // Update Count : 161 512 // Last Modified On : Sat Sep 30 17:31:15 2023 13 // Update Count : 1617 14 14 // 15 15 … … 53 53 #define TLSMODEL __attribute__(( tls_model("initial-exec") )) 54 54 55 //#define __STATISTICS__55 #define __STATISTICS__ 56 56 57 57 enum { … … 681 681 682 682 static HeapStatistics & collectStats( HeapStatistics & stats ) with( heapMaster ) { 683 lock( mgrLock );683 lock( heapMaster.mgrLock ); 684 684 685 685 stats += heapMaster.stats; … … 688 688 } // for 689 689 690 unlock( mgrLock );690 unlock( heapMaster.mgrLock ); 691 691 return stats; 692 692 } // collectStats 693 693 694 694 static inline void clearStats() { 695 lock( mgrLock );695 lock( heapMaster.mgrLock ); 696 696 697 697 // Zero the heap master and all active thread heaps. … … 701 701 } // for 702 702 703 unlock( mgrLock );703 unlock( heapMaster.mgrLock ); 704 704 } // clearStats 705 705 #endif // __STATISTICS__ -
libcfa/src/iostream.cfa
r85034ed r8cbe732 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : S at Sep 2 14:42:01 202314 // Update Count : 156 113 // Last Modified On : Sun Oct 8 12:10:21 2023 14 // Update Count : 1564 15 15 // 16 16 … … 22 22 #include <float.h> // DBL_DIG, LDBL_DIG 23 23 #include <complex.h> // creal, cimag 24 #include <ctype.h> // isspace 24 25 //#include <stdio.h> 25 26 … … 29 30 extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 30 31 extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 32 extern char *strchr(const char *str, int ch); 31 33 } // extern "C" 32 34 … … 649 651 exp10 = floor( exp10, 3 ); \ 650 652 value *= pow( 10.0, -exp10 ); \ 651 if ( pc < = 3) pc = 3; \653 if ( pc < 0 ) pc = 3; \ 652 654 } /* eng */ \ 653 655 \ … … 960 962 istype & ?|?( istype & is, _Istream_Cskip f ) { 961 963 // printf( "skip %s %d\n", f.scanset, f.wd ); 962 if ( f.scanset ) fmt( is, f.scanset, "" ); // no input arguments 964 if ( f.scanset ) { 965 int nscanset = strlen(f.scanset); 966 char fmtstr[ sizeof("%*[]") + nscanset ]; 967 int pos = 0; 968 fmtstr[pos] = '%'; pos += 1; 969 fmtstr[pos] = '*'; pos += 1; 970 fmtstr[pos] = '['; pos += 1; 971 strcpy( &fmtstr[pos], f.scanset ); pos += nscanset; 972 fmtstr[pos] = ']'; pos += 1; 973 fmtstr[pos] = '\0'; 974 fmt( is, fmtstr, (void*)0 ); // last arg is dummy: suppress gcc warning 975 } 963 976 else for ( f.wd ) fmt( is, "%*c" ); 964 977 return is; … … 980 993 // wd is buffer bytes available (for input chars + null terminator) 981 994 // rwd is count of input chars 982 int rwd = f.flags.rwd ? f.wd : (f.wd - 1); 995 int rwd; 996 if (f.flags.rwd) { 997 verify (f.wd >= 0); 998 rwd = f.wd; 999 } else { 1000 verify (f.wd >= 1); 1001 rwd = f.wd - 1; 1002 } // if 983 1003 start += sprintf( &fmtstr[start], "%d", rwd ); 984 1004 } … … 1000 1020 1001 1021 int check = f.wd - 2; 1002 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1022 if (! f.flags.ignore ) { 1023 f.s[0] = '\0'; 1024 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1025 } 1003 1026 len = fmt( is, fmtstr, f.s ); 1004 1027 //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1005 1028 1006 if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1007 throw (cstring_length){ &cstring_length_vt }; 1029 if ( ! f.flags.ignore && ! f.flags.rwd && f.s[check] != '\0' ) { // sentinel overwritten ? 1030 // buffer filled, but would we have kept going? 1031 if ( ! eof( is ) ) { 1032 char peek; 1033 fmt( is, "%c", &peek ); 1034 ungetc( is, peek ); 1035 bool hasMore; 1036 if (f.flags.delimiter) { // getline 1037 hasMore = (peek != f.delimiter[0]); 1038 } else if (f.scanset) { // incl/excl 1039 bool peekMatch = strchr(f.scanset, peek) != 0p; 1040 hasMore = f.flags.inex ? (!peekMatch) : (peekMatch); 1041 } else { // %s 1042 hasMore = !isspace(peek); 1043 } 1044 if (hasMore) throw (cstring_length){ &cstring_length_vt }; 1045 } // if 1046 } // if 1008 1047 1009 1048 if ( f.flags.delimiter ) { // getline ? -
libcfa/src/iostream.hfa
r85034ed r8cbe732 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Sep 2 14:42:13202313 // Update Count : 56 712 // Last Modified On : Sun Oct 8 12:02:55 2023 13 // Update Count : 568 14 14 // 15 15 … … 243 243 _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \ 244 244 _Ostream_Manip(T) sci( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'e', { .all : 0 } }; } \ 245 _Ostream_Manip(T) eng( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.eng : true } }; } \245 _Ostream_Manip(T) eng( T val ) { return (_Ostream_Manip(T))@{ val, 1, -1, 'g', { .flags.eng : true } }; } \ 246 246 _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'g', { .all : 0 } }; } \ 247 247 _Ostream_Manip(T) wd( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \ -
libcfa/src/rational.cfa
r85034ed r8cbe732 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 18 11:07:10202313 // Update Count : 19 712 // Last Modified On : Fri Oct 6 07:52:13 2023 13 // Update Count : 198 14 14 // 15 15 … … 76 76 } // denominator 77 77 78 [ T, T ] ?=?( & [ T, T ] d est, rational(T) src ) {79 return d est = src.[ numerator, denominator ];78 [ T, T ] ?=?( & [ T, T ] dst, rational(T) src ) { 79 return dst = src.[ numerator, denominator ]; 80 80 } // ?=? 81 81 -
libcfa/src/rational.hfa
r85034ed r8cbe732 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Tue Jul 18 11:08:24202315 // Update Count : 12 114 // Last Modified On : Fri Oct 6 07:52:20 2023 15 // Update Count : 122 16 16 // 17 17 … … 40 40 T numerator( rational(T) r ); 41 41 T denominator( rational(T) r ); 42 [ T, T ] ?=?( & [ T, T ] d est, rational(T) src );42 [ T, T ] ?=?( & [ T, T ] dst, rational(T) src ); 43 43 44 44 // numerator/denominator setter -
libcfa/src/stdlib.hfa
r85034ed r8cbe732 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Sep 2 18:29:35202313 // Update Count : 78 012 // Last Modified On : Sun Oct 8 09:18:28 2023 13 // Update Count : 789 14 14 // 15 15 … … 431 431 uint32_t seed; // current seed 432 432 PRNG_STATE_32_T state; // random state 433 }; // PRNG 433 }; // PRNG32 434 434 435 435 static inline { … … 442 442 uint32_t prng( PRNG32 & prng, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( prng, u - l + 1 ) + l; } // [l,u] 443 443 uint32_t calls( PRNG32 & prng ) __attribute__(( warn_unused_result )) with( prng ) { return callcnt; } 444 } // distribution 444 void copy( PRNG32 & dst, PRNG32 & src ) { dst = src; } // checkpoint PRNG state, use autogen assignment 445 } // distribution 446 void ?{}( PRNG32 &, PRNG32 & ) = void; // no copy, remove autogen copy constructor 447 PRNG32 & ?=?( PRNG32 &, const PRNG32 ) = void; // no assignment, remove autogen assignment 445 448 446 449 struct PRNG64 { … … 448 451 uint64_t seed; // current seed 449 452 PRNG_STATE_64_T state; // random state 450 }; // PRNG 453 }; // PRNG64 451 454 452 455 static inline { … … 459 462 uint64_t prng( PRNG64 & prng, uint64_t l, uint64_t u ) __attribute__(( warn_unused_result )) { return prng( prng, u - l + 1 ) + l; } // [l,u] 460 463 uint64_t calls( PRNG64 & prng ) __attribute__(( warn_unused_result )) with( prng ) { return callcnt; } 461 } // distribution 464 void copy( PRNG64 & dst, PRNG64 & src ) { dst = src; } // checkpoint PRNG state, use autogen assignment 465 } // distribution 466 void ?{}( PRNG64 &, PRNG64 & ) = void; // no copy, remove autogen copy constructor 467 PRNG64 & ?=?( PRNG64 &, const PRNG64 ) = void; // no assignment, remove autogen assignment 462 468 463 469 // Set default random-generator size. -
src/AST/Convert.cpp
r85034ed r8cbe732 269 269 node->location, 270 270 Type::StorageClasses( node->storage.val ), 271 271 get<Type>().accept1( node->base ), 272 272 LinkageSpec::Spec( node->linkage.val ) 273 273 ); … … 567 567 } 568 568 569 569 const ast::WhenClause * visit( const ast::WhenClause * node ) override final { 570 570 // There is no old-AST WhenClause, so this should never be called. 571 571 assert( !node ); … … 604 604 } 605 605 606 607 606 const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final { 607 // There is no old-AST WaitUntilStmt, so this should never be called. 608 608 assert( !node ); 609 609 return nullptr; … … 648 648 ); 649 649 return stmtPostamble( stmt, node ); 650 } 651 652 const ast::Stmt * visit( const ast::CorunStmt * node ) override final { 653 // There is no old-AST CorunStmt, so this should never be called. 654 assert( !node ); 655 return nullptr; 650 656 } 651 657 … … 853 859 // New workd: one public type: node->result, plus node->underlyer only to support roundtrip conversion 854 860 // preserving underlyer because the correct type for string literals is complicated to construct, 855 861 // and distinguishing a string from other literals using the type is hard to do accurately 856 862 // Both worlds: the outer, expression-level type can change during resolution 857 863 // for a string, that's char[k] before-resolve and char * after … … 859 865 // for a string, that's char[k] always 860 866 // Both worlds: the "rep" field of a constant is the C source file fragment that compiles to the desired value 861 867 // for a string, that includes outer quotes, backslashes, et al cases from the Literals test 862 868 ConstantExpr *rslt = new ConstantExpr(Constant( 863 869 get<Type>().accept1(node->underlyer), … … 1518 1524 return strict_dynamic_cast< ast::Decl * >( node ); 1519 1525 } 1520 1526 1521 1527 ConverterOldToNew() = default; 1522 1528 ConverterOldToNew(const ConverterOldToNew &) = delete; … … 1581 1587 ast::Label make_label(const Label* old) { 1582 1588 CodeLocation const & location = 1583 1589 ( old->labelled ) ? old->labelled->location : CodeLocation(); 1584 1590 return ast::Label( 1585 1591 location, … … 2240 2246 // TypeSubstitution shouldn't exist yet in old. 2241 2247 ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) { 2242 2243 2248 if (!old) return nullptr; 2244 2249 if (old->empty()) return nullptr; … … 2285 2290 ast::Expr * visitBaseExpr_SkipResultType( const Expression * old, ast::Expr * nw) { 2286 2291 2287 nw->env 2292 nw->env = convertTypeSubstitution(old->env); 2288 2293 2289 2294 nw->extension = old->extension; … … 2856 2861 2857 2862 virtual void visit( const EnumInstType * old ) override final { 2858 ast::EnumInstType * ty; 2863 ast::EnumInstType * ty; 2859 2864 if ( old->baseEnum ) { 2860 2865 ty = new ast::EnumInstType{ -
src/AST/Fwd.hpp
r85034ed r8cbe732 67 67 class ImplicitCtorDtorStmt; 68 68 class MutexStmt; 69 class CorunStmt; 69 70 70 71 class Expr; -
src/AST/Node.cpp
r85034ed r8cbe732 192 192 template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::weak >; 193 193 template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::strong >; 194 template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::weak >; 195 template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::strong >; 194 196 template class ast::ptr_base< ast::Expr, ast::Node::ref_type::weak >; 195 197 template class ast::ptr_base< ast::Expr, ast::Node::ref_type::strong >; -
src/AST/Pass.hpp
r85034ed r8cbe732 162 162 const ast::FinallyClause * visit( const ast::FinallyClause * ) override final; 163 163 const ast::Stmt * visit( const ast::SuspendStmt * ) override final; 164 164 const ast::WhenClause * visit( const ast::WhenClause * ) override final; 165 165 const ast::Stmt * visit( const ast::WaitForStmt * ) override final; 166 166 const ast::WaitForClause * visit( const ast::WaitForClause * ) override final; 167 167 const ast::Stmt * visit( const ast::WaitUntilStmt * ) override final; 168 168 const ast::Decl * visit( const ast::WithStmt * ) override final; 169 169 const ast::NullStmt * visit( const ast::NullStmt * ) override final; … … 171 171 const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * ) override final; 172 172 const ast::Stmt * visit( const ast::MutexStmt * ) override final; 173 const ast::Stmt * visit( const ast::CorunStmt * ) override final; 173 174 const ast::Expr * visit( const ast::ApplicationExpr * ) override final; 174 175 const ast::Expr * visit( const ast::UntypedExpr * ) override final; -
src/AST/Pass.impl.hpp
r85034ed r8cbe732 1121 1121 1122 1122 //-------------------------------------------------------------------------- 1123 // CorunStmt 1124 template< typename core_t > 1125 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CorunStmt * node ) { 1126 VISIT_START( node ); 1127 1128 if ( __visit_children() ) { 1129 maybe_accept( node, &CorunStmt::stmt ); 1130 } 1131 1132 VISIT_END( Stmt, node ); 1133 } 1134 1135 //-------------------------------------------------------------------------- 1123 1136 // ApplicationExpr 1124 1137 template< typename core_t > -
src/AST/Print.cpp
r85034ed r8cbe732 209 209 } 210 210 211 211 void print( const ast::WaitStmt * node ) { 212 212 if ( node->timeout_time ) { 213 213 os << indent-1 << "timeout of:" << endl; … … 860 860 } 861 861 862 862 virtual const ast::Stmt * visit( const ast::WaitUntilStmt * node ) override final { 863 863 os << "Waituntil Statement" << endl; 864 864 indent += 2; … … 866 866 clause->accept( *this ); 867 867 } 868 print(node); // calls print( const ast::WaitStmt * node ) 868 // calls print( const ast::WaitStmt * node ) 869 print(node); 869 870 return node; 870 871 } … … 913 914 printAll( node->mutexObjs ); 914 915 --indent; 916 os << indent << "... with Statement: "; 917 ++indent; 918 safe_print( node->stmt ); 919 --indent; 920 os << endl; 921 922 return node; 923 } 924 925 virtual const ast::Stmt * visit( const ast::CorunStmt * node ) override final { 926 os << "Corun Statement" << endl; 915 927 os << indent << "... with Statement: "; 916 928 ++indent; -
src/AST/Stmt.hpp
r85034ed r8cbe732 532 532 }; 533 533 534 // Corun Statement 535 class CorunStmt final : public Stmt { 536 public: 537 ptr<Stmt> stmt; 538 539 CorunStmt( const CodeLocation & loc, const Stmt * stmt, const std::vector<Label> && labels = {} ) 540 : Stmt(loc, std::move(labels)), stmt(stmt) {} 541 542 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 543 private: 544 CorunStmt * clone() const override { return new CorunStmt{ *this }; } 545 MUTATE_FRIEND 546 }; 547 534 548 } // namespace ast 535 549 -
src/AST/Visitor.hpp
r85034ed r8cbe732 59 59 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * ) = 0; 60 60 virtual const ast::Stmt * visit( const ast::MutexStmt * ) = 0; 61 virtual const ast::Stmt * visit( const ast::CorunStmt * ) = 0; 61 62 virtual const ast::Expr * visit( const ast::ApplicationExpr * ) = 0; 62 63 virtual const ast::Expr * visit( const ast::UntypedExpr * ) = 0; -
src/CodeGen/CodeGenerator.cc
r85034ed r8cbe732 1157 1157 1158 1158 void CodeGenerator::postvisit( WithStmt * with ) { 1159 if ( ! options.genC ) {1160 output << "with ( "; 1161 genCommaList( with->exprs.begin(), with->exprs.end() );1162 output << " ) ";1163 }1159 assertf( ! options.genC, "WithStmts should not reach code generation." ); 1160 1161 output << "with ( "; 1162 genCommaList( with->exprs.begin(), with->exprs.end() ); 1163 output << " ) "; 1164 1164 with->stmt->accept( *visitor ); 1165 1165 } -
src/CodeGen/LinkOnce.cc
r85034ed r8cbe732 10 10 // Created On : Thur May 13 10:10:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thur May 13 14:39:00 202113 // Update Count : 012 // Last Modified On : Wed Oct 4 10:52:00 2023 13 // Update Count : 1 14 14 // 15 15 … … 18 18 #include <algorithm> 19 19 20 #include "AST/Attribute.hpp" 21 #include "AST/Decl.hpp" 22 #include "AST/Expr.hpp" 23 #include "AST/Pass.hpp" 20 24 #include "Common/PassVisitor.h" // for PassVisitor, WithShortCircuiting 21 25 22 26 namespace CodeGen { 23 27 24 static bool is_cfa_linkonce( Attribute const * attr ) { 28 namespace { 29 30 bool is_cfa_linkonce_old( Attribute const * attr ) { 25 31 return std::string("cfa_linkonce") == attr->name; 26 32 } 27 33 28 static bool is_section_attribute( Attribute const * attr ) {34 bool is_section_attribute_old( Attribute const * attr ) { 29 35 return std::string("section") == attr->name; 30 36 } … … 39 45 std::list< Attribute * > & attributes = decl->attributes; 40 46 // See if we can find the element: 41 auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce );47 auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce_old ); 42 48 if ( attributes.end() != found ) { 43 49 // Remove any other sections: 44 attributes.remove_if( is_section_attribute );50 attributes.remove_if( is_section_attribute_old ); 45 51 // Iterator to the cfa_linkonce attribute should still be valid. 46 52 Attribute * attribute = *found; … … 63 69 }; 64 70 71 bool is_cfa_linkonce( ast::Attribute const * attr ) { 72 return "cfa_linkonce" == attr->name; 73 } 74 75 bool is_section_attribute( ast::Attribute const * attr ) { 76 return "section" == attr->name; 77 } 78 79 struct LinkOnceCore : public ast::WithShortCircuiting { 80 void previsit( ast::Decl const * ) { 81 visit_children = false; 82 } 83 84 ast::DeclWithType const * postvisit( ast::DeclWithType const * decl ) { 85 // Check to see if we have to mutate, because should be uncommon. 86 { 87 auto & attributes = decl->attributes; 88 auto found = std::find_if( attributes.begin(), attributes.end(), 89 is_cfa_linkonce ); 90 if ( attributes.end() == found ) return decl; 91 } 92 auto mutDecl = mutate( decl ); 93 auto & attributes = mutDecl->attributes; 94 95 // Remove all conflicting section attributes. 96 erase_if( attributes, is_section_attribute ); 97 98 // Get the attribute, and overwrite it as a section attribute. 99 auto found = std::find_if( attributes.begin(), attributes.end(), 100 is_cfa_linkonce ); 101 assert( attributes.end() != found ); 102 ast::Attribute * attribute = found->get_and_mutate(); 103 assert( attribute->params.empty() ); 104 assert( !decl->mangleName.empty() ); 105 106 attribute->name = "section"; 107 attribute->params.push_back( 108 ast::ConstantExpr::from_string( mutDecl->location, 109 ".gnu.linkonce." + decl->mangleName 110 ) 111 ); 112 113 // Unconditionnaly add "visibility(default)" to anything with 114 // .gnu.linkonce visibility is a mess otherwise. 115 attributes.push_back( new ast::Attribute( "visibility", { 116 ast::ConstantExpr::from_string( mutDecl->location, "default" ) 117 } ) ); 118 return mutDecl; 119 } 120 }; 121 122 } // namespace 123 65 124 void translateLinkOnce( std::list< Declaration *> & translationUnit ) { 66 125 PassVisitor<LinkOnceVisitorCore> translator; … … 68 127 } 69 128 129 void translateLinkOnce( ast::TranslationUnit & translationUnit ) { 130 ast::Pass<LinkOnceCore>::run( translationUnit ); 70 131 } 132 133 } // namespace CodeGen -
src/CodeGen/LinkOnce.h
r85034ed r8cbe732 10 10 // Created On : Thur May 13 10:06:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thur May 13 14:38:00 202113 // Update Count : 012 // Last Modified On : Wed Oct 4 10:52:00 2023 13 // Update Count : 1 14 14 // 15 15 … … 23 23 24 24 class Declaration; 25 namespace ast { 26 class TranslationUnit; 27 } 25 28 26 29 namespace CodeGen { 27 30 28 31 void translateLinkOnce( std::list< Declaration *> & translationUnit ); 32 void translateLinkOnce( ast::TranslationUnit & translationUnit ); 29 33 /* Convert the cfa_linkonce attribute on top level declaration into 30 34 * a special section declaration (.gnu.linkonce) so that it may be defined -
src/Common/CodeLocationTools.cpp
r85034ed r8cbe732 137 137 macro(ImplicitCtorDtorStmt, Stmt) \ 138 138 macro(MutexStmt, Stmt) \ 139 macro(CorunStmt, Stmt) \ 139 140 macro(ApplicationExpr, Expr) \ 140 141 macro(UntypedExpr, Expr) \ -
src/Concurrency/module.mk
r85034ed r8cbe732 18 18 Concurrency/Actors.cpp \ 19 19 Concurrency/Actors.hpp \ 20 Concurrency/Corun.cpp \ 21 Concurrency/Corun.hpp \ 20 22 Concurrency/KeywordsNew.cpp \ 21 23 Concurrency/Keywords.cc \ -
src/GenPoly/Box.h
r85034ed r8cbe732 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Box.h -- 7 // Box.h -- Implement polymorphic function calls and types. 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 : Sat Jul 22 09:23:52 201713 // Update Count : 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Oct 6 13:37:00 2022 13 // Update Count : 7 14 14 // 15 15 … … 19 19 20 20 class Declaration; 21 namespace ast { 22 class TranslationUnit; 23 } 21 24 22 25 namespace GenPoly { 23 26 /// boxes polymorphic function calls 24 27 void box( std::list< Declaration* >& translationUnit ); 28 void box( ast::TranslationUnit & translationUnit ); 25 29 } // namespace GenPoly 26 30 -
src/GenPoly/InstantiateGeneric.h
r85034ed r8cbe732 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InstantiateGeneric.h -- 7 // InstantiateGeneric.h -- Create concrete instances of generic types. 8 8 // 9 9 // Author : Aaron B. Moss … … 24 24 25 25 namespace GenPoly { 26 /// Replaces all generic types that have static layout with concrete 27 /// instantiations. Types with concrete values for otype parameters will be 28 /// template-expanded, while dtype and ftype parameters will be replaced by 29 /// the appropriate void type. 26 30 27 void instantiateGeneric( std::list< Declaration* > &translationUnit ); 31 28 void instantiateGeneric( ast::TranslationUnit & translationUnit ); 29 /// Replaces all generic types that have static layout with concrete 30 /// instantiations. Sized types are replaced with the concrete argument types 31 /// while unsized types are erased to a void type. 32 /// This pass can cause designators to ignore the pretty print option. 33 32 34 } // namespace GenPoly 33 35 -
src/GenPoly/InstantiateGenericNew.cpp
r85034ed r8cbe732 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InstantiateGenericNew.cpp -- 7 // InstantiateGenericNew.cpp -- Create concrete instances of generic types. 8 8 // 9 9 // Author : Andrew Beach … … 335 335 ast::Expr const * FixDtypeStatic::postvisit( ast::MemberExpr const * expr ) { 336 336 ast::ptr<ast::Type> const & type = expr->aggregate->result; 337 if ( !isGenericType( type ) ) { 338 return expr; 339 } else if ( auto inst = type.as<ast::StructInstType>() ) { 340 return fixMemberExpr( inst, expr ); 337 if ( auto inst = type.as<ast::StructInstType>() ) { 338 if ( !inst->params.empty() ) return fixMemberExpr( inst, expr ); 341 339 } else if ( auto inst = type.as<ast::UnionInstType>() ) { 342 return fixMemberExpr( inst, expr );340 if ( !inst->params.empty() ) return fixMemberExpr( inst, expr ); 343 341 } 344 342 return expr; … … 451 449 ast::Expr const * postvisit( ast::MemberExpr const * expr ); 452 450 ast::Expr const * postvisit( ast::Expr const * expr ); 453 void previsit( ast::ParseNode const * node ); 454 451 ast::Designation const * postvisit( ast::Designation const * ); 452 453 void previsit( ast::ParseNode const * node ) { 454 GuardValue( location ) = &node->location; 455 } 455 456 void previsit( ast::FunctionType const * ) { 456 457 GuardValue( inFunctionType ) = true; … … 628 629 } 629 630 630 void GenericInstantiator::previsit( ast::ParseNode const * node ) { 631 GuardValue( location ) = &node->location; 631 // This attempts to figure out what the final name of the field will be. 632 // Pretty printing can cause this to become incorrect. 633 std::string getPrintName( ast::DeclWithType const * decl ) { 634 return ( decl->linkage.is_mangled ) 635 ? decl->scopedMangleName() : decl->name; 636 } 637 638 ast::Designation const * GenericInstantiator::postvisit( 639 ast::Designation const * designation ) { 640 // Disconnect designator names from their fields. 641 // It is now incorrect to point at the generic definition where the used 642 // type now is replaced with a concrete instance. Ideally, new variable 643 // expressions would point at fields in the concrete instances, but that 644 // is work and that information should not be needed this late in 645 // compilation. 646 647 // Modify all designations, even if not needed. 648 auto mutNode = mutate( designation ); 649 for ( ast::ptr<ast::Expr> & designator : mutNode->designators ) { 650 if ( auto var = designator.as<ast::VariableExpr>() ) { 651 designator = new ast::NameExpr( 652 var->location, getPrintName( var->var ) ); 653 } 654 } 655 return mutNode; 632 656 } 633 657 -
src/GenPoly/module.mk
r85034ed r8cbe732 22 22 23 23 SRC += $(SRC_GENPOLY) \ 24 GenPoly/BoxNew.cpp \ 24 25 GenPoly/Box.cc \ 25 26 GenPoly/Box.h \ -
src/Parser/StatementNode.cc
r85034ed r8cbe732 498 498 } // build_mutex 499 499 500 ast::Stmt * build_corun( const CodeLocation & location, StatementNode * stmt ) { 501 ast::Stmt * body = maybeMoveBuild( stmt ); 502 return new ast::CorunStmt( location, body ); 503 } // build_corun 504 500 505 // Local Variables: // 501 506 // tab-width: 4 // -
src/Parser/StatementNode.h
r85034ed r8cbe732 105 105 ast::Stmt * build_with( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt ); 106 106 ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt ); 107 ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt ); -
src/Parser/lex.ll
r85034ed r8cbe732 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Fri Jun 9 10:04:00202313 * Update Count : 77 012 * Last Modified On : Tue Oct 3 17:10:57 2023 13 * Update Count : 773 14 14 */ 15 15 … … 217 217 218 218 /* keywords */ 219 alignas { KEYWORD_RETURN(ALIGNAS); } // CFA 219 220 _Alignas { KEYWORD_RETURN(ALIGNAS); } // C11 221 alignof { KEYWORD_RETURN(ALIGNOF); } // CFA 220 222 _Alignof { KEYWORD_RETURN(ALIGNOF); } // C11 221 223 __alignof { KEYWORD_RETURN(ALIGNOF); } // GCC … … 239 241 choose { KEYWORD_RETURN(CHOOSE); } // CFA 240 242 coerce { KEYWORD_RETURN(COERCE); } // CFA 243 corun { KEYWORD_RETURN(CORUN); } // CFA 244 cofor { KEYWORD_RETURN(COFOR); } // CFA 241 245 _Complex { KEYWORD_RETURN(COMPLEX); } // C99 242 246 __complex { KEYWORD_RETURN(COMPLEX); } // GCC … … 319 323 static { KEYWORD_RETURN(STATIC); } 320 324 _Static_assert { KEYWORD_RETURN(STATICASSERT); } // C11 321 _static_assert { KEYWORD_RETURN(STATICASSERT); } // C23325 static_assert { KEYWORD_RETURN(STATICASSERT); } // C23 322 326 struct { KEYWORD_RETURN(STRUCT); } 323 327 suspend { KEYWORD_RETURN(SUSPEND); } // CFA … … 326 330 __thread { KEYWORD_RETURN(THREADLOCALGCC); } // GCC 327 331 _Thread_local { KEYWORD_RETURN(THREADLOCALC11); } // C11 332 thread_local { KEYWORD_RETURN(THREADLOCALC11); } // C23 328 333 throw { KEYWORD_RETURN(THROW); } // CFA 329 334 throwResume { KEYWORD_RETURN(THROWRESUME); } // CFA -
src/Parser/parser.yy
r85034ed r8cbe732 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 4 18:28:12 202313 // Update Count : 639 312 // Last Modified On : Tue Oct 3 17:14:12 2023 13 // Update Count : 6396 14 14 // 15 15 … … 350 350 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 351 351 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL // CFA 352 %token CORUN COFOR 352 353 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 353 354 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) … … 422 423 %type<stmt> with_statement 423 424 %type<expr> with_clause_opt 425 %type<stmt> corun_statement cofor_statement 424 426 %type<stmt> exception_statement 425 427 %type<clause> handler_clause finally_clause … … 1140 1142 | waitfor_statement 1141 1143 | waituntil_statement 1144 | corun_statement 1145 | cofor_statement 1142 1146 | exception_statement 1143 1147 | enable_disable_statement … … 1713 1717 wor_waituntil_clause %prec THEN 1714 1718 { $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); } 1719 ; 1720 1721 corun_statement: 1722 CORUN statement 1723 { $$ = new StatementNode( build_corun( yylloc, $2 ) ); } 1724 ; 1725 1726 cofor_statement: 1727 COFOR '(' for_control_expression_list ')' statement 1728 { SemanticError( yylloc, "cofor statement is currently unimplemented." ); $$ = nullptr; } 1715 1729 ; 1716 1730 -
src/ResolvExpr/module.mk
r85034ed r8cbe732 72 72 ResolvExpr/AlternativePrinter.h \ 73 73 ResolvExpr/CandidatePrinter.cpp \ 74 ResolvExpr/CandidatePrinter.hpp 74 ResolvExpr/CandidatePrinter.hpp \ 75 ResolvExpr/EraseWith.cpp \ 76 ResolvExpr/EraseWith.hpp 75 77 76 78 SRCDEMANGLE += $(SRC_RESOLVEXPR) -
src/Validate/NoIdSymbolTable.hpp
r85034ed r8cbe732 20 20 namespace Validate { 21 21 22 // A SymbolTable that only has the operations used in the Translate Dimension 23 // pass. More importantly, it doesn't have some methods that should no be 22 // A SymbolTable that only tracks names relevant to Validate passes. 23 // It tracks type names but not identifier names. 24 // Some of the canonicalization that occurs before the resolver 25 // affects how identifier name errors get reported to the user. 26 // The Validate phase needs to chase type names, 27 // but it is too early to try tracking identifier names. 28 // Identifier skipping is acheived by omitting methods that should not be 24 29 // called by the Pass template (lookupId and addId). 25 30 class NoIdSymbolTable { 26 31 ast::SymbolTable base; 27 32 public: 33 // All names that are tracked (now) are eligible for collision validation (now). 34 // (Names that are only tracked later get their collision validation then.) 35 NoIdSymbolTable() : base(ast::SymbolTable::ValidateOnAdd) {} 36 28 37 # define FORWARD_X( func, types_and_names, just_names ) \ 29 38 inline auto func types_and_names -> decltype( base.func just_names ) { \ -
src/main.cc
r85034ed r8cbe732 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 10 21:12:17202313 // Update Count : 68 212 // Last Modified On : Thu Sep 28 22:28:45 2023 13 // Update Count : 687 14 14 // 15 15 … … 46 46 #include "Common/utility.h" // for deleteAll, filter, printAll 47 47 #include "Concurrency/Actors.hpp" // for implementActors 48 #include "Concurrency/Corun.hpp" // for implementCorun 48 49 #include "Concurrency/Keywords.h" // for implementMutex, implement... 49 50 #include "Concurrency/Waitfor.h" // for generateWaitfor … … 62 63 #include "Parser/RunParser.hpp" // for buildList, dumpParseTree,... 63 64 #include "ResolvExpr/CandidatePrinter.hpp" // for printCandidates 65 #include "ResolvExpr/EraseWith.hpp" // for eraseWith 64 66 #include "ResolvExpr/Resolver.h" // for resolve 65 67 #include "SynTree/LinkageSpec.h" // for Spec, Cforall, Intrinsic … … 344 346 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords, transUnit ); 345 347 PASS( "Fix Unique Ids", Validate::fixUniqueIds, transUnit ); 348 PASS( "Implement Corun", Concurrency::implementCorun, transUnit ); 346 349 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls, transUnit ); 347 350 … … 396 399 397 400 PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() ); 401 PASS( "Erase With", ResolvExpr::eraseWith, transUnit ); 398 402 399 403 // fix ObjectDecl - replaces ConstructorInit nodes … … 419 423 420 424 PASS( "Convert L-Value", GenPoly::convertLvalue, transUnit ); 425 DUMP( bboxp, std::move( transUnit ) ); 426 PASS( "Box", GenPoly::box, transUnit ); 427 PASS( "Link-Once", CodeGen::translateLinkOnce, transUnit ); 421 428 422 429 translationUnit = convert( std::move( transUnit ) ); 423 424 DUMP( bboxp, translationUnit );425 PASS( "Box", GenPoly::box, translationUnit );426 427 PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit );428 430 429 431 // Code has been lowered to C, now we can start generation. … … 540 542 { "ascodegen", codegenp, true, "print AST as codegen rather than AST" }, 541 543 { "asterr", errorp, true, "print AST on error" }, 542 { "declstats", declstatsp, true, " code property statistics" },543 { "parse", yydebug, true, " yacc (parsing) debug information" },544 { "declstats", declstatsp, true, "print code property statistics" }, 545 { "parse", yydebug, true, "print yacc (parsing) debug information" }, 544 546 { "pretty", prettycodegenp, true, "prettyprint for ascodegen flag" }, 545 547 { "rproto", resolvprotop, true, "resolver-proto instance" }, 546 548 { "rsteps", resolvep, true, "print resolver steps" }, 547 // codedumps549 // AST dumps 548 550 { "ast", astp, true, "print AST after parsing" }, 549 { "ex decl", exdeclp, true, "print AST after translating exception decls" },551 { "excpdecl", exdeclp, true, "print AST after translating exception decls" }, 550 552 { "symevt", symtabp, true, "print AST after symbol table events" }, 551 { " altexpr", expraltp, true, "print alternatives for expressions" },552 { " astdecl", validp, true, "print AST after declaration validation pass" },553 { " resolver", bresolvep, true, "print AST before resolver step" },554 { " astexpr", exprp, true, "print AST after expression analysis" },553 { "expralt", expraltp, true, "print AST after expressions alternatives" }, 554 { "valdecl", validp, true, "print AST after declaration validation pass" }, 555 { "bresolver", bresolvep, true, "print AST before resolver step" }, 556 { "expranly", exprp, true, "print AST after expression analysis" }, 555 557 { "ctordtor", ctorinitp, true, "print AST after ctor/dtor are replaced" }, 556 558 { "tuple", tuplep, true, "print AST after tuple expansion" }, 557 { " astgen", genericsp, true, "print AST after instantiate generics" },558 { "b ox", bboxp, true, "print AST before box step" },559 { " codegen", bcodegenp, true, "print AST before code generation" },559 { "instgen", genericsp, true, "print AST after instantiate generics" }, 560 { "bbox", bboxp, true, "print AST before box pass" }, 561 { "bcodegen", bcodegenp, true, "print AST before code generation" }, 560 562 }; 561 563 enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) }; -
tests/.expect/linkonce.txt
r85034ed r8cbe732 1 signed= -7 unsigned=121 signed=7 unsigned=12 -
tests/collections/.expect/string-istream-manip.txt
r85034ed r8cbe732 1 preS1 0123456 2 preS1 x 3 preS2 01234567 4 preS2 x 5 preS3 012345678 6 preS3 x 7 preS4 0123456789 8 preS4 x 9 preSMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 10 preSMN1 x 11 preSMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 12 preSMN2 x 13 preSMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 14 preSMN3 x 15 preSMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 16 preSMN4 x 17 preRMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 18 preRMN1 x 19 preRMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 20 preRMN2 x 21 preRMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 22 preRMN3 x 23 preRMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 24 preRMN4 x 25 preSMI1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 26 preSMI1 "x" 27 preSMI2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 28 preSMI2 "x" 29 preSMI3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 30 preSMI3 "x" 31 preSMI4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 32 preSMI4 "x" 33 preSME1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 34 preSME1 "x" 35 preSME2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 36 preSME2 "x" 37 preSME3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 38 preSME3 "x" 39 preSME4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 40 preSME4 "x" 41 preSMG1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 42 preSMG1 x 43 preSMG2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 44 preSMG2 x 45 preSMG3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 46 preSMG3 x 47 preSMG4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 48 preSMG4 x 49 preSMD1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 50 preSMD1 x 51 preSMD2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 52 preSMD2 x 53 preSMD3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 54 preSMD3 x 55 preSMD4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 56 preSMD4 x 1 57 1 yyyyyyyyyyyyyyyyyyyy 2 58 2 abcxxx … … 12 68 12 wwwwwwww 13 69 13 wwwwwwww 70 14 cccc 71 15 14 72 1 yyyyyyyyyyyyyyyyyyyy 15 73 2 abcxxx … … 25 83 12 wwwwwwww 26 84 13 wwwwwwww 85 14 cccc 86 15 -
tests/collections/.in/string-istream-manip.txt
r85034ed r8cbe732 1 0123456 x 2 01234567 x 3 012345678 x 4 0123456789 x 5 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x 6 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x 7 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x 8 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x 9 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x 10 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x 11 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x 12 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x 13 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 14 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 15 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 16 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 17 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 18 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 19 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 20 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 21 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 22 x 23 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 24 x 25 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 26 x 27 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 28 x 29 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456@x@ 30 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567@x@ 31 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678@x@ 32 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789@x@ 1 33 abc 2 abc34 cccccb 3 35 xx 4 36 abcxxx 5 37 abcyyy 6 38 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 39 uuuuuccccuuuuu 7 40 abc 8 abc41 cccccb 9 42 xx 10 43 abcxxx 11 44 abcyyy 12 45 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 46 uuuuuccccuuuuu -
tests/collections/string-istream-manip.cfa
r85034ed r8cbe732 3 3 #include <collections/string.hfa> 4 4 #include <collections/string_res.hfa> 5 #include <stdio.h> 6 7 // No-op manipulators. 8 // Temporary hack while there are two code paths in the string implementation. 9 // (One for reading plain strings, the other for reading via a manipulator.) 10 // The test cases that use plainjane(-) are exercising the via-manipulator code path, 11 // just with trivial manipulation. 12 static _Istream_Sstr plainjane( string & s ) { return (_Istream_Sstr)@{ s, {{0p}, -1, {.flags.rwd : false}} }; } 13 static _Istream_Rstr plainjane( string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, -1, {.flags.rwd : false}} }; } 14 15 static void forceStringHeapFreeSpaceTo(int desiredSize) { 16 for (1_000_000) { 17 string x = "a"; 18 (void)x; 19 if (desiredSize == DEBUG_string_bytes_avail_until_gc(DEBUG_string_heap())) return; 20 } 21 sout | "Unable to force size" | desiredSize | "in 1,000,000 tries"; 22 } 5 23 6 24 int main() { 25 // These "pre" cases deal with issues analogous to the "pre" cases of io/manipulatorsInput. 26 // The acceptance criterion is simpler but driving the cases is harder. 27 // The tests just read strings and echo what they read; acceptance of simple echoing assures 28 // no spurious splitting merging. 29 // The lengths of the strings are chosen to match white-box knowledge of when the string layer 30 // has tor drive the cstring layer through a second iteration: 31 // - for no-manip, lengths are near the room at end of string heap 32 // (chosen target size of 9 showed the original bug on preS2, aligned with the other cases) 33 // - for manip, lengths are near the auxiliary buffer size of 128 34 // Only first case repeats for string_res; rest run only from the passthru string layer. 35 // Similarly, the manipulator breadth isn't checked at the cstring layer either. 36 { 37 // S: string, no manipulator 38 void echoTillX(const char * casename) { 39 string s; 40 do { 41 forceStringHeapFreeSpaceTo(9); 42 sin | s; 43 sout | casename | s; 44 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 45 } 46 echoTillX("preS1"); 47 echoTillX("preS2"); 48 echoTillX("preS3"); 49 echoTillX("preS4"); 50 } 51 { 52 // SMN: string, manipulator for no-op 53 void echoTillX(const char * casename) { 54 string s; 55 do { 56 sin | plainjane( s ); 57 sout | casename | s; 58 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 59 } 60 echoTillX("preSMN1"); 61 echoTillX("preSMN2"); 62 echoTillX("preSMN3"); 63 echoTillX("preSMN4"); 64 } 65 { 66 // RMN: string_res, manipulator for no-op 67 void echoTillX(const char * casename) { 68 string_res s; 69 do { 70 sin | plainjane( s ); 71 sout | casename | s; 72 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 73 } 74 echoTillX("preRMN1"); 75 echoTillX("preRMN2"); 76 echoTillX("preRMN3"); 77 echoTillX("preRMN4"); 78 } 79 { 80 // SMI: string, manipulator `incl` 81 void echoTillX(const char * casename) { 82 string s; 83 do { 84 sin | skip("-\n"); 85 sin | incl( ".:|# x", s ); 86 sout | casename | " \"" | s | "\""; 87 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 88 } 89 echoTillX("preSMI1"); 90 echoTillX("preSMI2"); 91 echoTillX("preSMI3"); 92 echoTillX("preSMI4"); 93 } 94 { 95 // SME: string, manipulator `excl` 96 void echoTillX(const char * casename) { 97 string s; 98 do { 99 sin | skip("-\n"); 100 sin | excl( "-\n", s ); 101 sout | casename | " \"" | s | "\""; 102 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 103 } 104 echoTillX("preSME1"); 105 echoTillX("preSME2"); 106 echoTillX("preSME3"); 107 echoTillX("preSME4"); 108 } 109 sin | skip("-\n"); 110 { 111 // SMG: string, manipulator `getline` 112 void echoTillX(const char * casename) { 113 string s; 114 do { 115 sin | getline( s ); 116 sout | casename | s; 117 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 118 } 119 echoTillX("preSMG1"); 120 echoTillX("preSMG2"); 121 echoTillX("preSMG3"); 122 echoTillX("preSMG4"); 123 } 124 { 125 // SMD: string, manipulator (`getline` with custom) delimiter 126 void echoTillX(const char * casename) { 127 string s; 128 do { 129 sin | getline( s, '@' ); 130 sout | casename | s; 131 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 132 sin | skip(" \n"); 133 } 134 echoTillX("preSMD1"); 135 echoTillX("preSMD2"); 136 echoTillX("preSMD3"); 137 echoTillX("preSMD4"); 138 } 139 7 140 /* Keep harmonized with io/manipulatorsInput */ 8 141 { … … 23 156 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 24 157 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 25 } 158 159 s = "q"; 160 sin | incl( "abc", s ); sout | "14" | s; 161 s = "q"; 162 sin | excl( "u", s ); sout | "15" | s; 163 sin | skip( "u" ); 164 sin | "\n"; 165 } 166 // Full repeat on string_res layer assures the full manipulator vocabulary is supported there. 26 167 { 27 168 string_res s = "yyyyyyyyyyyyyyyyyyyy"; … … 41 182 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 42 183 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 184 185 s = "q"; 186 sin | incl( "abc", s ); sout | "14" | s; 187 s = "q"; 188 sin | excl( "u", s ); sout | "15" | s; 189 sin | skip( "u" ); 190 sin | "\n"; 43 191 } 44 192 } -
tests/concurrency/cofor.cfa
r85034ed r8cbe732 1 1 #include <cofor.hfa> 2 2 3 long total = 0; 4 void add_num( void * arg ) { __atomic_fetch_add( &total, (long)arg, __ATOMIC_SEQ_CST ); }3 4 void add_num( long * total, long val ) { __atomic_fetch_add( total, (long)val, __ATOMIC_SEQ_CST ); } 5 5 6 6 int main() { 7 7 printf("start\n"); 8 8 processor p[4]; 9 long total = 0; 9 10 COFOR( i, 0, 10, __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); ); 10 parallel_stmt_t stmts[5] = { add_num, add_num, add_num, add_num, add_num }; 11 void * nums[5] = { (void *)11, (void *)12, (void *)13, (void *)14, (void *)15 }; 12 parallel( stmts, nums, 5 ); 11 { 12 corun; // does nothing 13 corun{}; // does nothing 14 corun add_num( &total, 11 ); 15 corun { add_num( &total, 12 ); } 16 corun __atomic_fetch_add( &total, 13, __ATOMIC_SEQ_CST ); 17 corun { __atomic_fetch_add( &total, 14, __ATOMIC_SEQ_CST ); } 18 __atomic_fetch_add( &total, 15, __ATOMIC_SEQ_CST ); // run by main thd 19 } 13 20 printf("total: %ld\n", total); 14 21 printf("done\n"); -
tests/errors/.expect/scope.txt
r85034ed r8cbe732 1 errors/scope.cfa: 2:1 error: duplicate object definition for thisIsAnError: signed int2 errors/scope.cfa: 20:1 error: duplicate function definition for butThisIsAnError: function1 errors/scope.cfa:13:1 error: duplicate object definition for thisIsAnError: signed int 2 errors/scope.cfa:30:1 error: duplicate function definition for butThisIsAnError: function 3 3 ... with parameters 4 4 double -
tests/errors/scope.cfa
r85034ed r8cbe732 1 int thisIsAnError; 2 int thisIsAnError; 1 // Keep harmonized with errors/scope. 3 2 4 int thisIsNotAnError; 5 float thisIsNotAnError; 3 #ifdef OMIT_DRIVING_REJECTIONS 4 // For manual sanity checking: 5 // Leave out the offensive declarations and verify that what's left is accepted. 6 #define EXPREJ(...) 7 #else 8 #define EXPREJ(...) __VA_ARGS__ 9 #endif 6 10 7 int thisIsAlsoNotAnError() {8 int thisIsNotAnError;9 }10 11 11 int thisIsAlsoNotAnError( double x ) { 12 } 12 int thisIsAnError; 13 EXPREJ( int thisIsAnError; ) 13 14 14 double thisIsStillNotAnError( double );15 double thisIsStillNotAnError( double );15 int thisIsNotAnError; 16 float thisIsNotAnError; 16 17 17 double butThisIsAnError( double ) { 18 } 18 int thisIsAlsoNotAnError() { 19 int thisIsNotAnError; 20 } 19 21 20 double butThisIsAnError( double ) { 21 } 22 int thisIsAlsoNotAnError( double x ) { 23 } 24 25 double thisIsStillNotAnError( double ); 26 double thisIsStillNotAnError( double ); 27 28 double butThisIsAnError( double ) { 29 } 30 EXPREJ( 31 double butThisIsAnError( double ) { 32 } 33 ) 22 34 23 35 // Local Variables: // -
tests/io/.expect/manipulatorsInput.arm64.txt
r85034ed r8cbe732 1 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 4 7 1 yyyyyyyyyyyyyyyyyyyy 5 8 2 abcxxx … … 15 18 12 wwwwwwww 16 19 13 wwwwwwww 20 14 rc=1, cccc 21 15 rc=0, q 17 22 1 yyyyyyyyyyyyyyyyyyyy 18 23 2 abcxxx … … 28 33 12 wwwwwwww 29 34 13 wwwwwwww 35 14 cccc 36 15 30 37 a 31 38 a -
tests/io/.expect/manipulatorsInput.x64.txt
r85034ed r8cbe732 1 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 4 7 1 yyyyyyyyyyyyyyyyyyyy 5 8 2 abcxxx … … 15 18 12 wwwwwwww 16 19 13 wwwwwwww 20 14 rc=1, cccc 21 15 rc=0, q 17 22 1 yyyyyyyyyyyyyyyyyyyy 18 23 2 abcxxx … … 28 33 12 wwwwwwww 29 34 13 wwwwwwww 35 14 cccc 36 15 30 37 a 31 38 a -
tests/io/.expect/manipulatorsInput.x86.txt
r85034ed r8cbe732 1 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 4 7 1 yyyyyyyyyyyyyyyyyyyy 5 8 2 abcxxx … … 15 18 12 wwwwwwww 16 19 13 wwwwwwww 20 14 rc=1, cccc 21 15 rc=0, q 17 22 1 yyyyyyyyyyyyyyyyyyyy 18 23 2 abcxxx … … 28 33 12 wwwwwwww 29 34 13 wwwwwwww 35 14 cccc 36 15 30 37 a 31 38 a -
tests/io/.in/manipulatorsInput.txt
r85034ed r8cbe732 1 1 123456 2 1234567 3 12345678 2 4 123456789 3 5 abc 4 abc6 cccccb 5 7 xx 6 8 abcxxx 7 9 abcyyy 8 10 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 11 uuuuuccccuuuuu 9 12 abc 10 abc13 cccccb 11 14 xx 12 15 abcxxx 13 16 abcyyy 14 17 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 18 uuuuuccccuuuuu 15 19 ab 16 20 0xff 017 15-15 -
tests/io/manipulatorsInput.cfa
r85034ed r8cbe732 45 45 } 46 46 47 rep("pre1"); 48 rep("pre2a"); 49 rep("pre2b"); 47 rep("pre1"); // 123456 | 123456 48 rep("pre2"); // 1234567 | 1234567 49 rep("pre3a"); // 12345678 | 1234567 50 rep("pre3b"); // | 8 51 rep("pre4a"); // 123456789 | 1234567 52 rep("pre4b"); // | 89 53 50 54 scanf("\n"); // next test does not start with %s so does not tolerate leading whitespace 51 55 } 52 56 { 53 57 char s[] = "yyyyyyyyyyyyyyyyyyyy"; 54 const char sk [] = "abc";55 scanf( "abc " ); scanf( sk ); for ( 5 ) scanf( "%*c" );printf( "1 %s\n", s );58 const char sk_fmt[] = "%*[abc]"; 59 scanf( "abc " ); scanf( sk_fmt ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s ); 56 60 scanf( "%s", s ); printf( "2 %s\n", s ); 57 61 scanf( "%*s" ); printf( "3 %s\n", s ); … … 67 71 scanf( "%*8[abc]" ); printf( "12 %s\n", s ); 68 72 scanf( "%*8[^abc]" ); printf( "13 %s\n", s ); 73 74 int rc; 75 s[0] = 'q'; s[1] = '\0'; rc = 99; 76 rc = scanf( "%[abc]", s ); printf( "14 rc=%d, %s\n", rc, s ); 77 s[0] = 'q'; s[1] = '\0'; rc = 99; 78 rc = scanf( "%[^u]", s ); printf( "15 rc=%d, %s\n", rc, s ); 79 scanf( "%*[u]" ); 80 scanf("\n"); 69 81 } 70 82 { … … 85 97 sin | ignore( incl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "12" | s; 86 98 sin | ignore( excl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "13" | s; 99 100 s[0] = 'q'; s[1] = '\0'; 101 sin | incl( "abc", wdi( sizeof(s), s ) ); sout | "14" | s; 102 s[0] = 'q'; s[1] = '\0'; 103 sin | excl( "u", wdi( sizeof(s), s ) ); sout | "15" | s; 104 sin | skip( "u" ); 105 sin | "\n"; 87 106 } 88 107 /* Keep harmonized with collections/string-istream-manip */ -
tests/link-once/main.cfa
r85034ed r8cbe732 1 1 // Test our new cfa_linkonce attribute: 2 2 3 __attribute__(( cfa_linkonce )) signed int example = -7;3 __attribute__(( cfa_linkonce )) signed int example = 7; 4 4 __attribute__(( cfa_linkonce )) unsigned int example = 12; 5 5 -
tests/link-once/partner.cfa
r85034ed r8cbe732 1 1 // Side file for the link-once test. 2 2 3 __attribute__(( cfa_linkonce )) signed int example = -7;3 __attribute__(( cfa_linkonce )) signed int example = 7; 4 4 __attribute__(( cfa_linkonce )) unsigned int example = 12; 5 5 -
tests/test.py
r85034ed r8cbe732 116 116 parser.add_argument('--no-invariant', help='Tell the compiler not to check invariants.', action='store_false', dest='invariant') 117 117 parser.add_argument('--invariant', help='Tell the compiler to check invariants.', action='store_const', const=True) 118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default= 180)118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=240) 119 119 parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200) 120 120 parser.add_argument('--timeout-with-gdb', help='Instead of killing the command when it times out, orphan it and print process id to allow gdb to attach', type=yes_no, default="no") … … 125 125 parser.add_argument('--archive-errors', help='If called with a valid path, on test crashes the test script will copy the core dump and the executable to the specified path.', type=str, default='') 126 126 parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously, 0 (default) for unlimited', nargs='?', const=0, type=int) 127 parser.add_argument('--list-comp', help='List all valid earguments', action='store_true')127 parser.add_argument('--list-comp', help='List all valid arguments', action='store_true') 128 128 parser.add_argument('--list-dist', help='List all tests for distribution', action='store_true') 129 129 parser.add_argument('-I','--include', help='Directory of test to include, can be used multiple time, All if omitted', action='append') -
tools/build/cfa.m4
r85034ed r8cbe732 67 67 "x86_64" ) cannon_arch_name="x64";; 68 68 "aarch64" ) cannon_arch_name="arm64";; 69 "arm 4") cannon_arch_name="arm64";;69 "arm64" ) cannon_arch_name="arm64";; 70 70 "ARM64" ) cannon_arch_name="arm64";; 71 71 "x86" ) cannon_arch_name="x86";;
Note:
See TracChangeset
for help on using the changeset viewer.