Changeset 72b0573


Ignore:
Timestamp:
Sep 18, 2018, 5:01:11 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
e523b07
Parents:
56b53b2 (diff), 91a950c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
7 added
5 deleted
15 edited
102 moved

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    r56b53b2 r72b0573  
    939939    title       = {\textsf{C}$\mathbf{\forall}$ : Adding Modern Programming Language Features to C},
    940940    year        = 2018,
     941    month       = aug,
    941942    journal     = spe,
    942     note        = {Accepted, to appear},
     943    note        = {http://dx.doi.org/10.1002/spe.2624},
    943944}
    944945
     
    962963    comment     = {
    963964        The evidence given is thin.
    964         }
     965    },
    965966}
    966967
     
    15801581
    15811582@mastersthesis{Delisle18,
    1582     author      = {Thierry Delisle },
     1583    author      = {Thierry Delisle},
    15831584    title       = {Concurrency in \textsf{C}$\mathbf{\forall}$},
    15841585    school      = {School of Computer Science, University of Waterloo},
     
    18271828    key         = {Peter Buhr},
    18281829    title       = {CS343},
    1829     year        = 2017,
     1830    year        = 2018,
    18301831    howpublished= {\href{https://www.student.cs.uwaterloo.ca/~cs343}{https://\-www.student.cs.uwaterloo.ca/\-~cs343}},
    18311832}
     
    33623363    author      = {Peter Buhr and David Dice and Wim H. Hesselink},
    33633364    journal     = ccpe,
    3364     volumeopt   = 30,
    3365     numberopt   = 4,
     3365    volume      = 30,
     3366    number      = 18,
    33663367    year        = 2018,
    3367     month       = may,
     3368    month       = sep,
    33683369    publisher   = {John Wiley \& Sons},
    33693370    note        = {\url{https://doi-org.proxy.lib.uwaterloo.ca/10.1002/cpe.4475}}
     
    38493850    keywords    = {concurrency, critical section},
    38503851    contributer = {pabuhr@plg},
    3851     author      = {Dominic Duggan and G. V. Cormack and John Ophel},
     3852    author      = {Dominic Duggan and Gordon V. Cormack and John Ophel},
    38523853    title       = {Kinded Type Inference for Parametric Overloading},
    38533854    journal     = acta,
     
    58555856    keywords    = {Cyclone, existential types, polymorphism, type variables},
    58565857    contributer = {a3moss@plg},
    5857     author      = {D. Grossman},
     5858    author      = {Dan Grossman},
    58585859    title       = {Quantified Types in an Imperative Language},
    58595860    journal     = toplas,
  • doc/theses/aaron_moss_PhD/phd/introduction.tex

    r56b53b2 r72b0573  
    44In the 30 years since its first standardization, it has consistently been one of the most popular programming languages, with millions of lines of C code still in active use, and tens of thousands of trained programmers producing it. The TIOBE index\cite{TIOBE} tracks popularity of programming languages over time, and C has never dropped below second place:
    55
    6 \begin{table}
     6\begin{table}[h]
    77\label{tiobe-table}
    88\caption[TIOBE index over time]{Current top 5 places in the TIOBE index averaged over years}
     
    2020
    2121The impact of C on programming language design is also obvious from Table~\ref{tiobe-table}; with the exception of Python, all of the top five languages use C-like syntax and procedural control structures.
    22 \CC is even a largely backwards-compatible extension of C, with development dating back nearly as far as C itself.
     22\CC{} is even a largely backwards-compatible extension of C, with development dating back nearly as far as C itself.
    2323Though its lasting popularity and wide impact on programming language design point to the continued relevance of C, they also highlight the widespread desire of programmers for languages with more expressive power and programmer-friendly features; accommodating both low-impact maintenance of legacy C code and low-effort development of the software of the future is a difficult task for a single programming language.
    2424
     
    3030This thesis is focused on making \CFA{} a more powerful and expressive language, both by adding new features to the \CFA{} type system and ensuring that both added and existing features can be efficiently implemented in \CFACC{}, the \CFA{} reference compiler.
    3131Particular contributions of this work include design and implementation of
    32 parametric-polymorphic (``generic'') types in a manner compatible with the existing polymorphism design of \CFA{} (Chapter~\ref{generic-chap}), a type environment data structure based on a novel variant of the union-find algorithm (Chapter~\ref{env-chap}), and a new expression resolution algorithm designed to quickly locate the optimal declarations for a \CFA{} declaration (Chapter~\ref{resolution-chap}).
     32parametric-polymorphic (``generic'') types in a manner compatible with the existing polymorphism design of \CFA{} (Chapter~\ref{generic-chap}), a type environment data structure based on a novel variant of the union-find algorithm (Chapter~\ref{env-chap}), and a new expression resolution algorithm designed to quickly locate the optimal declarations for a \CFA{} expression (Chapter~\ref{resolution-chap}).
    3333This expression resolution algorithm was designed with the aid of a purpose-built prototype system which encapsulates the essential aspects of the \CFA{} type system without incurring the technical debt of the existing system or the friction-inducing necessity of maintaining a working compiler; the goal of this prototype system was to discover effective heuristics to avoid performing unnecessary work in the process of locating the optimal \CFA{} expression resolution.
    3434
    3535Though the direction and validation of this work was fairly narrowly focused on the \CFA{} programming language, the tools used and results obtained should be of interest to a wider compiler and programming language design community.
    3636In particular, with the addition of \emph{concepts} in \CCtwenty{}, conforming \CC{} compilers must support a model of type assertions very similar to that in \CFA{}, and the algorithmic techniques used in the expression resolution algorithm presented here may prove useful.
    37 Type environments are also widely modelled in compiler implementations, particularly of functional languages, though also increasingly commonly in other languages (such as Rust) which also perform type inference; the type environment presented here may be useful to those language implementers.
     37Type environments are also widely modelled in compiler implementations, particularly of functional languages, though also increasingly commonly in other languages (such as Rust) which perform type inference; the type environment presented here may be useful to those language implementers.
  • doc/theses/aaron_moss_PhD/phd/macros.tex

    r56b53b2 r72b0573  
    2020
    2121\newcommand{\TODO}[1]{\textbf{TODO:} \textit{#1}}
     22\newcommand{\cit}{\textsuperscript{[citation needed]}}
  • doc/theses/aaron_moss_PhD/phd/resolution-heuristics.tex

    r56b53b2 r72b0573  
    33
    44Talk about the resolution heuristics. This is the bulk of the thesis.
     5
     6% Discuss changes to cost model, as promised in Ch. 2
  • doc/theses/aaron_moss_PhD/phd/thesis.tex

    r56b53b2 r72b0573  
    5757        urlcolor=black}
    5858}{} % end of ifthenelse (no else)
     59
     60\input{cfa-macros} % must be loaded after hyperref
    5961
    6062% \usepackage[automake,toc,abbreviations]{glossaries-extra} % Exception to the rule of hyperref being the last add-on package
     
    139141\addcontentsline{toc}{chapter}{\textbf{References}}
    140142
    141 \bibliography{aaron-thesis}
     143\bibliography{pl}
    142144% Tip 5: You can create multiple .bib files to organize your references.
    143145% Just list them all in the \bibliogaphy command, separated by commas (no spaces).
  • doc/user/user.tex

    r56b53b2 r72b0573  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Thu Jul 26 17:29:05 2018
    14 %% Update Count     : 3366
     13%% Last Modified On : Fri Aug 31 07:54:50 2018
     14%% Update Count     : 3396
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    210210Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction.
    211211For system programming, where direct access to hardware, storage management, and real-time issues are a requirement, C is usually the only language of choice.
    212 The TIOBE index~\cite{TIOBE} for July 2018 ranks the top 5 most \emph{popular} programming languages as: \Index*{Java} 16\%, C 14\%, \Index*[C++]{\CC{}} 7.5\%, Python 6\%, Visual Basic 4\% = 47.5\%, where the next 50 languages are less than 4\% each, with a long tail.
     212The TIOBE index~\cite{TIOBE} for July 2018 ranks the top five most \emph{popular} programming languages as \Index*{Java} 16\%, C 14\%, \Index*[C++]{\CC{}} 7.5\%, Python 6\%, Visual Basic 4\% = 47.5\%, where the next 50 languages are less than 4\% each, with a long tail.
    213213The top 3 rankings over the past 30 years are:
    214214\begin{center}
     
    351351The 2011 C standard plus GNU extensions.
    352352\item
    353 \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]@-fgnu89-inline@}}
     353\Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]$-fgnu89-inline$}}
    354354Use the traditional GNU semantics for inline routines in C11 mode, which allows inline routines in header files.
    355355\end{description}
     
    455455#endif
    456456
    457 ®#include_next <bfdlink.h>                                      §\C{// must have internal check for multiple expansion}§
     457®#include_next <bfdlink.h>                      §\C{// must have internal check for multiple expansion}§
    458458®
    459459#if defined( with ) && defined( __CFA_BFD_H__ ) §\C{// reset only if set}§
     
    504504
    505505C, \CC, and Java (and many other programming languages) have no exponentiation operator\index{exponentiation!operator}\index{operator!exponentiation}, \ie $x^y$, and instead use a routine, like \Indexc{pow}, to perform the exponentiation operation.
    506 \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@\lstinline@?\?@} and ©?\=?©\index{?\\=?@\lstinline@?\=?@}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$.
     506\CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@©?\?©} and ©?\=?©\index{?\\=?@©\=?©}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$.
    507507The priority of the exponentiation operator is between the cast and multiplicative operators, so that ©w * (int)x \ (int)y * z© is parenthesized as ©((w * (((int)x) \ ((int)y))) * z)©.
    508508
     
    516516256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    517517\end{cfa}
    518 Parenthesis are necessary for the complex constants or the expression is parsed as ©1.0f+(2.0fi \ 3.0f)+2.0fi©.
     518Parenthesis are necessary for complex constants or the expression is parsed as ©1.0f+®(®2.0fi \ 3.0f®)®+2.0fi©.
    519519The exponentiation operator is available for all the basic types, but for user-defined types, only the integral-computation versions are available.
    520520For returning an integral value, the user type ©T© must define multiplication, ©*©, and one, ©1©;
     
    527527
    528528
    529 %\subsection{\texorpdfstring{\protect\lstinline@if@ Statement}{if Statement}}
    530 \subsection{\texorpdfstring{\LstKeywordStyle{if} Statement}{if Statement}}
    531 
    532 The ©if© expression allows declarations, similar to ©for© declaration expression:
    533 \begin{cfa}
    534 if ( int x = f() ) ...                                          §\C{// x != 0}§
    535 if ( int x = f(), y = g() ) ...                         §\C{// x != 0 \&\& y != 0}§
    536 if ( int x = f(), y = g(); ®x < y® ) ...        §\C{// relational expression}§
    537 \end{cfa}
    538 Unless a relational expression is specified, each variable is compared not equal to 0, which is the standard semantics for the ©if© expression, and the results are combined using the logical ©&&© operator.\footnote{\CC only provides a single declaration always compared not equal to 0.}
     529%\subsection{\texorpdfstring{\protect\lstinline@if@/\protect\lstinline@while@ Statement}{if Statement}}
     530\subsection{\texorpdfstring{\LstKeywordStyle{if}/\LstKeywordStyle{while} Statement}{if/while Statement}}
     531
     532The ©if©/©while© expression allows declarations, similar to ©for© declaration expression.
     533(Does not make sense for ©do©-©while©.)
     534\begin{cfa}
     535if ( ®int x = f()® ) ...                                        §\C{// x != 0}§
     536if ( ®int x = f(), y = g()® ) ...                       §\C{// x != 0 \&\& y != 0}§
     537if ( ®int x = f(), y = g(); x < y® ) ...        §\C{// relational expression}§
     538if ( ®struct S { int i; } x = { f() }; x.i < 4® ) §\C{// relational expression}§
     539
     540while ( ®int x = f()® ) ...                                     §\C{// x != 0}§
     541while ( ®int x = f(), y = g()® ) ...            §\C{// x != 0 \&\& y != 0}§
     542while ( ®int x = f(), y = g(); x < y® ) ... §\C{// relational expression}§
     543while ( ®struct S { int i; } x = { f() }; x.i < 4® ) ... §\C{// relational expression}§
     544\end{cfa}
     545Unless a relational expression is specified, each variable is compared not equal to 0, which is the standard semantics for the ©if©/©while© expression, and the results are combined using the logical ©&&© operator.\footnote{\CC only provides a single declaration always compared not equal to 0.}
    539546The scope of the declaration(s) is local to the @if@ statement but exist within both the ``then'' and ``else'' clauses.
     547
     548
     549%\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}}
     550\subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}}
     551
     552The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges.
     553An empty conditional implies ©1©.
     554The up-to range ©~©\index{~@©~©} means exclusive range [M,N);
     555the up-to range ©~=©\index{~=@©~=©} means inclusive range [M,N].
     556The down-to range ©-~©\index{-~@©-~©} means exclusive range [N,M);
     557the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M].
     558©0© is the implicit start value;
     559©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range.
     560The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©.
     561\begin{cquote}
     562\begin{tabular}{@{}ll|l@{}}
     563\multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\
     564\hline
     565\begin{cfa}
     566while ®()® { sout | "empty"; break; }
     567do { sout | "empty"; break; } while ®()®;
     568for ®()® { sout | "empty"; break; }
     569for ( ®0® ) { sout | "A"; }
     570for ( ®1® ) { sout | "A"; }
     571for ( ®10® ) { sout | "A"; }
     572for ( ®1 ~= 10 ~ 2® ) { sout | "B"; }
     573for ( ®10 -~= 1 ~ -2® ) { sout | "C"; }
     574for ( ®0.5 ~ 5.5® ) { sout | "D"; }
     575for ( ®5.5 -~ 0.5® ) { sout | "E"; }
     576for ( ®i; 10® ) { sout | i; }
     577for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; }
     578for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; }
     579for ( ®i; 0.5 ~ 5.5® ) { sout | i; }
     580for ( ®i; 5.5 -~ 0.5® ) { sout | i; }
     581for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; }
     582for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; }
     583int start = 3, comp = 10, inc = 2;
     584for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; }
     585\end{cfa}
     586&
     587\begin{cfa}
     588sout | endl;
     589sout | endl;
     590sout | endl;
     591sout | endl;
     592sout | endl;
     593sout | endl;
     594sout | endl;
     595sout | endl;
     596sout | endl;
     597sout | endl;
     598sout | endl;
     599sout | endl;
     600sout | endl;
     601sout | endl;
     602sout | endl;
     603sout | endl;
     604sout | endl;
     605
     606sout | endl;
     607\end{cfa}
     608&
     609\begin{cfa}
     610empty
     611empty
     612empty
     613
     614A
     615A A A A A A A A A A
     616B B B B B
     617C C C C C
     618D D D D D
     619E E E E E
     6200 1 2 3 4 5 6 7 8 9
     6211 3 5 7 9
     62210 8 6 4 2
     6230.5 1.5 2.5 3.5 4.5
     6245.5 4.5 3.5 2.5 1.5
     6252 4 6 8 10
     62610 8 6 4 2
     627
     6283 6 9
     629\end{cfa}
     630\end{tabular}
     631\end{cquote}
    540632
    541633
     
    800892
    801893
     894% for ()  => for ( ;; )
     895% for ( 10 - t ) => for ( typeof(10 - t) ? = 0 ; ? < 10 - t; ? += 1 ) // using 0 and 1
     896% for ( i ; 10 - t ) => for ( typeof(10 - t) i = 0 ; i < 10 - t; i += 1 ) // using 0 and 1
     897% for ( T i ; 10 - t ) => for ( T i = 0 ; i < 10 - t; i += 1 ) // using 0 and 1
     898% for ( 3~9 ) => for ( int ? = 3 ; ? < 9; ? += 1 ) // using 1
     899% for ( i ; 3~9 ) => for ( int i = 3 ; i < 9; i += 1 ) // using 1
     900% for ( T i ; 3~9 ) => for ( T i = 3 ; i < 9; i += 1 ) // using 1
     901
     902
    802903%\subsection{\texorpdfstring{Labelled \protect\lstinline@continue@ / \protect\lstinline@break@}{Labelled continue / break}}
    803904\subsection{\texorpdfstring{Labelled \LstKeywordStyle{continue} / \LstKeywordStyle{break} Statement}{Labelled continue / break Statement}}
     
    805906While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    806907Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
    807 To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline@continue@!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline@break@!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java.
     908To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@©continue©!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@©break©!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java.
    808909For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    809910for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
     
    890991\end{figure}
    891992
    892 Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline@goto@!restricted} restricted in the following ways:
     993Both labelled ©continue© and ©break© are a ©goto©\index{goto@©goto©!restricted} restricted in the following ways:
    893994\begin{itemize}
    894995\item
  • driver/as.cc

    r56b53b2 r72b0573  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // as.c --
     7// as.c -- map assembler file, scan for debug information. If found, expand file by one character and insert Cforall
     8//         language code on the N line from the start of the debug information.
    89//
    910// Author           : Peter A. Buhr
    1011// Created On       : Wed Aug  1 10:49:42 2018
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 22 17:30:24 2018
    13 // Update Count     : 93
     13// Last Modified On : Sat Sep  8 08:40:16 2018
     14// Update Count     : 97
    1415//
    1516
     
    4344        off_t size = mystat.st_size;
    4445
    45         char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
    46         if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
     46        if ( size ) {                                                                           // cannot map 0 sized file
     47                char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
     48                if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
    4749
    48         if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
    49                 // Expand file by one byte to hold 2 character Cforall language code.
    50                 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
     50                if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
     51                        // Expand file by one byte to hold 2 character Cforall language code.
     52                        if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
    5153
    52                 for ( int i = 0; i < 8; i += 1 ) {                              // move N (magic) lines forward
    53                         cursor = strstr( cursor, "\n" ) + 1;
    54                 } // for
     54                        for ( int i = 0; i < 8; i += 1 ) {                      // move N (magic) lines forward
     55                                cursor = strstr( cursor, "\n" ) + 1;
     56                        } // for
    5557
    56                 cursor -= 2;                                                                    // backup over "c\n" language value
    57                 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };
     58                        cursor -= 2;                                                            // backup over "c\n" language value
     59                        if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };
    5860
    59                 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
     61                        memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
    6062
    61                 *(cursor) = '2';                                                                // replace C language value with CFA
    62                 *(cursor + 1) = '5';
     63                        *(cursor) = '2';                                                        // replace C language value with CFA
     64                        *(cursor + 1) = '5';
     65                } // if
     66
     67                if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk
    6368        } // if
    64 
    65         if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk
    6669
    6770        argv[0] = "as";
  • driver/cc1.cc

    r56b53b2 r72b0573  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 09:48:40 2018
    13 // Update Count     : 122
     12// Last Modified On : Mon Sep  3 16:57:05 2018
     13// Update Count     : 125
    1414//
    1515
     
    3232string compiler_name( CFA_BACKEND_CC );                                 // path/name of C compiler
    3333
    34 string D__GCC_X__( "-D__GCC_X__=" );
    3534string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" );
    3635string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
     
    4645enum { NumSuffixes = 2 };
    4746const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    48 
    4947
    5048void suffix( string arg, const char * args[], int & nargs ) {
     
    116114void Stage1( const int argc, const char * const argv[] ) {
    117115        int code;
    118         int i;
    119116
    120117        string arg;
     
    139136        cerr << "Stage1" << endl;
    140137        #endif // __DEBUG_H__
     138        checkEnv( args, nargs );                                                        // arguments passed via environment variables
     139        #ifdef __DEBUG_H__
     140        for ( int i = 1; i < argc; i += 1 ) {
     141                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     142        } // for
     143        #endif // __DEBUG_H__
    141144
    142145        // process all the arguments
    143146
    144         checkEnv( args, nargs );                                                        // arguments passed via environment variables
    145 
    146         for ( i = 1; i < argc; i += 1 ) {
    147                 #ifdef __DEBUG_H__
    148                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    149                 #endif // __DEBUG_H__
     147        for ( int i = 1; i < argc; i += 1 ) {
    150148                arg = argv[i];
    151                 #ifdef __DEBUG_H__
    152                 cerr << "arg:\"" << arg << "\"" << endl;
    153                 #endif // __DEBUG_H__
    154149                if ( prefix( arg, "-" ) ) {
    155150                        // strip g++ flags that are inappropriate or cause duplicates in subsequent passes
     
    185180                                ncargs += 1;
    186181                                i += 1;                                                                 // and the argument
    187                         // } else if ( prefix( arg, D__GCC_X__ ) ) {
    188                         //      args[nargs] = "-x";
    189                         //      nargs += 1;
    190                         //      args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along
    191                         //      nargs += 1;
    192                         // } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {
    193                         //      args[nargs] = "-x";
    194                         //      nargs += 1;
    195                         //      args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along
    196                         //      nargs += 1;
    197                         //      i += 1;                                                                 // and the argument
    198182                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
    199183                                bprefix = arg.substr( D__GCC_BPREFIX__.size() );
     
    251235        #ifdef __DEBUG_H__
    252236        cerr << "args:";
    253         for ( i = 1; i < nargs; i += 1 ) {
     237        for ( int i = 1; i < nargs; i += 1 ) {
    254238                cerr << " " << args[i];
    255239        } // for
     
    282266                #ifdef __DEBUG_H__
    283267                cerr << "nargs: " << nargs << endl;
    284                 for ( i = 0; args[i] != NULL; i += 1 ) {
     268                for ( int i = 0; args[i] != NULL; i += 1 ) {
    285269                        cerr << args[i] << " ";
    286270                } // for
     
    324308                #ifdef __DEBUG_H__
    325309                cerr << "cpp nargs: " << nargs << endl;
    326                 for ( i = 0; args[i] != NULL; i += 1 ) {
     310                for ( int i = 0; args[i] != NULL; i += 1 ) {
    327311                        cerr << args[i] << " ";
    328312                } // for
     
    377361                #ifdef __DEBUG_H__
    378362                cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
    379                 for ( i = 0; cargs[i] != NULL; i += 1 ) {
     363                for ( int i = 0; cargs[i] != NULL; i += 1 ) {
    380364                        cerr << cargs[i] << " ";
    381365                } // for
     
    407391
    408392void Stage2( const int argc, const char * const * argv ) {
    409         int i;
    410 
    411393        string arg;
    412394
     
    419401        cerr << "Stage2" << endl;
    420402        #endif // __DEBUG_H__
     403        checkEnv( args, nargs );                                                        // arguments passed via environment variables
     404        #ifdef __DEBUG_H__
     405        for ( int i = 1; i < argc; i += 1 ) {
     406                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     407        } // for
     408        #endif // __DEBUG_H__
    421409
    422410        // process all the arguments
    423411
    424         checkEnv( args, nargs );                                                        // arguments passed via environment variables
    425 
    426         for ( i = 1; i < argc; i += 1 ) {
    427                 #ifdef __DEBUG_H__
    428                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    429                 #endif // __DEBUG_H__
     412        for ( int i = 1; i < argc; i += 1 ) {
    430413                arg = argv[i];
    431                 #ifdef __DEBUG_H__
    432                 cerr << "arg:\"" << arg << "\"" << endl;
    433                 #endif // __DEBUG_H__
    434414                if ( prefix( arg, "-" ) ) {
    435415                        // strip inappropriate flags
     
    476456        #ifdef __DEBUG_H__
    477457        cerr << "args:";
    478         for ( i = 1; i < nargs; i += 1 ) {
     458        for ( int i = 1; i < nargs; i += 1 ) {
    479459                cerr << " " << args[i];
    480460        } // for
     
    492472        #ifdef __DEBUG_H__
    493473        cerr << "stage2 nargs: " << nargs << endl;
    494         for ( i = 0; args[i] != NULL; i += 1 ) {
     474        for ( int i = 0; args[i] != NULL; i += 1 ) {
    495475                cerr << args[i] << " ";
    496476        } // for
     
    506486int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    507487        #ifdef __DEBUG_H__
    508         for ( int i = 0; env[i] != NULL; i += 1 ) {
     488        for ( int int i = 0; env[i] != NULL; i += 1 ) {
    509489                cerr << env[i] << endl;
    510490        } // for
  • driver/cfa.cc

    r56b53b2 r72b0573  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 15:41:55 2018
    13 // Update Count     : 270
     12// Last Modified On : Mon Sep  3 16:47:59 2018
     13// Update Count     : 275
    1414//
    1515
     
    4343const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4444
    45 void suffix( string arg, const char * args[], int & nargs ) {
     45bool suffix( string arg, const char * args[], int & nargs ) {
    4646        //std::cerr << arg << std::endl;
    4747        size_t dot = arg.find_last_of( "." );
    4848        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    49         if ( dot == string::npos ) return;
     49        if ( dot == string::npos ) return false;
    5050        string sx = arg.substr( dot + 1 );
    5151        for ( int i = 0; i < NumSuffixes; i += 1 ) {
     
    5555                        args[nargs] = "c";
    5656                        nargs += 1;
    57                         return;
     57                        return true;
    5858                } // if
    5959        } // for
     60        return false;
    6061} // suffix
    6162
     
    128129        #ifdef __DEBUG_H__
    129130        cerr << "CFA:" << endl;
     131        for ( int i = 1; i < argc; i += 1 ) {
     132            cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     133        } // for
    130134        #endif // __DEBUG_H__
    131135
     
    133137
    134138        for ( int i = 1; i < argc; i += 1 ) {
    135                 #ifdef __DEBUG_H__
    136                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    137                 #endif // __DEBUG_H__
    138139                arg = argv[i];                                                                  // convert to string value
    139                 #ifdef __DEBUG_H__
    140                 cerr << "arg:\"" << arg << "\"" << endl;
    141                 #endif // __DEBUG_H__
    142140                if ( prefix( arg, "-" ) ) {
    143141                        // pass through arguments
     
    202200                                args[nargs] = argv[i];                                  // pass the argument along
    203201                                nargs += 1;
    204                         } else if ( arg == "-x" ) {
    205                                 xflag = true;
    206                                 args[nargs] = argv[i];                                  // pass the argument along
    207                                 nargs += 1;
    208                                 i += 1;                                                                 // advance to argument
    209                                 args[nargs] = argv[i];                                  // pass the argument along
    210                                 nargs += 1;
    211                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x
    212                                 // nargs += 1;
    213                         } else if ( prefix( arg, "-x" ) ) {
    214                                 xflag = true;
    215                                 args[nargs] = argv[i];                                  // pass the argument along
    216                                 nargs += 1;
    217                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x
    218                                 // nargs += 1;
    219202                        } else if ( arg == "-w" ) {
    220203                                args[nargs] = argv[i];                                  // pass the argument along
     
    298281                        } // if
    299282                } else {
    300                         bool opt = false;
    301                         if ( ! xflag ) {
    302                                 suffix( arg, args, nargs );                             // check suffix
    303                                 // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x
    304                                 // nargs += 1;
    305                                 opt = true;
    306                         } // if
    307                         // concatenate other arguments
    308                         args[nargs] = argv[i];
     283                        bool cfa = suffix( arg, args, nargs );          // check suffix
     284                        args[nargs] = argv[i];                                          // concatenate file
    309285                        nargs += 1;
    310                         if ( opt ) {
     286                        if ( cfa ) {
    311287                                args[nargs] = "-x";
    312288                                nargs += 1;
    313289                                args[nargs] = "none";
    314290                                nargs += 1;
    315                                 // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x
    316                                 // nargs += 1;
    317291                        } // if
    318292                        nonoptarg = true;
     
    320294                } // if
    321295        } // for
     296
     297    args[nargs] = "-x";                                 // turn off language
     298    nargs += 1;
     299    args[nargs] = "none";
     300    nargs += 1;
    322301
    323302        #ifdef __x86_64__
  • libcfa/configure

    r56b53b2 r72b0573  
    19591959
    19601960
     1961
    19611962am__api_version='1.15'
    19621963
  • libcfa/src/heap.cfa

    r56b53b2 r72b0573  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 06:11:44 2018
    13 // Update Count     : 511
     12// Last Modified On : Thu Sep  6 09:01:30 2018
     13// Update Count     : 513
    1414//
    1515
     
    329329        #endif // __CFA_DEBUG__
    330330
    331         assert( heapManager.heapBegin == 0 );                           // always perform check, done once
    332         heapManager{};
     331        //assert( heapManager.heapBegin != 0 );
     332        //heapManager{};
     333        if ( heapManager.heapBegin == 0 ) heapManager{};
    333334} // memory_startup
    334335
     
    700701
    701702static inline void * mallocNoStats( size_t size ) {             // necessary for malloc statistics
    702         assert( heapManager.heapBegin != 0 );
     703        //assert( heapManager.heapBegin != 0 );
     704        if ( unlikely( heapManager.heapBegin == 0 ) ) heapManager{}; // called before memory_startup ?
    703705        void * area = doMalloc( size );
    704706        if ( unlikely( area == 0 ) ) errno = ENOMEM;            // POSIX
  • src/CodeTools/module.mk

    r56b53b2 r72b0573  
    1616
    1717SRC += CodeTools/DeclStats.cc \
     18        CodeTools/ResolvProtoDump.cc \
    1819        CodeTools/TrackLoc.cc
  • src/CompilationState.cc

    r56b53b2 r72b0573  
    3030        parsep = false,
    3131        resolvep = false,
     32        resolvprotop = false,
    3233        symtabp = false,
    3334        treep = false,
  • src/CompilationState.h

    r56b53b2 r72b0573  
    3131        parsep,
    3232        resolvep,
     33        resolvprotop,
    3334        symtabp,
    3435        treep,
  • src/Makefile.in

    r56b53b2 r72b0573  
    220220        CodeGen/FixNames.$(OBJEXT) CodeGen/FixMain.$(OBJEXT) \
    221221        CodeGen/OperatorTable.$(OBJEXT) CodeTools/DeclStats.$(OBJEXT) \
     222        CodeTools/ResolvProtoDump.$(OBJEXT) \
    222223        CodeTools/TrackLoc.$(OBJEXT) Concurrency/Keywords.$(OBJEXT) \
    223224        Concurrency/Waitfor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \
     
    519520        CodeGen/FixNames.cc CodeGen/FixMain.cc \
    520521        CodeGen/OperatorTable.cc CodeTools/DeclStats.cc \
    521         CodeTools/TrackLoc.cc Concurrency/Keywords.cc \
    522         Concurrency/Waitfor.cc Common/SemanticError.cc \
    523         Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \
    524         Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \
     522        CodeTools/ResolvProtoDump.cc CodeTools/TrackLoc.cc \
     523        Concurrency/Keywords.cc Concurrency/Waitfor.cc \
     524        Common/SemanticError.cc Common/UniqueName.cc \
     525        Common/DebugMalloc.cc Common/Assert.cc Common/Heap.cc \
     526        Common/Eval.cc ControlStruct/LabelGenerator.cc \
    525527        ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \
    526528        ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
     
    9991001CodeTools/DeclStats.$(OBJEXT): CodeTools/$(am__dirstamp) \
    10001002        CodeTools/$(DEPDIR)/$(am__dirstamp)
     1003CodeTools/ResolvProtoDump.$(OBJEXT): CodeTools/$(am__dirstamp) \
     1004        CodeTools/$(DEPDIR)/$(am__dirstamp)
    10011005CodeTools/TrackLoc.$(OBJEXT): CodeTools/$(am__dirstamp) \
    10021006        CodeTools/$(DEPDIR)/$(am__dirstamp)
     
    11011105@AMDEP_TRUE@@am__include@ @am__quote@CodeGen/$(DEPDIR)/OperatorTable.Po@am__quote@
    11021106@AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/DeclStats.Po@am__quote@
     1107@AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/ResolvProtoDump.Po@am__quote@
    11031108@AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/TrackLoc.Po@am__quote@
    11041109@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@
  • src/Parser/LinkageSpec.cc

    r56b53b2 r72b0573  
    1010// Created On       : Sat May 16 13:22:09 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul  7 11:11:00 2017
    13 // Update Count     : 25
     12// Last Modified On : Thr Spt 12 15:59:00 2018
     13// Update Count     : 26
    1414//
    1515
     
    2323
    2424namespace LinkageSpec {
    25 
    26 Spec linkageCheck( CodeLocation location, const string * spec ) {
    27         assert( spec );
    28         unique_ptr<const string> guard( spec ); // allocated by lexer
    29         if ( *spec == "\"Cforall\"" ) {
    30                 return Cforall;
    31         } else if ( *spec == "\"C\"" ) {
    32                 return C;
    33         } else if ( *spec == "\"BuiltinC\"" ) {
    34                 return BuiltinC;
    35         } else {
    36                 SemanticError( location, "Invalid linkage specifier " + *spec );
    37         } // if
    38 }
    3925
    4026Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) {
  • src/Parser/LinkageSpec.h

    r56b53b2 r72b0573  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul  2 07:46:49 2018
    13 // Update Count     : 16
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Spt 13 15:59:00 2018
     13// Update Count     : 17
    1414//
    1515
     
    4141
    4242
    43         Spec linkageCheck( CodeLocation location, const std::string * );
    44         // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
    4543        Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd );
    4644        /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
  • src/SymTab/Validate.cc

    r56b53b2 r72b0573  
    403403                        assert( aggr ); // TODO: need to handle forward declarations
    404404                        for ( Declaration * member : aggr->members ) {
    405                                 if ( StructInstType * inst = dynamic_cast< StructInstType * >( child ) ) {
    406                                         if ( StructDecl * aggr = dynamic_cast< StructDecl * >( member ) ) {
    407                                                 if ( aggr->name == inst->name ) {
    408                                                         // TODO: is this case, and other non-TypeInstType cases, necessary?
    409                                                         return new StructInstType( qualType->get_qualifiers(), aggr );
    410                                                 }
    411                                         }
    412                                 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( child ) ) {
    413                                         if ( UnionDecl * aggr = dynamic_cast< UnionDecl * > ( member ) ) {
    414                                                 if ( aggr->name == inst->name ) {
    415                                                         return new UnionInstType( qualType->get_qualifiers(), aggr );
    416                                                 }
    417                                         }
    418                                 } else if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( child ) ) {
    419                                         if ( EnumDecl * aggr = dynamic_cast< EnumDecl * > ( member ) ) {
    420                                                 if ( aggr->name == inst->name ) {
    421                                                         return new EnumInstType( qualType->get_qualifiers(), aggr );
    422                                                 }
    423                                         }
    424                                 } else if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) {
     405                                if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) {
    425406                                        // name on the right is a typedef
    426407                                        if ( NamedTypeDecl * aggr = dynamic_cast< NamedTypeDecl * > ( member ) ) {
     
    429410                                                        Type * ret = aggr->base->clone();
    430411                                                        ret->get_qualifiers() = qualType->get_qualifiers();
     412                                                        TypeSubstitution sub = parent->genericSubstitution();
     413                                                        sub.apply(ret);
    431414                                                        return ret;
    432415                                                }
  • src/main.cc

    r56b53b2 r72b0573  
    3434#include "CodeGen/Generate.h"               // for generate
    3535#include "CodeTools/DeclStats.h"            // for printDeclStats
     36#include "CodeTools/ResolvProtoDump.h"      // for dumpAsResolvProto
    3637#include "CodeTools/TrackLoc.h"             // for fillLocations
    3738#include "Common/CompilerError.h"           // for CompilerError
     
    271272                CodeTools::fillLocations( translationUnit );
    272273
     274                if ( resolvprotop ) {
     275                        CodeTools::dumpAsResolvProto( translationUnit );
     276                        return 0;
     277                }
     278
    273279                PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
    274280                if ( exprp ) {
     
    376382
    377383void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    378         enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
     384        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Symbol, Tree, TupleExpansion, Validate, };
    379385
    380386        static struct option long_opts[] = {
     
    395401                { "no-prototypes", no_argument, 0, Prototypes },
    396402                { "resolver", no_argument, 0, Resolver },
     403                { "resolv-proto", no_argument, 0, ResolvProto },
    397404                { "symbol", no_argument, 0, Symbol },
    398405                { "tree", no_argument, 0, Tree },
     
    407414        bool Wsuppress = false, Werror = false;
    408415        int c;
    409         while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
     416        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
    410417                switch ( c ) {
    411418                  case Ast:
     
    479486                  case 'r':                                                                             // print resolver steps
    480487                        resolvep = true;
     488                        break;
     489                        case 'R':                                                                               // dump resolv-proto instance
     490                        resolvprotop = true;
    481491                        break;
    482492                  case Symbol:
Note: See TracChangeset for help on using the changeset viewer.