Changes in / [99ee64d:9e2c1f0]


Ignore:
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r99ee64d r9e2c1f0  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue May  3 07:59:41 2016
    14 %% Update Count     : 44
     13%% Last Modified On : Wed May  4 08:01:10 2016
     14%% Update Count     : 54
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    132132% blocks and titles
    133133\newcommand{\define}[1]{\emph{#1\/}\index{#1}}
    134 \newcommand{\rewrite}{\(\Rightarrow\)}
    135134\newcommand{\rewriterules}{\paragraph{Rewrite Rules}~\par\noindent}
    136135\newcommand{\examples}{\paragraph{Examples}~\par\noindent}
     
    144143\newcommand{\lhs}[1]{\par{\emph{#1:}}\index{#1@{\emph{#1}}|italic}}
    145144\newcommand{\rhs}{\hfil\break\hbox{\hskip1in}}
    146 \newcommand{\oldlhs}[1]{\emph{#1: \ldots}\index{#1@{\emph{#1}}|italic}}
     145\newcommand{\oldlhs}[1]{\emph{#1: \dots}\index{#1@{\emph{#1}}|italic}}
    147146\newcommand{\nonterm}[1]{\emph{#1\/}\index{#1@{\emph{#1}}|italic}}
    148147\newcommand{\opt}{$_{opt}$\ }
     
    200199belowskip=2pt,
    201200moredelim=**[is][\color{red}]{®}{®}, % red highlighting
    202 % moredelim=**[is][\color{blue}]{©}{©}, % blue highlighting
     201% moredelim=**[is][\color{blue}]{¢}{¢}, % blue highlighting
    203202moredelim=[is][\lstset{keywords={}}]{¶}{¶}, % temporarily turn off keywords
    204203% literate={\\`}{\raisebox{0.3ex}{\ttfamily\upshape \hspace*{-2pt}`}}1, % escape \`, otherwise used for red highlighting
     204literate={...}{{$\dots$}}1 {<-}{{$\leftarrow$}}1 {=>}{{$\Rightarrow$}}1,
    205205}%
    206206
  • doc/refrat/refrat.tex

    r99ee64d r9e2c1f0  
    1010%% Created On       : Wed Apr  6 14:52:25 2016
    1111%% Last Modified By : Peter A. Buhr
    12 %% Last Modified On : Tue May  3 09:23:43 2016
    13 %% Update Count     : 52
     12%% Last Modified On : Tue May  3 18:00:28 2016
     13%% Update Count     : 64
    1414%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1515
     
    139139\subsection{Scopes of identifiers}\index{scopes}
    140140
    141 \CFA's scope rules differ from C's in one major respect: a declaration of an identifier may overload\index{overloading} outer declarations of lexically identical identifiers in the same
    142 \Index{name space}, instead of hiding them.
     141\CFA's scope rules differ from C's in one major respect: a declaration of an identifier may overload\index{overloading} outer declarations of lexically identical identifiers in the same \Index{name space}, instead of hiding them.
    143142The outer declaration is hidden if the two declarations have \Index{compatible type}, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type, or if one declaration is a ©type©\use{type} or ©typedef©\use{typedef} declaration and the other is not.
    144143The outer declaration becomes \Index{visible} when the scope of the inner declaration terminates.
     
    153152
    154153\CFA's linkage rules differ from C's in only one respect: instances of a particular identifier with external or internal linkage do not necessarily denote the same object or function.
    155 Instead, in the set of translation units and libraries that constitutes an entire program, any two instances of a particular identifier with \Index{external linkage} denote the same object or function if they have
    156 \Index{compatible type}s, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type.
     154Instead, in the set of translation units and libraries that constitutes an entire program, any two instances of a particular identifier with \Index{external linkage} denote the same object or function if they have \Index{compatible type}s, or if one declares an array type and the other declares a pointer type and the element type and pointed-at type are compatible, or if one has function type and the other is a pointer to a compatible function type.
    157155Within one translation unit, each instance of an identifier with \Index{internal linkage} denotes the same object or function in the same circumstances.
    158156Identifiers with \Index{no linkage} always denote unique entities.
     
    229227\CFA defines situations where values of one type are automatically converted to another type.
    230228These conversions are called \define{implicit conversion}s.
    231 The programmer can request
    232 \define{explicit conversion}s using cast expressions.
     229The programmer can request \define{explicit conversion}s using cast expressions.
    233230
    234231
     
    281278\label{anon-conv}
    282279
    283 If an expression's type is a pointer to a structure or union type that has a member that is an
    284 \Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's type.
     280If an expression's type is a pointer to a structure or union type that has a member that is an \Index{anonymous structure} or an \Index{anonymous union}, it can be implicitly converted\index{implicit conversion} to a pointer to the anonymous structure's or anonymous union's type.
    285281The result of the conversion is a pointer to the member.
    286282
     
    708704\rewriterules
    709705\begin{lstlisting}
    710 a[b] §\rewrite§ ?[?]( b, a ) // if a has integer type§\use{?[?]}§
    711 a[b] §\rewrite§ ?[?]( a, b ) // otherwise
    712 a( §\emph{arguments}§ ) §\rewrite§ ?()( a, §\emph{arguments}§ )§\use{?()}§
    713 a++ §\rewrite§ ?++(&( a ))§\use{?++}§
    714 a-- §\rewrite§ ?--(&( a ))§\use{?--}§
     706a[b] => ?[?]( b, a ) // if a has integer type§\use{?[?]}§
     707a[b] => ?[?]( a, b ) // otherwise
     708a( §\emph{arguments}§ ) => ?()( a, §\emph{arguments}§ )§\use{?()}§
     709a++ => ?++(&( a ))§\use{?++}§
     710a-- => ?--(&( a ))§\use{?--}§
    715711\end{lstlisting}
    716712
     
    744740Subscript expressions are rewritten as function calls that pass the first parameter by value.
    745741This is somewhat unfortunate, since array-like types tend to be large.
    746 The alternative is to use the rewrite rule ``©a[b]© \rewrite ©?[?](&(a), b)©''.
     742The alternative is to use the rewrite rule ``©a[b] => ?[?](&(a), b)©''.
    747743However, C semantics forbid this approach: the ©a© in ``©a[b]©'' can be an arbitrary pointer value, which does not have an address.
    748744
     
    771767The type of the valid interpretation is the return type of the function designator.
    772768
    773 For those combinations where the interpretation of the \nonterm{postfix-expression} is a
    774 \Index{polymorphic function} designator and the function designator accepts the number of arguments given, there shall be at least one set of \define{implicit argument}s for the implicit parameters such that
     769For those combinations where the interpretation of the \nonterm{postfix-expression} is a \Index{polymorphic function} designator and the function designator accepts the number of arguments given, there shall be at least one set of \define{implicit argument}s for the implicit parameters such that
    775770\begin{itemize}
    776771\item
     
    798793For instance, it should be possible to replace a function ``©int f( int );©'' with ``©forall( otype T ) T f( T );©'' without affecting any calls of ©f©.
    799794
    800 \CFA\index{deficiencies!generalizability} does not fully possess this property, because
    801 \Index{unsafe conversion} are not done when arguments are passed to polymorphic parameters.
     795\CFA\index{deficiencies!generalizability} does not fully possess this property, because \Index{unsafe conversion} are not done when arguments are passed to polymorphic parameters.
    802796Consider
    803797\begin{lstlisting}
     
    11231117\rewriterules
    11241118\begin{lstlisting}
    1125 *a      §\rewrite§ *?( a ) §\use{*?}§
    1126 +a      §\rewrite§ +?( a ) §\use{+?}§
    1127 -a      §\rewrite§ -?( a ) §\use{-?}§
    1128 ~a      §\rewrite§ ~?( a ) §\use{~?}§
    1129 !a      §\rewrite§ !?( a ) §\use{"!?}§
    1130 ++a     §\rewrite§ ++?(&( a )) §\use{++?}§
    1131 --a     §\rewrite§ --?(&( a )) §\use{--?}§
     1119*a      => *?( a )§\use{*?}§
     1120+a      => +?( a )§\use{+?}§
     1121-a      => -?( a )§\use{-?}§
     1122~a      => ~?( a )§\use{~?}§
     1123!a      => !?( a )§\use{"!?}§
     1124++a     => ++?(&( a ))§\use{++?}§
     1125--a     => --?(&( a ))§\use{--?}§
    11321126\end{lstlisting}
    11331127
     
    12701264
    12711265\constraints
    1272 The operand of the unary ``©&©'' operator shall have exactly one
    1273 \Index{interpretation}\index{ambiguous interpretation}, which shall be unambiguous.
     1266The operand of the unary ``©&©'' operator shall have exactly one \Index{interpretation}\index{ambiguous interpretation}, which shall be unambiguous.
    12741267
    12751268\semantics
     
    13171310long int li;
    13181311void eat_double( double );§\use{eat_double}§
    1319 eat_double(-li ); // §\rewrite§ eat_double( -?( li ) );
     1312eat_double(-li ); // => eat_double( -?( li ) );
    13201313\end{lstlisting}
    13211314The valid interpretations of ``©-li©'' (assuming no extended integer types exist) are
     
    14251418\rewriterules
    14261419\begin{lstlisting}
    1427 a * b §\rewrite§ ?*?( a, b )§\use{?*?}§
    1428 a / b §\rewrite§ ?/?( a, b )§\use{?/?}§
    1429 a % b §\rewrite§ ?%?( a, b )§\use{?%?}§
     1420a * b => ?*?( a, b )§\use{?*?}§
     1421a / b => ?/?( a, b )§\use{?/?}§
     1422a % b => ?%?( a, b )§\use{?%?}§
    14301423\end{lstlisting}
    14311424
     
    14611454
    14621455\begin{rationale}
    1463 {\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the
    1464 \Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
     1456{\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s.  Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.
    14651457\end{rationale}
    14661458
     
    15361528\rewriterules
    15371529\begin{lstlisting}
    1538 a + b §\rewrite§ ?+?( a, b )§\use{?+?}§
    1539 a - b §\rewrite§ ?-?( a, b )§\use{?-?}§
     1530a + b => ?+?( a, b )§\use{?+?}§
     1531a - b => ?-?( a, b )§\use{?-?}§
    15401532\end{lstlisting}
    15411533
     
    16151607\end{syntax}
    16161608
    1617 \rewriterules \use{?>>?}%use{?<<?}
    1618 \begin{lstlisting}
    1619 a << b §\rewrite§ ?<<?( a, b )
    1620 a >> b §\rewrite§ ?>>?( a, b )
     1609\rewriterules
     1610\begin{lstlisting}
     1611a << b => ?<<?( a, b )§\use{?<<?}§
     1612a >> b => ?>>?( a, b )§\use{?>>?}§
    16211613\end{lstlisting}
    16221614
     
    16561648\end{syntax}
    16571649
    1658 \rewriterules\use{?>?}\use{?>=?}%use{?<?}%use{?<=?}
    1659 \begin{lstlisting}
    1660 a < b §\rewrite§ ?<?( a, b )
    1661 a > b §\rewrite§ ?>?( a, b )
    1662 a <= b §\rewrite§ ?<=?( a, b )
    1663 a >= b §\rewrite§ ?>=?( a, b )
     1650\rewriterules
     1651\begin{lstlisting}
     1652a < b => ?<?( a, b )§\use{?<?}§
     1653a > b => ?>?( a, b )§\use{?>?}§
     1654a <= b => ?<=?( a, b )§\use{?<=?}§
     1655a >= b => ?>=?( a, b )§\use{?>=?}§
    16641656\end{lstlisting}
    16651657
     
    17171709\rewriterules
    17181710\begin{lstlisting}
    1719 a == b §\rewrite§ ?==?( a, b )§\use{?==?}§
    1720 a != b §\rewrite§ ?!=?( a, b )§\use{?"!=?}§
     1711a == b => ?==?( a, b )§\use{?==?}§
     1712a != b => ?!=?( a, b )§\use{?"!=?}§
    17211713\end{lstlisting}
    17221714
     
    18051797\rewriterules
    18061798\begin{lstlisting}
    1807 a & b §\rewrite§ ?&?( a, b )§\use{?&?}§
     1799a & b => ?&?( a, b )§\use{?&?}§
    18081800\end{lstlisting}
    18091801
     
    18371829\rewriterules
    18381830\begin{lstlisting}
    1839 a ^ b §\rewrite§ ?^?( a, b )§\use{?^?}§
     1831a ^ b => ?^?( a, b )§\use{?^?}§
    18401832\end{lstlisting}
    18411833
     
    18671859\end{syntax}
    18681860
    1869 \rewriterules\use{?"|?}
    1870 \begin{lstlisting}
    1871 a | b §\rewrite§ ?|?( a, b )
     1861\rewriterules
     1862\begin{lstlisting}
     1863a | b => ?|?( a, b )§\use{?"|?}§
    18721864\end{lstlisting}
    18731865
     
    20242016         \nonterm{assignment-expression}
    20252017\lhs{assignment-operator} one of
    2026 \rhs ©=©\ \ ©*=©\ \ ©/=©\ \ ©%=©\ \ ©+=©\ \ ©-=©\ \ 
    2027          ©<<=©\ \ ©>>=©\ \ ©&=©\ \ ©^=©\ \ ©|=©
     2018\rhs ©=©\ \ ©*=©\ \ ©/=©\ \ ©%=©\ \ ©+=©\ \ ©-=©\ \ ©<<=©\ \ ©>>=©\ \ ©&=©\ \ ©^=©\ \ ©|=©
    20282019\end{syntax}
    20292020
    20302021\rewriterules
    2031 Let ``\(\leftarrow\)'' be any of the assignment operators.
     2022Let ``©<-©'' be any of the assignment operators.
    20322023Then
    2033 \use{?=?}\use{?*=?}\use{?/=?}\use{?%=?}\use{?+=?}\use{?-=?}
    2034 \use{?>>=?}\use{?&=?}\use{?^=?}\use{?"|=?}%use{?<<=?}
    2035 \begin{lstlisting}
    2036 a §$\leftarrow$§ b §\rewrite§ ?§$\leftarrow$§?( &( a ), b )
     2024\use{?=?}\use{?*=?}\use{?/=?}\use{?%=?}\use{?+=?}\use{?-=?}\use{?>>=?}\use{?&=?}\use{?^=?}\use{?"|=?}%use{?<<=?}
     2025\begin{lstlisting}
     2026a <- b => ?<-?( &( a ), b )
    20372027\end{lstlisting}
    20382028
     
    27092699D( §\normalsize\nonterm{parameter-type-list}§ )
    27102700\end{lstlisting} then a type identifier declared by one of the \nonterm{forall-specifier}s is an \define{inferred parameter} of the function declarator if and only if it is not an inferred parameter of a function declarator in ©D©, and it is used in the type of a parameter in the following
    2711 \nonterm{type-parameter-list} or it and an inferred parameter are used as arguments of a
    2712 \Index{specification} in one of the \nonterm{forall-specifier}s.
     2701\nonterm{type-parameter-list} or it and an inferred parameter are used as arguments of a \Index{specification} in one of the \nonterm{forall-specifier}s.
    27132702The identifiers declared by assertions that use an inferred parameter of a function declarator are \Index{assertion parameter}s of that function declarator.
    27142703
     
    27322721
    27332722If a function declarator is part of a function definition, its inferred parameters and assertion parameters have \Index{block scope};
    2734 otherwise, identifiers declared by assertions have a
    2735 \define{declaration scope}, which terminates at the end of the \nonterm{declaration}.
     2723otherwise, identifiers declared by assertions have a \define{declaration scope}, which terminates at the end of the \nonterm{declaration}.
    27362724
    27372725A function type that has at least one inferred parameter is a \define{polymorphic function} type.
     
    27422730Let $f$ and $g$ be two polymorphic function types with the same number of inferred parameters, and let $f_i$ and $g_i$ be the inferred parameters of $f$ and $g$ in their order of occurance in the function types' \nonterm{parameter-type-list}s.
    27432731Let $f'$ be $f$ with every occurrence of $f_i$ replaced by $g_i$, for all $i$.
    2744 Then $f$ and $g$ are
    2745 \Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same identifier and compatible type, and vice versa.
     2732Then $f$ and $g$ are \Index{compatible type}s if $f'$'s and $g$'s return types and parameter lists are compatible, and if for every assertion parameter of $f'$ there is an assertion parameter in $g$ with the same identifier and compatible type, and vice versa.
    27462733
    27472734\examples
     
    29602947
    29612948\semantics
    2962 An \define{assertion} is a declaration of a collection of objects and functions, called
    2963 \define{assertion parameters}.
     2949An \define{assertion} is a declaration of a collection of objects and functions, called \define{assertion parameters}.
    29642950
    29652951The assertion parameters produced by an assertion that applies the name of a specification to type arguments are found by taking the declarations specified in the specification and treating each of the specification's parameters as a synonym for the corresponding \nonterm{type-name} argument.
     
    30403026
    30413027A type declaration without an \Index{initializer} and without a \Index{storage-class specifier} or with storage-class specifier ©static©\use{static} defines an \Index{incomplete type}.
    3042 If a
    3043 \Index{translation unit} or \Index{block} contains one or more such declarations for an identifier, it must contain exactly one definition of the identifier ( but not in an enclosed block, which would define a new type known only within that block).
     3028If a \Index{translation unit} or \Index{block} contains one or more such declarations for an identifier, it must contain exactly one definition of the identifier ( but not in an enclosed block, which would define a new type known only within that block).
    30443029\begin{rationale}
    30453030Incomplete type declarations allow compact mutually-recursive types.
     
    30593044
    30603045A type declaration without an initializer and with \Index{storage-class specifier} ©extern©\use{extern} is an \define{opaque type declaration}.
    3061 Opaque types are
    3062 \Index{object type}s.
     3046Opaque types are \Index{object type}s.
    30633047An opaque type is not a \nonterm{constant-expression};
    3064 neither is a structure or union that has a member whose type is not a \nonterm{constant-expression}.  Every other
    3065 \Index{object type} is a \nonterm{constant-expression}.
     3048neither is a structure or union that has a member whose type is not a \nonterm{constant-expression}.
     3049Every other \Index{object type} is a \nonterm{constant-expression}.
    30663050Objects with static storage duration shall be declared with a type that is a \nonterm{constant-expression}.
    30673051\begin{rationale}
     
    30753059An \Index{incomplete type} which is not a qualified version\index{qualified type} of a type is a value of \Index{type-class} ©dtype©.
    30763060An object type\index{object types} which is not a qualified version of a type is a value of type-classes ©type© and ©dtype©.
    3077 A
    3078 \Index{function type} is a value of type-class ©ftype©.
     3061A \Index{function type} is a value of type-class ©ftype©.
    30793062\begin{rationale}
    30803063Syntactically, a type value is a \nonterm{type-name}, which is a declaration for an object which omits the identifier being declared.
     
    31283111//  File a.c:
    31293112        extern type t1;
    3130         type t2 = struct { t1 f1; ... } // illegal
     3113        type t2 = struct { t1 f1; ... } // illegal
    31313114//  File b.c:
    31323115        extern type t2;
    3133         type t1 = struct { t2 f2; ... } // illegal
     3116        type t1 = struct { t2 f2; ... } // illegal
    31343117\end{lstlisting}
    31353118\end{rationale}
     
    31543137#include <stdlib.h>
    31553138T * new( otype T ) { return ( T * )malloc( sizeof( T) ); };
    3156 §\ldots§ int * ip = new( int );
     3139... int * ip = new( int );
    31573140\end{lstlisting}
    31583141This looks sensible, but \CFA's declaration-before-use rules mean that ``©T©'' in the function body refers to the parameter, but the ``©T©'' in the return type refers to the meaning of ©T© in the scope that contains ©new©;
     
    32393222
    32403223A definition\index{type definition} of a type identifier ©T© with \Index{implementation type} ©I© and type-class ©type© implicitly defines a default assignment function.
    3241 A definition\index{type definition} of a type identifier ©T© with implementation type ©I© and an assertion list implicitly defines \define{default function}s and
    3242 \define{default object}s as declared by the assertion declarations.
     3224A definition\index{type definition} of a type identifier ©T© with implementation type ©I© and an assertion list implicitly defines \define{default function}s and \define{default object}s as declared by the assertion declarations.
    32433225The default objects and functions have the same \Index{scope} and \Index{linkage} as the identifier ©T©.
    32443226Their values are determined as follows:
     
    32963278Default functions and objects are subject to the normal scope rules.
    32973279\begin{lstlisting}
    3298 otype T = §\ldots§;
    3299 T a_T = §\ldots§;               // Default assignment used.
     3280otype T = ...;
     3281T a_T = ...;            // Default assignment used.
    33003282T ?=?( T *, T );
    3301 T a_T = §\ldots§;               // Programmer-defined assignment called.
     3283T a_T = ...;            // Programmer-defined assignment called.
    33023284\end{lstlisting}
    33033285\begin{rationale}
     
    34213403The statement
    34223404\begin{lstlisting}
    3423 for ( a; b; c ) §\ldots§
     3405for ( a; b; c ) ...
    34243406\end{lstlisting} is treated as
    34253407\begin{lstlisting}
     
    35813563\end{lstlisting}
    35823564
    3583 The various flavors of ©char© and ©int© and the enumerated types make up the
    3584 \define{integral types}.
     3565The various flavors of ©char© and ©int© and the enumerated types make up the \define{integral types}.
    35853566\begin{lstlisting}
    35863567trait integral( otype T | arithmetic( T ) ) {§\impl{integral}§§\use{arithmetic}§
  • src/CodeGen/CodeGenerator.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 27 11:59:36 2016
     12// Last Modified On : Fri May 06 16:01:00 2016
    1313// Update Count     : 255
    1414//
     
    7676        //*** Declarations
    7777        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
     78                // generalize this
     79                FunctionDecl::Attribute attr = functionDecl->get_attribute();
     80                switch ( attr.type ) {
     81                        case FunctionDecl::Attribute::Constructor:
     82                                output << "__attribute__ ((constructor";
     83                                if ( attr.priority != FunctionDecl::Attribute::Default ) {
     84                                        output << "(" << attr.priority << ")";
     85                                }
     86                                output << ")) ";
     87                                break;
     88                        case FunctionDecl::Attribute::Destructor:
     89                                output << "__attribute__ ((destructor";
     90                                if ( attr.priority != FunctionDecl::Attribute::Default ) {
     91                                        output << "(" << attr.priority << ")";
     92                                }
     93                                output << ")) ";
     94                                break;
     95                        default:
     96                                break;
     97                }
    7898                handleStorageClass( functionDecl );
    7999                if ( functionDecl->get_isInline() ) {
  • src/InitTweak/GenInit.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 28 12:26:47 2016
     12// Last Modified On : Fri May 06 16:11:15 2016
    1313// Update Count     : 166
    1414//
     
    129129        }
    130130
     131        bool tryConstruct( ObjectDecl * objDecl ) {
     132                // xxx - handle designations
     133                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
     134                        (objDecl->get_init() == NULL ||
     135                        ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ));
     136        }
    131137        namespace {
    132                 bool tryConstruct( ObjectDecl * objDecl ) {
    133                         // xxx - handle designations
    134                         return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    135                                 (objDecl->get_init() == NULL ||
    136                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ));
    137                 }
    138138
    139139                Expression * makeCtorDtorExpr( std::string name, ObjectDecl * objDecl, std::list< Expression * > args ) {
     
    209209                                        objDecl->set_init( new ConstructorInit( ctorStmt, dtorStmt, objDecl->get_init() ) );
    210210                                }
    211                         } else {
    212                                 // xxx - find a way to construct/destruct globals
    213                                 // hack: implicit "static" initialization routine for each struct type? or something similar?
    214                                 // --ties into module system
    215                                 // this can be done by mangling main and replacing it with our own main which calls each
    216                                 // module initialization routine in some decided order (order given in link command?)
    217                                 // and finally calls mangled main
    218211                        }
    219212                }
  • src/InitTweak/GenInit.h

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 28 12:22:09 2016
     12// Last Modified On : Fri May 06 16:18:22 2016
    1313// Update Count     : 3
    1414//
     
    2727        /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
    2828        void genInit( std::list< Declaration * > & translationUnit );
     29        /// True if the resolver should try to construct objDecl
     30        bool tryConstruct( ObjectDecl * objDecl );
    2931} // namespace
    3032
    31 #endif // GENPOLY_POLYMUTATOR_H
     33#endif // INITTWEAK_GENINIT_H
    3234
    3335// Local Variables: //
  • src/InitTweak/module.mk

    r99ee64d r9e2c1f0  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Thu Apr 28 12:23:17 2016
     13## Last Modified On : Fri May 06 15:59:27 2016
    1414## Update Count     : 3
    1515###############################################################################
    1616
    1717SRC += InitTweak/GenInit.cc \
    18         InitTweak/FixInit.cc
     18        InitTweak/FixInit.cc \
     19        InitTweak/FixGlobalInit.cc
     20
  • src/Makefile.in

    r99ee64d r9e2c1f0  
    125125        InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) \
    126126        InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) \
     127        InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \
    127128        Parser/driver_cfa_cpp-parser.$(OBJEXT) \
    128129        Parser/driver_cfa_cpp-lex.$(OBJEXT) \
     
    348349        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    349350        GenPoly/DeclMutator.cc InitTweak/GenInit.cc \
    350         InitTweak/FixInit.cc Parser/parser.yy Parser/lex.ll \
    351         Parser/TypedefTable.cc Parser/ParseNode.cc \
    352         Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
    353         Parser/StatementNode.cc Parser/InitializerNode.cc \
    354         Parser/TypeData.cc Parser/LinkageSpec.cc \
    355         Parser/parseutility.cc Parser/Parser.cc \
     351        InitTweak/FixInit.cc InitTweak/FixGlobalInit.cc \
     352        Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
     353        Parser/ParseNode.cc Parser/DeclarationNode.cc \
     354        Parser/ExpressionNode.cc Parser/StatementNode.cc \
     355        Parser/InitializerNode.cc Parser/TypeData.cc \
     356        Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \
    356357        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    357358        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    569570InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
    570571        InitTweak/$(DEPDIR)/$(am__dirstamp)
     572InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT):  \
     573        InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
    571574Parser/parser.h: Parser/parser.cc
    572575        @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi
     
    800803        -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT)
    801804        -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT)
     805        -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT)
    802806        -rm -f InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT)
    803807        -rm -f InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT)
     
    907911@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@
    908912@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@
     913@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@
    909914@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po@am__quote@
    910915@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po@am__quote@
     
    14061411@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi`
    14071412
     1413InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc
     1414@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1415@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1416@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.o' libtool=no @AMDEPBACKSLASH@
     1417@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1418@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1419
     1420InitTweak/driver_cfa_cpp-FixGlobalInit.obj: InitTweak/FixGlobalInit.cc
     1421@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1422@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1423@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.obj' libtool=no @AMDEPBACKSLASH@
     1424@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1425@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1426
    14081427Parser/driver_cfa_cpp-parser.o: Parser/parser.cc
    14091428@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc
  • src/SynTree/Declaration.h

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 11 16:55:12 2016
    13 // Update Count     : 36
     12// Last Modified On : Fri May 06 16:26:12 2016
     13// Update Count     : 33
    1414//
    1515
     
    115115        typedef DeclarationWithType Parent;
    116116  public:
    117         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn );
     117        // temporary - merge this into general GCC attributes
     118        struct Attribute {
     119                enum Type {
     120                        NoAttribute, Constructor, Destructor,
     121                } type;
     122                enum Priority {
     123                        // priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case
     124                        Default = 100, High,
     125                } priority;
     126                Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {};
     127        };
     128
     129        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() );
    118130        FunctionDecl( const FunctionDecl &other );
    119131        virtual ~FunctionDecl();
     
    128140        std::list< std::string >& get_oldIdents() { return oldIdents; }
    129141        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
     142        Attribute get_attribute() const { return attribute; }
     143        void set_attribute( Attribute newValue ) { attribute = newValue; }
    130144
    131145        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     
    139153        std::list< std::string > oldIdents;
    140154        std::list< Declaration* > oldDecls;
     155        Attribute attribute;
    141156};
    142157
  • src/SynTree/FunctionDecl.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue May 03 15:37:43 2016
     12// Last Modified On : Fri May 06 15:59:48 2016
    1313// Update Count     : 19
    1414//
     
    2121#include "Common/utility.h"
    2222
    23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
    24                 : Parent( name, sc, linkage ), type( type ), statements( statements ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) {
    2525        set_isInline( isInline );
    2626        set_isNoreturn( isNoreturn );
     
    3232
    3333FunctionDecl::FunctionDecl( const FunctionDecl &other )
    34         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     34        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
    3535}
    3636
     
    6565                os << "_Noreturn ";
    6666        } // if
     67        switch ( attribute.type ) {
     68                case Attribute::Constructor:
     69                        os << "Global Constructor ";
     70                        break;
     71                case Attribute::Destructor:
     72                        os << "Global Destructor ";
     73                        break;
     74                default:
     75                        break;
     76        }
     77        if ( attribute.priority != Attribute::Default ) {
     78                os << "with priority " << attribute.priority << " ";
     79        }
    6780        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    6881                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    105118                os << "_Noreturn ";
    106119        } // if
     120        switch ( attribute.type ) {
     121                case Attribute::Constructor:
     122                        os << " Global Constructor ";
     123                        break;
     124                case Attribute::Destructor:
     125                        os << " Global Destructor ";
     126                        break;
     127                default:
     128                        break;
     129        }
     130        if ( attribute.priority != Attribute::Default ) {
     131                os << "with priority " << attribute.priority << " ";
     132        }
    107133        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    108134                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
  • src/driver/cc1.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 25 16:05:15 2016
    13 // Update Count     : 56
     12// Last Modified On : Thu May  5 16:04:30 2016
     13// Update Count     : 77
    1414//
    1515
     
    108108        const char *args[argc + 100];                                           // leave space for 100 additional cpp command line values
    109109        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
    110         const char *uargs[20];                                                          // leave space for 20 additional cfa-cpp command line values
    111         int nuargs = 1;                                                                         // 0 => command name
     110        const char *cargs[20];                                                          // leave space for 20 additional cfa-cpp command line values
     111        int ncargs = 1;                                                                         // 0 => command name
    112112
    113113        signal( SIGINT,  sigTermHandler );
    114114        signal( SIGTERM, sigTermHandler );
     115
     116#ifdef __DEBUG_H__
     117        cerr << "Stage1" << endl;
     118#endif // __DEBUG_H__
    115119
    116120        // process all the arguments
     
    153157                                CFA_flag = true;
    154158                        } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
    155                                 uargs[nuargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
    156                                 nuargs += 1;
     159                                cargs[ncargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
     160                                ncargs += 1;
    157161                        } else if ( arg == "-D" && prefix( argv[i + 1], D__CFA_FLAGPREFIX__.substr(2) ) ) {
    158                                 uargs[nuargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
    159                                 nuargs += 1;
     162                                cargs[ncargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
     163                                ncargs += 1;
    160164                                i += 1;                                                                 // and the argument
    161165                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
     
    317321
    318322        if ( fork() == 0 ) {                                                            // child runs CFA
    319                 uargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
    320 
    321                 uargs[nuargs] = tmpname;
    322                 nuargs += 1;
     323                cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
     324
     325                // Source file-name used to generate routine names containing global initializations for TU.
     326                cargs[ncargs] = ( *new string( "-F" ) ).c_str();
     327                ncargs += 1;
     328                cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str();
     329                ncargs += 1;
     330
     331                cargs[ncargs] = tmpname;
     332                ncargs += 1;
    323333                if ( o_name != NULL ) {
    324                         uargs[nuargs] = o_name;
    325                         nuargs += 1;
     334                        cargs[ncargs] = o_name;
     335                        ncargs += 1;
    326336                } else if ( ! CFA_flag ) {                                              // run cfa-cpp ?
    327                         uargs[nuargs] = cpp_out;
    328                         nuargs += 1;
     337                        cargs[ncargs] = cpp_out;
     338                        ncargs += 1;
    329339                } // if
    330                 uargs[nuargs] = NULL;                                                   // terminate argument list
    331 
    332 #ifdef __DEBUG_H__
    333                 cerr << "cfa-cpp nuargs: " << o_name << " " << CFA_flag << " " << nuargs << endl;
    334                 for ( i = 0; uargs[i] != NULL; i += 1 ) {
    335                         cerr << uargs[i] << " ";
     340                cargs[ncargs] = NULL;                                                   // terminate argument list
     341
     342#ifdef __DEBUG_H__
     343                cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
     344                for ( i = 0; cargs[i] != NULL; i += 1 ) {
     345                        cerr << cargs[i] << " ";
    336346                } // for
    337347                cerr << endl;
    338348#endif // __DEBUG_H__
    339349
    340                 execvp( uargs[0], (char * const *)uargs );              // should not return
     350                execvp( cargs[0], (char * const *)cargs );              // should not return
    341351                perror( "CFA Translator error: cpp level, execvp" );
    342352                exit( EXIT_FAILURE );
     
    370380        const char *args[argc + 100];                                           // leave space for 100 additional cfa command line values
    371381        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
     382
     383#ifdef __DEBUG_H__
     384        cerr << "Stage2" << endl;
     385#endif // __DEBUG_H__
    372386
    373387        // process all the arguments
     
    467481
    468482        if ( arg == "-E" ) {
    469 #ifdef __DEBUG_H__
    470                 cerr << "Stage1" << endl;
    471 #endif // __DEBUG_H__
    472483                Stage1( argc, argv );
    473484        } else if ( arg == "-fpreprocessed" ) {
    474 #ifdef __DEBUG_H__
    475                 cerr << "Stage2" << endl;
    476 #endif // __DEBUG_H__
    477485                Stage2( argc, argv );
    478486        } else {
  • src/examples/abstype.c

    r99ee64d r9e2c1f0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:10:01 2015
    13 // Update Count     : 4
     12// Last Modified On : Wed Apr  6 22:16:08 2016
     13// Update Count     : 8
    1414//
    1515
    16 type T | { T x( T ); };
     16otype T | { T x( T ); };
    1717
    1818T y( T t ) {
     
    2121}
    2222
    23 forall(type T) lvalue T *?( T* );
    24 int ?++( int *);
    25 int ?=?( int*, int );
    26 forall(dtype DT) DT* ?=?( DT **, DT* );
     23forall( otype T ) lvalue T *?( T* );
     24int ?++( int * );
     25int ?=?( int *, int );
     26forall( dtype DT ) DT * ?=?( DT **, DT* );
    2727
    28 type U = int*;
     28otype U = int *;
    2929
    3030U x( U u ) {
  • src/examples/alloc.c

    r99ee64d r9e2c1f0  
    1111// Created On       : Wed Feb  3 07:56:22 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb 17 11:43:23 2016
    14 // Update Count     : 40
     13// Last Modified On : Fri Mar 11 17:42:08 2016
     14// Update Count     : 59
    1515//
    1616
     17forall( otype T ) T * malloc( char fill );
     18forall( dtype T ) T *?=?( T **, void * );
     19void *malloc( unsigned long int );
     20#if 0
    1721#include <fstream>
    1822#include <stdlib>
     
    2529int * bar( int * p, int c ) { return p; }
    2630int * baz( int * p, int c ) { return p; }
     31#endif
    2732
    2833int main( void ) {
     34#if 0
    2935    size_t size = 10;
    3036    int * p;
    3137    struct S { int x; double y; } * s;
     38#endif
    3239
     40#if 0
    3341    p = malloc( sizeof(*p) );                                                   // C malloc, type unsafe
    3442        printf( "here1\n" );
     
    3745        printf( "here2\n" );
    3846    free( p );
    39     p = malloc( (char)'\0' );                                                                   // CFA malloc, type safe
     47#endif
     48//    int * p;
     49//    p = malloc( (char)'\0' );                                                                 // CFA malloc, type safe
     50    (int *)malloc( (char)'\0' );                                                                        // CFA malloc, type safe
     51    (void *)malloc( (char)'\0' );                                                                       // CFA malloc, type safe
     52#if 0
    4053        printf( "here3\n" );
    4154    p = malloc( p, 1000 );                                                              // CFA remalloc, type safe
     
    6073        printf( "here9\n" );
    6174    free( p );
    62 #if 0
     75
    6376    float * fp = malloc() + 1;
    6477    fprintf( stderr, "%p %p\n", fp, fp - 1 );
  • src/examples/includes.c

    r99ee64d r9e2c1f0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 23:28:02 2016
    13 // Update Count     : 328
     12// Last Modified On : Wed Apr 13 22:30:02 2016
     13// Update Count     : 370
    1414//
    1515
     
    2424#if 1
    2525#define _GNU_SOURCE
    26 #include <aio.h>
    27 #include <a.out.h>
    28 #include <aliases.h>
    29 #include <alloca.h>
    30 #include <ansidecl.h>
    31 #include <ar.h>
    32 #include <argp.h>
     26//#include <aio.h>
     27//#include <a.out.h>
     28//#include <aliases.h>
     29//#include <alloca.h>
     30//#include <ansidecl.h>
     31//#include <ar.h>
     32//#include <argp.h>
    3333#include <argz.h>
    34 #include <assert.h>
     34//#include <assert.h>
    3535#include <bfd.h>
     36#if 0
    3637#include <bfdlink.h>
    3738#include <byteswap.h>
     
    5657#include <err.h>
    5758#include <errno.h>
    58 #if 0
    5959#include <error.h>
    60 #endif
    6160#include <eti.h>
    6261#include <evdns.h>
    6362#include <event.h>
    6463#include <evhttp.h>
     64#endif
    6565#if 0
    6666#include <evrpc.h>
     
    129129
    130130//#define _GNU_SOURCE
    131 #include <error.h>
     131#include <bfd.h>
     132//#include <error.h>
    132133
    133134#endif // 0
  • src/main.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 29 12:02:21 2016
    13 // Update Count     : 200
     12// Last Modified On : Fri May 06 15:59:09 2016
     13// Update Count     : 203
    1414//
    1515
     
    4242#include "InitTweak/GenInit.h"
    4343#include "InitTweak/FixInit.h"
     44#include "InitTweak/FixGlobalInit.h"
    4445//#include "Explain/GenProlog.h"
    4546//#include "Try/Visit.h"
     
    102103        std::ostream *output = &std::cout;
    103104        int long_index;
    104         std::list< Declaration* > translationUnit;
     105        std::list< Declaration * > translationUnit;
     106        const char *filename = NULL;
    105107
    106108        opterr = 0;                                                                                     // prevent getopt from printing error messages
    107109
    108110        int c;
    109         while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     111        while ( (c = getopt_long( argc, argv, "abBcefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
    110112                switch ( c ) {
    111113                  case Ast:
     
    174176                        break;
    175177                  case 'D':                                                                             // ignore -Dxxx
     178                        break;
     179                  case 'F':                                                                             // source file-name without suffix
     180                        filename = optarg;
    176181                        break;
    177182                  case '?':
     
    188193                        input = fopen( argv[ optind ], "r" );
    189194                        if ( ! input ) {
    190                                 std::cout << "Error: can't open " << argv[optind] << std::endl;
     195                                std::cout << "Error: can't open " << argv[ optind ] << std::endl;
    191196                                exit( 1 );
    192197                        } // if
     198                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
     199                        if ( filename == NULL ) filename = argv[ optind ];
     200                        // prelude filename comes in differently
     201                        if ( libcfap ) filename = "prelude.cf";
    193202                        optind += 1;
    194203                } else {
     
    263272                OPTPRINT( "fixNames" )
    264273                CodeGen::fixNames( translationUnit );
     274                OPTPRINT( "fixGlobalInit" );
     275                InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep );
    265276                OPTPRINT( "tweakInit" )
    266277                InitTweak::genInit( translationUnit );
Note: See TracChangeset for help on using the changeset viewer.