Changeset 1f44196


Ignore:
Timestamp:
Nov 29, 2016, 3:30:59 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8e5724e
Parents:
3a2128f (diff), 9129a84 (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 plg2:software/cfa/cfa-cc

Conflicts:

src/Parser/parser.cc

Files:
22 added
5 deleted
70 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/concurrency/Makefile

    r3a2128f r1f44196  
    99SOURCES = ${addsuffix .tex, \
    1010concurrency \
     11style \
     12glossary \
    1113}
    1214
  • doc/proposals/concurrency/concurrency.tex

    r3a2128f r1f44196  
    1414
    1515% Latex packages used in the document.
    16 \usepackage[T1]{fontenc}                                % allow Latin1 (extended ASCII) characters
     16\usepackage[T1]{fontenc}                                        % allow Latin1 (extended ASCII) characters
    1717\usepackage{textcomp}
    1818\usepackage[latin1]{inputenc}
    1919\usepackage{fullpage,times,comment}
    2020\usepackage{epic,eepic}
    21 \usepackage{upquote}                                                                    % switch curled `'" to straight
     21\usepackage{upquote}                                            % switch curled `'" to straight
    2222\usepackage{calc}
    2323\usepackage{xspace}
     
    2525\usepackage{tabularx}
    2626\usepackage[acronym]{glossaries}
    27 \usepackage{varioref}                                                           % extended references
     27\usepackage{varioref}                                           % extended references
    2828\usepackage{inconsolata}
    29 \usepackage{listings}                                                                   % format program code
    30 \usepackage[flushmargin]{footmisc}                                              % support label/reference in footnote
    31 \usepackage{latexsym}                                   % \Box glyph
    32 \usepackage{mathptmx}                                   % better math font with "times"
     29\usepackage{listings}                                           % format program code
     30\usepackage[flushmargin]{footmisc}                              % support label/reference in footnote
     31\usepackage{latexsym}                                           % \Box glyph
     32\usepackage{mathptmx}                                           % better math font with "times"
    3333\usepackage[usenames]{color}
    3434\usepackage[pagewise]{lineno}
    3535\usepackage{fancyhdr}
    3636\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    37 \input{common}                                          % bespoke macros used in the document
     37\input{style}                                                   % bespoke macros used in the document
    3838\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    3939\usepackage{breakurl}
     
    4444\renewcommand{\UrlFont}{\small\sf}
    4545
    46 \setlength{\topmargin}{-0.45in}                                                 % move running title into header
     46\setlength{\topmargin}{-0.45in}                         % move running title into header
    4747\setlength{\headsep}{0.25in}
    4848
     
    8686\title{Concurrency in \CFA}
    8787\author{Thierry Delisle \\
    88 Dept. of Computer Science, University of Waterloo, \\ Waterloo, Ontario, Canada
     88School of Computer Science, University of Waterloo, \\ Waterloo, Ontario, Canada
    8989}
    9090
     
    100100
    101101\section{Introduction}
    102 This proposal provides a minimal core concurrency API that is both simple, efficient and can be reused to build higher-level features. The simplest possible core is a thread and a lock but this low-level approach is hard to master. An easier approach for users is to support higher-level construct as the basis of the concurrency in \CFA.
    103 Indeed, for highly productive parallel programming high-level approaches are much more popular\cite{HPP:Study}. Examples are task based parallelism, message passing, implicit threading.
    104 
    105 There are actually two problems that need to be solved in the design of the concurrency for a language. Which concurrency tools are available to the users and which parallelism tools are available. While these two concepts are often seen together, they are in fact distinct concepts that require different sorts of tools\cite{Buhr05a}. Concurrency tools need to handle mutual exclusion and synchronization while parallelism tools are more about performance, cost and resource utilization.
     102This proposal provides a minimal core concurrency API that is both simple, efficient and can be reused to build higher-level features. The simplest possible concurrency core is a thread and a lock but this low-level approach is hard to master. An easier approach for users is to support higher-level constructs as the basis of the concurrency in \CFA. Indeed, for highly productive parallel programming, high-level approaches are much more popular~\cite{HPP:Study}. Examples are task based, message passing and implicit threading.
     103
     104There are actually two problems that need to be solved in the design of the concurrency for a programming language: which concurrency tools are available to the users and which parallelism tools are available. While these two concepts are often seen together, they are in fact distinct concepts that require different sorts of tools~\cite{Buhr05a}. Concurrency tools need to handle mutual exclusion and synchronization, while parallelism tools are more about performance, cost and resource utilization.
    106105
    107106%  #####  ####### #     #  #####  #     # ######  ######  ####### #     #  #####  #     #
     
    114113
    115114\section{Concurrency}
    116 % Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared state, some languages and libraries simply disallow mutable shared-state (Erlang\cite{Erlang}, Haskell\cite{Haskell}, Akka (Scala)\cite{Akka}). In these paradigms, interaction among concurrent objects rely on message passing or other paradigms that often closely relate to networking concepts. However, in imperative or OO languages, these approaches entail a clear distinction between concurrent and non-concurrent paradigms (i.e. message passing versus routine call). Which in turns mean that programmers need to learn two sets of designs patterns in order to be effective. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on non-concurrent constructs like routine calls and objects. At a lower level these can be implemented as locks and atomic operations. However, for productivity reasons it is desireable to have a higher-level construct to be the core concurrency paradigm\cite{HPP:Study}. This project proposes Monitors\cite{Hoare74} as the core concurrency construct.
    117 % \\
    118 
    119 Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared state, some languages and libraries simply disallow mutable shared-state (Erlang\cite{Erlang}, Haskell\cite{Haskell}, Akka (Scala)\cite{Akka}). In these paradigms, interaction among concurrent objects rely on message passing\cite{Thoth,Harmony,V-Kernel} or other paradigms that often closely relate to networking concepts. However, in imperative or OO languages, these approaches entail a clear distinction between concurrent and non-concurrent paradigms (i.e. message passing versus routine call). Which in turns mean that programmers need to learn two sets of designs patterns in order to be effective. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on non-concurrent constructs like routine calls and objects. At a lower level these can be implemented as locks and atomic operations. Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}. However, for productivity reasons it is desireable to have a higher-level construct to be the core concurrency paradigm\cite{HPP:Study}. One of the most natural, elegant, and efficient mechanisms for synchronization and communication, especially for shared memory systems, is the \emph{monitor}.
    120 
    121 Monitors were first proposed by Brinch Hansen~\cite{Hansen73} and later described and extended by C.A.R.~Hoare~\cite{Hoare74}.
    122 Many programming languages---e.g., Concurrent Pascal~\cite{ConcurrentPascal}, Mesa~\cite{Mesa}, Modula~\cite{Modula-2}, Turing~\cite{Turing:old}, Modula-3~\cite{Modula-3}, NeWS~\cite{NeWS}, Emerald~\cite{Emerald}, \uC~\cite{Buhr92a} and Java~\cite{Java}---provide monitors as explicit language constructs. In addition, operating-system kernels and device drivers have a monitor-like structure, although they often use lower-level primitives such as semaphores or locks to simulate monitors. For these reasons, this project proposes Monitors as the core concurrency construct.
    123 \\
    124 
    125 Finally, an approach that is worth mentionning because it is gaining in popularity is transactionnal memory\cite{Dice10}. However, the performance and feature set is currently too restrictive to be possible to add such a paradigm to a language like C or \CC\cit, which is why it was rejected as the core paradigm for concurrency in \CFA.
     115Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared-state, some languages and libraries simply disallow mutable shared-state (Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, Akka (Scala)~\cite{Akka}). In these paradigms, interaction among concurrent objects relies on message passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms that closely relate to networking concepts (channels\cit for example). However, in languages that use routine calls as their core abstraction mechanism, these approaches force a clear distinction between concurrent and non-concurrent paradigms (i.e., message passing versus routine call). Which in turn means that, in order to be effective, programmers need to learn two sets of designs patterns. This distinction can be hidden away in library code, but effective use of the librairy still has to take both paradigms into account. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on basic constructs like routine calls and objects. At a lower level these can be implemented as locks and atomic operations. Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}. However, for productivity reasons it is desireable to have a higher-level construct be the core concurrency paradigm~\cite{HPP:Study}. An approach that is worth mentionning because it is gaining in popularity is transactionnal memory~\cite{Dice10}[Check citation]. While this approach is even pursued by system languages like \CC\cit, the performance and feature set is currently too restrictive to add such a paradigm to a language like C or \CC\cit, which is why it was rejected as the core paradigm for concurrency in \CFA. One of the most natural, elegant, and efficient mechanisms for synchronization and communication, especially for shared memory systems, is the \emph{monitor}. Monitors were first proposed by Brinch Hansen~\cite{Hansen73} and later described and extended by C.A.R.~Hoare~\cite{Hoare74}. Many programming languages---e.g., Concurrent Pascal~\cite{ConcurrentPascal}, Mesa~\cite{Mesa}, Modula~\cite{Modula-2}, Turing~\cite{Turing:old}, Modula-3~\cite{Modula-3}, NeWS~\cite{NeWS}, Emerald~\cite{Emerald}, \uC~\cite{Buhr92a} and Java~\cite{Java}---provide monitors as explicit language constructs. In addition, operating-system kernels and device drivers have a monitor-like structure, although they often use lower-level primitives such as semaphores or locks to simulate monitors. For these reasons, this project proposes monitors as the core concurrency construct.
    126116
    127117% #     # ####### #     # ### ####### ####### ######   #####
     
    134124
    135125\subsection{Monitors}
    136 A monitor is a set of routines that ensure mutual exclusion when accessing shared state. This concept is generally associated with Object-Oriented Languages like Java\cite{Java} or \uC\cite{uC++book} but does not strictly require OOP semantics. The only requirements is the ability to declare a handle to a shared object and a set of routines that act on it :
     126A monitor is a set of routines that ensure mutual exclusion when accessing shared state. This concept is generally associated with Object-Oriented Languages like Java~\cite{Java} or \uC~\cite{uC++book} but does not strictly require OOP semantics. The only requirements is the ability to declare a handle to a shared object and a set of routines that act on it :
    137127\begin{lstlisting}
    138128        typedef /*some monitor type*/ monitor;
     
    154144
    155145\subsubsection{Call semantics} \label{call}
    156 The above example of monitors already displays some of their intrinsic caracteristics. Indeed, it is necessary to use pass-by-reference over pass-by-value for monitor routines. This semantics is important because at their core, monitors are implicit mutual exclusion objects (locks), and these objects cannot be copied. Therefore, monitors are implicitly non-copyable.
    157 \\
    158 
    159 Another aspect to consider is when a monitor acquires its mutual exclusion. Indeed, a monitor may need to be passed through multiple helper routines that do not acquire the monitor mutual exclusion on entry. Examples of this can be both generic helper routines (\code{swap}, \code{sort}, etc.) or specific helper routines like the following example :
    160 
    161 \begin{lstlisting}
    162         mutex struct counter_t { /*...*/ };
    163 
    164         void ?{}(counter_t & nomutex this);
    165         int ++?(counter_t & mutex this);
    166         void ?{}(Int * this, counter_t & mutex cnt);
    167 \end{lstlisting}
    168 *semantics of the declaration of \code{mutex struct counter_t} are discussed in details in section \ref{data}
    169 \\
    170 
    171 This example is of a monitor implementing an atomic counter. Here, the constructor uses the \code{nomutex} keyword to signify that it does not acquire the coroutine mutual exclusion when constructing. This is because object not yet constructed should never be shared and therefore do not require mutual exclusion. The prefix increment operator
    172 uses \code{mutex} to protect the incrementing process from race conditions. Finally, we have a conversion operator from \code{counter_t} to \code{Int}. This conversion may or may not require the \code{mutex} key word depending whether or not reading an \code{Int} is an atomic operation or not.
    173 \\
    174 
    175 Having both \code{mutex} and \code{nomutex} keywords could be argued to be redundant based on the meaning of a routine having neither of these keywords. If there were a meaning to routine \code{void foo(counter_t & this)} then one could argue that it should be to default to the safest option : \code{mutex}. On the other hand, the option of having routine \code{void foo(counter_t & this)} mean \code{nomutex} is unsafe by default and may easily cause subtle errors. It can be argued that this is the more "normal" behavior, \code{nomutex} effectively stating explicitly that "this routine has nothing special". An other alternative is to make one of these keywords mandatory, which would provide the same semantics but without the ambiguity of supporting routine \code{void foo(counter_t & this)}. Mandatory keywords would also have the added benefice of being more clearly self-documented but at the cost of extra typing. In the end, which solution should be picked is still up for debate. For the reminder of this proposal, the explicit approach will be used for the sake of clarity.
    176 \\
    177 
    178 Regardless of which keyword is kept, it is important to establish when mutex/nomutex may be used depending on type parameters.
     146The above monitor example displays some of the intrinsic characteristics. Indeed, it is necessary to use pass-by-reference over pass-by-value for monitor routines. This semantics is important because at their core, monitors are implicit mutual-exclusion objects (locks), and these objects cannot be copied. Therefore, monitors are implicitly non-copyable.
     147
     148Another aspect to consider is when a monitor acquires its mutual exclusion. For example, a monitor may need to be passed through multiple helper routines that do not acquire the monitor mutual-exclusion on entry. Pass through can be both generic helper routines (\code{swap}, \code{sort}, etc.) or specific helper routines like the following to implement an atomic counter :
     149
     150\begin{lstlisting}
     151        mutex struct counter_t { /*...see section §\ref{data}§...*/ };
     152
     153        void ?{}(counter_t & nomutex this); //constructor
     154        size_t ++?(counter_t & mutex this); //increment
     155
     156        //need for mutex is platform dependent here
     157        void ?{}(size_t * this, counter_t & mutex cnt); //conversion
     158\end{lstlisting}
     159
     160Here, the constructor(\code{?\{\}}) uses the \code{nomutex} keyword to signify that it does not acquire the monitor mutual exclusion when constructing. This semantics is because an object not yet constructed should never be shared and therefore does not require mutual exclusion. The prefix increment operator uses \code{mutex} to protect the incrementing process from race conditions. Finally, there is a conversion operator from \code{counter_t} to \code{size_t}. This conversion may or may not require the \code{mutex} key word depending on whether or not reading an \code{size_t} is an atomic operation or not.
     161
     162Having both \code{mutex} and \code{nomutex} keywords could be argued to be redundant based on the meaning of a routine having neither of these keywords. For example, given a routine without wualifiers \code{void foo(counter_t & this)} then one could argue that it should default to the safest option \code{mutex}. On the other hand, the option of having routine \code{void foo(counter_t & this)} mean \code{nomutex} is unsafe by default and may easily cause subtle errors. It can be argued that \code{nomutex} is the more "normal" behaviour, the \code{nomutex} keyword effectively stating explicitly that "this routine has nothing special". Another alternative is to make having exactly one of these keywords mandatory, which would provide the same semantics but without the ambiguity of supporting routine \code{void foo(counter_t & this)}. Mandatory keywords would also have the added benefice of being self-documented but at the cost of extra typing. In the end, which solution should be picked is still up for debate. For the reminder of this proposal, the explicit approach is used for clarity.
     163
     164The next semantic decision is to establish when mutex/nomutex may be used as a type qualifier. Consider the following declarations:
    179165\begin{lstlisting}
    180166        int f1(monitor & mutex m);
     
    184170        int f5(graph(monitor*) & mutex m);
    185171\end{lstlisting}
    186 
    187 The problem is to indentify which object(s) should be acquired. Furthermore we also need to acquire each objects only once. In case of simple routines like \code{f1} and \code{f2} it is easy to identify an exhaustive list of objects to acquire on entering. Adding indirections (\code{f3}) still allows the compiler and programmer to indentify which object will be acquired. However, adding in arrays (\code{f4}) makes it much harder. Array lengths aren't necessarily known in C and even then making sure we only acquire objects once becomes also none trivial. This can be extended to absurd limits like \code{f5} which uses a custom graph of monitors. To keep everyone as sane as possible\cite{Chicken}, this projects imposes the requirement that a routine may only acquire one monitor per parameter and it must be the type of the parameter (ignoring potential qualifiers and indirections).
     172The problem is to indentify which object(s) should be acquired. Furthermore, each object needs to be acquired only once. In the case of simple routines like \code{f1} and \code{f2} it is easy to identify an exhaustive list of objects to acquire on entry. Adding indirections (\code{f3}) still allows the compiler and programmer to indentify which object is acquired. However, adding in arrays (\code{f4}) makes it much harder. Array lengths are not necessarily known in C and even then making sure we only acquire objects once becomes also none trivial. This can be extended to absurd limits like \code{f5}, which uses a graph of monitors. To keep everyone as sane as possible~\cite{Chicken}, this projects imposes the requirement that a routine may only acquire one monitor per parameter and it must be the type of the parameter (ignoring potential qualifiers and indirections). Also note that while routine \code{f3} can be supported, meaning that monitor \code{**m} is be acquired, passing an array to this routine would be type safe and yet result in undefined behavior because only the first element of the array is acquired. However, this ambiguity is part of the C type system with respects to arrays. For this reason, it would also be reasonnable to disallow mutex in the context where arrays may be passed.
    188173
    189174% ######     #    #######    #
     
    196181
    197182\subsubsection{Data semantics} \label{data}
    198 Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contian shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appripriate protection. For example here is a more fleshed-out version of the counter showed in \ref{call}:
     183Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contian shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appropriate protection. For example, here is a complete version of the counter showed in section \ref{call}:
    199184\begin{lstlisting}
    200185        mutex struct counter_t {
     
    207192
    208193        int ++?(counter_t & mutex this) {
    209                 return ++this->value;
    210         }
    211 
     194                return ++this.value;
     195        }
     196
     197        //need for mutex is platform dependent here
    212198        void ?{}(int * this, counter_t & mutex cnt) {
    213199                *this = (int)cnt;
    214200        }
    215201\end{lstlisting}
    216 \begin{tabular}{ c c }
    217 Thread 1 & Thread 2 \\
    218 \begin{lstlisting}
    219         void f(counter_t & mutex c) {
    220                 for(;;) {
    221                         sout | (int)c | endl;
    222                 }
    223         }
    224 \end{lstlisting} &\begin{lstlisting}
    225         void g(counter_t & mutex c) {
    226                 for(;;) {
    227                         ++c;
    228                 }
    229         }
    230 
     202
     203This simple counter is used as follows:
     204\begin{center}
     205\begin{tabular}{c @{\hskip 0.35in} c @{\hskip 0.35in} c}
     206\begin{lstlisting}
     207        //shared counter
     208        counter_t cnt;
     209
     210        //multiple threads access counter
     211        thread 1 : cnt++;
     212        thread 2 : cnt++;
     213        thread 3 : cnt++;
     214          ...
     215        thread N : cnt++;
    231216\end{lstlisting}
    232217\end{tabular}
    233 \\
    234 
    235 
    236 This simple counter offers an example of monitor usage. Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting. \\
    237 
    238 These simple mutual exclusion semantics also naturally expand to multi-monitor calls.
     218\end{center}
     219
     220Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting. Unlike object-oriented monitors, where calling a mutex member \emph{implicitly} acquires mutual-exclusion, \CFA uses an explicit mechanism to acquire mutual-exclusion. A consequence of this approach is that it extends to multi-monitor calls.
    239221\begin{lstlisting}
    240222        int f(MonitorA & mutex a, MonitorB & mutex b);
     
    244226        f(a,b);
    245227\end{lstlisting}
    246 
    247 This code acquires both locks before entering the critical section. In practice, writing multi-locking routines that can not lead to deadlocks can be very tricky. Having language level support for such feature is therefore a significant asset for \CFA. However, this does have significant repercussions relating to scheduling (see \ref{insched} and \ref{extsched}). Furthermore, the ability to acquire multiple monitors at the same time does incur a significant pitfall even without looking into scheduling. For example :
    248 \begin{lstlisting}
    249         void foo(A & mutex a, B & mutex a) {
    250                 //...
    251         }
    252 
    253         void bar(A & mutex a, B & nomutex a)
    254                 //...
    255                 foo(a, b);
    256                 //...
    257         }
    258 
    259         void baz(A & nomutex a, B & mutex a)
    260                 //...
    261                 foo(a, b);
    262                 //...
    263         }
    264 \end{lstlisting}
    265 
    266 Recursive mutex routine calls are allowed in \CFA but if not done carefully it can lead to nested monitor call problems\cite{Lister77}. These problems which are a specific  implementation of the lock acquiring order problem. In the example above, the user uses implicit ordering in the case of function \code{bar} but explicit ordering in the case of \code{baz}. This subtle mistake can mean that calling these two functions concurrently will lead to deadlocks, depending on the implicit ordering matching the explicit ordering. As shown on several occasion\cit, there isn't really any solutions to this problem, users simply need to be carefull when acquiring multiple monitors at the same time.
     228This code acquires both locks before entering the critical section, called \emph{\gls{group-acquire}}. In practice, writing multi-locking routines that do not lead to deadlocks is tricky. Having language support for such a feature is therefore a significant asset for \CFA. In the case presented above, \CFA guarantees that the order of aquisition is consistent across calls to routines using the same monitors as arguments. However, since \CFA monitors use multi-acquisition locks, users can effectively force the acquiring order. For example, notice which routines use \code{mutex}/\code{nomutex} and how this affects aquiring order :
     229\begin{lstlisting}
     230        void foo(A & mutex a, B & mutex b) { //acquire a & b
     231                //...
     232        }
     233
     234        void bar(A & mutex a, B & nomutex b) { //acquire a
     235                //...
     236                foo(a, b); //acquire b
     237                //...
     238        }
     239
     240        void baz(A & nomutex a, B & mutex b) { //acquire b
     241                //...
     242                foo(a, b); //acquire a
     243                //...
     244        }
     245\end{lstlisting}
     246
     247The multi-acquisition monitor lock allows a monitor lock to be acquired by both \code{bar} or \code{baz} and acquired again in \code{foo}. In the calls to \code{bar} and \code{baz} the monitors are acquired in opposite order. such use leads to nested monitor call problems~\cite{Lister77}, which is a specific implementation of the lock acquiring order problem. In the example above, the user uses implicit ordering in the case of function \code{foo} but explicit ordering in the case of \code{bar} and \code{baz}. This subtle mistake means that calling these routines concurrently may lead to deadlock and is therefore undefined behavior. As shown on several occasion\cit, solving this problem requires :
     248\begin{enumerate}
     249        \item Dynamically tracking of the monitor-call order.
     250        \item Implement rollback semantics.
     251\end{enumerate}
     252
     253While the first requirement is already a significant constraint on the system, implementing a general rollback semantics in a C-like language is prohibitively complex \cit. In \CFA, users simply need to be carefull when acquiring multiple monitors at the same time.
    267254
    268255% ######  ####### #######    #    ### #        #####
     
    283270
    284271\subsubsection{Implementation Details: Interaction with polymorphism}
    285 At first glance, interaction between monitors and \CFA's concept of polymorphism seem complexe to support. However, it can be reasoned that entry-point locking can solve most of the issues that could be present with polymorphism.
    286 
    287 First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore the main question is how to support \code{dtype} polymorphism. We must remember that monitors' main purpose is to ensure mutual exclusion when accessing shared data. This implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handle incomplete types (by definition) no \code{dtype} polymorphic routine can access shared data since the data would require knowledge about the type. Therefore the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines. With callsite-locking, this would require significant amount of work since any \code{dtype} routine could have to obtain some lock before calling a routine. However, with entry-point-locking calling a monitor routine becomes exactly the same as calling it from anywhere else.
     272At first glance, interaction between monitors and \CFA's concept of polymorphism seems complex to support. However, it is shown that entry-point locking can solve most of the issues.
     273
     274Before looking into complex control flow, it is important to present the difference between the two acquiring options : \gls{callsite-locking} and \gls{entry-point-locking}, i.e. acquiring the monitors before making a mutex call or as the first instruction of the mutex call. For example:
     275
     276\begin{center}
     277\begin{tabular}{|c|c|c|}
     278Code & \gls{callsite-locking} & \gls{entry-point-locking} \\
     279\CFA & pseudo-code & pseudo-code \\
     280\hline
     281\begin{lstlisting}
     282void foo(monitor & mutex a) {
     283
     284
     285
     286        //Do Work
     287        //...
     288
     289}
     290
     291void main() {
     292        monitor a;
     293
     294
     295
     296        foo(a);
     297
     298}
     299\end{lstlisting} &\begin{lstlisting}
     300foo(& a) {
     301
     302
     303
     304        //Do Work
     305        //...
     306
     307}
     308
     309main() {
     310        monitor a;
     311        //calling routine
     312        //handles concurrency
     313        acquire(a);
     314        foo(a);
     315        release(a);
     316}
     317\end{lstlisting} &\begin{lstlisting}
     318foo(& a) {
     319        //called routine
     320        //handles concurrency
     321        acquire(a);
     322        //Do Work
     323        //...
     324        release(a);
     325}
     326
     327main() {
     328        monitor a;
     329
     330
     331
     332        foo(a);
     333
     334}
     335\end{lstlisting}
     336\end{tabular}
     337\end{center}
     338
     339First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore, the main question is how to support \code{dtype} polymorphism. Since a monitor's main purpose is to ensure mutual exclusion when accessing shared data, this implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handles incomplete types (by definition), no \code{dtype} polymorphic routine can access shared data since the data requires knowledge about the type. Therefore, the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines. \Gls{callsite-locking} would require a significant amount of work, since any \code{dtype} routine may have to obtain some lock before calling a routine, depending on whether or not the type passed is a monitor. However, with \gls{entry-point-locking} calling a monitor routine becomes exactly the same as calling it from anywhere else.
     340
     341
    288342
    289343% ### #     # #######         #####   #####  #     # ####### ######
     
    296350
    297351\subsection{Internal scheduling} \label{insched}
    298 Monitors should also be able to schedule what threads access it as a mean of synchronization. Internal scheduling is one of the simple examples of such a feature. It allows users to declare condition variables and wait for them to be signaled. Here is a simple example of such a technique :
     352Monitors also need to schedule waiting threads internally as a mean of synchronization. Internal scheduling is one of the simple examples of such a feature. It allows users to declare condition variables and have threads wait and signaled from them. Here is a simple example of such a technique :
    299353
    300354\begin{lstlisting}
     
    314368\end{lstlisting}
    315369
    316 Here routine \code{foo} waits on the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering. This semantic can easily be extended to multi-monitor calls by offering the same guarantee.
    317 
     370Note that in \CFA, \code{condition} have no particular need to be stored inside a monitor, beyond any software engineering reasons. Here routine \code{foo} waits for the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering. This semantic can easily be extended to multi-monitor calls by offering the same guarantee.
    318371\begin{center}
    319372\begin{tabular}{ c @{\hskip 0.65in} c }
     
    321374\begin{lstlisting}
    322375void foo(monitor & mutex a,
    323          monitor & mutex b) {
     376           monitor & mutex b) {
    324377        //...
    325378        wait(a.e);
     
    330383\end{lstlisting} &\begin{lstlisting}
    331384void bar(monitor & mutex a,
    332          monitor & mutex b) {
     385           monitor & mutex b) {
    333386        signal(a.e);
    334387}
     
    340393\end{tabular}
    341394\end{center}
    342 
    343 A direct extension of the single monitor semantics would be to release all locks when waiting and transferring ownership of all locks when signalling. However, for the purpose of synchronization it may be usefull to only release some of the locks but keep others. On the technical side, partially releasing lock is feasible but from the user perspective a choice must be made for the syntax of this feature. It is possible to do without any extra syntax by relying on order of acquisition (Note that here the use of helper routines is irrelevant, only routines the acquire mutual exclusion have an impact on internal scheduling):
     395A direct extension of the single monitor semantics is to release all locks when waiting and transferring ownership of all locks when signalling. However, for the purpose of synchronization it may be usefull to only release some of the locks but keep others. It is possible to support internal scheduling and \gls{group-acquire} without any extra syntax by relying on order of acquisition. Here is an example of the different contexts in which internal scheduling can be used. (Note that here the use of helper routines is irrelevant, only routines acquire mutual exclusion have an impact on internal scheduling):
    344396
    345397\begin{center}
     
    350402condition e;
    351403
     404//acquire a & b
    352405void foo(monitor & mutex a,
    353          monitor & mutex b) {
    354         wait(e);
     406           monitor & mutex b) {
     407
     408        wait(e); //release a & b
    355409}
    356410
     
    364418condition e;
    365419
     420//acquire a
    366421void bar(monitor & mutex a,
    367          monitor & nomutex b) {
     422           monitor & nomutex b) {
    368423        foo(a,b);
    369424}
    370425
     426//acquire a & b
    371427void foo(monitor & mutex a,
    372          monitor & mutex b) {
    373         wait(e);
     428           monitor & mutex b) {
     429        wait(e);  //release a & b
    374430}
    375431
     
    378434condition e;
    379435
     436//acquire a
    380437void bar(monitor & mutex a,
    381          monitor & nomutex b) {
    382         foo(a,b);
    383 }
    384 
     438           monitor & nomutex b) {
     439        baz(a,b);
     440}
     441
     442//acquire b
    385443void baz(monitor & nomutex a,
    386          monitor & mutex b) {
    387         wait(e);
     444           monitor & mutex b) {
     445        wait(e);  //release b
    388446}
    389447
     
    393451\end{center}
    394452
    395 This can be interpreted in two different ways :
    396 \begin{flushleft}
    397 \begin{enumerate}
    398         \item \code{wait} atomically releases the monitors acquired by the inner-most routine, \underline{ignoring} nested calls.
    399         \item \code{wait} atomically releases the monitors acquired by the inner-most routine, \underline{considering} nested calls.
    400 \end{enumerate}
    401 \end{flushleft}
    402 While the difference between these two is subtle, it has a significant impact. In the first case it means that the calls to \code{foo} would behave the same in Context 1 and 2. This semantic would also mean that the call to \code{wait} in routine \code{baz} would only release \code{monitor b}. While this may seem intuitive with these examples, it does have one significant implication, it creates a strong distinction between acquiring multiple monitors in sequence and acquiring the same monitors simulatenously, i.e. :
     453Context 1 is the simplest way of acquiring more than one monitor (\gls{group-acquire}), using a routine with multiple parameters having the \code{mutex} keyword. Context 2 also uses \gls{group-acquire} as well in routine \code{foo}. However, the routine is called by routine \code{bar}, which only acquires monitor \code{a}. Since monitors can be acquired multiple times this does not cause a deadlock by itself but it does force the acquiring order to \code{a} then \code{b}. Context 3 also forces the acquiring order to be \code{a} then \code{b} but does not use \gls{group-acquire}. The previous example tries to illustrate the semantics that must be established to support releasing monitors in a \code{wait} statement. In all cases, the behavior of the wait statment is to release all the locks that were acquired my the inner-most monitor call. That is \code{a & b} in context 1 and 2 and \code{b} only in context 3. Here are a few other examples of this behavior.
     454
    403455
    404456\begin{center}
    405 \begin{tabular}{c @{\hskip 0.35in} c @{\hskip 0.35in} c}
    406 \begin{lstlisting}
    407 enterMonitor(a);
    408 enterMonitor(b);
    409 // do stuff
    410 leaveMonitor(b);
    411 leaveMonitor(a);
    412 \end{lstlisting} & != &\begin{lstlisting}
    413 enterMonitor(a);
    414 enterMonitor(a, b);
    415 // do stuff
    416 leaveMonitor(a, b);
    417 leaveMonitor(a);
     457\begin{tabular}{|c|c|c|}
     458\begin{lstlisting}
     459condition e;
     460
     461//acquire b
     462void foo(monitor & nomutex a,
     463           monitor & mutex b) {
     464        bar(a,b);
     465}
     466
     467//acquire a
     468void bar(monitor & mutex a,
     469           monitor & nomutex b) {
     470
     471        wait(e); //release a
     472                  //keep b
     473}
     474
     475foo(a, b);
     476\end{lstlisting} &\begin{lstlisting}
     477condition e;
     478
     479//acquire a & b
     480void foo(monitor & mutex a,
     481           monitor & mutex b) {
     482        bar(a,b);
     483}
     484
     485//acquire b
     486void bar(monitor & mutex a,
     487           monitor & nomutex b) {
     488
     489        wait(e); //release b
     490                  //keep a
     491}
     492
     493foo(a, b);
     494\end{lstlisting} &\begin{lstlisting}
     495condition e;
     496
     497//acquire a & b
     498void foo(monitor & mutex a,
     499           monitor & mutex b) {
     500        bar(a,b);
     501}
     502
     503//acquire none
     504void bar(monitor & nomutex a,
     505           monitor & nomutex b) {
     506
     507        wait(e); //release a & b
     508                  //keep none
     509}
     510
     511foo(a, b);
    418512\end{lstlisting}
    419513\end{tabular}
    420514\end{center}
    421 
    422 This is not intuitive because even if both methods display the same monitors state both inside and outside the critical section respectively, the behavior is different. Furthermore, the actual acquiring order will be exaclty the same since acquiring a monitor from inside its mutual exclusion is a no-op. This means that even if the data and the actual control flow are the same using both methods, the behavior of the \code{wait} will be different. The alternative is option 2, that is releasing acquired monitors, \underline{considering} nesting. This solves the issue of having the two acquiring method differ at the cost of making routine \code{foo} behave differently depending on from which context it is called (Context 1 or 2). Indeed in Context 2, routine \code{foo} actually behaves like routine \code{baz} rather than having the same behavior than in Context 1. The fact that both implicit approaches can be unintuitive depending on the perspective may be a sign that the explicit approach is superior. For this reason this \CFA does not support implicit monitor releasing and uses explicit semantics.
    423 \\
    424 
    425 The following examples shows three alternatives of explicit wait semantics :
    426 \\
    427 
     515Note the right-most example is actually a trick pulled on the reader. Monitor state information is stored in thread local storage rather then in the routine context, which means that helper routines and other \code{nomutex} routines are invisible to the runtime system in regards to concurrency. This means that in the right-most example, the routine parameters are completly unnecessary. However, calling this routine from outside a valid monitor context is undefined.
     516
     517These semantics imply that in order to release of subset of the monitors currently held, users must write (and name) a routine that only acquires the desired subset and simply calls wait. While users can use this method, \CFA offers the \code{wait_release}\footnote{Not sure if an overload of \code{wait} would work...} which will release only the specified monitors. In the center previous examples, the code in the center uses the \code{bar} routine to only release monitor \code{b}. Using the \code{wait_release} helper, this can be rewritten without having the name two routines :
    428518\begin{center}
    429 \begin{tabular}{|c|c|c|}
    430 Case 1 & Case 2 & Case 3 \\
    431 Branding on construction & Explicit release list & Explicit ignore list \\
    432 \hline
    433 \begin{lstlisting}
    434 void foo(monitor & mutex a,
    435          monitor & mutex b,
    436            condition & c)
    437 {
    438         // Releases monitors
    439         // branded in ctor
    440         wait(c);
    441 }
    442 
    443 monitor a;
    444 monitor b;
    445 condition1 c1 = {a};
    446 condition2 c2 = {a, b};
    447 
    448 //Will release only a
    449 foo(a,b,c1);
    450 
    451 //Will release a and b
    452 foo(a,b,c2);
     519\begin{tabular}{ c c c }
     520\begin{lstlisting}
     521        condition e;
     522
     523        //acquire a & b
     524        void foo(monitor & mutex a,
     525                   monitor & mutex b) {
     526                bar(a,b);
     527        }
     528
     529        //acquire b
     530        void bar(monitor & mutex a,
     531                   monitor & nomutex b) {
     532
     533                wait(e); //release b
     534                          //keep a
     535        }
     536
     537        foo(a, b);
    453538\end{lstlisting} &\begin{lstlisting}
    454 void foo(monitor & mutex a,
    455          monitor & mutex b,
    456            condition & c)
    457 {
    458         // Releases monitor a
    459         // Holds monitor b
    460         waitRelease(c, [a]);
    461 }
    462 
    463 monitor a;
    464 monitor b;
    465 condition c;
    466 
    467 
    468 
    469 foo(a,b,c);
    470 
    471 
    472 
     539        =>
    473540\end{lstlisting} &\begin{lstlisting}
    474 void foo(monitor & mutex a,
    475          monitor & mutex b,
    476            condition & c)
    477 {
    478         // Releases monitor a
    479         // Holds monitor b
    480         waitHold(c, [b]);
    481 }
    482 
    483 monitor a;
    484 monitor b;
    485 condition c;
    486 
    487 
    488 
    489 foo(a,b,c);
    490 
    491 
    492 
     541        condition e;
     542
     543        //acquire a & b
     544        void foo(monitor & mutex a,
     545                   monitor & mutex b) {
     546                wait_release(e,b); //release b
     547                                         //keep a
     548        }
     549
     550        foo(a, b);
    493551\end{lstlisting}
    494552\end{tabular}
    495553\end{center}
    496 (Note : Case 2 and 3 use tuple semantics to pass a variable length list of elements.)
    497 \\
    498 
    499 All these cases have their pros and cons. Case 1 is more distinct because it means programmers need to be carefull about where the condition is initialized as well as where it is used. On the other hand, it is very clear and explicitly states which monitor is released and which monitor stays acquired. This is similar to Case 2, which releases only the monitors explictly listed. However, in Case 2, calling the \code{wait} routine instead of the \code{waitRelease} routine releases all the acquired monitor. The Case 3 is an improvement on that since it releases all the monitors except those specified. The result is that the \code{wait} routine can be written as follows :
    500 \begin{lstlisting}
    501 void wait(condition & cond) {
    502         waitHold(cond, []);
    503 }
    504 \end{lstlisting}
    505 This alternative offers nice and consistent behavior between \code{wait} and \code{waitHold}. However, one large pitfall is that mutual exclusion can now be violated by calls to library code. Indeed, even if the following example seems benign there is one significant problem :
    506 \begin{lstlisting}
    507 monitor global;
    508 
    509 extern void doStuff(); //uses global
    510 
    511 void foo(monitor & mutex m) {
    512         //...
    513         doStuff(); //warning can release monitor m
    514         //...
    515 }
    516 
    517 foo(global);
    518 \end{lstlisting}
    519 
    520 Indeed, if Case 2 or 3 are chosen it any code can violate the mutual exclusion of the calling code by issuing calls to \code{wait} or \code{waitHold} in a nested monitor context. Case 2 can be salvaged by removing the \code{wait} routine from the API but Case 3 cannot prevent users from calling \code{waitHold(someCondition, [])}. For this reason the syntax proposed in Case 3 is rejected. Note that the syntax proposed in case 1 and 2 are not exclusive. Indeed, by supporting two types of condition both cases can be supported :
    521 \begin{lstlisting}
    522 struct condition { /*...*/ };
    523 
    524 // Second argument is a variable length tuple.
    525 void wait(condition & cond, [...] monitorsToRelease);
    526 void signal(condition & cond);
    527 
    528 struct conditionN { /*...*/ };
    529 
    530 void ?{}(conditionN* this, /*list of N monitors to release*/);
    531 void wait(conditionN & cond);
    532 void signal(conditionN & cond);
    533 \end{lstlisting}
    534 
    535 Regardless of the option chosen for wait semantics, signal must be symmetrical. In all cases, signal only needs a single parameter, the condition variable that needs to be signalled. But \code{signal} needs to be called from the same monitor(s) that call to \code{wait}. Otherwise, mutual exclusion cannot be properly transferred back to the waiting monitor.
    536 
    537 Finally, an additionnal semantic which can be very usefull is the \code{signalBlock} routine. This routine behaves like signal for all of the semantics discussed above, but with the subtelty that mutual exclusion is transferred to the waiting task immediately rather than wating for the end of the critical section.
     554
     555Regardless of the context in which the \code{wait} statement is used, \code{signal} must be called holding the same set of monitors. In all cases, signal only needs a single parameter, the condition variable that needs to be signalled. But \code{signal} needs to be called from the same monitor(s) that call to \code{wait}. Otherwise, mutual exclusion cannot be properly transferred back to the waiting monitor.
     556
     557Finally, an additional semantic which can be very usefull is the \code{signal_block} routine. This routine behaves like signal for all of the semantics discussed above, but with the subtelty that mutual exclusion is transferred to the waiting task immediately rather than wating for the end of the critical section.
    538558\\
    539559
     
    545565% #        #   #     #    ###    #     # #     # #     # #       #     #
    546566% ####### #     #    #    ###     #####   #####  #     # ####### ######
    547 
     567\newpage
    548568\subsection{External scheduling} \label{extsched}
    549 As one might expect, the alternative to Internal scheduling is to use External scheduling instead. This method is somewhat more robust to deadlocks since one of the threads keeps a relatively tight control on scheduling. Indeed, as the following examples will demonstrate, external scheduling allows users to wait for events from other threads without the concern of unrelated events occuring. External scheduling can generally be done either in terms of control flow (ex: \uC) or in terms of data (ex: Go). Of course, both of these paradigms have their own strenghts and weaknesses but for this project control flow semantics where chosen to stay consistent with the rest of the languages semantics. Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multi-monitor routines. The following example shows what a simple use \code{accept} versus \code{wait}/\code{signal} and its advantages.
     569An alternative to internal scheduling is to use external scheduling instead. This method is more constrained and explicit which may help users tone down the undeterministic nature of concurrency. Indeed, as the following examples demonstrates, external scheduling allows users to wait for events from other threads without the concern of unrelated events occuring. External scheduling can generally be done either in terms of control flow (ex: \uC) or in terms of data (ex: Go). Of course, both of these paradigms have their own strenghts and weaknesses but for this project control flow semantics where chosen to stay consistent with the rest of the languages semantics. Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multi-monitor routines. The following example shows a simple use \code{accept} versus \code{wait}/\code{signal} and its advantages.
    550570
    551571\begin{center}
     
    565585
    566586        public:
    567                 void f();
     587                void f() { /*...*/ }
    568588                void g() { _Accept(f); }
    569589        private:
     
    573593\end{center}
    574594
    575 In the case of internal scheduling, the call to \code{wait} only guarantees that \code{g} was the last routine to access the monitor. This intails that the routine \code{f} may have acquired mutual exclusion several times while routine \code{h} was waiting. On the other hand, external scheduling guarantees that while routine \code{h} was waiting, no routine other than \code{g} could acquire the monitor.
     595In the case of internal scheduling, the call to \code{wait} only guarantees that \code{g} is the last routine to access the monitor. This intails that the routine \code{f} may have acquired mutual exclusion several times while routine \code{h} was waiting. On the other hand, external scheduling guarantees that while routine \code{h} was waiting, no routine other than \code{g} could acquire the monitor.
    576596\\
    577597
     
    756776% #       #     # #     # #     # ####### ####### ####### ####### ###  #####  #     #
    757777\section{Parallelism}
    758 Historically, computer performance was about processor speeds and instructions count. However, with heat dissipation being an ever growing challenge, parallelism has become the new source of greatest performance \cite{Sutter05, Sutter05b}. In this decade, it is not longer reasonnable to create high-performance application without caring about parallelism. Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization. The lowest level approach of parallelism is to use \glspl{kthread}. However since these have significant costs and limitations \glspl{kthread} are now mostly used as an implementation tool rather than a user oriented one. There are several alternatives to solve these issues which all have strengths and weaknesses.
     778Historically, computer performance was about processor speeds and instructions count. However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}. In this decade, it is not longer reasonnable to create a high-performance application without caring about parallelism. Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization. The lowest-level approach of parallelism is to use \glspl{kthread} in combination with semantics like \code{fork}, \code{join}, etc. However, since these have significant costs and limitations, \glspl{kthread} are now mostly used as an implementation tool rather than a user oriented one. There are several alternatives to solve these issues that all have strengths and weaknesses. While there are many variations of the presented paradigms, most of these variations do not actually change the guarantees or the semantics, they simply move costs in order to achieve better performance for certain workloads.
    759779
    760780\subsection{User-level threads}
    761 A direct improvement on the \gls{kthread} approach is to use \glspl{uthread}. These threads offer most of the same features that the operating system already provide but can be used on a much larger scale. This is the most powerfull solution as it allows all the features of multi-threading while removing several of the more expensives costs of using kernel threads. The down side is that almost none of the low-level threading complexities are hidden, users still have to think about data races, deadlocks and synchronization issues. This can be somewhat alleviated by a concurrency toolkit with strong garantees but the parallelism toolkit offers very little to reduce complexity in itself.
    762 
    763 Examples of languages that support are Java\cite{Java}, Haskell\cite{Haskell} and \uC\cite{uC++book}.
     781A direct improvement on the \gls{kthread} approach is to use \glspl{uthread}. These threads offer most of the same features that the operating system already provide but can be used on a much larger scale. This approach is the most powerfull solution as it allows all the features of multi-threading, while removing several of the more expensives costs of using kernel threads. The down side is that almost none of the low-level threading problems are hidden, users still have to think about data races, deadlocks and synchronization issues. These issues can be somewhat alleviated by a concurrency toolkit with strong garantees but the parallelism toolkit offers very little to reduce complexity in itself.
     782
     783Examples of languages that support \glspl{uthread} are Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
     784
     785\subsubsection{Fibers : user-level threads without preemption}
     786A popular varient of \glspl{uthread} is what is often reffered to as \glspl{fiber}. However, \glspl{fiber} do not present meaningful semantical differences with \glspl{uthread}. Advocates of \glspl{fiber} list their high performance and ease of implementation as majors strenghts of \glspl{fiber} but the performance difference between \glspl{uthread} and \glspl{fiber} is controversial and the ease of implementation, while true, is a weak argument in the context of language design. Therefore this proposal largely ignore fibers.
     787
     788An example of a language that uses fibers is Go~\cite{Go}
    764789
    765790\subsection{Jobs and thread pools}
    766 The approach on the opposite end of the spectrum is to base parallelism on \glspl{job}. Indeed, \glspl{job} offer limited flexibility but at the benefit of a simpler user interface. In \gls{job} based systems users express parallelism as units of work and the dependency graph (either explicit or implicit) that tie them together. This means users need not to worry about concurrency but significantly limits the interaction that can occur between different jobs. Indeed, any \gls{job} that blocks also blocks the underlying \gls{kthread}, this effectively mean the CPU utilization, and therefore throughput, will suffer noticeably.
    767 The golden standard of this implementation is Intel's TBB library\cite{TBB}.
    768 
    769 \subsection{Fibers : user-level threads without preemption}
    770 Finally, in the middle of the flexibility versus complexity spectrum lay \glspl{fiber} which offer \glspl{uthread} without the complexity of preemption. This means users don't have to worry about other \glspl{fiber} suddenly executing between two instructions which signficantly reduces complexity. However, any call to IO or other concurrency primitives can lead to context switches. Furthermore, users can also block \glspl{fiber} in the middle of their execution without blocking a full processor core. This means users still have to worry about mutual exclusion, deadlocks and race conditions in their code, raising the complexity significantly.
    771 An example of a language that uses fibers is Go\cite{Go}
     791The approach on the opposite end of the spectrum is to base parallelism on \glspl{pool}. Indeed, \glspl{pool} offer limited flexibility but at the benefit of a simpler user interface. In \gls{pool} based systems, users express parallelism as units of work and a dependency graph (either explicit or implicit) that tie them together. This approach means users need not worry about concurrency but significantly limits the interaction that can occur among jobs. Indeed, any \gls{job} that blocks also blocks the underlying worker, which effectively means the CPU utilization, and therefore throughput, suffers noticeably. It can be argued that a solution to this problem is to use more workers than available cores. However, unless the number of jobs and the number of workers are comparable, having a significant amount of blocked jobs always results in idles cores.
     792
     793The gold standard of this implementation is Intel's TBB library~\cite{TBB}.
    772794
    773795\subsection{Paradigm performance}
    774 While the choice between the three paradigms listed above may have significant performance implication, it is difficult to pin the performance implications of chosing a model at the language level. Indeed, in many situations one of these paradigms will show better performance but it all strongly depends on the usage. Having mostly indepent units of work to execute almost guarantess that the \gls{job} based system will have the best performance. However, add interactions between jobs and the processor utilisation might suffer. User-level threads may allow maximum ressource utilisation but context switches will be more expansive and it is also harder for users to get perfect tunning. As with every example, fibers sit somewhat in the middle of the spectrum. Furthermore, if the units of uninterrupted work are large enough the paradigm choice will be largely amorticised by the actual work done.
     796While the choice between the three paradigms listed above may have significant performance implication, it is difficult to pindown the performance implications of chosing a model at the language level. Indeed, in many situations one of these paradigms may show better performance but it all strongly depends on the workload. Having a large amount of mostly independent units of work to execute almost guarantess that the \gls{pool} based system has the best performance thanks to the lower memory overhead. However, interactions between jobs can easily exacerbate contention. User-level threads allow fine-grain context switching, which results in better resource utilisation, but context switches will be more expansive and the extra control means users need to tweak more variables to get the desired performance. Furthermore, if the units of uninterrupted work are large enough the paradigm choice is largely amorticised by the actual work done.
    775797
    776798%  #####  #######    #          ####### ######  ######
     
    783805
    784806\section{\CFA 's Thread Building Blocks}
    785 As a system level language, \CFA should offer both performance and flexibilty as its primary goals, simplicity and user-friendliness being a secondary concern. Therefore, the core of parallelism in \CFA should prioritize power and efficiency. With this said, it is possible to deconstruct the three paradigms details aboved in order to get simple building blocks. Here is a table showing the core caracteristics of the mentionned paradigms :
    786 \begin{center}
    787 \begin{tabular}[t]{| r | c | c |}
    788 \cline{2-3}
    789 \multicolumn{1}{ c| }{} & Has a stack & Preemptive \\
    790 \hline
    791 \Glspl{job} & X & X \\
    792 \hline
    793 \Glspl{fiber} & \checkmark & X \\
    794 \hline
    795 \Glspl{uthread} & \checkmark & \checkmark \\
    796 \hline
    797 \end{tabular}
    798 \end{center}
    799 
    800 As shown in section \ref{cfaparadigms} these different blocks being available in \CFA it is trivial to reproduce any of these paradigm.
     807As a system-level language, \CFA should offer both performance and flexibilty as its primary goals, simplicity and user-friendliness being a secondary concern. Therefore, the core of parallelism in \CFA should prioritize power and efficiency. With this said, deconstructing popular paradigms in order to get simple building blocks yields \glspl{uthread} as the core parallelism block. \Glspl{pool} and other parallelism paradigms can then be built on top of the underlying threading model.
    801808
    802809% ####### #     # ######  #######    #    ######   #####
     
    809816
    810817\subsection{Thread Interface}
    811 The basic building blocks of \CFA are \glspl{cfathread}. By default these are implemented as \glspl{uthread} and as such offer a flexible and lightweight threading interface (lightweight comparatievely to \glspl{kthread}). A thread can be declared using a struct declaration prefix with the \code{thread} as follows :
     818The basic building blocks of \CFA are \glspl{cfathread}. By default these are implemented as \glspl{uthread}, and as such, offer a flexible and lightweight threading interface (lightweight compared to \glspl{kthread}). A thread can be declared using a struct declaration with prefix \code{thread} as follows :
    812819
    813820\begin{lstlisting}
     
    815822\end{lstlisting}
    816823
    817 Obviously, for this thread implementation to be usefull it must run some user code. Several other threading interfaces use some function pointer representation as the interface of threads (for example : \Csharp \cite{Csharp} and Scala \cite{Scala}). However, we consider that statically tying a \code{main} routine to a thread superseeds this approach. Since the \code{main} routine is definetely a special routine in \CFA, we can reuse the existing syntax for declaring routines with unordinary name, i.e. operator overloading. As such the \code{main} routine of a thread can be defined as such :
     824Obviously, for this thread implementation to be usefull it must run some user code. Several other threading interfaces use a function-pointer representation as the interface of threads (for example : \Csharp~\cite{Csharp} and Scala~\cite{Scala}). However, this proposal considers that statically tying a \code{main} routine to a thread superseeds this approach. Since the \code{main} routine is already a special routine in \CFA (where the program begins), the existing syntax for declaring routines names with special semantics can be extended, i.e. operator overloading. As such the \code{main} routine of a thread can be defined as :
    818825\begin{lstlisting}
    819826        thread struct foo {};
    820827
    821         void ?main(thread foo* this) {
    822                 /*... Some useful code ...*/
    823         }
    824 \end{lstlisting}
    825 
    826 With these semantics it is trivial to write a thread type that takes a function pointer as parameter and executes it on its stack asynchronously :
     828        void ?main(foo* this) {
     829                sout | "Hello World!" | endl;
     830        }
     831\end{lstlisting}
     832
     833In this example, threads of type \code{foo} will start there execution in the \code{void ?main(foo*)} routine which in this case prints \code{"Hello World!"}. While this proposoal encourages this approach which is enforces strongly type programming. Users may prefer to use the routine based thread semantics for the sake of simplicity. With these semantics it is trivial to write a thread type that takes a function pointer as parameter and executes it on its stack asynchronously :
    827834\begin{lstlisting}
    828835        typedef void (*voidFunc)(void);
     
    833840
    834841        //ctor
    835         void ?{}(thread FuncRunner* this, voidFunc inFunc) {
     842        void ?{}(FuncRunner* this, voidFunc inFunc) {
    836843                func = inFunc;
    837844        }
    838845
    839846        //main
    840         void ?main(thread FuncRunner* this) {
     847        void ?main(FuncRunner* this) {
    841848                this->func();
    842849        }
    843850\end{lstlisting}
    844851
    845 % In this example \code{func} is a function pointer stored in \acrfull{tls}, which is \CFA is both easy to use and completly typesafe.
    846 
    847 Of course for threads to be useful, it must be possible to start and stop threads and wait for them to complete execution. While using an \acrshort{api} such as \code{fork} and \code{join} is relatively common in the literature, such an interface is not needed. Indeed, the simplest approach is to use \acrshort{raii} principles and have threads \code{fork} once the constructor has completed and \code{join} before the destructor runs.
    848 \begin{lstlisting}
    849 thread struct FuncRunner; //FuncRunner declared above
    850 
    851 void world() {
     852Of course for threads to be useful, it must be possible to start and stop threads and wait for them to complete execution. While using an \acrshort{api} such as \code{fork} and \code{join} is relatively common in the literature, such an interface is unnecessary. Indeed, the simplest approach is to use \acrshort{raii} principles and have threads \code{fork} once the constructor has completed and \code{join} before the destructor runs.
     853\begin{lstlisting}
     854thread struct World; //FuncRunner declared above
     855
     856void ?main(thread World* this) {
    852857        sout | "World!" | endl;
    853858}
    854859
    855860void main() {
    856         FuncRunner run = {world};
     861        World w;
    857862        //Thread run forks here
    858863
     
    863868}
    864869\end{lstlisting}
    865 This semantic has several advantages over explicit semantics : typesafety is guaranteed, any thread will always be started and stopped exaclty once and users can't make any progamming errors. Furthermore it naturally follows the memory allocation semantics which means users don't need to learn multiple semantics.
    866 
    867 These semantics also naturally scale to multiple threads meaning basic synchronisation is very simple :
     870This semantic has several advantages over explicit semantics : typesafety is guaranteed, a thread is always started and stopped exaclty once and users cannot make any progamming errors. However, one of the apparent drawbacks of this system is that threads now always form a lattice, that is they are always destroyed in opposite order of construction. While this seems like a significant limitation, existing \CFA semantics can solve this problem. Indeed, by using dynamic allocation to create threads will naturally let threads outlive the scope in which the thread was created much like dynamically allocating memory will let objects outlive the scope in which thy were created :
     871
    868872\begin{lstlisting}
    869873        thread struct MyThread {
     
    872876
    873877        //ctor
    874         void ?{}(thread MyThread* this) {}
     878        void ?{}(MyThread* this,
     879                     bool is_special = false) {
     880                //...
     881        }
    875882
    876883        //main
    877         void ?main(thread MyThread* this) {
     884        void ?main(MyThread* this) {
     885                //...
     886        }
     887
     888        void foo() {
     889                MyThread* special_thread;
     890                {
     891                        MyThread thrds = {false};
     892                        //Start a thread at the beginning of the scope
     893
     894                        DoStuff();
     895
     896                        //create a other thread that will outlive the thread in this scope
     897                        special_thread = new MyThread{true};
     898
     899                        //Wait for the thread to finish
     900                }
     901                DoMoreStuff();
     902
     903                //Now wait for the special
     904        }
     905\end{lstlisting}
     906
     907Another advantage of this semantic is that it naturally scale to multiple threads meaning basic synchronisation is very simple :
     908
     909\begin{lstlisting}
     910        thread struct MyThread {
     911                //...
     912        };
     913
     914        //ctor
     915        void ?{}(MyThread* this) {}
     916
     917        //main
     918        void ?main(MyThread* this) {
    878919                //...
    879920        }
     
    889930\end{lstlisting}
    890931
     932\subsection{Coroutines : A stepping stone}\label{coroutine}
     933While the main focus of this proposal is concurrency and paralellism, it is important to adress coroutines which are actually a significant underlying aspect of the concurrency system. Indeed, while having nothing todo with parallelism and arguably very little to do with concurrency, coroutines need to deal with context-switchs and and other context management operations. Therefore, this proposal includes coroutines both as an intermediate step for the implementation of threads and a first class feature of \CFA.
     934
     935The core API of coroutines revolve around two features : independent stacks and suspedn/resume. Much like threads the syntax for declaring a coroutine is declaring a type and a main routine for it to start :
     936\begin{lstlisting}
     937        coroutine struct MyCoroutine {
     938                //...
     939        };
     940
     941        //ctor
     942        void ?{}(MyCoroutine* this) {
     943
     944        }
     945
     946        //main
     947        void ?main(MyCoroutine* this) {
     948                sout | "Hello World!" | endl;
     949        }
     950\end{lstlisting}
     951
     952One a coroutine is created, users can context switch to it using \code{suspend} and come back using \code{resume}. Here is an example of a solution to the fibonnaci problem using coroutines :
     953\begin{lstlisting}
     954        coroutine struct Fibonacci {
     955                int fn; // used for communication
     956        };
     957
     958        void ?main(Fibonacci* this) {
     959                int fn1, fn2;           // retained between resumes
     960                this->fn = 0;
     961                fn1 = this->fn;
     962                suspend(this);          // return to last resume
     963
     964                this->fn = 1;
     965                fn2 = fn1;
     966                fn1 = this->fn;
     967                suspend(this);          // return to last resume
     968
     969                for ( ;; ) {
     970                        this->fn = fn1 + fn2;
     971                        fn2 = fn1;
     972                        fn1 = this->fn;
     973                        suspend(this);  // return to last resume
     974                }
     975        }
     976
     977        int next(Fibonacci& this) {
     978                resume(&this); // transfer to last suspend
     979                return this.fn;
     980        }
     981
     982        void main() {
     983                Fibonacci f1, f2;
     984                for ( int i = 1; i <= 10; i += 1 ) {
     985                        sout | next(f1) | '§\verb+ +§' | next(f2) | endl;
     986                }
     987        }
     988\end{lstlisting}
     989
    891990\newpage
    892 \large{\textbf{WORK IN PROGRESS}}
     991\bf{WORK IN PROGRESS}
    893992\subsection{The \CFA Kernel : Processors, Clusters and Threads}\label{kernel}
    894993
  • doc/proposals/concurrency/glossary.tex

    r3a2128f r1f44196  
    11\makeglossaries
     2
     3\longnewglossaryentry{callsite-locking}
     4{name={callsite-locking}}
     5{
     6Locking done by the calling routine. With this technique, a routine calling a monitor routine will aquire the monitor \emph{before} making the call to the actuall routine.
     7}
     8
     9\longnewglossaryentry{entry-point-locking}
     10{name={entry-point-locking}}
     11{
     12Locking done by the called routine. With this technique, a monitor routine called by another routine will aquire the monitor \emph{after} entering the routine body but prior to any other code.
     13}
     14
     15\longnewglossaryentry{group-acquire}
     16{name={bulked acquiring}}
     17{
     18Implicitly acquiring several monitors when entering a monitor.
     19}
     20
     21
    222\longnewglossaryentry{uthread}
    323{name={user-level thread}}
     
    3050
    3151\textit{Synonyms : Tasks.}
     52}
     53
     54\longnewglossaryentry{pool}
     55{name={thread-pool}}
     56{
     57Group of homogeneuous threads that loop executing units of works after another.
     58
     59\textit{Synonyms : }
    3260}
    3361
  • doc/proposals/concurrency/version

    r3a2128f r1f44196  
    1 0.4.99
     10.7.48
  • doc/working/resolver_design.md

    r3a2128f r1f44196  
    13821382hypothesis needs to be empirically validated.
    13831383
     1384Another approach would be to abandon expression-tree ordering for
     1385subexpression matching, and order by "most constrained symbol"; symbols would 
     1386be more constrained if there were fewer matching declarations, fewer
     1387subexpressions yet to resolve, or possibly fewer possible types the expression
     1388could resolve to. Ordering the expressions in a priority-queue by this metric
     1389would not necessarily produce a top-down or a bottom-up order, but would add
     1390opportunities for pruning based on memoized upper and lower bounds.
     1391
    13841392Both Baker and Cormack explicitly generate all possible interpretations of a
    13851393given expression; thinking of the set of interpretations of an expression as a
  • src/CodeGen/CodeGenerator.cc

    r3a2128f r1f44196  
    307307                                                } else {
    308308                                                        // no address-of operator, so must be a pointer - add dereference
     309                                                        // NOTE: if the assertion starts to trigger, check that the application expr isn't being shared.
     310                                                        // Since its arguments are modified here, this assertion most commonly triggers when the application
     311                                                        // is visited multiple times.
    309312                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    310313                                                        newExpr->get_args().push_back( *arg );
    311                                                         assert( (*arg)->get_results().size() == 1 );
    312                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
    313                                                         assert( type );
    314                                                         newExpr->get_results().push_back( type->clone() );
     314                                                        Type * type = InitTweak::getPointerBase( (*arg)->get_result() );
     315                                                        assertf( type, "First argument to a derefence must be a pointer. Ensure that expressions are not being shared." );
     316                                                        newExpr->set_result( type->clone() );
    315317                                                        *arg = newExpr;
    316318                                                } // if
     
    527529                extension( castExpr );
    528530                output << "(";
    529                 if ( castExpr->get_results().empty() ) {
     531                if ( castExpr->get_result()->isVoid() ) {
    530532                        output << "(void)" ;
    531                 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
     533                } else if ( ! castExpr->get_result()->get_isLvalue() ) {
    532534                        // at least one result type of cast, but not an lvalue
    533535                        output << "(";
    534                         output << genType( castExpr->get_results().front(), "" );
     536                        output << genType( castExpr->get_result(), "" );
    535537                        output << ")";
    536538                } else {
     
    640642        }
    641643
    642         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
     644        void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
    643645
    644646        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    654656                asmExpr->get_operand()->accept( *this );
    655657                output << " )";
     658        }
     659
     660        void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
     661                assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
     662                output << "(" << genType( compLitExpr->get_type(), "" ) << ")";
     663                compLitExpr->get_initializer()->accept( *this );
     664        }
     665
     666        void CodeGenerator::visit( StmtExpr * stmtExpr ) {
     667                std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     668                output << "({" << std::endl;
     669                cur_indent += CodeGenerator::tabsize;
     670                unsigned int numStmts = stmts.size();
     671                unsigned int i = 0;
     672                for ( Statement * stmt : stmts ) {
     673                        output << indent << printLabels( stmt->get_labels() );
     674                        if ( i+1 == numStmts ) {
     675                                // last statement in a statement expression needs to be handled specially -
     676                                // cannot cast to void, otherwise the expression statement has no value
     677                                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
     678                                        exprStmt->get_expr()->accept( *this );
     679                                        output << ";" << endl;
     680                                        ++i;
     681                                        break;
     682                                }
     683                        }
     684                        stmt->accept( *this );
     685                        output << endl;
     686                        if ( wantSpacing( stmt ) ) {
     687                                output << endl;
     688                        } // if
     689                        ++i;
     690                }
     691                cur_indent -= CodeGenerator::tabsize;
     692                output << indent << "})";
    656693        }
    657694
  • src/CodeGen/CodeGenerator.h

    r3a2128f r1f44196  
    7070                virtual void visit( ConditionalExpr *conditionalExpr );
    7171                virtual void visit( CommaExpr *commaExpr );
     72                virtual void visit( CompoundLiteralExpr *compLitExpr );
    7273                virtual void visit( TupleExpr *tupleExpr );
    7374                virtual void visit( TypeExpr *typeExpr );
    7475                virtual void visit( AsmExpr * );
     76                virtual void visit( StmtExpr * );
    7577
    7678                //*** Statements
  • src/CodeGen/GenType.cc

    r3a2128f r1f44196  
    227227                        typeString = "_Atomic " + typeString;
    228228                } // if
    229                 if ( type->get_isAttribute() ) {
    230                         typeString = "__attribute(( )) " + typeString;
    231                 } // if
    232229        }
    233230} // namespace CodeGen
  • src/Common/utility.h

    r3a2128f r1f44196  
    148148}
    149149
     150// replace element of list with all elements of another list
    150151template< typename T >
    151152void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
     
    158159
    159160        return;
     161}
     162
     163// replace range of a list with a single element
     164template< typename T >
     165void replace( std::list< T > &org, typename std::list< T >::iterator begin, typename std::list< T >::iterator end, const T & with ) {
     166        org.insert( begin, with );
     167        org.erase( begin, end );
    160168}
    161169
  • src/ControlStruct/Mutate.cc

    r3a2128f r1f44196  
    2323#include "MLEMutator.h"
    2424#include "ForExprMutator.h"
    25 #include "LabelTypeChecker.h"
    2625//#include "ExceptMutator.h"
    2726
     
    4140
    4241                //ExceptMutator exc;
    43                 // LabelTypeChecker lbl;
    4442
    4543                mutateAll( translationUnit, formut );
    4644                acceptAll( translationUnit, lfix );
    4745                //mutateAll( translationUnit, exc );
    48                 //acceptAll( translationUnit, lbl );
    4946        }
    5047} // namespace CodeGen
  • src/ControlStruct/module.mk

    r3a2128f r1f44196  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    1919        ControlStruct/MLEMutator.cc \
    2020        ControlStruct/Mutate.cc \
    21         ControlStruct/ForExprMutator.cc \
    22         ControlStruct/LabelTypeChecker.cc
     21        ControlStruct/ForExprMutator.cc
    2322
  • src/GenPoly/Box.cc

    r3a2128f r1f44196  
    113113                        void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars );
    114114                        /// Stores assignment operators from assertion list in local map of assignment operations
    115                         void findTypeOps( const std::list< TypeDecl *> &forall );
     115                        void findTypeOps( const Type::ForallList &forall );
    116116                        void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars );
    117117                        FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars );
     
    619619                }
    620620
    621                 void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) {
     621                void Pass1::findTypeOps( const Type::ForallList &forall ) {
    622622                        // what if a nested function uses an assignment operator?
    623623                        // assignOps.clear();
    624                         for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     624                        for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    625625                                for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    626626                                        std::string typeName;
     
    687687                                std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    688688                                std::list< FunctionType *> functions;
    689                                 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     689                                for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    690690                                        for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    691691                                                findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter );
     
    789789
    790790                        // add size/align for generic types to parameter list
    791                         if ( appExpr->get_function()->get_results().empty() ) return;
    792                         FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
     791                        if ( ! appExpr->get_function()->has_result() ) return;
     792                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() );
    793793                        assert( funcType );
    794794
     
    806806                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    807807                                VariableExpr *fnArgBase = getBaseVar( *fnArg );
    808                                 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;
    809                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes );
     808                                if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results
     809                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );
    810810                        }
    811811                }
     
    897897                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    898898                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    899                         appExpr->set_function( new NameExpr( adapterName ) );
     899                        appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr
    900900
    901901                        return ret;
     
    903903
    904904                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    905                         assert( ! arg->get_results().empty() );
     905                        assert( arg->has_result() );
    906906                        if ( isPolyType( param, exprTyVars ) ) {
    907                                 if ( isPolyType( arg->get_results().front() ) ) {
     907                                if ( isPolyType( arg->get_result() ) ) {
    908908                                        // if the argument's type is polymorphic, we don't need to box again!
    909909                                        return;
    910                                 } else if ( arg->get_results().front()->get_isLvalue() ) {
     910                                } else if ( arg->get_result()->get_isLvalue() ) {
    911911                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
    912912                                        // xxx - need to test that this code is still reachable
     
    953953                void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    954954                        std::list< Expression *>::iterator cur = arg;
    955                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     955                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    956956                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    957957                                        InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() );
     
    994994                                        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    995995                                        deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
    996                                         deref->get_results().push_back( arg->get_type()->clone() );
     996                                        deref->set_result( arg->get_type()->clone() );
    997997                                        return deref;
    998998                                } // if
     
    10201020                        Statement *bodyStmt;
    10211021
    1022                         std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();
    1023                         std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();
    1024                         std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin();
     1022                        Type::ForallList::iterator tyArg = realType->get_forall().begin();
     1023                        Type::ForallList::iterator tyParam = adapterType->get_forall().begin();
     1024                        Type::ForallList::iterator realTyParam = adaptee->get_forall().begin();
    10251025                        for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
    10261026                                assert( tyArg != realType->get_forall().end() );
     
    10711071                        std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
    10721072                        std::list< FunctionType *> functions;
    1073                         for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
     1073                        for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {
    10741074                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    10751075                                        findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter );
     
    11311131                        } // if
    11321132                        addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) );
    1133                         addAssign->get_results().front() = appExpr->get_results().front()->clone();
     1133                        addAssign->set_result( appExpr->get_result()->clone() );
    11341134                        if ( appExpr->get_env() ) {
    11351135                                addAssign->set_env( appExpr->get_env() );
     
    11451145                                if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    11461146                                        if ( varExpr->get_var()->get_name() == "?[?]" ) {
    1147                                                 assert( ! appExpr->get_results().empty() );
     1147                                                assert( appExpr->has_result() );
    11481148                                                assert( appExpr->get_args().size() == 2 );
    1149                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
    1150                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
     1149                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1150                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    11511151                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    11521152                                                UntypedExpr *ret = 0;
     
    11681168                                                } // if
    11691169                                                if ( baseType1 || baseType2 ) {
    1170                                                         ret->get_results().push_front( appExpr->get_results().front()->clone() );
     1170                                                        ret->set_result( appExpr->get_result()->clone() );
    11711171                                                        if ( appExpr->get_env() ) {
    11721172                                                                ret->set_env( appExpr->get_env() );
     
    11781178                                                } // if
    11791179                                        } else if ( varExpr->get_var()->get_name() == "*?" ) {
    1180                                                 assert( ! appExpr->get_results().empty() );
     1180                                                assert( appExpr->has_result() );
    11811181                                                assert( ! appExpr->get_args().empty() );
    1182                                                 if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1182                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
    11831183                                                        Expression *ret = appExpr->get_args().front();
    1184                                                         delete ret->get_results().front();
    1185                                                         ret->get_results().front() = appExpr->get_results().front()->clone();
     1184                                                        delete ret->get_result();
     1185                                                        ret->set_result( appExpr->get_result()->clone() );
    11861186                                                        if ( appExpr->get_env() ) {
    11871187                                                                ret->set_env( appExpr->get_env() );
     
    11931193                                                } // if
    11941194                                        } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) {
    1195                                                 assert( ! appExpr->get_results().empty() );
     1195                                                assert( appExpr->has_result() );
    11961196                                                assert( appExpr->get_args().size() == 1 );
    1197                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
    1198                                                         Type *tempType = appExpr->get_results().front()->clone();
     1197                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
     1198                                                        Type *tempType = appExpr->get_result()->clone();
    11991199                                                        if ( env ) {
    12001200                                                                env->apply( tempType );
     
    12131213                                                } // if
    12141214                                        } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) {
    1215                                                 assert( ! appExpr->get_results().empty() );
     1215                                                assert( appExpr->has_result() );
    12161216                                                assert( appExpr->get_args().size() == 1 );
    1217                                                 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) {
     1217                                                if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) {
    12181218                                                        return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" );
    12191219                                                } // if
    12201220                                        } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) {
    1221                                                 assert( ! appExpr->get_results().empty() );
     1221                                                assert( appExpr->has_result() );
    12221222                                                assert( appExpr->get_args().size() == 2 );
    1223                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
    1224                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
     1223                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
     1224                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
    12251225                                                if ( baseType1 && baseType2 ) {
    12261226                                                        UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) );
    12271227                                                        divide->get_args().push_back( appExpr );
    12281228                                                        divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) );
    1229                                                         divide->get_results().push_front( appExpr->get_results().front()->clone() );
     1229                                                        divide->set_result( appExpr->get_result()->clone() );
    12301230                                                        if ( appExpr->get_env() ) {
    12311231                                                                divide->set_env( appExpr->get_env() );
     
    12451245                                                } // if
    12461246                                        } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) {
    1247                                                 assert( ! appExpr->get_results().empty() );
     1247                                                assert( appExpr->has_result() );
    12481248                                                assert( appExpr->get_args().size() == 2 );
    1249                                                 Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env );
     1249                                                Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env );
    12501250                                                if ( baseType ) {
    12511251                                                        UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) );
     
    12731273                        useRetval = oldUseRetval;
    12741274
    1275                         assert( ! appExpr->get_function()->get_results().empty() );
    1276                         PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
    1277                         assert( pointer );
    1278                         FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
    1279                         assert( function );
     1275                        assert( appExpr->get_function()->has_result() );
     1276                        PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1277                        FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    12801278
    12811279                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    13151313
    13161314                Expression *Pass1::mutate( UntypedExpr *expr ) {
    1317                         if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1315                        if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13181316                                if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13191317                                        if ( name->get_name() == "*?" ) {
     
    13291327
    13301328                Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    1331                         assert( ! addrExpr->get_arg()->get_results().empty() );
     1329                        assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );
    13321330
    13331331                        bool needs = false;
    13341332                        if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) {
    1335                                 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {
     1333                                if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {
    13361334                                        if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) {
    13371335                                                if ( name->get_name() == "*?" ) {
    13381336                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    1339                                                                 assert( ! appExpr->get_function()->get_results().empty() );
    1340                                                                 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
    1341                                                                 assert( pointer );
    1342                                                                 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
    1343                                                                 assert( function );
     1337                                                                assert( appExpr->get_function()->has_result() );
     1338                                                                PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
     1339                                                                FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
    13441340                                                                needs = needsAdapter( function, scopeTyVars );
    13451341                                                        } // if
     
    13501346                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
    13511347                        // out of the if condition.
    1352                         bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
     1348                        bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env );
    13531349                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    13541350                        if ( polytype || needs ) {
    13551351                                Expression *ret = addrExpr->get_arg();
    1356                                 delete ret->get_results().front();
    1357                                 ret->get_results().front() = addrExpr->get_results().front()->clone();
     1352                                delete ret->get_result();
     1353                                ret->set_result( addrExpr->get_result()->clone() );
    13581354                                addrExpr->set_arg( 0 );
    13591355                                delete addrExpr;
     
    13931389                Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
    13941390                        if ( retval && returnStmt->get_expr() ) {
    1395                                 assert( ! returnStmt->get_expr()->get_results().empty() );
     1391                                assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
    13961392                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    13971393                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     
    14271423                                        // find each of its needed secondary assignment operators
    14281424                                        std::list< Expression* > &tyParams = refType->get_parameters();
    1429                                         std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall();
     1425                                        Type::ForallList &forallParams = functionDecl->get_type()->get_forall();
    14301426                                        std::list< Expression* >::const_iterator tyIt = tyParams.begin();
    1431                                         std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();
     1427                                        Type::ForallList::const_iterator forallIt = forallParams.begin();
    14321428                                        for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) {
    14331429                                                // Add appropriate mapping to assignment expression environment
     
    14731469                                // replace return statement with appropriate assignment to out parameter
    14741470                                Expression *retParm = new NameExpr( retval->get_name() );
    1475                                 retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
     1471                                retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );
    14761472                                assignExpr->get_args().push_back( retParm );
    14771473                                assignExpr->get_args().push_back( returnStmt->get_expr() );
     
    16031599                        ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0,
    16041600                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1605                         for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1601                        for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    16061602                                ObjectDecl *sizeParm, *alignParm;
    16071603                                // add all size and alignment parameters to parameter list
  • src/GenPoly/CopyParams.cc

    r3a2128f r1f44196  
    5454                                std::map< std::string, DeclarationWithType* > assignOps;
    5555                                // assume the assignment operator is the first assert param after any "type" parameter
    56                                 for ( std::list< TypeDecl* >::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
     56                                for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
    5757                                        if ( (*tyVar)->get_kind() == TypeDecl::Any ) {
    5858                                                assert( !(*tyVar)->get_assertions().empty() );
  • src/GenPoly/FindFunction.cc

    r3a2128f r1f44196  
    2929                virtual Type *mutate( PointerType *pointerType );
    3030          private:
    31                 void handleForall( const std::list< TypeDecl* > &forall );
     31                void handleForall( const Type::ForallList &forall );
    3232
    3333                std::list< FunctionType* > &functions;
     
    5151        }
    5252
    53         void FindFunction::handleForall( const std::list< TypeDecl* > &forall ) {
    54                 for ( std::list< TypeDecl* >::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
     53        void FindFunction::handleForall( const Type::ForallList &forall ) {
     54                for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
    5555                        TyVarMap::iterator var = tyVars.find( (*i)->get_name() );
    5656                        if ( var != tyVars.end() ) {
  • src/GenPoly/GenPoly.cc

    r3a2128f r1f44196  
    110110        ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) {
    111111                if ( function->get_returnVals().empty() ) return 0;
    112                
     112
    113113                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
    114114        }
     
    127127//              } // if
    128128                if ( isDynRet( adaptee, tyVars ) ) return true;
    129                
     129
    130130                for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
    131131//                      if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {
     
    228228
    229229        void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) {
    230                 for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
     230                for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
    231231                        assert( *tyVar );
    232232                        tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
  • src/GenPoly/Lvalue.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Lvalue.cc -- 
     7// Lvalue.cc --
    88//
    99// Author           : Richard C. Bilson
     
    4141                  public:
    4242                        Pass1();
    43  
     43
    4444                        virtual Expression *mutate( ApplicationExpr *appExpr );
    4545                        virtual Statement *mutate( ReturnStmt *appExpr );
     
    5555                  private:
    5656                };
     57
     58                /// GCC-like Generalized Lvalues (which have since been removed from GCC)
     59                /// https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues
     60                /// Replaces &(a,b) with (a, &b), &(a ? b : c) with (a ? &b : &c)
     61                class GeneralizedLvalue : public Mutator {
     62                        typedef Mutator Parent;
     63
     64                        virtual Expression * mutate( AddressExpr * addressExpr );
     65                };
    5766        } // namespace
    5867
     
    6069                Pass1 p1;
    6170                Pass2 p2;
     71                GeneralizedLvalue genLval;
    6272                mutateAll( translationUnit, p1 );
    6373                acceptAll( translationUnit, p2 );
     74                mutateAll( translationUnit, genLval );
    6475        }
    6576
     
    99110                        appExpr->get_function()->acceptMutator( *this );
    100111                        mutateAll( appExpr->get_args(), *this );
    101  
    102                         assert( ! appExpr->get_function()->get_results().empty() );
    103112
    104                         PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    105                         assert( pointer );
    106                         FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    107                         assert( function );
     113                        PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     114                        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    108115
    109116                        Type *funType = isLvalueRet( function );
    110117                        if ( funType && ! isIntrinsicApp( appExpr ) ) {
    111118                                Expression *expr = appExpr;
    112                                 Type *appType = appExpr->get_results().front();
     119                                Type *appType = appExpr->get_result();
    113120                                if ( isPolyType( funType ) && ! isPolyType( appType ) ) {
    114121                                        // make sure cast for polymorphic type is inside dereference
     
    116123                                }
    117124                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    118                                 deref->get_results().push_back( appType->clone() );
    119                                 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
     125                                deref->set_result( appType->clone() );
     126                                appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) );
    120127                                deref->get_args().push_back( expr );
    121128                                return deref;
     
    127134                Statement * Pass1::mutate(ReturnStmt *retStmt) {
    128135                        if ( retval && retStmt->get_expr() ) {
    129                                 assert( ! retStmt->get_expr()->get_results().empty() );
    130                                 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) {
     136                                if ( retStmt->get_expr()->get_result()->get_isLvalue() ) {
    131137                                        // ***** Code Removal ***** because casts may be stripped already
    132138
     
    155161                                retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) );
    156162                        } // if
    157  
     163
    158164                        Visitor::visit( funType );
     165                }
     166
     167                Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) {
     168                        addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) );
     169                        if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( addrExpr->get_arg() ) ) {
     170                                Expression * arg1 = commaExpr->get_arg1()->clone();
     171                                Expression * arg2 = commaExpr->get_arg2()->clone();
     172                                delete addrExpr;
     173                                return new CommaExpr( arg1, new AddressExpr( arg2 ) );
     174                        } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( addrExpr->get_arg() ) ) {
     175                                Expression * arg1 = condExpr->get_arg1()->clone();
     176                                Expression * arg2 = condExpr->get_arg2()->clone();
     177                                Expression * arg3 = condExpr->get_arg3()->clone();
     178                                delete addrExpr;
     179                                return new ConditionalExpr( arg1, new AddressExpr( arg2 ), new AddressExpr( arg3 ) );
     180                        }
     181                        return addrExpr;
    159182                }
    160183        } // namespace
  • src/GenPoly/Specialize.cc

    r3a2128f r1f44196  
    148148
    149149        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    150                 assert( ! actual->get_results().empty() ); // using front, should have this assert
    151                 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
     150                assertf( actual->has_result(), "attempting to specialize an untyped expression" );
     151                if ( needsSpecialization( formalType, actual->get_result(), env ) ) {
    152152                        FunctionType *funType;
    153153                        if ( ( funType = getFunctionType( formalType ) ) ) {
     
    172172        void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) {
    173173                // create thunks for the explicit parameters
    174                 assert( ! appExpr->get_function()->get_results().empty() );
    175                 FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() );
     174                assert( appExpr->get_function()->has_result() );
     175                FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
    176176                assert( function );
    177177                std::list< DeclarationWithType* >::iterator formal;
     
    201201        Expression * Specialize::mutate( AddressExpr *addrExpr ) {
    202202                addrExpr->get_arg()->acceptMutator( *this );
    203                 assert( ! addrExpr->get_results().empty() );
    204                 addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) );
     203                assert( addrExpr->has_result() );
     204                addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) );
    205205                return addrExpr;
    206206        }
     
    208208        Expression * Specialize::mutate( CastExpr *castExpr ) {
    209209                castExpr->get_arg()->acceptMutator( *this );
    210                 if ( castExpr->get_results().empty() ) {
     210                if ( castExpr->get_result()->isVoid() ) {
    211211                        // can't specialize if we don't have a return value
    212212                        return castExpr;
    213213                }
    214                 Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
     214                Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() );
    215215                if ( specialized != castExpr->get_arg() ) {
    216216                        // assume here that the specialization incorporates the cast
  • src/InitTweak/FixInit.cc

    r3a2128f r1f44196  
    1818#include <iterator>
    1919#include <algorithm>
     20#include <unordered_map>
     21#include <unordered_set>
    2022#include "InitTweak.h"
    2123#include "FixInit.h"
     
    3537#include "GenPoly/DeclMutator.h"
    3638#include "SynTree/AddStmtVisitor.h"
    37 #include "CodeGen/GenType.h"  // for warnings
    38 
    39 bool ctordtorp = false;
    40 bool ctorp = false;
    41 bool cpctorp = false;
    42 bool dtorp = false;
     39#include "CodeGen/GenType.h"  // for warning/error messages
     40
     41bool ctordtorp = false; // print all debug
     42bool ctorp = false; // print ctor debug
     43bool cpctorp = false; // print copy ctor debug
     44bool dtorp = false; // print dtor debug
    4345#define PRINT( text ) if ( ctordtorp ) { text }
    4446#define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text }
     
    4749namespace InitTweak {
    4850        namespace {
    49                 const std::list<Label> noLabels;
    50                 const std::list<Expression*> noDesignators;
    51 
    5251                class InsertImplicitCalls final : public GenPoly::PolyMutator {
    5352                public:
     
    6766                        static void resolveImplicitCalls( std::list< Declaration * > & translationUnit );
    6867
    69                         using SymTab::Indexer::visit;
     68                        typedef SymTab::Indexer Parent;
     69                        using Parent::visit;
     70
    7071                        virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override;
     72                        virtual void visit( UniqueExpr * unqExpr );
    7173
    7274                        /// create and resolve ctor/dtor expression: fname(var, [cpArg])
    73                         ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
     75                        Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
     76                        Expression * makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg = NULL );
    7477                        /// true if type does not need to be copy constructed to ensure correctness
    75                         bool skipCopyConstruct( Type * );
     78                        bool skipCopyConstruct( Type * type );
     79                        void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr );
     80                        void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr );
    7681                private:
    7782                        TypeSubstitution * env;
     
    183188                        using GenPoly::PolyMutator::mutate;
    184189                        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override;
     190                        virtual Expression * mutate( UniqueExpr * unqExpr ) override;
    185191                };
    186192
     
    368374                }
    369375
    370                 ApplicationExpr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
     376                Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
    371377                        assert( var );
     378                        return makeCtorDtor( fname, new AddressExpr( new VariableExpr( var ) ), cpArg );
     379                }
     380
     381                Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg ) {
     382                        assert( thisArg );
    372383                        UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) );
    373                         untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ) );
     384                        untyped->get_args().push_back( thisArg );
    374385                        if (cpArg) untyped->get_args().push_back( cpArg->clone() );
    375386
     
    378389                        // (VariableExpr and already resolved expression)
    379390                        CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
    380                         ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
     391                        Expression * resolved = ResolvExpr::findVoidExpression( untyped, *this );
     392                        assert( resolved );
    381393                        if ( resolved->get_env() ) {
    382394                                env->add( *resolved->get_env() );
    383395                        } // if
    384396
    385                         assert( resolved );
    386397                        delete untyped;
    387398                        return resolved;
    388399                }
    389400
     401                void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) {
     402                        static UniqueName tempNamer("_tmp_cp");
     403                        CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
     404                        assert( arg->has_result() );
     405                        Type * result = arg->get_result();
     406                        if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types
     407
     408                        // type may involve type variables, so apply type substitution to get temporary variable's actual type
     409                        result = result->clone();
     410                        impCpCtorExpr->get_env()->apply( result );
     411                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
     412                        tmp->get_type()->set_isConst( false );
     413
     414                        // create and resolve copy constructor
     415                        CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
     416                        Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg );
     417
     418                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) {
     419                                // if the chosen constructor is intrinsic, the copy is unnecessary, so
     420                                // don't create the temporary and don't call the copy constructor
     421                                VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
     422                                assert( function );
     423                                if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return;
     424                        }
     425
     426                        // replace argument to function call with temporary
     427                        arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
     428                        impCpCtorExpr->get_tempDecls().push_back( tmp );
     429                        impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
     430                }
     431
     432                void ResolveCopyCtors::destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ) {
     433                        impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( ret ) ) );
     434                }
     435
    390436                void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    391                         static UniqueName tempNamer("_tmp_cp");
    392                         static UniqueName retNamer("_tmp_cp_ret");
    393 
    394437                        CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
    395                         Visitor::visit( impCpCtorExpr );
     438                        Parent::visit( impCpCtorExpr );
    396439                        env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer...
    397440
     
    400443                        // take each argument and attempt to copy construct it.
    401444                        for ( Expression * & arg : appExpr->get_args() ) {
    402                                 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
    403                                 // xxx - need to handle tuple arguments
    404                                 assert( ! arg->get_results().empty() );
    405                                 Type * result = arg->get_results().front();
    406                                 if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types
    407                                 // type may involve type variables, so apply type substitution to get temporary variable's actual type
    408                                 result = result->clone();
    409                                 impCpCtorExpr->get_env()->apply( result );
    410                                 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    411                                 tmp->get_type()->set_isConst( false );
    412 
    413                                 // create and resolve copy constructor
    414                                 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
    415                                 ApplicationExpr * cpCtor = makeCtorDtor( "?{}", tmp, arg );
    416 
    417                                 // if the chosen constructor is intrinsic, the copy is unnecessary, so
    418                                 // don't create the temporary and don't call the copy constructor
    419                                 VariableExpr * function = dynamic_cast< VariableExpr * >( cpCtor->get_function() );
    420                                 assert( function );
    421                                 if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) {
    422                                         // replace argument to function call with temporary
    423                                         arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
    424                                         impCpCtorExpr->get_tempDecls().push_back( tmp );
    425                                         impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
    426                                 } // if
     445                                copyConstructArg( arg, impCpCtorExpr );
    427446                        } // for
    428447
     
    434453                        // level. Trying to pass that environment along.
    435454                        callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    436                         for ( Type * result : appExpr->get_results() ) {
     455                        Type * result = appExpr->get_result();
     456                        if ( ! result->isVoid() ) {
     457                                static UniqueName retNamer("_tmp_cp_ret");
    437458                                result = result->clone();
    438459                                impCpCtorExpr->get_env()->apply( result );
     
    441462                                impCpCtorExpr->get_returnDecls().push_back( ret );
    442463                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    443                                 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
     464                                if ( ! result->get_isLvalue() ) {
     465                                        // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
     466                                        destructRet( new VariableExpr( ret ), impCpCtorExpr );
     467                                }
    444468                        } // for
    445469                        CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
     470                }
     471
     472                void ResolveCopyCtors::visit( UniqueExpr * unqExpr ) {
     473                        static std::unordered_set< int > vars;
     474                        if ( vars.count( unqExpr->get_id() ) ) {
     475                                // xxx - hack to prevent double-handling of unique exprs, otherwise too many temporary variables and destructors are generated
     476                                return;
     477                        }
     478
     479                        Parent::visit( unqExpr );
     480                        // it should never be necessary to wrap a void-returning expression in a UniqueExpr - if this assumption changes, this needs to be rethought
     481                        assert( unqExpr->get_result() );
     482                        if ( ImplicitCopyCtorExpr * impCpCtorExpr = dynamic_cast<ImplicitCopyCtorExpr*>( unqExpr->get_expr() ) ) {
     483                                // note the variable used as the result from the call
     484                                assert( impCpCtorExpr->get_result() && impCpCtorExpr->get_returnDecls().size() == 1 );
     485                                unqExpr->set_var( new VariableExpr( impCpCtorExpr->get_returnDecls().front() ) );
     486                        } else {
     487                                // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
     488                                unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );
     489                                unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) );
     490                        }
     491                        vars.insert( unqExpr->get_id() );
    446492                }
    447493
     
    490536                                // know the result type of the assignment is the type of the LHS (minus the pointer), so
    491537                                // add that onto the assignment expression so that later steps have the necessary information
    492                                 assign->add_result( returnDecl->get_type()->clone() );
     538                                assign->set_result( returnDecl->get_type()->clone() );
    493539
    494540                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    495                                 if ( callExpr->get_results().front()->get_isLvalue() ) {
     541                                if ( callExpr->get_result()->get_isLvalue() ) {
    496542                                        // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning
    497543                                        // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the
     
    500546                                        // an AddressExpr.  Effectively, this turns
    501547                                        //   lvalue T f();
    502                                         //   &*f()
     548                                        //   &*f();
    503549                                        // into
     550                                        //   T * f();
    504551                                        //   T * tmp_cp_retN;
    505                                         //   tmp_cp_ret_N = &*(tmp_cp_ret_N = &*f(), tmp_cp_ret);
     552                                        //   &*(tmp_cp_retN = &*f(), tmp_cp_retN);              // the first * and second & are generated here
    506553                                        // which work out in terms of types, but is pretty messy. It would be nice to find a better way.
    507554                                        assign->get_args().back() = new AddressExpr( assign->get_args().back() );
    508555
    509                                         Type * resultType = returnDecl->get_type()->clone();
    510556                                        returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) );
    511                                         UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    512                                         deref->get_args().push_back( retExpr );
    513                                         deref->add_result( resultType );
    514                                         retExpr = deref;
     557                                        retExpr->set_result( new PointerType( Type::Qualifiers(), retExpr->get_result() ) );
     558                                        retExpr = UntypedExpr::createDeref( retExpr );
    515559                                } // if
    516560                                retExpr->set_env( env->clone() );
     
    519563                                return callExpr;
    520564                        } // if
     565                }
     566
     567                Expression * FixCopyCtors::mutate( UniqueExpr * unqExpr ) {
     568                        static std::unordered_map< int, UniqueExpr * > unqMap;
     569                        static std::unordered_set< int > addDeref;
     570                        // has to be done to clean up ImplicitCopyCtorExpr nodes, even when this node was skipped in previous passes
     571                        unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) );
     572                        if ( unqMap.count( unqExpr->get_id() ) ) {
     573                                // take data from other UniqueExpr to ensure consistency
     574                                delete unqExpr->get_expr();
     575                                unqExpr->set_expr( unqMap[unqExpr->get_id()]->get_expr()->clone() );
     576                                delete unqExpr->get_result();
     577                                unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) );
     578                                if ( addDeref.count( unqExpr->get_id() ) ) {
     579                                        // other UniqueExpr was dereferenced because it was an lvalue return, so this one should be too
     580                                        return UntypedExpr::createDeref( unqExpr );
     581                                }
     582                                return unqExpr;
     583                        }
     584                        unqMap[unqExpr->get_id()] = unqExpr;
     585                        if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) {
     586                                // unique expression is now a dereference, because the inner expression is an lvalue returning function call.
     587                                // Normalize the expression by dereferencing the unique expression, rather than the inner expression
     588                                // (i.e. move the dereference out a level)
     589                                assert( getFunctionName( deref ) == "*?" );
     590                                unqExpr->set_expr( getCallArg( deref, 0 ) );
     591                                getCallArg( deref, 0 ) = unqExpr;
     592                                addDeref.insert( unqExpr->get_id() );
     593                                return deref;
     594                        }
     595                        return unqExpr;
    521596                }
    522597
     
    9501025                Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) {
    9511026                        static UniqueName tempNamer( "_tmp_ctor_expr" );
    952                         assert( ctorExpr->get_results().size() == 1 );
    953                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr );
     1027                        // xxx - is the size check necessary?
     1028                        assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 );
     1029                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );
    9541030                        addDeclaration( tmp );
    9551031
     
    9631039                        assign->get_args().push_back( new VariableExpr( tmp ) );
    9641040                        assign->get_args().push_back( firstArg );
    965                         cloneAll( ctorExpr->get_results(), assign->get_results() );
     1041                        assign->set_result( ctorExpr->get_result()->clone() );
    9661042                        firstArg = assign;
    9671043
  • src/InitTweak/GenInit.cc

    r3a2128f r1f44196  
    2929#include "GenPoly/DeclMutator.h"
    3030#include "GenPoly/ScopedSet.h"
     31#include "ResolvExpr/typeops.h"
    3132
    3233namespace InitTweak {
     
    5051
    5152          protected:
    52                 std::list<DeclarationWithType*> returnVals;
     53                FunctionType * ftype;
    5354                UniqueName tempNamer;
    5455                std::string funcName;
     
    8687
    8788                bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
     89                bool isManaged( Type * type ) const; // determine if type is managed
    8890                void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
    8991                GenPoly::ScopedSet< std::string > managedTypes;
     
    136138
    137139        Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
    138                 // update for multiple return values
     140                std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
    139141                assert( returnVals.size() == 0 || returnVals.size() == 1 );
    140142                // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
     
    158160
    159161        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    160                 ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals );
     162                // xxx - need to handle named return values - this pass may need to happen
     163                // after resolution? the ordering is tricky because return statements must be
     164                // constructed - the simplest way to do that (while also handling multiple
     165                // returns) is to structure the returnVals into a tuple, as done here.
     166                // however, if the tuple return value is structured before resolution,
     167                // it's difficult to resolve named return values, since the name is lost
     168                // in conversion to a tuple. this might be easiest to deal with
     169                // after reference types are added, as it may then be possible to
     170                // uniformly move named return values to the parameter list directly
     171                ValueGuard< FunctionType * > oldFtype( ftype );
    161172                ValueGuard< std::string > oldFuncName( funcName );
    162173
    163                 FunctionType * type = functionDecl->get_functionType();
    164                 returnVals = type->get_returnVals();
     174                ftype = functionDecl->get_functionType();
     175                std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();
     176                if ( retVals.size() > 1 ) {
     177                        TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) );
     178                        ObjectDecl * newRet = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
     179                        retVals.clear();
     180                        retVals.push_back( newRet );
     181                }
    165182                funcName = functionDecl->get_name();
    166183                DeclarationWithType * decl = Mutator::mutate( functionDecl );
     
    222239        }
    223240
     241        bool CtorDtor::isManaged( Type * type ) const {
     242                if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) {
     243                        // tuple is also managed if any of its components are managed
     244                        if ( std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); }) ) {
     245                                return true;
     246                        }
     247                }
     248                return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
     249        }
     250
    224251        bool CtorDtor::isManaged( ObjectDecl * objDecl ) const {
    225252                Type * type = objDecl->get_type();
     
    227254                        type = at->get_base();
    228255                }
    229                 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
     256                return isManaged( type );
    230257        }
    231258
     
    238265                        managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) );
    239266                }
     267        }
     268
     269        ConstructorInit * genCtorInit( ObjectDecl * objDecl ) {
     270                // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
     271                // for each constructable object
     272                std::list< Statement * > ctor;
     273                std::list< Statement * > dtor;
     274
     275                InitExpander srcParam( objDecl->get_init() );
     276                InitExpander nullParam( (Initializer *)NULL );
     277                SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl );
     278                SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false );
     279
     280                // Currently genImplicitCall produces a single Statement - a CompoundStmt
     281                // which  wraps everything that needs to happen. As such, it's technically
     282                // possible to use a Statement ** in the above calls, but this is inherently
     283                // unsafe, so instead we take the slightly less efficient route, but will be
     284                // immediately informed if somehow the above assumption is broken. In this case,
     285                // we could always wrap the list of statements at this point with a CompoundStmt,
     286                // but it seems reasonable at the moment for this to be done by genImplicitCall
     287                // itself. It is possible that genImplicitCall produces no statements (e.g. if
     288                // an array type does not have a dimension). In this case, it's fine to ignore
     289                // the object for the purposes of construction.
     290                assert( ctor.size() == dtor.size() && ctor.size() <= 1 );
     291                if ( ctor.size() == 1 ) {
     292                        // need to remember init expression, in case no ctors exist
     293                        // if ctor does exist, want to use ctor expression instead of init
     294                        // push this decision to the resolver
     295                        assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) );
     296                        return new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() );
     297                }
     298                return nullptr;
    240299        }
    241300
     
    250309                        if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl );
    251310
    252                         // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
    253                         // for each constructable object
    254                         std::list< Statement * > ctor;
    255                         std::list< Statement * > dtor;
    256 
    257                         InitExpander srcParam( objDecl->get_init() );
    258                         InitExpander nullParam( (Initializer *)NULL );
    259                         SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl );
    260                         SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false );
    261 
    262                         // Currently genImplicitCall produces a single Statement - a CompoundStmt
    263                         // which  wraps everything that needs to happen. As such, it's technically
    264                         // possible to use a Statement ** in the above calls, but this is inherently
    265                         // unsafe, so instead we take the slightly less efficient route, but will be
    266                         // immediately informed if somehow the above assumption is broken. In this case,
    267                         // we could always wrap the list of statements at this point with a CompoundStmt,
    268                         // but it seems reasonable at the moment for this to be done by genImplicitCall
    269                         // itself. It is possible that genImplicitCall produces no statements (e.g. if
    270                         // an array type does not have a dimension). In this case, it's fine to ignore
    271                         // the object for the purposes of construction.
    272                         assert( ctor.size() == dtor.size() && ctor.size() <= 1 );
    273                         if ( ctor.size() == 1 ) {
    274                                 // need to remember init expression, in case no ctors exist
    275                                 // if ctor does exist, want to use ctor expression instead of init
    276                                 // push this decision to the resolver
    277                                 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) );
    278                                 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) );
    279                         }
     311                        objDecl->set_init( genCtorInit( objDecl ) );
    280312                }
    281313                return Parent::mutate( objDecl );
     
    290322                managedTypes.beginScope();
    291323                // go through assertions and recursively add seen ctor/dtors
    292                 for ( TypeDecl * tyDecl : functionDecl->get_functionType()->get_forall() ) {
     324                for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) {
    293325                        for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
    294326                                assertion = assertion->acceptMutator( *this );
  • src/InitTweak/GenInit.h

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // RemoveInit.h --
     7// GenInit.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2727        /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
    2828        void genInit( std::list< Declaration * > & translationUnit );
     29
     30        /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer
     31        ConstructorInit * genCtorInit( ObjectDecl * objDecl );
    2932} // namespace
    3033
  • src/InitTweak/InitTweak.cc

    r3a2128f r1f44196  
    340340                return allofCtorDtor( stmt, []( Expression * callExpr ){
    341341                        if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
    342                                 assert( ! appExpr->get_function()->get_results().empty() );
    343                                 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() );
     342                                FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() );
    344343                                assert( funcType );
    345344                                return funcType->get_parameters().size() == 1;
     
    388387                                return memberExpr->get_member()->get_name();
    389388                        } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) {
    390                                 return memberExpr->get_member();
     389                                return funcName( memberExpr->get_member() );
    391390                        } else {
    392391                                assertf( false, "Unexpected expression type being called as a function in call expression" );
     
    451450                // virtual void visit( LogicalExpr *logicalExpr );
    452451                // virtual void visit( ConditionalExpr *conditionalExpr );
    453                 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
    454                 virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; }
    455452                virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }
    456453                virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }
    457454                virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }
    458455                virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
     456                virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
     457                virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
    459458
    460459                bool isConstExpr;
  • src/Makefile.in

    r3a2128f r1f44196  
    105105        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    106106        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
    107         ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \
    108107        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    109108        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    190189        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    191190        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
     191        SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) \
    192192        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    193         Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
     193        Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \
     194        Tuples/driver_cfa_cpp-Explode.$(OBJEXT)
    194195am_driver_cfa_cpp_OBJECTS = $(am__objects_1)
    195196driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS)
     
    364365        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    365366        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    366         ControlStruct/ForExprMutator.cc \
    367         ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \
     367        ControlStruct/ForExprMutator.cc GenPoly/Box.cc \
    368368        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    369369        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
     
    404404        SynTree/Initializer.cc SynTree/Visitor.cc SynTree/Mutator.cc \
    405405        SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \
    406         SynTree/Attribute.cc Tuples/TupleAssignment.cc \
    407         Tuples/NameMatcher.cc
     406        SynTree/Attribute.cc SynTree/VarExprReplacer.cc \
     407        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
     408        Tuples/Explode.cc
    408409MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    409410        ${cfa_cpplib_PROGRAMS}}
     
    541542        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    542543ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT):  \
    543         ControlStruct/$(am__dirstamp) \
    544         ControlStruct/$(DEPDIR)/$(am__dirstamp)
    545 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT):  \
    546544        ControlStruct/$(am__dirstamp) \
    547545        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     
    769767SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \
    770768        SynTree/$(DEPDIR)/$(am__dirstamp)
     769SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT):  \
     770        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    771771Tuples/$(am__dirstamp):
    772772        @$(MKDIR_P) Tuples
     
    777777Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT):  \
    778778        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    779 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \
     779Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT):  \
     780        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
     781Tuples/driver_cfa_cpp-Explode.$(OBJEXT): Tuples/$(am__dirstamp) \
    780782        Tuples/$(DEPDIR)/$(am__dirstamp)
    781783driver/$(am__dirstamp):
     
    800802        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
    801803        -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT)
    802         -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)
    803804        -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT)
    804805        -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT)
     
    884885        -rm -f SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT)
    885886        -rm -f SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT)
     887        -rm -f SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT)
    886888        -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT)
    887889        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
    888890        -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT)
    889         -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
     891        -rm -f Tuples/driver_cfa_cpp-Explode.$(OBJEXT)
    890892        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
     893        -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT)
    891894
    892895distclean-compile:
     
    907910@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
    908911@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@
    909 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@
    910912@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@
    911913@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
     
    991993@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@
    992994@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@
     995@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po@am__quote@
    993996@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@
    994997@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    995998@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
    996 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@
     999@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po@am__quote@
    9971000@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
     1001@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@
    9981002
    9991003.cc.o:
     
    12371241@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi`
    12381242
    1239 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc
    1240 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
    1241 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
    1242 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@
    1243 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1244 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc
    1245 
    1246 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc
    1247 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
    1248 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po
    1249 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@
    1250 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1251 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
    1252 
    12531243GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    12541244@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc
     
    24272417@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi`
    24282418
     2419SynTree/driver_cfa_cpp-VarExprReplacer.o: SynTree/VarExprReplacer.cc
     2420@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc
     2421@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po
     2422@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.o' libtool=no @AMDEPBACKSLASH@
     2423@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2424@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc
     2425
     2426SynTree/driver_cfa_cpp-VarExprReplacer.obj: SynTree/VarExprReplacer.cc
     2427@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi`
     2428@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po
     2429@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.obj' libtool=no @AMDEPBACKSLASH@
     2430@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2431@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi`
     2432
    24292433Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc
    24302434@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleAssignment.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Tpo -c -o Tuples/driver_cfa_cpp-TupleAssignment.o `test -f 'Tuples/TupleAssignment.cc' || echo '$(srcdir)/'`Tuples/TupleAssignment.cc
     
    24412445@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleAssignment.obj `if test -f 'Tuples/TupleAssignment.cc'; then $(CYGPATH_W) 'Tuples/TupleAssignment.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleAssignment.cc'; fi`
    24422446
    2443 Tuples/driver_cfa_cpp-NameMatcher.o: Tuples/NameMatcher.cc
    2444 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc
    2445 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po
    2446 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.o' libtool=no @AMDEPBACKSLASH@
    2447 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2448 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc
    2449 
    2450 Tuples/driver_cfa_cpp-NameMatcher.obj: Tuples/NameMatcher.cc
    2451 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi`
    2452 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po
    2453 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.obj' libtool=no @AMDEPBACKSLASH@
    2454 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2455 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi`
     2447Tuples/driver_cfa_cpp-TupleExpansion.o: Tuples/TupleExpansion.cc
     2448@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc
     2449@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po
     2450@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.o' libtool=no @AMDEPBACKSLASH@
     2451@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2452@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc
     2453
     2454Tuples/driver_cfa_cpp-TupleExpansion.obj: Tuples/TupleExpansion.cc
     2455@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi`
     2456@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po
     2457@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.obj' libtool=no @AMDEPBACKSLASH@
     2458@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2459@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi`
     2460
     2461Tuples/driver_cfa_cpp-Explode.o: Tuples/Explode.cc
     2462@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Explode.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo -c -o Tuples/driver_cfa_cpp-Explode.o `test -f 'Tuples/Explode.cc' || echo '$(srcdir)/'`Tuples/Explode.cc
     2463@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po
     2464@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/Explode.cc' object='Tuples/driver_cfa_cpp-Explode.o' libtool=no @AMDEPBACKSLASH@
     2465@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2466@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.o `test -f 'Tuples/Explode.cc' || echo '$(srcdir)/'`Tuples/Explode.cc
     2467
     2468Tuples/driver_cfa_cpp-Explode.obj: Tuples/Explode.cc
     2469@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Explode.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi`
     2470@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po
     2471@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/Explode.cc' object='Tuples/driver_cfa_cpp-Explode.obj' libtool=no @AMDEPBACKSLASH@
     2472@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2473@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi`
    24562474
    24572475.ll.cc:
  • src/Parser/ExpressionNode.cc

    r3a2128f r1f44196  
    172172} // build_constantStr
    173173
     174Expression * build_field_name_FLOATINGconstant( const std::string & str ) {
     175        // str is of the form A.B -> separate at the . and return member expression
     176        int a, b;
     177        char dot;
     178        std::stringstream ss( str );
     179        ss >> a >> dot >> b;
     180        UntypedMemberExpr * ret = new UntypedMemberExpr(
     181                new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( b ) ) ),
     182                new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( a ) ) ) );
     183        delete &str;
     184        return ret;
     185} // build_field_name_FLOATINGconstant
     186
     187Expression * make_field_name_fraction_constants( Expression * fieldName, Expression * fracts ) {
     188        if ( fracts ) {
     189                if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * >( fracts ) ) {
     190                        memberExpr->set_member( make_field_name_fraction_constants( fieldName, memberExpr->get_aggregate() ) );
     191                        return memberExpr;
     192                } else {
     193                        return new UntypedMemberExpr( fracts, fieldName );
     194                }
     195        }
     196        return fieldName;
     197} // make_field_name_fraction_constants
     198
     199Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ) {
     200        return make_field_name_fraction_constants( fieldName, maybeMoveBuild< Expression >( fracts ) );
     201} // build_field_name_fraction_constants
     202
     203Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) {
     204        assert( str[0] == '.' );
     205        Expression * ret = build_constantInteger( *new std::string( str.substr(1) ) );
     206        delete &str;
     207        return ret;
     208} // build_field_name_REALFRACTIONconstant
     209
     210Expression * build_field_name_REALDECIMALconstant( const std::string & str ) {
     211        assert( str[str.size()-1] == '.' );
     212        Expression * ret = build_constantInteger( *new std::string( str.substr( 0, str.size()-1 ) ) );
     213        delete &str;
     214        return ret;
     215} // build_field_name_REALDECIMALconstant
     216
    174217NameExpr * build_varref( const string *name, bool labelp ) {
    175218        NameExpr *expr = new NameExpr( *name, nullptr );
     
    198241}
    199242
    200 Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) {
    201         UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeMoveBuild< Expression >(expr_node) );
    202         delete member;
    203         return ret;
    204 }
    205 
    206 Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) {
     243Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
     244        UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     245        return ret;
     246}
     247
     248Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) {
    207249        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    208250        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    209         UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
    210         delete member;
     251        UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref );
    211252        return ret;
    212253}
  • src/Parser/ParseNode.h

    r3a2128f r1f44196  
    155155Expression * build_constantChar( const std::string &str );
    156156ConstantExpr * build_constantStr( const std::string &str );
     157Expression * build_field_name_FLOATINGconstant( const std::string & str );
     158Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts );
     159Expression * build_field_name_REALFRACTIONconstant( const std::string & str );
     160Expression * build_field_name_REALDECIMALconstant( const std::string & str );
    157161
    158162NameExpr * build_varref( const std::string * name, bool labelp = false );
     
    160164
    161165Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    162 Expression * build_fieldSel( ExpressionNode * expr_node, NameExpr * member );
    163 Expression * build_pfieldSel( ExpressionNode * expr_node, NameExpr * member );
     166Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     167Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member );
    164168Expression * build_addressOf( ExpressionNode * expr_node );
    165169Expression * build_sizeOfexpr( ExpressionNode * expr_node );
     
    383387//##############################################################################
    384388
    385 template< typename SynTreeType, typename NodeType >
    386 void buildList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) {
     389template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
     390void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
    387391        SemanticError errors;
    388         std::back_insert_iterator< std::list< SynTreeType * > > out( outputList );
     392        std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
    389393        const NodeType * cur = firstNode;
    390394
  • src/Parser/TypeData.cc

    r3a2128f r1f44196  
    385385} // TypeData::print
    386386
    387 void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) {
     387template< typename ForallList >
     388void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) {
    388389        buildList( firstNode, outputList );
    389         for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    390                 if ( (*i)->get_kind() == TypeDecl::Any ) {
     390        for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     391                TypeDecl * td = static_cast<TypeDecl*>(*i);
     392                if ( td->get_kind() == TypeDecl::Any ) {
    391393                        // add assertion parameters to `type' tyvars in reverse order
    392394                        // add dtor:  void ^?{}(T *)
    393395                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    394                         dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    395                         (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
     396                        dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     397                        td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
    396398
    397399                        // add copy ctor:  void ?{}(T *, T)
    398400                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );
    399                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    400                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    401                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
     401                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     402                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     403                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
    402404
    403405                        // add default ctor:  void ?{}(T *)
    404406                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    405                         ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    406                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
     407                        ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     408                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
    407409
    408410                        // add assignment operator:  T * ?=?(T *, T)
    409411                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );
    410                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    411                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    412                         assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    413                         (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
     412                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     413                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     414                        assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     415                        td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
    414416                } // if
    415417        } // for
     
    515517                // character types. The implementation shall define char to have the same range, representation, and behavior as
    516518                // either signed char or unsigned char.
    517                 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 
     519                static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char };
    518520
    519521                if ( td->length != DeclarationNode::NoLength ) {
  • src/Parser/parser.cc

    r3a2128f r1f44196  
    10301030static const yytype_uint16 yyrline[] =
    10311031{
    1032        0,   306,   306,   310,   317,   318,   319,   320,   321,   325,
    1033      326,   327,   331,   332,   336,   337,   341,   342,   346,   350,
    1034      351,   362,   364,   366,   367,   369,   374,   375,   381,   383,
    1035      385,   386,   387,   389,   390,   392,   394,   396,   405,   406,
    1036      412,   413,   417,   418,   422,   424,   426,   428,   430,   432,
    1037      434,   439,   441,   443,   447,   449,   453,   456,   458,   460,
    1038      465,   478,   480,   482,   484,   486,   488,   490,   492,   494,
    1039      496,   498,   505,   506,   512,   513,   514,   515,   519,   520,
    1040      527,   528,   530,   532,   537,   538,   540,   545,   546,   548,
    1041      553,   554,   556,   558,   560,   565,   566,   568,   573,   574,
    1042      579,   580,   585,   586,   591,   592,   597,   598,   603,   604,
    1043      607,   614,   619,   620,   628,   629,   633,   634,   635,   636,
    1044      637,   638,   639,   640,   641,   642,   643,   644,   654,   656,
    1045      661,   662,   667,   668,   674,   675,   681,   682,   683,   684,
    1046      685,   686,   687,   688,   689,   699,   706,   708,   718,   719,
    1047      724,   726,   732,   734,   738,   739,   744,   749,   752,   754,
    1048      756,   766,   768,   779,   780,   782,   786,   788,   792,   793,
    1049      798,   799,   803,   808,   809,   813,   815,   821,   822,   826,
    1050      828,   830,   832,   838,   839,   843,   845,   850,   852,   854,
    1051      859,   861,   866,   868,   872,   875,   879,   882,   886,   888,
    1052      890,   892,   897,   899,   901,   906,   908,   910,   912,   914,
    1053      919,   921,   923,   925,   930,   942,   943,   948,   950,   955,
    1054      959,   961,   963,   965,   967,   973,   974,   980,   981,   985,
    1055      986,   991,   993,   999,  1000,  1002,  1007,  1012,  1022,  1024,
    1056     1028,  1029,  1034,  1036,  1040,  1041,  1045,  1047,  1051,  1052,
    1057     1056,  1057,  1061,  1062,  1077,  1078,  1079,  1080,  1081,  1085,
    1058     1090,  1097,  1107,  1112,  1117,  1125,  1130,  1135,  1140,  1145,
    1059     1175,  1180,  1187,  1189,  1196,  1201,  1206,  1217,  1222,  1227,
    1060     1232,  1237,  1246,  1251,  1259,  1260,  1261,  1262,  1268,  1273,
    1061     1281,  1282,  1283,  1284,  1288,  1289,  1290,  1291,  1296,  1297,
    1062     1306,  1307,  1312,  1313,  1318,  1320,  1322,  1324,  1326,  1329,
    1063     1328,  1340,  1341,  1343,  1353,  1354,  1359,  1361,  1363,  1365,
    1064     1367,  1370,  1372,  1375,  1380,  1382,  1384,  1386,  1388,  1390,
    1065     1392,  1394,  1396,  1398,  1400,  1402,  1404,  1406,  1408,  1414,
    1066     1415,  1417,  1419,  1421,  1426,  1427,  1433,  1434,  1436,  1438,
    1067     1443,  1445,  1447,  1449,  1454,  1455,  1457,  1459,  1464,  1465,
    1068     1467,  1472,  1473,  1475,  1477,  1482,  1484,  1486,  1491,  1492,
    1069     1496,  1498,  1504,  1503,  1507,  1509,  1514,  1516,  1522,  1523,
    1070     1528,  1529,  1531,  1532,  1541,  1542,  1544,  1546,  1551,  1553,
    1071     1559,  1560,  1562,  1565,  1568,  1573,  1574,  1579,  1584,  1588,
    1072     1590,  1596,  1595,  1602,  1604,  1610,  1611,  1619,  1620,  1624,
    1073     1625,  1626,  1628,  1630,  1637,  1638,  1640,  1642,  1647,  1648,
    1074     1654,  1655,  1659,  1660,  1665,  1666,  1667,  1669,  1677,  1678,
    1075     1680,  1683,  1685,  1689,  1690,  1691,  1693,  1695,  1699,  1704,
    1076     1712,  1713,  1722,  1724,  1729,  1730,  1731,  1735,  1736,  1737,
    1077     1741,  1742,  1743,  1747,  1748,  1749,  1754,  1755,  1756,  1757,
    1078     1763,  1764,  1766,  1771,  1772,  1777,  1778,  1779,  1780,  1781,
    1079     1796,  1797,  1802,  1803,  1809,  1811,  1814,  1816,  1818,  1841,
    1080     1842,  1844,  1846,  1851,  1852,  1854,  1859,  1864,  1865,  1871,
    1081     1870,  1874,  1878,  1880,  1882,  1888,  1889,  1894,  1899,  1901,
    1082     1906,  1908,  1909,  1911,  1916,  1918,  1920,  1925,  1927,  1932,
    1083     1937,  1945,  1951,  1950,  1964,  1965,  1970,  1971,  1975,  1980,
    1084     1985,  1993,  1998,  2009,  2010,  2015,  2016,  2022,  2023,  2027,
    1085     2028,  2029,  2032,  2031,  2042,  2051,  2057,  2063,  2072,  2078,
    1086     2084,  2090,  2096,  2104,  2110,  2118,  2124,  2133,  2134,  2135,
    1087     2139,  2143,  2145,  2150,  2151,  2155,  2156,  2161,  2167,  2168,
    1088     2171,  2173,  2174,  2178,  2179,  2180,  2181,  2215,  2217,  2218,
    1089     2220,  2225,  2230,  2235,  2237,  2239,  2244,  2246,  2248,  2250,
    1090     2255,  2257,  2266,  2268,  2269,  2274,  2276,  2278,  2283,  2285,
    1091     2287,  2292,  2294,  2296,  2305,  2306,  2307,  2311,  2313,  2315,
    1092     2320,  2322,  2324,  2329,  2331,  2333,  2348,  2350,  2351,  2353,
    1093     2358,  2359,  2364,  2366,  2368,  2373,  2375,  2377,  2379,  2384,
    1094     2386,  2388,  2398,  2400,  2401,  2403,  2408,  2410,  2412,  2417,
    1095     2419,  2421,  2423,  2428,  2430,  2432,  2463,  2465,  2466,  2468,
    1096     2473,  2478,  2486,  2488,  2490,  2495,  2497,  2502,  2504,  2518,
    1097     2519,  2521,  2526,  2528,  2530,  2532,  2534,  2539,  2540,  2542,
    1098     2544,  2549,  2551,  2553,  2559,  2561,  2563,  2567,  2569,  2571,
    1099     2573,  2587,  2588,  2590,  2595,  2597,  2599,  2601,  2603,  2608,
    1100     2609,  2611,  2613,  2618,  2620,  2622,  2628,  2629,  2631,  2640,
    1101     2643,  2645,  2648,  2650,  2652,  2665,  2666,  2668,  2673,  2675,
    1102     2677,  2679,  2681,  2686,  2687,  2689,  2691,  2696,  2698,  2706,
    1103     2707,  2708,  2713,  2714,  2718,  2720,  2722,  2724,  2726,  2728,
    1104     2735,  2737,  2739,  2741,  2743,  2746,  2748,  2750,  2752,  2754,
    1105     2759,  2761,  2763,  2768,  2794,  2795,  2797,  2801,  2802,  2806,
    1106     2808,  2810,  2812,  2814,  2816,  2823,  2825,  2827,  2829,  2831,
    1107     2833,  2838,  2845,  2847,  2865,  2867,  2872,  2873
     1032       0,   305,   305,   309,   316,   317,   318,   319,   320,   324,
     1033     325,   326,   330,   331,   335,   336,   340,   341,   345,   349,
     1034     350,   361,   363,   365,   366,   368,   373,   374,   380,   382,
     1035     384,   386,   388,   390,   392,   394,   396,   398,   407,   408,
     1036     414,   415,   419,   420,   424,   425,   427,   429,   431,   433,
     1037     435,   440,   442,   444,   450,   451,   459,   462,   464,   466,
     1038     471,   484,   486,   488,   490,   492,   494,   496,   498,   500,
     1039     502,   504,   511,   512,   518,   519,   520,   521,   525,   526,
     1040     533,   534,   536,   538,   543,   544,   546,   551,   552,   554,
     1041     559,   560,   562,   564,   566,   571,   572,   574,   579,   580,
     1042     585,   586,   591,   592,   597,   598,   603,   604,   609,   610,
     1043     613,   620,   625,   626,   634,   635,   639,   640,   641,   642,
     1044     643,   644,   645,   646,   647,   648,   649,   650,   660,   662,
     1045     667,   668,   673,   674,   680,   681,   687,   688,   689,   690,
     1046     691,   692,   693,   694,   695,   705,   712,   714,   724,   725,
     1047     730,   732,   738,   740,   744,   745,   750,   755,   758,   760,
     1048     762,   772,   774,   785,   786,   788,   792,   794,   798,   799,
     1049     804,   805,   809,   814,   815,   819,   821,   827,   828,   832,
     1050     834,   836,   838,   844,   845,   849,   851,   856,   858,   860,
     1051     865,   867,   872,   874,   878,   881,   885,   888,   892,   894,
     1052     896,   898,   903,   905,   907,   912,   914,   916,   918,   920,
     1053     925,   927,   929,   931,   936,   948,   949,   954,   956,   961,
     1054     965,   967,   969,   971,   973,   979,   980,   986,   987,   991,
     1055     992,   997,   999,  1005,  1006,  1008,  1013,  1018,  1028,  1030,
     1056    1034,  1035,  1040,  1042,  1046,  1047,  1051,  1053,  1057,  1058,
     1057    1062,  1063,  1067,  1068,  1083,  1084,  1085,  1086,  1087,  1091,
     1058    1096,  1103,  1113,  1118,  1123,  1131,  1136,  1141,  1146,  1151,
     1059    1181,  1186,  1193,  1195,  1202,  1207,  1212,  1223,  1228,  1233,
     1060    1238,  1243,  1252,  1257,  1265,  1266,  1267,  1268,  1274,  1279,
     1061    1287,  1288,  1289,  1290,  1294,  1295,  1296,  1297,  1302,  1303,
     1062    1312,  1313,  1318,  1319,  1324,  1326,  1328,  1330,  1332,  1335,
     1063    1334,  1346,  1347,  1349,  1359,  1360,  1365,  1367,  1369,  1371,
     1064    1373,  1376,  1378,  1381,  1386,  1388,  1390,  1392,  1394,  1396,
     1065    1398,  1400,  1402,  1404,  1406,  1408,  1410,  1412,  1414,  1420,
     1066    1421,  1423,  1425,  1427,  1432,  1433,  1439,  1440,  1442,  1444,
     1067    1449,  1451,  1453,  1455,  1460,  1461,  1463,  1465,  1470,  1471,
     1068    1473,  1478,  1479,  1481,  1483,  1488,  1490,  1492,  1497,  1498,
     1069    1502,  1504,  1510,  1509,  1513,  1515,  1520,  1522,  1528,  1529,
     1070    1534,  1535,  1537,  1538,  1547,  1548,  1550,  1552,  1557,  1559,
     1071    1565,  1566,  1568,  1571,  1574,  1579,  1580,  1585,  1590,  1594,
     1072    1596,  1602,  1601,  1608,  1610,  1616,  1617,  1625,  1626,  1630,
     1073    1631,  1632,  1634,  1636,  1643,  1644,  1646,  1648,  1653,  1654,
     1074    1660,  1661,  1665,  1666,  1671,  1672,  1673,  1675,  1683,  1684,
     1075    1686,  1689,  1691,  1695,  1696,  1697,  1699,  1701,  1705,  1710,
     1076    1718,  1719,  1728,  1730,  1735,  1736,  1737,  1741,  1742,  1743,
     1077    1747,  1748,  1749,  1753,  1754,  1755,  1760,  1761,  1762,  1763,
     1078    1769,  1770,  1772,  1777,  1778,  1783,  1784,  1785,  1786,  1787,
     1079    1802,  1803,  1808,  1809,  1815,  1817,  1820,  1822,  1824,  1847,
     1080    1848,  1850,  1852,  1857,  1858,  1860,  1865,  1870,  1871,  1877,
     1081    1876,  1880,  1884,  1886,  1888,  1894,  1895,  1900,  1905,  1907,
     1082    1912,  1914,  1915,  1917,  1922,  1924,  1926,  1931,  1933,  1938,
     1083    1943,  1951,  1957,  1956,  1970,  1971,  1976,  1977,  1981,  1986,
     1084    1991,  1999,  2004,  2015,  2016,  2021,  2022,  2028,  2029,  2033,
     1085    2034,  2035,  2038,  2037,  2048,  2057,  2063,  2069,  2078,  2084,
     1086    2090,  2096,  2102,  2110,  2116,  2124,  2130,  2139,  2140,  2141,
     1087    2145,  2149,  2151,  2156,  2157,  2161,  2162,  2167,  2173,  2174,
     1088    2177,  2179,  2180,  2184,  2185,  2186,  2187,  2221,  2223,  2224,
     1089    2226,  2231,  2236,  2241,  2243,  2245,  2250,  2252,  2254,  2256,
     1090    2261,  2263,  2272,  2274,  2275,  2280,  2282,  2284,  2289,  2291,
     1091    2293,  2298,  2300,  2302,  2311,  2312,  2313,  2317,  2319,  2321,
     1092    2326,  2328,  2330,  2335,  2337,  2339,  2354,  2356,  2357,  2359,
     1093    2364,  2365,  2370,  2372,  2374,  2379,  2381,  2383,  2385,  2390,
     1094    2392,  2394,  2404,  2406,  2407,  2409,  2414,  2416,  2418,  2423,
     1095    2425,  2427,  2429,  2434,  2436,  2438,  2469,  2471,  2472,  2474,
     1096    2479,  2484,  2492,  2494,  2496,  2501,  2503,  2508,  2510,  2524,
     1097    2525,  2527,  2532,  2534,  2536,  2538,  2540,  2545,  2546,  2548,
     1098    2550,  2555,  2557,  2559,  2565,  2567,  2569,  2573,  2575,  2577,
     1099    2579,  2593,  2594,  2596,  2601,  2603,  2605,  2607,  2609,  2614,
     1100    2615,  2617,  2619,  2624,  2626,  2628,  2634,  2635,  2637,  2646,
     1101    2649,  2651,  2654,  2656,  2658,  2671,  2672,  2674,  2679,  2681,
     1102    2683,  2685,  2687,  2692,  2693,  2695,  2697,  2702,  2704,  2712,
     1103    2713,  2714,  2719,  2720,  2724,  2726,  2728,  2730,  2732,  2734,
     1104    2741,  2743,  2745,  2747,  2749,  2752,  2754,  2756,  2758,  2760,
     1105    2765,  2767,  2769,  2774,  2800,  2801,  2803,  2807,  2808,  2812,
     1106    2814,  2816,  2818,  2820,  2822,  2829,  2831,  2833,  2835,  2837,
     1107    2839,  2844,  2851,  2853,  2871,  2873,  2878,  2879
    11081108};
    11091109#endif
     
    49284928
    49294929/* Line 1806 of yacc.c  */
    4930 #line 306 "parser.yy"
     4930#line 305 "parser.yy"
    49314931    { typedefTable.enterScope(); }
    49324932    break;
     
    49354935
    49364936/* Line 1806 of yacc.c  */
    4937 #line 310 "parser.yy"
     4937#line 309 "parser.yy"
    49384938    { typedefTable.leaveScope(); }
    49394939    break;
     
    49424942
    49434943/* Line 1806 of yacc.c  */
     4944#line 316 "parser.yy"
     4945    { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); }
     4946    break;
     4947
     4948  case 5:
     4949
     4950/* Line 1806 of yacc.c  */
    49444951#line 317 "parser.yy"
    4945     { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); }
    4946     break;
    4947 
    4948   case 5:
     4952    { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }
     4953    break;
     4954
     4955  case 6:
    49494956
    49504957/* Line 1806 of yacc.c  */
     
    49534960    break;
    49544961
    4955   case 6:
     4962  case 7:
    49564963
    49574964/* Line 1806 of yacc.c  */
     
    49604967    break;
    49614968
    4962   case 7:
     4969  case 8:
    49634970
    49644971/* Line 1806 of yacc.c  */
    49654972#line 320 "parser.yy"
    4966     { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }
    4967     break;
    4968 
    4969   case 8:
    4970 
    4971 /* Line 1806 of yacc.c  */
    4972 #line 321 "parser.yy"
    49734973    { (yyval.en) = new ExpressionNode( build_constantChar( *(yyvsp[(1) - (1)].tok) ) ); }
    49744974    break;
     
    49774977
    49784978/* Line 1806 of yacc.c  */
    4979 #line 346 "parser.yy"
     4979#line 345 "parser.yy"
    49804980    { (yyval.constant) = build_constantStr( *(yyvsp[(1) - (1)].str) ); }
    49814981    break;
     
    49844984
    49854985/* Line 1806 of yacc.c  */
    4986 #line 350 "parser.yy"
     4986#line 349 "parser.yy"
    49874987    { (yyval.str) = (yyvsp[(1) - (1)].tok); }
    49884988    break;
     
    49914991
    49924992/* Line 1806 of yacc.c  */
    4993 #line 352 "parser.yy"
     4993#line 351 "parser.yy"
    49944994    {
    49954995                        appendStr( (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].tok) );                                            // append 2nd juxtaposed string to 1st
     
    50025002
    50035003/* Line 1806 of yacc.c  */
    5004 #line 363 "parser.yy"
     5004#line 362 "parser.yy"
    50055005    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    50065006    break;
     
    50095009
    50105010/* Line 1806 of yacc.c  */
    5011 #line 365 "parser.yy"
     5011#line 364 "parser.yy"
    50125012    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    50135013    break;
     
    50165016
    50175017/* Line 1806 of yacc.c  */
    5018 #line 368 "parser.yy"
     5018#line 367 "parser.yy"
    50195019    { (yyval.en) = (yyvsp[(2) - (3)].en); }
    50205020    break;
     
    50235023
    50245024/* Line 1806 of yacc.c  */
    5025 #line 370 "parser.yy"
     5025#line 369 "parser.yy"
    50265026    { (yyval.en) = new ExpressionNode( build_valexpr( (yyvsp[(2) - (3)].sn) ) ); }
    50275027    break;
     
    50305030
    50315031/* Line 1806 of yacc.c  */
    5032 #line 380 "parser.yy"
     5032#line 379 "parser.yy"
    50335033    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Index, (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ) ); }
    50345034    break;
     
    50375037
    50385038/* Line 1806 of yacc.c  */
    5039 #line 382 "parser.yy"
     5039#line 381 "parser.yy"
    50405040    { (yyval.en) = new ExpressionNode( build_func( (yyvsp[(1) - (4)].en), (yyvsp[(3) - (4)].en) ) ); }
    50415041    break;
     
    50445044
    50455045/* Line 1806 of yacc.c  */
    5046 #line 384 "parser.yy"
     5046#line 383 "parser.yy"
    50475047    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); }
    50485048    break;
    50495049
     5050  case 30:
     5051
     5052/* Line 1806 of yacc.c  */
     5053#line 385 "parser.yy"
     5054    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5055    break;
     5056
     5057  case 31:
     5058
     5059/* Line 1806 of yacc.c  */
     5060#line 387 "parser.yy"
     5061    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (2)].en), build_field_name_REALFRACTIONconstant( *(yyvsp[(2) - (2)].tok) ) ) ); }
     5062    break;
     5063
    50505064  case 32:
    50515065
    50525066/* Line 1806 of yacc.c  */
    5053 #line 388 "parser.yy"
     5067#line 389 "parser.yy"
    50545068    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); }
    50555069    break;
    50565070
     5071  case 33:
     5072
     5073/* Line 1806 of yacc.c  */
     5074#line 391 "parser.yy"
     5075    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
     5076    break;
     5077
    50575078  case 34:
    50585079
    50595080/* Line 1806 of yacc.c  */
    5060 #line 391 "parser.yy"
     5081#line 393 "parser.yy"
    50615082    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, (yyvsp[(1) - (2)].en) ) ); }
    50625083    break;
     
    50655086
    50665087/* Line 1806 of yacc.c  */
    5067 #line 393 "parser.yy"
     5088#line 395 "parser.yy"
    50685089    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, (yyvsp[(1) - (2)].en) ) ); }
    50695090    break;
     
    50725093
    50735094/* Line 1806 of yacc.c  */
    5074 #line 395 "parser.yy"
     5095#line 397 "parser.yy"
    50755096    { (yyval.en) = new ExpressionNode( build_compoundLiteral( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ) ); }
    50765097    break;
     
    50795100
    50805101/* Line 1806 of yacc.c  */
    5081 #line 397 "parser.yy"
     5102#line 399 "parser.yy"
    50825103    {
    50835104                        Token fn;
     
    50905111
    50915112/* Line 1806 of yacc.c  */
    5092 #line 407 "parser.yy"
     5113#line 409 "parser.yy"
    50935114    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    50945115    break;
     
    50975118
    50985119/* Line 1806 of yacc.c  */
    5099 #line 412 "parser.yy"
     5120#line 414 "parser.yy"
    51005121    { (yyval.en) = 0; }
    51015122    break;
     
    51045125
    51055126/* Line 1806 of yacc.c  */
    5106 #line 418 "parser.yy"
     5127#line 420 "parser.yy"
    51075128    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    51085129    break;
    51095130
    5110   case 44:
    5111 
    5112 /* Line 1806 of yacc.c  */
    5113 #line 423 "parser.yy"
    5114     { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }
    5115     break;
    5116 
    51175131  case 45:
    51185132
    51195133/* Line 1806 of yacc.c  */
    5120 #line 425 "parser.yy"
    5121     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(2) - (2)].en), build_varref( (yyvsp[(1) - (2)].tok) ) ) ); }
     5134#line 426 "parser.yy"
     5135    { (yyval.en) = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *(yyvsp[(1) - (2)].tok) ) ), maybeMoveBuild<Expression>( (yyvsp[(2) - (2)].en) ) ) ); }
    51225136    break;
    51235137
     
    51255139
    51265140/* Line 1806 of yacc.c  */
    5127 #line 427 "parser.yy"
    5128     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(4) - (6)].en), build_varref( (yyvsp[(1) - (6)].tok) ) ) ); }
     5141#line 428 "parser.yy"
     5142    { (yyval.en) = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *(yyvsp[(1) - (6)].tok) ) ), build_tuple( (yyvsp[(4) - (6)].en) ) ) ); }
    51295143    break;
    51305144
     
    51325146
    51335147/* Line 1806 of yacc.c  */
    5134 #line 429 "parser.yy"
    5135     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
     5148#line 430 "parser.yy"
     5149    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); }
    51365150    break;
    51375151
     
    51395153
    51405154/* Line 1806 of yacc.c  */
    5141 #line 431 "parser.yy"
    5142     { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
     5155#line 432 "parser.yy"
     5156    { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
    51435157    break;
    51445158
     
    51465160
    51475161/* Line 1806 of yacc.c  */
    5148 #line 433 "parser.yy"
    5149     { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }
     5162#line 434 "parser.yy"
     5163    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); }
    51505164    break;
    51515165
     
    51535167
    51545168/* Line 1806 of yacc.c  */
    5155 #line 435 "parser.yy"
    5156     { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }
     5169#line 436 "parser.yy"
     5170    { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); }
    51575171    break;
    51585172
     
    51605174
    51615175/* Line 1806 of yacc.c  */
    5162 #line 440 "parser.yy"
    5163     { (yyval.tok) = (yyvsp[(1) - (2)].tok); }
     5176#line 441 "parser.yy"
     5177    { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *(yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); }
    51645178    break;
    51655179
     
    51675181
    51685182/* Line 1806 of yacc.c  */
    5169 #line 442 "parser.yy"
    5170     { (yyval.tok) = (yyvsp[(1) - (2)].tok); }
     5183#line 443 "parser.yy"
     5184    { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *(yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); }
    51715185    break;
    51725186
     
    51745188
    51755189/* Line 1806 of yacc.c  */
    5176 #line 444 "parser.yy"
    5177     { (yyval.tok) = (yyvsp[(1) - (2)].tok); }
     5190#line 445 "parser.yy"
     5191    { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_varref( (yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); }
     5192    break;
     5193
     5194  case 54:
     5195
     5196/* Line 1806 of yacc.c  */
     5197#line 450 "parser.yy"
     5198    { (yyval.en) = nullptr; }
     5199    break;
     5200
     5201  case 55:
     5202
     5203/* Line 1806 of yacc.c  */
     5204#line 452 "parser.yy"
     5205    {
     5206                        Expression * constant = build_field_name_REALFRACTIONconstant( *(yyvsp[(2) - (2)].tok) );
     5207                        (yyval.en) = (yyvsp[(1) - (2)].en) != nullptr ? new ExpressionNode( build_fieldSel( (yyvsp[(1) - (2)].en),  constant ) ) : new ExpressionNode( constant );
     5208                }
    51785209    break;
    51795210
     
    51815212
    51825213/* Line 1806 of yacc.c  */
    5183 #line 457 "parser.yy"
     5214#line 463 "parser.yy"
    51845215    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    51855216    break;
     
    51885219
    51895220/* Line 1806 of yacc.c  */
    5190 #line 459 "parser.yy"
     5221#line 465 "parser.yy"
    51915222    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    51925223    break;
     
    51955226
    51965227/* Line 1806 of yacc.c  */
    5197 #line 461 "parser.yy"
     5228#line 467 "parser.yy"
    51985229    { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); }
    51995230    break;
     
    52025233
    52035234/* Line 1806 of yacc.c  */
    5204 #line 466 "parser.yy"
     5235#line 472 "parser.yy"
    52055236    {
    52065237                        switch ( (yyvsp[(1) - (2)].op) ) {
     
    52205251
    52215252/* Line 1806 of yacc.c  */
    5222 #line 479 "parser.yy"
     5253#line 485 "parser.yy"
    52235254    { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); }
    52245255    break;
     
    52275258
    52285259/* Line 1806 of yacc.c  */
    5229 #line 481 "parser.yy"
     5260#line 487 "parser.yy"
    52305261    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); }
    52315262    break;
     
    52345265
    52355266/* Line 1806 of yacc.c  */
    5236 #line 483 "parser.yy"
     5267#line 489 "parser.yy"
    52375268    { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); }
    52385269    break;
     
    52415272
    52425273/* Line 1806 of yacc.c  */
    5243 #line 485 "parser.yy"
     5274#line 491 "parser.yy"
    52445275    { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52455276    break;
     
    52485279
    52495280/* Line 1806 of yacc.c  */
    5250 #line 487 "parser.yy"
     5281#line 493 "parser.yy"
    52515282    { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52525283    break;
     
    52555286
    52565287/* Line 1806 of yacc.c  */
    5257 #line 489 "parser.yy"
     5288#line 495 "parser.yy"
    52585289    { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); }
    52595290    break;
     
    52625293
    52635294/* Line 1806 of yacc.c  */
    5264 #line 491 "parser.yy"
     5295#line 497 "parser.yy"
    52655296    { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); }
    52665297    break;
     
    52695300
    52705301/* Line 1806 of yacc.c  */
    5271 #line 493 "parser.yy"
     5302#line 499 "parser.yy"
    52725303    { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); }
    52735304    break;
     
    52765307
    52775308/* Line 1806 of yacc.c  */
    5278 #line 495 "parser.yy"
     5309#line 501 "parser.yy"
    52795310    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); }
    52805311    break;
     
    52835314
    52845315/* Line 1806 of yacc.c  */
    5285 #line 497 "parser.yy"
     5316#line 503 "parser.yy"
    52865317    { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); }
    52875318    break;
     
    52905321
    52915322/* Line 1806 of yacc.c  */
    5292 #line 499 "parser.yy"
     5323#line 505 "parser.yy"
    52935324    { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); }
    52945325    break;
     
    52975328
    52985329/* Line 1806 of yacc.c  */
    5299 #line 505 "parser.yy"
     5330#line 511 "parser.yy"
    53005331    { (yyval.op) = OperKinds::PointTo; }
    53015332    break;
     
    53045335
    53055336/* Line 1806 of yacc.c  */
    5306 #line 506 "parser.yy"
     5337#line 512 "parser.yy"
    53075338    { (yyval.op) = OperKinds::AddressOf; }
    53085339    break;
     
    53115342
    53125343/* Line 1806 of yacc.c  */
    5313 #line 512 "parser.yy"
     5344#line 518 "parser.yy"
    53145345    { (yyval.op) = OperKinds::UnPlus; }
    53155346    break;
     
    53185349
    53195350/* Line 1806 of yacc.c  */
    5320 #line 513 "parser.yy"
     5351#line 519 "parser.yy"
    53215352    { (yyval.op) = OperKinds::UnMinus; }
    53225353    break;
     
    53255356
    53265357/* Line 1806 of yacc.c  */
    5327 #line 514 "parser.yy"
     5358#line 520 "parser.yy"
    53285359    { (yyval.op) = OperKinds::Neg; }
    53295360    break;
     
    53325363
    53335364/* Line 1806 of yacc.c  */
    5334 #line 515 "parser.yy"
     5365#line 521 "parser.yy"
    53355366    { (yyval.op) = OperKinds::BitNeg; }
    53365367    break;
     
    53395370
    53405371/* Line 1806 of yacc.c  */
    5341 #line 521 "parser.yy"
     5372#line 527 "parser.yy"
    53425373    { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); }
    53435374    break;
     
    53465377
    53475378/* Line 1806 of yacc.c  */
    5348 #line 529 "parser.yy"
     5379#line 535 "parser.yy"
    53495380    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53505381    break;
     
    53535384
    53545385/* Line 1806 of yacc.c  */
    5355 #line 531 "parser.yy"
     5386#line 537 "parser.yy"
    53565387    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53575388    break;
     
    53605391
    53615392/* Line 1806 of yacc.c  */
    5362 #line 533 "parser.yy"
     5393#line 539 "parser.yy"
    53635394    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53645395    break;
     
    53675398
    53685399/* Line 1806 of yacc.c  */
    5369 #line 539 "parser.yy"
     5400#line 545 "parser.yy"
    53705401    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53715402    break;
     
    53745405
    53755406/* Line 1806 of yacc.c  */
    5376 #line 541 "parser.yy"
     5407#line 547 "parser.yy"
    53775408    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53785409    break;
     
    53815412
    53825413/* Line 1806 of yacc.c  */
    5383 #line 547 "parser.yy"
     5414#line 553 "parser.yy"
    53845415    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53855416    break;
     
    53885419
    53895420/* Line 1806 of yacc.c  */
    5390 #line 549 "parser.yy"
     5421#line 555 "parser.yy"
    53915422    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53925423    break;
     
    53955426
    53965427/* Line 1806 of yacc.c  */
    5397 #line 555 "parser.yy"
     5428#line 561 "parser.yy"
    53985429    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    53995430    break;
     
    54025433
    54035434/* Line 1806 of yacc.c  */
    5404 #line 557 "parser.yy"
     5435#line 563 "parser.yy"
    54055436    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54065437    break;
     
    54095440
    54105441/* Line 1806 of yacc.c  */
    5411 #line 559 "parser.yy"
     5442#line 565 "parser.yy"
    54125443    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54135444    break;
     
    54165447
    54175448/* Line 1806 of yacc.c  */
    5418 #line 561 "parser.yy"
     5449#line 567 "parser.yy"
    54195450    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54205451    break;
     
    54235454
    54245455/* Line 1806 of yacc.c  */
    5425 #line 567 "parser.yy"
     5456#line 573 "parser.yy"
    54265457    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54275458    break;
     
    54305461
    54315462/* Line 1806 of yacc.c  */
    5432 #line 569 "parser.yy"
     5463#line 575 "parser.yy"
    54335464    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54345465    break;
     
    54375468
    54385469/* Line 1806 of yacc.c  */
    5439 #line 575 "parser.yy"
     5470#line 581 "parser.yy"
    54405471    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54415472    break;
     
    54445475
    54455476/* Line 1806 of yacc.c  */
    5446 #line 581 "parser.yy"
     5477#line 587 "parser.yy"
    54475478    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54485479    break;
     
    54515482
    54525483/* Line 1806 of yacc.c  */
    5453 #line 587 "parser.yy"
     5484#line 593 "parser.yy"
    54545485    { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54555486    break;
     
    54585489
    54595490/* Line 1806 of yacc.c  */
    5460 #line 593 "parser.yy"
     5491#line 599 "parser.yy"
    54615492    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); }
    54625493    break;
     
    54655496
    54665497/* Line 1806 of yacc.c  */
    5467 #line 599 "parser.yy"
     5498#line 605 "parser.yy"
    54685499    { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); }
    54695500    break;
     
    54725503
    54735504/* Line 1806 of yacc.c  */
    5474 #line 605 "parser.yy"
     5505#line 611 "parser.yy"
    54755506    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); }
    54765507    break;
     
    54795510
    54805511/* Line 1806 of yacc.c  */
    5481 #line 608 "parser.yy"
     5512#line 614 "parser.yy"
    54825513    { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); }
    54835514    break;
     
    54865517
    54875518/* Line 1806 of yacc.c  */
    5488 #line 621 "parser.yy"
     5519#line 627 "parser.yy"
    54895520    { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    54905521    break;
     
    54935524
    54945525/* Line 1806 of yacc.c  */
    5495 #line 628 "parser.yy"
     5526#line 634 "parser.yy"
    54965527    { (yyval.en) = nullptr; }
    54975528    break;
     
    55005531
    55015532/* Line 1806 of yacc.c  */
    5502 #line 633 "parser.yy"
     5533#line 639 "parser.yy"
    55035534    { (yyval.op) = OperKinds::Assign; }
    55045535    break;
     
    55075538
    55085539/* Line 1806 of yacc.c  */
    5509 #line 634 "parser.yy"
     5540#line 640 "parser.yy"
    55105541    { (yyval.op) = OperKinds::AtAssn; }
    55115542    break;
     
    55145545
    55155546/* Line 1806 of yacc.c  */
    5516 #line 635 "parser.yy"
     5547#line 641 "parser.yy"
    55175548    { (yyval.op) = OperKinds::MulAssn; }
    55185549    break;
     
    55215552
    55225553/* Line 1806 of yacc.c  */
    5523 #line 636 "parser.yy"
     5554#line 642 "parser.yy"
    55245555    { (yyval.op) = OperKinds::DivAssn; }
    55255556    break;
     
    55285559
    55295560/* Line 1806 of yacc.c  */
    5530 #line 637 "parser.yy"
     5561#line 643 "parser.yy"
    55315562    { (yyval.op) = OperKinds::ModAssn; }
    55325563    break;
     
    55355566
    55365567/* Line 1806 of yacc.c  */
    5537 #line 638 "parser.yy"
     5568#line 644 "parser.yy"
    55385569    { (yyval.op) = OperKinds::PlusAssn; }
    55395570    break;
     
    55425573
    55435574/* Line 1806 of yacc.c  */
    5544 #line 639 "parser.yy"
     5575#line 645 "parser.yy"
    55455576    { (yyval.op) = OperKinds::MinusAssn; }
    55465577    break;
     
    55495580
    55505581/* Line 1806 of yacc.c  */
    5551 #line 640 "parser.yy"
     5582#line 646 "parser.yy"
    55525583    { (yyval.op) = OperKinds::LSAssn; }
    55535584    break;
     
    55565587
    55575588/* Line 1806 of yacc.c  */
    5558 #line 641 "parser.yy"
     5589#line 647 "parser.yy"
    55595590    { (yyval.op) = OperKinds::RSAssn; }
    55605591    break;
     
    55635594
    55645595/* Line 1806 of yacc.c  */
    5565 #line 642 "parser.yy"
     5596#line 648 "parser.yy"
    55665597    { (yyval.op) = OperKinds::AndAssn; }
    55675598    break;
     
    55705601
    55715602/* Line 1806 of yacc.c  */
    5572 #line 643 "parser.yy"
     5603#line 649 "parser.yy"
    55735604    { (yyval.op) = OperKinds::ERAssn; }
    55745605    break;
     
    55775608
    55785609/* Line 1806 of yacc.c  */
    5579 #line 644 "parser.yy"
     5610#line 650 "parser.yy"
    55805611    { (yyval.op) = OperKinds::OrAssn; }
    55815612    break;
     
    55845615
    55855616/* Line 1806 of yacc.c  */
    5586 #line 655 "parser.yy"
     5617#line 661 "parser.yy"
    55875618    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); }
    55885619    break;
     
    55915622
    55925623/* Line 1806 of yacc.c  */
    5593 #line 657 "parser.yy"
     5624#line 663 "parser.yy"
    55945625    { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); }
    55955626    break;
     
    55985629
    55995630/* Line 1806 of yacc.c  */
    5600 #line 663 "parser.yy"
     5631#line 669 "parser.yy"
    56015632    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    56025633    break;
     
    56055636
    56065637/* Line 1806 of yacc.c  */
    5607 #line 669 "parser.yy"
     5638#line 675 "parser.yy"
    56085639    { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    56095640    break;
     
    56125643
    56135644/* Line 1806 of yacc.c  */
    5614 #line 674 "parser.yy"
     5645#line 680 "parser.yy"
    56155646    { (yyval.en) = 0; }
    56165647    break;
     
    56195650
    56205651/* Line 1806 of yacc.c  */
    5621 #line 683 "parser.yy"
     5652#line 689 "parser.yy"
    56225653    { (yyval.sn) = (yyvsp[(1) - (1)].sn); }
    56235654    break;
     
    56265657
    56275658/* Line 1806 of yacc.c  */
    5628 #line 690 "parser.yy"
     5659#line 696 "parser.yy"
    56295660    {
    56305661                        Token fn;
     
    56375668
    56385669/* Line 1806 of yacc.c  */
    5639 #line 700 "parser.yy"
     5670#line 706 "parser.yy"
    56405671    {
    56415672                        (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) );
     
    56465677
    56475678/* Line 1806 of yacc.c  */
    5648 #line 707 "parser.yy"
     5679#line 713 "parser.yy"
    56495680    { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    56505681    break;
     
    56535684
    56545685/* Line 1806 of yacc.c  */
    5655 #line 714 "parser.yy"
     5686#line 720 "parser.yy"
    56565687    { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); }
    56575688    break;
     
    56605691
    56615692/* Line 1806 of yacc.c  */
    5662 #line 720 "parser.yy"
     5693#line 726 "parser.yy"
    56635694    { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } }
    56645695    break;
     
    56675698
    56685699/* Line 1806 of yacc.c  */
    5669 #line 725 "parser.yy"
     5700#line 731 "parser.yy"
    56705701    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    56715702    break;
     
    56745705
    56755706/* Line 1806 of yacc.c  */
    5676 #line 727 "parser.yy"
     5707#line 733 "parser.yy"
    56775708    {   // mark all fields in list
    56785709                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    56855716
    56865717/* Line 1806 of yacc.c  */
    5687 #line 733 "parser.yy"
     5718#line 739 "parser.yy"
    56885719    { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
    56895720    break;
     
    56925723
    56935724/* Line 1806 of yacc.c  */
    5694 #line 740 "parser.yy"
     5725#line 746 "parser.yy"
    56955726    { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } }
    56965727    break;
     
    56995730
    57005731/* Line 1806 of yacc.c  */
    5701 #line 745 "parser.yy"
     5732#line 751 "parser.yy"
    57025733    { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); }
    57035734    break;
     
    57065737
    57075738/* Line 1806 of yacc.c  */
    5708 #line 751 "parser.yy"
     5739#line 757 "parser.yy"
    57095740    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }
    57105741    break;
     
    57135744
    57145745/* Line 1806 of yacc.c  */
    5715 #line 753 "parser.yy"
     5746#line 759 "parser.yy"
    57165747    { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }
    57175748    break;
     
    57205751
    57215752/* Line 1806 of yacc.c  */
    5722 #line 755 "parser.yy"
     5753#line 761 "parser.yy"
    57235754    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57245755    break;
     
    57275758
    57285759/* Line 1806 of yacc.c  */
    5729 #line 757 "parser.yy"
     5760#line 763 "parser.yy"
    57305761    {
    57315762                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    57425773
    57435774/* Line 1806 of yacc.c  */
    5744 #line 767 "parser.yy"
     5775#line 773 "parser.yy"
    57455776    { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57465777    break;
     
    57495780
    57505781/* Line 1806 of yacc.c  */
    5751 #line 769 "parser.yy"
     5782#line 775 "parser.yy"
    57525783    {
    57535784                        StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     
    57595790
    57605791/* Line 1806 of yacc.c  */
    5761 #line 779 "parser.yy"
     5792#line 785 "parser.yy"
    57625793    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    57635794    break;
     
    57665797
    57675798/* Line 1806 of yacc.c  */
    5768 #line 781 "parser.yy"
     5799#line 787 "parser.yy"
    57695800    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    57705801    break;
     
    57735804
    57745805/* Line 1806 of yacc.c  */
    5775 #line 786 "parser.yy"
     5806#line 792 "parser.yy"
    57765807    { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); }
    57775808    break;
     
    57805811
    57815812/* Line 1806 of yacc.c  */
    5782 #line 788 "parser.yy"
     5813#line 794 "parser.yy"
    57835814    { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }
    57845815    break;
     
    57875818
    57885819/* Line 1806 of yacc.c  */
    5789 #line 792 "parser.yy"
     5820#line 798 "parser.yy"
    57905821    { (yyval.sn) = (yyvsp[(2) - (3)].sn); }
    57915822    break;
     
    57945825
    57955826/* Line 1806 of yacc.c  */
    5796 #line 793 "parser.yy"
     5827#line 799 "parser.yy"
    57975828    { (yyval.sn) = new StatementNode( build_default() ); }
    57985829    break;
     
    58015832
    58025833/* Line 1806 of yacc.c  */
    5803 #line 799 "parser.yy"
     5834#line 805 "parser.yy"
    58045835    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); }
    58055836    break;
     
    58085839
    58095840/* Line 1806 of yacc.c  */
    5810 #line 803 "parser.yy"
     5841#line 809 "parser.yy"
    58115842    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58125843    break;
     
    58155846
    58165847/* Line 1806 of yacc.c  */
    5817 #line 808 "parser.yy"
     5848#line 814 "parser.yy"
    58185849    { (yyval.sn) = 0; }
    58195850    break;
     
    58225853
    58235854/* Line 1806 of yacc.c  */
    5824 #line 814 "parser.yy"
     5855#line 820 "parser.yy"
    58255856    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
    58265857    break;
     
    58295860
    58305861/* Line 1806 of yacc.c  */
    5831 #line 816 "parser.yy"
     5862#line 822 "parser.yy"
    58325863    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); }
    58335864    break;
     
    58365867
    58375868/* Line 1806 of yacc.c  */
    5838 #line 821 "parser.yy"
     5869#line 827 "parser.yy"
    58395870    { (yyval.sn) = 0; }
    58405871    break;
     
    58435874
    58445875/* Line 1806 of yacc.c  */
    5845 #line 827 "parser.yy"
     5876#line 833 "parser.yy"
    58465877    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); }
    58475878    break;
     
    58505881
    58515882/* Line 1806 of yacc.c  */
    5852 #line 829 "parser.yy"
     5883#line 835 "parser.yy"
    58535884    { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); }
    58545885    break;
     
    58575888
    58585889/* Line 1806 of yacc.c  */
    5859 #line 831 "parser.yy"
     5890#line 837 "parser.yy"
    58605891    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); }
    58615892    break;
     
    58645895
    58655896/* Line 1806 of yacc.c  */
    5866 #line 833 "parser.yy"
     5897#line 839 "parser.yy"
    58675898    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(3) - (4)].sn)->set_last( (yyvsp[(4) - (4)].sn) ) ) ) ) ) ); }
    58685899    break;
     
    58715902
    58725903/* Line 1806 of yacc.c  */
    5873 #line 838 "parser.yy"
     5904#line 844 "parser.yy"
    58745905    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    58755906    break;
     
    58785909
    58795910/* Line 1806 of yacc.c  */
    5880 #line 844 "parser.yy"
     5911#line 850 "parser.yy"
    58815912    { (yyval.sn) = 0; }
    58825913    break;
     
    58855916
    58865917/* Line 1806 of yacc.c  */
    5887 #line 846 "parser.yy"
     5918#line 852 "parser.yy"
    58885919    { (yyval.sn) = 0; }
    58895920    break;
     
    58925923
    58935924/* Line 1806 of yacc.c  */
    5894 #line 851 "parser.yy"
     5925#line 857 "parser.yy"
    58955926    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    58965927    break;
     
    58995930
    59005931/* Line 1806 of yacc.c  */
    5901 #line 853 "parser.yy"
     5932#line 859 "parser.yy"
    59025933    { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); }
    59035934    break;
     
    59065937
    59075938/* Line 1806 of yacc.c  */
    5908 #line 855 "parser.yy"
     5939#line 861 "parser.yy"
    59095940    { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }
    59105941    break;
     
    59135944
    59145945/* Line 1806 of yacc.c  */
    5915 #line 860 "parser.yy"
     5946#line 866 "parser.yy"
    59165947    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); }
    59175948    break;
     
    59205951
    59215952/* Line 1806 of yacc.c  */
    5922 #line 862 "parser.yy"
     5953#line 868 "parser.yy"
    59235954    { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); }
    59245955    break;
     
    59275958
    59285959/* Line 1806 of yacc.c  */
    5929 #line 867 "parser.yy"
     5960#line 873 "parser.yy"
    59305961    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }
    59315962    break;
     
    59345965
    59355966/* Line 1806 of yacc.c  */
    5936 #line 871 "parser.yy"
     5967#line 877 "parser.yy"
    59375968    { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
    59385969    break;
     
    59415972
    59425973/* Line 1806 of yacc.c  */
    5943 #line 874 "parser.yy"
     5974#line 880 "parser.yy"
    59445975    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); }
    59455976    break;
     
    59485979
    59495980/* Line 1806 of yacc.c  */
    5950 #line 878 "parser.yy"
     5981#line 884 "parser.yy"
    59515982    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); }
    59525983    break;
     
    59555986
    59565987/* Line 1806 of yacc.c  */
    5957 #line 881 "parser.yy"
     5988#line 887 "parser.yy"
    59585989    { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); }
    59595990    break;
     
    59625993
    59635994/* Line 1806 of yacc.c  */
    5964 #line 885 "parser.yy"
     5995#line 891 "parser.yy"
    59655996    { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); }
    59665997    break;
     
    59696000
    59706001/* Line 1806 of yacc.c  */
    5971 #line 887 "parser.yy"
     6002#line 893 "parser.yy"
    59726003    { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); }
    59736004    break;
     
    59766007
    59776008/* Line 1806 of yacc.c  */
    5978 #line 889 "parser.yy"
     6009#line 895 "parser.yy"
    59796010    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    59806011    break;
     
    59836014
    59846015/* Line 1806 of yacc.c  */
    5985 #line 891 "parser.yy"
     6016#line 897 "parser.yy"
    59866017    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    59876018    break;
     
    59906021
    59916022/* Line 1806 of yacc.c  */
    5992 #line 893 "parser.yy"
     6023#line 899 "parser.yy"
    59936024    { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); }
    59946025    break;
     
    59976028
    59986029/* Line 1806 of yacc.c  */
    5999 #line 898 "parser.yy"
     6030#line 904 "parser.yy"
    60006031    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }
    60016032    break;
     
    60046035
    60056036/* Line 1806 of yacc.c  */
    6006 #line 900 "parser.yy"
     6037#line 906 "parser.yy"
    60076038    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }
    60086039    break;
     
    60116042
    60126043/* Line 1806 of yacc.c  */
    6013 #line 902 "parser.yy"
     6044#line 908 "parser.yy"
    60146045    { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }
    60156046    break;
     
    60186049
    60196050/* Line 1806 of yacc.c  */
    6020 #line 909 "parser.yy"
     6051#line 915 "parser.yy"
    60216052    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60226053    break;
     
    60256056
    60266057/* Line 1806 of yacc.c  */
    6027 #line 911 "parser.yy"
     6058#line 917 "parser.yy"
    60286059    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60296060    break;
     
    60326063
    60336064/* Line 1806 of yacc.c  */
    6034 #line 913 "parser.yy"
     6065#line 919 "parser.yy"
    60356066    { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60366067    break;
     
    60396070
    60406071/* Line 1806 of yacc.c  */
    6041 #line 915 "parser.yy"
     6072#line 921 "parser.yy"
    60426073    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60436074    break;
     
    60466077
    60476078/* Line 1806 of yacc.c  */
    6048 #line 920 "parser.yy"
     6079#line 926 "parser.yy"
    60496080    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60506081    break;
     
    60536084
    60546085/* Line 1806 of yacc.c  */
    6055 #line 922 "parser.yy"
     6086#line 928 "parser.yy"
    60566087    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    60576088    break;
     
    60606091
    60616092/* Line 1806 of yacc.c  */
    6062 #line 924 "parser.yy"
     6093#line 930 "parser.yy"
    60636094    { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60646095    break;
     
    60676098
    60686099/* Line 1806 of yacc.c  */
    6069 #line 926 "parser.yy"
     6100#line 932 "parser.yy"
    60706101    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    60716102    break;
     
    60746105
    60756106/* Line 1806 of yacc.c  */
    6076 #line 931 "parser.yy"
     6107#line 937 "parser.yy"
    60776108    {
    60786109                        (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) );
     
    60836114
    60846115/* Line 1806 of yacc.c  */
    6085 #line 944 "parser.yy"
     6116#line 950 "parser.yy"
    60866117    {
    60876118                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    60936124
    60946125/* Line 1806 of yacc.c  */
    6095 #line 949 "parser.yy"
     6126#line 955 "parser.yy"
    60966127    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    60976128    break;
     
    61006131
    61016132/* Line 1806 of yacc.c  */
    6102 #line 951 "parser.yy"
     6133#line 957 "parser.yy"
    61036134    {
    61046135                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    61106141
    61116142/* Line 1806 of yacc.c  */
    6112 #line 960 "parser.yy"
     6143#line 966 "parser.yy"
    61136144    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); }
    61146145    break;
     
    61176148
    61186149/* Line 1806 of yacc.c  */
    6119 #line 962 "parser.yy"
     6150#line 968 "parser.yy"
    61206151    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); }
    61216152    break;
     
    61246155
    61256156/* Line 1806 of yacc.c  */
    6126 #line 964 "parser.yy"
     6157#line 970 "parser.yy"
    61276158    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); }
    61286159    break;
     
    61316162
    61326163/* Line 1806 of yacc.c  */
    6133 #line 966 "parser.yy"
     6164#line 972 "parser.yy"
    61346165    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ) ); }
    61356166    break;
     
    61386169
    61396170/* Line 1806 of yacc.c  */
    6140 #line 968 "parser.yy"
     6171#line 974 "parser.yy"
    61416172    { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ) ); }
    61426173    break;
     
    61456176
    61466177/* Line 1806 of yacc.c  */
    6147 #line 973 "parser.yy"
     6178#line 979 "parser.yy"
    61486179    { (yyval.flag) = false; }
    61496180    break;
     
    61526183
    61536184/* Line 1806 of yacc.c  */
    6154 #line 975 "parser.yy"
     6185#line 981 "parser.yy"
    61556186    { (yyval.flag) = true; }
    61566187    break;
     
    61596190
    61606191/* Line 1806 of yacc.c  */
    6161 #line 980 "parser.yy"
     6192#line 986 "parser.yy"
    61626193    { (yyval.en) = 0; }
    61636194    break;
     
    61666197
    61676198/* Line 1806 of yacc.c  */
    6168 #line 987 "parser.yy"
     6199#line 993 "parser.yy"
    61696200    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); }
    61706201    break;
     
    61736204
    61746205/* Line 1806 of yacc.c  */
    6175 #line 992 "parser.yy"
     6206#line 998 "parser.yy"
    61766207    { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }
    61776208    break;
     
    61806211
    61816212/* Line 1806 of yacc.c  */
    6182 #line 994 "parser.yy"
     6213#line 1000 "parser.yy"
    61836214    { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }
    61846215    break;
     
    61876218
    61886219/* Line 1806 of yacc.c  */
    6189 #line 999 "parser.yy"
     6220#line 1005 "parser.yy"
    61906221    { (yyval.en) = 0; }
    61916222    break;
     
    61946225
    61956226/* Line 1806 of yacc.c  */
    6196 #line 1001 "parser.yy"
     6227#line 1007 "parser.yy"
    61976228    { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); }
    61986229    break;
     
    62016232
    62026233/* Line 1806 of yacc.c  */
    6203 #line 1003 "parser.yy"
     6234#line 1009 "parser.yy"
    62046235    { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); }
    62056236    break;
     
    62086239
    62096240/* Line 1806 of yacc.c  */
    6210 #line 1008 "parser.yy"
     6241#line 1014 "parser.yy"
    62116242    {
    62126243                        (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) );
     
    62186249
    62196250/* Line 1806 of yacc.c  */
    6220 #line 1013 "parser.yy"
     6251#line 1019 "parser.yy"
    62216252    {
    62226253                        (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) );
     
    62286259
    62296260/* Line 1806 of yacc.c  */
    6230 #line 1023 "parser.yy"
     6261#line 1029 "parser.yy"
    62316262    { (yyval.decl) = 0; }
    62326263    break;
     
    62356266
    62366267/* Line 1806 of yacc.c  */
    6237 #line 1030 "parser.yy"
     6268#line 1036 "parser.yy"
    62386269    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    62396270    break;
     
    62426273
    62436274/* Line 1806 of yacc.c  */
    6244 #line 1035 "parser.yy"
     6275#line 1041 "parser.yy"
    62456276    { (yyval.decl) = 0; }
    62466277    break;
     
    62496280
    62506281/* Line 1806 of yacc.c  */
    6251 #line 1042 "parser.yy"
     6282#line 1048 "parser.yy"
    62526283    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    62536284    break;
     
    62566287
    62576288/* Line 1806 of yacc.c  */
    6258 #line 1056 "parser.yy"
     6289#line 1062 "parser.yy"
    62596290    {}
    62606291    break;
     
    62636294
    62646295/* Line 1806 of yacc.c  */
    6265 #line 1057 "parser.yy"
     6296#line 1063 "parser.yy"
    62666297    {}
    62676298    break;
     
    62706301
    62716302/* Line 1806 of yacc.c  */
    6272 #line 1086 "parser.yy"
     6303#line 1092 "parser.yy"
    62736304    {
    62746305                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    62806311
    62816312/* Line 1806 of yacc.c  */
    6282 #line 1093 "parser.yy"
     6313#line 1099 "parser.yy"
    62836314    {
    62846315                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    62906321
    62916322/* Line 1806 of yacc.c  */
    6292 #line 1098 "parser.yy"
     6323#line 1104 "parser.yy"
    62936324    {
    62946325                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID );
     
    63006331
    63016332/* Line 1806 of yacc.c  */
    6302 #line 1108 "parser.yy"
     6333#line 1114 "parser.yy"
    63036334    {
    63046335                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63106341
    63116342/* Line 1806 of yacc.c  */
    6312 #line 1113 "parser.yy"
     6343#line 1119 "parser.yy"
    63136344    {
    63146345                        typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) );
     
    63206351
    63216352/* Line 1806 of yacc.c  */
    6322 #line 1118 "parser.yy"
     6353#line 1124 "parser.yy"
    63236354    {
    63246355                        typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) );
     
    63306361
    63316362/* Line 1806 of yacc.c  */
    6332 #line 1126 "parser.yy"
     6363#line 1132 "parser.yy"
    63336364    {
    63346365                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63406371
    63416372/* Line 1806 of yacc.c  */
    6342 #line 1131 "parser.yy"
     6373#line 1137 "parser.yy"
    63436374    {
    63446375                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63506381
    63516382/* Line 1806 of yacc.c  */
    6352 #line 1136 "parser.yy"
     6383#line 1142 "parser.yy"
    63536384    {
    63546385                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63606391
    63616392/* Line 1806 of yacc.c  */
    6362 #line 1141 "parser.yy"
     6393#line 1147 "parser.yy"
    63636394    {
    63646395                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    63706401
    63716402/* Line 1806 of yacc.c  */
    6372 #line 1146 "parser.yy"
     6403#line 1152 "parser.yy"
    63736404    {
    63746405                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    63806411
    63816412/* Line 1806 of yacc.c  */
    6382 #line 1177 "parser.yy"
     6413#line 1183 "parser.yy"
    63836414    {
    63846415                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    63896420
    63906421/* Line 1806 of yacc.c  */
    6391 #line 1181 "parser.yy"
     6422#line 1187 "parser.yy"
    63926423    {
    63936424                        (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true );
     
    63986429
    63996430/* Line 1806 of yacc.c  */
    6400 #line 1188 "parser.yy"
     6431#line 1194 "parser.yy"
    64016432    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    64026433    break;
     
    64056436
    64066437/* Line 1806 of yacc.c  */
    6407 #line 1192 "parser.yy"
     6438#line 1198 "parser.yy"
    64086439    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); }
    64096440    break;
     
    64126443
    64136444/* Line 1806 of yacc.c  */
    6414 #line 1197 "parser.yy"
     6445#line 1203 "parser.yy"
    64156446    {
    64166447                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64226453
    64236454/* Line 1806 of yacc.c  */
    6424 #line 1202 "parser.yy"
     6455#line 1208 "parser.yy"
    64256456    {
    64266457                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64326463
    64336464/* Line 1806 of yacc.c  */
    6434 #line 1207 "parser.yy"
     6465#line 1213 "parser.yy"
    64356466    {
    64366467                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD );
     
    64426473
    64436474/* Line 1806 of yacc.c  */
    6444 #line 1218 "parser.yy"
     6475#line 1224 "parser.yy"
    64456476    {
    64466477                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64526483
    64536484/* Line 1806 of yacc.c  */
    6454 #line 1223 "parser.yy"
     6485#line 1229 "parser.yy"
    64556486    {
    64566487                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64626493
    64636494/* Line 1806 of yacc.c  */
    6464 #line 1228 "parser.yy"
     6495#line 1234 "parser.yy"
    64656496    {
    64666497                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64726503
    64736504/* Line 1806 of yacc.c  */
    6474 #line 1233 "parser.yy"
     6505#line 1239 "parser.yy"
    64756506    {
    64766507                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64826513
    64836514/* Line 1806 of yacc.c  */
    6484 #line 1238 "parser.yy"
     6515#line 1244 "parser.yy"
    64856516    {
    64866517                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     
    64926523
    64936524/* Line 1806 of yacc.c  */
    6494 #line 1247 "parser.yy"
     6525#line 1253 "parser.yy"
    64956526    {
    64966527                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD );
     
    65026533
    65036534/* Line 1806 of yacc.c  */
    6504 #line 1252 "parser.yy"
     6535#line 1258 "parser.yy"
    65056536    {
    65066537                        typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD );
     
    65126543
    65136544/* Line 1806 of yacc.c  */
    6514 #line 1269 "parser.yy"
     6545#line 1275 "parser.yy"
    65156546    {
    65166547                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65226553
    65236554/* Line 1806 of yacc.c  */
    6524 #line 1274 "parser.yy"
     6555#line 1280 "parser.yy"
    65256556    {
    65266557                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    65326563
    65336564/* Line 1806 of yacc.c  */
    6534 #line 1296 "parser.yy"
     6565#line 1302 "parser.yy"
    65356566    { (yyval.decl) = 0; }
    65366567    break;
     
    65396570
    65406571/* Line 1806 of yacc.c  */
    6541 #line 1308 "parser.yy"
     6572#line 1314 "parser.yy"
    65426573    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    65436574    break;
     
    65466577
    65476578/* Line 1806 of yacc.c  */
    6548 #line 1319 "parser.yy"
     6579#line 1325 "parser.yy"
    65496580    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); }
    65506581    break;
     
    65536584
    65546585/* Line 1806 of yacc.c  */
    6555 #line 1321 "parser.yy"
     6586#line 1327 "parser.yy"
    65566587    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); }
    65576588    break;
     
    65606591
    65616592/* Line 1806 of yacc.c  */
    6562 #line 1323 "parser.yy"
     6593#line 1329 "parser.yy"
    65636594    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); }
    65646595    break;
     
    65676598
    65686599/* Line 1806 of yacc.c  */
    6569 #line 1325 "parser.yy"
     6600#line 1331 "parser.yy"
    65706601    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
    65716602    break;
     
    65746605
    65756606/* Line 1806 of yacc.c  */
    6576 #line 1327 "parser.yy"
     6607#line 1333 "parser.yy"
    65776608    { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
    65786609    break;
     
    65816612
    65826613/* Line 1806 of yacc.c  */
    6583 #line 1329 "parser.yy"
     6614#line 1335 "parser.yy"
    65846615    {
    65856616                        typedefTable.enterScope();
     
    65906621
    65916622/* Line 1806 of yacc.c  */
    6592 #line 1333 "parser.yy"
     6623#line 1339 "parser.yy"
    65936624    {
    65946625                        typedefTable.leaveScope();
     
    66006631
    66016632/* Line 1806 of yacc.c  */
    6602 #line 1342 "parser.yy"
     6633#line 1348 "parser.yy"
    66036634    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66046635    break;
     
    66076638
    66086639/* Line 1806 of yacc.c  */
    6609 #line 1344 "parser.yy"
     6640#line 1350 "parser.yy"
    66106641    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    66116642    break;
     
    66146645
    66156646/* Line 1806 of yacc.c  */
    6616 #line 1355 "parser.yy"
     6647#line 1361 "parser.yy"
    66176648    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    66186649    break;
     
    66216652
    66226653/* Line 1806 of yacc.c  */
    6623 #line 1360 "parser.yy"
     6654#line 1366 "parser.yy"
    66246655    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
    66256656    break;
     
    66286659
    66296660/* Line 1806 of yacc.c  */
    6630 #line 1362 "parser.yy"
     6661#line 1368 "parser.yy"
    66316662    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); }
    66326663    break;
     
    66356666
    66366667/* Line 1806 of yacc.c  */
    6637 #line 1364 "parser.yy"
     6668#line 1370 "parser.yy"
    66386669    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
    66396670    break;
     
    66426673
    66436674/* Line 1806 of yacc.c  */
    6644 #line 1366 "parser.yy"
     6675#line 1372 "parser.yy"
    66456676    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    66466677    break;
     
    66496680
    66506681/* Line 1806 of yacc.c  */
    6651 #line 1369 "parser.yy"
     6682#line 1375 "parser.yy"
    66526683    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; }
    66536684    break;
     
    66566687
    66576688/* Line 1806 of yacc.c  */
    6658 #line 1371 "parser.yy"
     6689#line 1377 "parser.yy"
    66596690    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
    66606691    break;
     
    66636694
    66646695/* Line 1806 of yacc.c  */
    6665 #line 1374 "parser.yy"
     6696#line 1380 "parser.yy"
    66666697    { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; }
    66676698    break;
     
    66706701
    66716702/* Line 1806 of yacc.c  */
    6672 #line 1376 "parser.yy"
     6703#line 1382 "parser.yy"
    66736704    { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }
    66746705    break;
     
    66776708
    66786709/* Line 1806 of yacc.c  */
    6679 #line 1381 "parser.yy"
     6710#line 1387 "parser.yy"
    66806711    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    66816712    break;
     
    66846715
    66856716/* Line 1806 of yacc.c  */
    6686 #line 1383 "parser.yy"
     6717#line 1389 "parser.yy"
    66876718    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); }
    66886719    break;
     
    66916722
    66926723/* Line 1806 of yacc.c  */
    6693 #line 1385 "parser.yy"
     6724#line 1391 "parser.yy"
    66946725    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    66956726    break;
     
    66986729
    66996730/* Line 1806 of yacc.c  */
    6700 #line 1387 "parser.yy"
     6731#line 1393 "parser.yy"
    67016732    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); }
    67026733    break;
     
    67056736
    67066737/* Line 1806 of yacc.c  */
    6707 #line 1389 "parser.yy"
     6738#line 1395 "parser.yy"
    67086739    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); }
    67096740    break;
     
    67126743
    67136744/* Line 1806 of yacc.c  */
    6714 #line 1391 "parser.yy"
     6745#line 1397 "parser.yy"
    67156746    { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); }
    67166747    break;
     
    67196750
    67206751/* Line 1806 of yacc.c  */
    6721 #line 1393 "parser.yy"
     6752#line 1399 "parser.yy"
    67226753    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
    67236754    break;
     
    67266757
    67276758/* Line 1806 of yacc.c  */
    6728 #line 1395 "parser.yy"
     6759#line 1401 "parser.yy"
    67296760    { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
    67306761    break;
     
    67336764
    67346765/* Line 1806 of yacc.c  */
    6735 #line 1397 "parser.yy"
     6766#line 1403 "parser.yy"
    67366767    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    67376768    break;
     
    67406771
    67416772/* Line 1806 of yacc.c  */
    6742 #line 1399 "parser.yy"
     6773#line 1405 "parser.yy"
    67436774    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    67446775    break;
     
    67476778
    67486779/* Line 1806 of yacc.c  */
    6749 #line 1401 "parser.yy"
     6780#line 1407 "parser.yy"
    67506781    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
    67516782    break;
     
    67546785
    67556786/* Line 1806 of yacc.c  */
    6756 #line 1403 "parser.yy"
     6787#line 1409 "parser.yy"
    67576788    { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
    67586789    break;
     
    67616792
    67626793/* Line 1806 of yacc.c  */
    6763 #line 1405 "parser.yy"
     6794#line 1411 "parser.yy"
    67646795    { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    67656796    break;
     
    67686799
    67696800/* Line 1806 of yacc.c  */
    6770 #line 1407 "parser.yy"
     6801#line 1413 "parser.yy"
    67716802    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    67726803    break;
     
    67756806
    67766807/* Line 1806 of yacc.c  */
    6777 #line 1409 "parser.yy"
     6808#line 1415 "parser.yy"
    67786809    { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    67796810    break;
     
    67826813
    67836814/* Line 1806 of yacc.c  */
    6784 #line 1416 "parser.yy"
     6815#line 1422 "parser.yy"
    67856816    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    67866817    break;
     
    67896820
    67906821/* Line 1806 of yacc.c  */
    6791 #line 1418 "parser.yy"
     6822#line 1424 "parser.yy"
    67926823    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    67936824    break;
     
    67966827
    67976828/* Line 1806 of yacc.c  */
    6798 #line 1420 "parser.yy"
     6829#line 1426 "parser.yy"
    67996830    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68006831    break;
     
    68036834
    68046835/* Line 1806 of yacc.c  */
    6805 #line 1422 "parser.yy"
     6836#line 1428 "parser.yy"
    68066837    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); }
    68076838    break;
     
    68106841
    68116842/* Line 1806 of yacc.c  */
    6812 #line 1428 "parser.yy"
     6843#line 1434 "parser.yy"
    68136844    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68146845    break;
     
    68176848
    68186849/* Line 1806 of yacc.c  */
    6819 #line 1435 "parser.yy"
     6850#line 1441 "parser.yy"
    68206851    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68216852    break;
     
    68246855
    68256856/* Line 1806 of yacc.c  */
    6826 #line 1437 "parser.yy"
     6857#line 1443 "parser.yy"
    68276858    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68286859    break;
     
    68316862
    68326863/* Line 1806 of yacc.c  */
    6833 #line 1439 "parser.yy"
     6864#line 1445 "parser.yy"
    68346865    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); }
    68356866    break;
     
    68386869
    68396870/* Line 1806 of yacc.c  */
    6840 #line 1444 "parser.yy"
     6871#line 1450 "parser.yy"
    68416872    { (yyval.decl) = (yyvsp[(3) - (4)].decl); }
    68426873    break;
     
    68456876
    68466877/* Line 1806 of yacc.c  */
    6847 #line 1446 "parser.yy"
     6878#line 1452 "parser.yy"
    68486879    { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); }
    68496880    break;
     
    68526883
    68536884/* Line 1806 of yacc.c  */
    6854 #line 1448 "parser.yy"
     6885#line 1454 "parser.yy"
    68556886    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); }
    68566887    break;
     
    68596890
    68606891/* Line 1806 of yacc.c  */
    6861 #line 1450 "parser.yy"
     6892#line 1456 "parser.yy"
    68626893    { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    68636894    break;
     
    68666897
    68676898/* Line 1806 of yacc.c  */
    6868 #line 1456 "parser.yy"
     6899#line 1462 "parser.yy"
    68696900    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68706901    break;
     
    68736904
    68746905/* Line 1806 of yacc.c  */
    6875 #line 1458 "parser.yy"
     6906#line 1464 "parser.yy"
    68766907    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68776908    break;
     
    68806911
    68816912/* Line 1806 of yacc.c  */
    6882 #line 1460 "parser.yy"
     6913#line 1466 "parser.yy"
    68836914    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    68846915    break;
     
    68876918
    68886919/* Line 1806 of yacc.c  */
    6889 #line 1466 "parser.yy"
     6920#line 1472 "parser.yy"
    68906921    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    68916922    break;
     
    68946925
    68956926/* Line 1806 of yacc.c  */
    6896 #line 1468 "parser.yy"
     6927#line 1474 "parser.yy"
    68976928    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    68986929    break;
     
    69016932
    69026933/* Line 1806 of yacc.c  */
    6903 #line 1474 "parser.yy"
     6934#line 1480 "parser.yy"
    69046935    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69056936    break;
     
    69086939
    69096940/* Line 1806 of yacc.c  */
    6910 #line 1476 "parser.yy"
     6941#line 1482 "parser.yy"
    69116942    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69126943    break;
     
    69156946
    69166947/* Line 1806 of yacc.c  */
    6917 #line 1478 "parser.yy"
     6948#line 1484 "parser.yy"
    69186949    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    69196950    break;
     
    69226953
    69236954/* Line 1806 of yacc.c  */
    6924 #line 1483 "parser.yy"
     6955#line 1489 "parser.yy"
    69256956    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); }
    69266957    break;
     
    69296960
    69306961/* Line 1806 of yacc.c  */
    6931 #line 1485 "parser.yy"
     6962#line 1491 "parser.yy"
    69326963    { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    69336964    break;
     
    69366967
    69376968/* Line 1806 of yacc.c  */
    6938 #line 1487 "parser.yy"
     6969#line 1493 "parser.yy"
    69396970    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    69406971    break;
     
    69436974
    69446975/* Line 1806 of yacc.c  */
    6945 #line 1497 "parser.yy"
     6976#line 1503 "parser.yy"
    69466977    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); }
    69476978    break;
     
    69506981
    69516982/* Line 1806 of yacc.c  */
    6952 #line 1499 "parser.yy"
     6983#line 1505 "parser.yy"
    69536984    {
    69546985                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    69606991
    69616992/* Line 1806 of yacc.c  */
    6962 #line 1504 "parser.yy"
     6993#line 1510 "parser.yy"
    69636994    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    69646995    break;
     
    69676998
    69686999/* Line 1806 of yacc.c  */
    6969 #line 1506 "parser.yy"
     7000#line 1512 "parser.yy"
    69707001    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); }
    69717002    break;
     
    69747005
    69757006/* Line 1806 of yacc.c  */
    6976 #line 1508 "parser.yy"
     7007#line 1514 "parser.yy"
    69777008    { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); }
    69787009    break;
     
    69817012
    69827013/* Line 1806 of yacc.c  */
    6983 #line 1510 "parser.yy"
     7014#line 1516 "parser.yy"
    69847015    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    69857016    break;
     
    69887019
    69897020/* Line 1806 of yacc.c  */
    6990 #line 1515 "parser.yy"
     7021#line 1521 "parser.yy"
    69917022    { (yyval.aggKey) = DeclarationNode::Struct; }
    69927023    break;
     
    69957026
    69967027/* Line 1806 of yacc.c  */
    6997 #line 1517 "parser.yy"
     7028#line 1523 "parser.yy"
    69987029    { (yyval.aggKey) = DeclarationNode::Union; }
    69997030    break;
     
    70027033
    70037034/* Line 1806 of yacc.c  */
    7004 #line 1522 "parser.yy"
     7035#line 1528 "parser.yy"
    70057036    { (yyval.decl) = 0; }
    70067037    break;
     
    70097040
    70107041/* Line 1806 of yacc.c  */
    7011 #line 1524 "parser.yy"
     7042#line 1530 "parser.yy"
    70127043    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    70137044    break;
     
    70167047
    70177048/* Line 1806 of yacc.c  */
    7018 #line 1530 "parser.yy"
     7049#line 1536 "parser.yy"
    70197050    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
    70207051    break;
     
    70237054
    70247055/* Line 1806 of yacc.c  */
    7025 #line 1533 "parser.yy"
     7056#line 1539 "parser.yy"
    70267057    {   // mark all fields in list
    70277058                        for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    70347065
    70357066/* Line 1806 of yacc.c  */
    7036 #line 1543 "parser.yy"
     7067#line 1549 "parser.yy"
    70377068    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); }
    70387069    break;
     
    70417072
    70427073/* Line 1806 of yacc.c  */
    7043 #line 1545 "parser.yy"
     7074#line 1551 "parser.yy"
    70447075    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); }
    70457076    break;
     
    70487079
    70497080/* Line 1806 of yacc.c  */
    7050 #line 1547 "parser.yy"
     7081#line 1553 "parser.yy"
    70517082    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); }
    70527083    break;
     
    70557086
    70567087/* Line 1806 of yacc.c  */
    7057 #line 1552 "parser.yy"
     7088#line 1558 "parser.yy"
    70587089    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    70597090    break;
     
    70627093
    70637094/* Line 1806 of yacc.c  */
    7064 #line 1554 "parser.yy"
     7095#line 1560 "parser.yy"
    70657096    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); }
    70667097    break;
     
    70697100
    70707101/* Line 1806 of yacc.c  */
    7071 #line 1559 "parser.yy"
     7102#line 1565 "parser.yy"
    70727103    { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ }
    70737104    break;
     
    70767107
    70777108/* Line 1806 of yacc.c  */
    7078 #line 1561 "parser.yy"
     7109#line 1567 "parser.yy"
    70797110    { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); }
    70807111    break;
     
    70837114
    70847115/* Line 1806 of yacc.c  */
    7085 #line 1564 "parser.yy"
     7116#line 1570 "parser.yy"
    70867117    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
    70877118    break;
     
    70907121
    70917122/* Line 1806 of yacc.c  */
    7092 #line 1567 "parser.yy"
     7123#line 1573 "parser.yy"
    70937124    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }
    70947125    break;
     
    70977128
    70987129/* Line 1806 of yacc.c  */
    7099 #line 1573 "parser.yy"
     7130#line 1579 "parser.yy"
    71007131    { (yyval.en) = 0; }
    71017132    break;
     
    71047135
    71057136/* Line 1806 of yacc.c  */
    7106 #line 1575 "parser.yy"
     7137#line 1581 "parser.yy"
    71077138    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    71087139    break;
     
    71117142
    71127143/* Line 1806 of yacc.c  */
    7113 #line 1580 "parser.yy"
     7144#line 1586 "parser.yy"
    71147145    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    71157146    break;
     
    71187149
    71197150/* Line 1806 of yacc.c  */
    7120 #line 1589 "parser.yy"
     7151#line 1595 "parser.yy"
    71217152    { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); }
    71227153    break;
     
    71257156
    71267157/* Line 1806 of yacc.c  */
    7127 #line 1591 "parser.yy"
     7158#line 1597 "parser.yy"
    71287159    {
    71297160                        typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) );
     
    71357166
    71367167/* Line 1806 of yacc.c  */
    7137 #line 1596 "parser.yy"
     7168#line 1602 "parser.yy"
    71387169    { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); }
    71397170    break;
     
    71427173
    71437174/* Line 1806 of yacc.c  */
    7144 #line 1598 "parser.yy"
     7175#line 1604 "parser.yy"
    71457176    { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); }
    71467177    break;
     
    71497180
    71507181/* Line 1806 of yacc.c  */
    7151 #line 1603 "parser.yy"
     7182#line 1609 "parser.yy"
    71527183    { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); }
    71537184    break;
     
    71567187
    71577188/* Line 1806 of yacc.c  */
    7158 #line 1605 "parser.yy"
     7189#line 1611 "parser.yy"
    71597190    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); }
    71607191    break;
     
    71637194
    71647195/* Line 1806 of yacc.c  */
    7165 #line 1610 "parser.yy"
     7196#line 1616 "parser.yy"
    71667197    { (yyval.en) = 0; }
    71677198    break;
     
    71707201
    71717202/* Line 1806 of yacc.c  */
    7172 #line 1612 "parser.yy"
     7203#line 1618 "parser.yy"
    71737204    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    71747205    break;
     
    71777208
    71787209/* Line 1806 of yacc.c  */
    7179 #line 1619 "parser.yy"
     7210#line 1625 "parser.yy"
    71807211    { (yyval.decl) = 0; }
    71817212    break;
     
    71847215
    71857216/* Line 1806 of yacc.c  */
    7186 #line 1627 "parser.yy"
     7217#line 1633 "parser.yy"
    71877218    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    71887219    break;
     
    71917222
    71927223/* Line 1806 of yacc.c  */
    7193 #line 1629 "parser.yy"
     7224#line 1635 "parser.yy"
    71947225    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    71957226    break;
     
    71987229
    71997230/* Line 1806 of yacc.c  */
    7200 #line 1631 "parser.yy"
     7231#line 1637 "parser.yy"
    72017232    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72027233    break;
     
    72057236
    72067237/* Line 1806 of yacc.c  */
    7207 #line 1639 "parser.yy"
     7238#line 1645 "parser.yy"
    72087239    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72097240    break;
     
    72127243
    72137244/* Line 1806 of yacc.c  */
    7214 #line 1641 "parser.yy"
     7245#line 1647 "parser.yy"
    72157246    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72167247    break;
     
    72197250
    72207251/* Line 1806 of yacc.c  */
    7221 #line 1643 "parser.yy"
     7252#line 1649 "parser.yy"
    72227253    { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); }
    72237254    break;
     
    72267257
    72277258/* Line 1806 of yacc.c  */
    7228 #line 1649 "parser.yy"
     7259#line 1655 "parser.yy"
    72297260    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72307261    break;
     
    72337264
    72347265/* Line 1806 of yacc.c  */
    7235 #line 1654 "parser.yy"
     7266#line 1660 "parser.yy"
    72367267    { (yyval.decl) = 0; }
    72377268    break;
     
    72407271
    72417272/* Line 1806 of yacc.c  */
    7242 #line 1661 "parser.yy"
     7273#line 1667 "parser.yy"
    72437274    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); }
    72447275    break;
     
    72477278
    72487279/* Line 1806 of yacc.c  */
    7249 #line 1668 "parser.yy"
     7280#line 1674 "parser.yy"
    72507281    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72517282    break;
     
    72547285
    72557286/* Line 1806 of yacc.c  */
    7256 #line 1670 "parser.yy"
     7287#line 1676 "parser.yy"
    72577288    { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); }
    72587289    break;
     
    72617292
    72627293/* Line 1806 of yacc.c  */
    7263 #line 1679 "parser.yy"
     7294#line 1685 "parser.yy"
    72647295    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
    72657296    break;
     
    72687299
    72697300/* Line 1806 of yacc.c  */
    7270 #line 1682 "parser.yy"
     7301#line 1688 "parser.yy"
    72717302    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }
    72727303    break;
     
    72757306
    72767307/* Line 1806 of yacc.c  */
    7277 #line 1684 "parser.yy"
     7308#line 1690 "parser.yy"
    72787309    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); }
    72797310    break;
     
    72827313
    72837314/* Line 1806 of yacc.c  */
    7284 #line 1694 "parser.yy"
     7315#line 1700 "parser.yy"
    72857316    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    72867317    break;
     
    72897320
    72907321/* Line 1806 of yacc.c  */
    7291 #line 1700 "parser.yy"
     7322#line 1706 "parser.yy"
    72927323    {
    72937324                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    72997330
    73007331/* Line 1806 of yacc.c  */
    7301 #line 1705 "parser.yy"
     7332#line 1711 "parser.yy"
    73027333    {
    73037334                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    73097340
    73107341/* Line 1806 of yacc.c  */
    7311 #line 1714 "parser.yy"
     7342#line 1720 "parser.yy"
    73127343    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73137344    break;
     
    73167347
    73177348/* Line 1806 of yacc.c  */
    7318 #line 1723 "parser.yy"
     7349#line 1729 "parser.yy"
    73197350    { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); }
    73207351    break;
     
    73237354
    73247355/* Line 1806 of yacc.c  */
    7325 #line 1725 "parser.yy"
     7356#line 1731 "parser.yy"
    73267357    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); }
    73277358    break;
     
    73307361
    73317362/* Line 1806 of yacc.c  */
    7332 #line 1750 "parser.yy"
     7363#line 1756 "parser.yy"
    73337364    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73347365    break;
     
    73377368
    73387369/* Line 1806 of yacc.c  */
    7339 #line 1758 "parser.yy"
     7370#line 1764 "parser.yy"
    73407371    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); }
    73417372    break;
     
    73447375
    73457376/* Line 1806 of yacc.c  */
    7346 #line 1763 "parser.yy"
     7377#line 1769 "parser.yy"
    73477378    { (yyval.in) = 0; }
    73487379    break;
     
    73517382
    73527383/* Line 1806 of yacc.c  */
    7353 #line 1765 "parser.yy"
     7384#line 1771 "parser.yy"
    73547385    { (yyval.in) = (yyvsp[(2) - (2)].in); }
    73557386    break;
     
    73587389
    73597390/* Line 1806 of yacc.c  */
    7360 #line 1767 "parser.yy"
     7391#line 1773 "parser.yy"
    73617392    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); }
    73627393    break;
     
    73657396
    73667397/* Line 1806 of yacc.c  */
    7367 #line 1771 "parser.yy"
     7398#line 1777 "parser.yy"
    73687399    { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); }
    73697400    break;
     
    73727403
    73737404/* Line 1806 of yacc.c  */
    7374 #line 1772 "parser.yy"
     7405#line 1778 "parser.yy"
    73757406    { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); }
    73767407    break;
     
    73797410
    73807411/* Line 1806 of yacc.c  */
    7381 #line 1777 "parser.yy"
     7412#line 1783 "parser.yy"
    73827413    { (yyval.in) = 0; }
    73837414    break;
     
    73867417
    73877418/* Line 1806 of yacc.c  */
    7388 #line 1779 "parser.yy"
     7419#line 1785 "parser.yy"
    73897420    { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); }
    73907421    break;
     
    73937424
    73947425/* Line 1806 of yacc.c  */
    7395 #line 1780 "parser.yy"
     7426#line 1786 "parser.yy"
    73967427    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); }
    73977428    break;
     
    74007431
    74017432/* Line 1806 of yacc.c  */
    7402 #line 1782 "parser.yy"
     7433#line 1788 "parser.yy"
    74037434    { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); }
    74047435    break;
     
    74077438
    74087439/* Line 1806 of yacc.c  */
    7409 #line 1798 "parser.yy"
     7440#line 1804 "parser.yy"
    74107441    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); }
    74117442    break;
     
    74147445
    74157446/* Line 1806 of yacc.c  */
    7416 #line 1804 "parser.yy"
     7447#line 1810 "parser.yy"
    74177448    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); }
    74187449    break;
     
    74217452
    74227453/* Line 1806 of yacc.c  */
    7423 #line 1810 "parser.yy"
     7454#line 1816 "parser.yy"
    74247455    { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); }
    74257456    break;
     
    74287459
    74297460/* Line 1806 of yacc.c  */
    7430 #line 1813 "parser.yy"
     7461#line 1819 "parser.yy"
    74317462    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74327463    break;
     
    74357466
    74367467/* Line 1806 of yacc.c  */
    7437 #line 1815 "parser.yy"
     7468#line 1821 "parser.yy"
    74387469    { (yyval.en) = (yyvsp[(3) - (5)].en); }
    74397470    break;
     
    74427473
    74437474/* Line 1806 of yacc.c  */
    7444 #line 1817 "parser.yy"
     7475#line 1823 "parser.yy"
    74457476    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); }
    74467477    break;
     
    74497480
    74507481/* Line 1806 of yacc.c  */
    7451 #line 1819 "parser.yy"
     7482#line 1825 "parser.yy"
    74527483    { (yyval.en) = (yyvsp[(4) - (6)].en); }
    74537484    break;
     
    74567487
    74577488/* Line 1806 of yacc.c  */
    7458 #line 1843 "parser.yy"
     7489#line 1849 "parser.yy"
    74597490    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    74607491    break;
     
    74637494
    74647495/* Line 1806 of yacc.c  */
    7465 #line 1845 "parser.yy"
     7496#line 1851 "parser.yy"
    74667497    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    74677498    break;
     
    74707501
    74717502/* Line 1806 of yacc.c  */
    7472 #line 1847 "parser.yy"
     7503#line 1853 "parser.yy"
    74737504    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); }
    74747505    break;
     
    74777508
    74787509/* Line 1806 of yacc.c  */
    7479 #line 1853 "parser.yy"
     7510#line 1859 "parser.yy"
    74807511    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    74817512    break;
     
    74847515
    74857516/* Line 1806 of yacc.c  */
    7486 #line 1855 "parser.yy"
     7517#line 1861 "parser.yy"
    74877518    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    74887519    break;
     
    74917522
    74927523/* Line 1806 of yacc.c  */
    7493 #line 1860 "parser.yy"
     7524#line 1866 "parser.yy"
    74947525    { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); }
    74957526    break;
     
    74987529
    74997530/* Line 1806 of yacc.c  */
    7500 #line 1866 "parser.yy"
     7531#line 1872 "parser.yy"
    75017532    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); }
    75027533    break;
     
    75057536
    75067537/* Line 1806 of yacc.c  */
    7507 #line 1871 "parser.yy"
     7538#line 1877 "parser.yy"
    75087539    { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); }
    75097540    break;
     
    75127543
    75137544/* Line 1806 of yacc.c  */
    7514 #line 1873 "parser.yy"
     7545#line 1879 "parser.yy"
    75157546    { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); }
    75167547    break;
     
    75197550
    75207551/* Line 1806 of yacc.c  */
    7521 #line 1879 "parser.yy"
     7552#line 1885 "parser.yy"
    75227553    { (yyval.tclass) = DeclarationNode::Otype; }
    75237554    break;
     
    75267557
    75277558/* Line 1806 of yacc.c  */
    7528 #line 1881 "parser.yy"
     7559#line 1887 "parser.yy"
    75297560    { (yyval.tclass) = DeclarationNode::Ftype; }
    75307561    break;
     
    75337564
    75347565/* Line 1806 of yacc.c  */
    7535 #line 1883 "parser.yy"
     7566#line 1889 "parser.yy"
    75367567    { (yyval.tclass) = DeclarationNode::Dtype; }
    75377568    break;
     
    75407571
    75417572/* Line 1806 of yacc.c  */
    7542 #line 1888 "parser.yy"
     7573#line 1894 "parser.yy"
    75437574    { (yyval.decl) = 0; }
    75447575    break;
     
    75477578
    75487579/* Line 1806 of yacc.c  */
    7549 #line 1890 "parser.yy"
     7580#line 1896 "parser.yy"
    75507581    { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); }
    75517582    break;
     
    75547585
    75557586/* Line 1806 of yacc.c  */
    7556 #line 1895 "parser.yy"
     7587#line 1901 "parser.yy"
    75577588    {
    75587589                        typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) );
     
    75647595
    75657596/* Line 1806 of yacc.c  */
    7566 #line 1900 "parser.yy"
     7597#line 1906 "parser.yy"
    75677598    { (yyval.decl) = (yyvsp[(4) - (5)].decl); }
    75687599    break;
     
    75717602
    75727603/* Line 1806 of yacc.c  */
    7573 #line 1902 "parser.yy"
     7604#line 1908 "parser.yy"
    75747605    { (yyval.decl) = 0; }
    75757606    break;
     
    75787609
    75797610/* Line 1806 of yacc.c  */
    7580 #line 1907 "parser.yy"
     7611#line 1913 "parser.yy"
    75817612    { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); }
    75827613    break;
     
    75857616
    75867617/* Line 1806 of yacc.c  */
    7587 #line 1910 "parser.yy"
     7618#line 1916 "parser.yy"
    75887619    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); }
    75897620    break;
     
    75927623
    75937624/* Line 1806 of yacc.c  */
    7594 #line 1912 "parser.yy"
     7625#line 1918 "parser.yy"
    75957626    { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); }
    75967627    break;
     
    75997630
    76007631/* Line 1806 of yacc.c  */
    7601 #line 1917 "parser.yy"
     7632#line 1923 "parser.yy"
    76027633    { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
    76037634    break;
     
    76067637
    76077638/* Line 1806 of yacc.c  */
    7608 #line 1919 "parser.yy"
     7639#line 1925 "parser.yy"
    76097640    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); }
    76107641    break;
     
    76137644
    76147645/* Line 1806 of yacc.c  */
    7615 #line 1921 "parser.yy"
     7646#line 1927 "parser.yy"
    76167647    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); }
    76177648    break;
     
    76207651
    76217652/* Line 1806 of yacc.c  */
    7622 #line 1926 "parser.yy"
     7653#line 1932 "parser.yy"
    76237654    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); }
    76247655    break;
     
    76277658
    76287659/* Line 1806 of yacc.c  */
    7629 #line 1928 "parser.yy"
     7660#line 1934 "parser.yy"
    76307661    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); }
    76317662    break;
     
    76347665
    76357666/* Line 1806 of yacc.c  */
    7636 #line 1933 "parser.yy"
     7667#line 1939 "parser.yy"
    76377668    {
    76387669                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD );
     
    76447675
    76457676/* Line 1806 of yacc.c  */
    7646 #line 1938 "parser.yy"
     7677#line 1944 "parser.yy"
    76477678    {
    76487679                        typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG );
     
    76547685
    76557686/* Line 1806 of yacc.c  */
    7656 #line 1946 "parser.yy"
     7687#line 1952 "parser.yy"
    76577688    {
    76587689                        typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID );
     
    76647695
    76657696/* Line 1806 of yacc.c  */
    7666 #line 1951 "parser.yy"
     7697#line 1957 "parser.yy"
    76677698    {
    76687699                        typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) );
     
    76747705
    76757706/* Line 1806 of yacc.c  */
    7676 #line 1956 "parser.yy"
     7707#line 1962 "parser.yy"
    76777708    {
    76787709                        typedefTable.leaveTrait();
     
    76857716
    76867717/* Line 1806 of yacc.c  */
    7687 #line 1966 "parser.yy"
     7718#line 1972 "parser.yy"
    76887719    { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); }
    76897720    break;
     
    76927723
    76937724/* Line 1806 of yacc.c  */
    7694 #line 1976 "parser.yy"
     7725#line 1982 "parser.yy"
    76957726    {
    76967727                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77027733
    77037734/* Line 1806 of yacc.c  */
    7704 #line 1981 "parser.yy"
     7735#line 1987 "parser.yy"
    77057736    {
    77067737                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77127743
    77137744/* Line 1806 of yacc.c  */
    7714 #line 1986 "parser.yy"
     7745#line 1992 "parser.yy"
    77157746    {
    77167747                        typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID );
     
    77227753
    77237754/* Line 1806 of yacc.c  */
    7724 #line 1994 "parser.yy"
     7755#line 2000 "parser.yy"
    77257756    {
    77267757                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77327763
    77337764/* Line 1806 of yacc.c  */
    7734 #line 1999 "parser.yy"
     7765#line 2005 "parser.yy"
    77357766    {
    77367767                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    77427773
    77437774/* Line 1806 of yacc.c  */
    7744 #line 2009 "parser.yy"
     7775#line 2015 "parser.yy"
    77457776    {}
    77467777    break;
     
    77497780
    77507781/* Line 1806 of yacc.c  */
    7751 #line 2011 "parser.yy"
     7782#line 2017 "parser.yy"
    77527783    { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl);    }
    77537784    break;
     
    77567787
    77577788/* Line 1806 of yacc.c  */
    7758 #line 2017 "parser.yy"
     7789#line 2023 "parser.yy"
    77597790    { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); }
    77607791    break;
     
    77637794
    77647795/* Line 1806 of yacc.c  */
    7765 #line 2022 "parser.yy"
     7796#line 2028 "parser.yy"
    77667797    { (yyval.decl) = 0; }
    77677798    break;
     
    77707801
    77717802/* Line 1806 of yacc.c  */
    7772 #line 2030 "parser.yy"
     7803#line 2036 "parser.yy"
    77737804    {}
    77747805    break;
     
    77777808
    77787809/* Line 1806 of yacc.c  */
    7779 #line 2032 "parser.yy"
     7810#line 2038 "parser.yy"
    77807811    {
    77817812                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     
    77877818
    77887819/* Line 1806 of yacc.c  */
    7789 #line 2037 "parser.yy"
     7820#line 2043 "parser.yy"
    77907821    {
    77917822                        linkage = linkageStack.top();
     
    77987829
    77997830/* Line 1806 of yacc.c  */
    7800 #line 2043 "parser.yy"
     7831#line 2049 "parser.yy"
    78017832    {   // mark all fields in list
    78027833                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     
    78097840
    78107841/* Line 1806 of yacc.c  */
    7811 #line 2058 "parser.yy"
     7842#line 2064 "parser.yy"
    78127843    {
    78137844                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78207851
    78217852/* Line 1806 of yacc.c  */
    7822 #line 2064 "parser.yy"
     7853#line 2070 "parser.yy"
    78237854    {
    78247855                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78317862
    78327863/* Line 1806 of yacc.c  */
    7833 #line 2073 "parser.yy"
     7864#line 2079 "parser.yy"
    78347865    {
    78357866                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78427873
    78437874/* Line 1806 of yacc.c  */
    7844 #line 2079 "parser.yy"
     7875#line 2085 "parser.yy"
    78457876    {
    78467877                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78517882
    78527883  case 540:
    7853 
    7854 /* Line 1806 of yacc.c  */
    7855 #line 2085 "parser.yy"
    7856     {
    7857                         typedefTable.addToEnclosingScope( TypedefTable::ID );
    7858                         typedefTable.leaveScope();
    7859                         (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) );
    7860                 }
    7861     break;
    7862 
    7863   case 541:
    78647884
    78657885/* Line 1806 of yacc.c  */
     
    78727892    break;
    78737893
     7894  case 541:
     7895
     7896/* Line 1806 of yacc.c  */
     7897#line 2097 "parser.yy"
     7898    {
     7899                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     7900                        typedefTable.leaveScope();
     7901                        (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) );
     7902                }
     7903    break;
     7904
    78747905  case 542:
    78757906
    78767907/* Line 1806 of yacc.c  */
    7877 #line 2097 "parser.yy"
     7908#line 2103 "parser.yy"
    78787909    {
    78797910                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78867917
    78877918/* Line 1806 of yacc.c  */
    7888 #line 2105 "parser.yy"
     7919#line 2111 "parser.yy"
    78897920    {
    78907921                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    78977928
    78987929/* Line 1806 of yacc.c  */
    7899 #line 2111 "parser.yy"
     7930#line 2117 "parser.yy"
    79007931    {
    79017932                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79087939
    79097940/* Line 1806 of yacc.c  */
    7910 #line 2119 "parser.yy"
     7941#line 2125 "parser.yy"
    79117942    {
    79127943                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79197950
    79207951/* Line 1806 of yacc.c  */
    7921 #line 2125 "parser.yy"
     7952#line 2131 "parser.yy"
    79227953    {
    79237954                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    79307961
    79317962/* Line 1806 of yacc.c  */
    7932 #line 2140 "parser.yy"
     7963#line 2146 "parser.yy"
    79337964    { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); }
    79347965    break;
     
    79377968
    79387969/* Line 1806 of yacc.c  */
    7939 #line 2145 "parser.yy"
     7970#line 2151 "parser.yy"
    79407971    { delete (yyvsp[(3) - (5)].str); }
    79417972    break;
     
    79447975
    79457976/* Line 1806 of yacc.c  */
    7946 #line 2150 "parser.yy"
     7977#line 2156 "parser.yy"
    79477978    { (yyval.decl) = 0; }
    79487979    break;
     
    79517982
    79527983/* Line 1806 of yacc.c  */
    7953 #line 2157 "parser.yy"
     7984#line 2163 "parser.yy"
    79547985    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    79557986    break;
     
    79587989
    79597990/* Line 1806 of yacc.c  */
    7960 #line 2163 "parser.yy"
     7991#line 2169 "parser.yy"
    79617992    { (yyval.decl) = 0; }
    79627993    break;
     
    79657996
    79667997/* Line 1806 of yacc.c  */
    7967 #line 2174 "parser.yy"
     7998#line 2180 "parser.yy"
    79687999    { delete (yyvsp[(3) - (4)].en); }
    79698000    break;
     
    79728003
    79738004/* Line 1806 of yacc.c  */
    7974 #line 2178 "parser.yy"
     8005#line 2184 "parser.yy"
    79758006    { delete (yyvsp[(1) - (1)].tok); }
    79768007    break;
     
    79798010
    79808011/* Line 1806 of yacc.c  */
    7981 #line 2179 "parser.yy"
     8012#line 2185 "parser.yy"
    79828013    { delete (yyvsp[(1) - (1)].decl); }
    79838014    break;
     
    79868017
    79878018/* Line 1806 of yacc.c  */
    7988 #line 2180 "parser.yy"
     8019#line 2186 "parser.yy"
    79898020    { delete (yyvsp[(1) - (1)].decl); }
    79908021    break;
     
    79938024
    79948025/* Line 1806 of yacc.c  */
    7995 #line 2181 "parser.yy"
     8026#line 2187 "parser.yy"
    79968027    { delete (yyvsp[(1) - (1)].decl); }
    79978028    break;
     
    80008031
    80018032/* Line 1806 of yacc.c  */
    8002 #line 2216 "parser.yy"
     8033#line 2222 "parser.yy"
    80038034    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    80048035    break;
     
    80078038
    80088039/* Line 1806 of yacc.c  */
    8009 #line 2219 "parser.yy"
     8040#line 2225 "parser.yy"
    80108041    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    80118042    break;
     
    80148045
    80158046/* Line 1806 of yacc.c  */
    8016 #line 2221 "parser.yy"
     8047#line 2227 "parser.yy"
    80178048    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    80188049    break;
     
    80218052
    80228053/* Line 1806 of yacc.c  */
    8023 #line 2226 "parser.yy"
     8054#line 2232 "parser.yy"
    80248055    {
    80258056                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    80318062
    80328063/* Line 1806 of yacc.c  */
    8033 #line 2231 "parser.yy"
     8064#line 2237 "parser.yy"
    80348065    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80358066    break;
     
    80388069
    80398070/* Line 1806 of yacc.c  */
    8040 #line 2236 "parser.yy"
     8071#line 2242 "parser.yy"
    80418072    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    80428073    break;
     
    80458076
    80468077/* Line 1806 of yacc.c  */
    8047 #line 2238 "parser.yy"
     8078#line 2244 "parser.yy"
    80488079    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    80498080    break;
     
    80528083
    80538084/* Line 1806 of yacc.c  */
    8054 #line 2240 "parser.yy"
     8085#line 2246 "parser.yy"
    80558086    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80568087    break;
     
    80598090
    80608091/* Line 1806 of yacc.c  */
    8061 #line 2245 "parser.yy"
     8092#line 2251 "parser.yy"
    80628093    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    80638094    break;
     
    80668097
    80678098/* Line 1806 of yacc.c  */
    8068 #line 2247 "parser.yy"
     8099#line 2253 "parser.yy"
    80698100    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    80708101    break;
     
    80738104
    80748105/* Line 1806 of yacc.c  */
    8075 #line 2249 "parser.yy"
     8106#line 2255 "parser.yy"
    80768107    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    80778108    break;
     
    80808111
    80818112/* Line 1806 of yacc.c  */
    8082 #line 2251 "parser.yy"
     8113#line 2257 "parser.yy"
    80838114    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80848115    break;
     
    80878118
    80888119/* Line 1806 of yacc.c  */
    8089 #line 2256 "parser.yy"
     8120#line 2262 "parser.yy"
    80908121    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    80918122    break;
     
    80948125
    80958126/* Line 1806 of yacc.c  */
    8096 #line 2258 "parser.yy"
     8127#line 2264 "parser.yy"
    80978128    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    80988129    break;
     
    81018132
    81028133/* Line 1806 of yacc.c  */
    8103 #line 2267 "parser.yy"
     8134#line 2273 "parser.yy"
    81048135    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    81058136    break;
     
    81088139
    81098140/* Line 1806 of yacc.c  */
    8110 #line 2270 "parser.yy"
     8141#line 2276 "parser.yy"
    81118142    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    81128143    break;
     
    81158146
    81168147/* Line 1806 of yacc.c  */
    8117 #line 2275 "parser.yy"
     8148#line 2281 "parser.yy"
    81188149    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    81198150    break;
     
    81228153
    81238154/* Line 1806 of yacc.c  */
    8124 #line 2277 "parser.yy"
     8155#line 2283 "parser.yy"
    81258156    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    81268157    break;
     
    81298160
    81308161/* Line 1806 of yacc.c  */
    8131 #line 2279 "parser.yy"
     8162#line 2285 "parser.yy"
    81328163    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81338164    break;
     
    81368167
    81378168/* Line 1806 of yacc.c  */
    8138 #line 2284 "parser.yy"
     8169#line 2290 "parser.yy"
    81398170    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    81408171    break;
     
    81438174
    81448175/* Line 1806 of yacc.c  */
    8145 #line 2286 "parser.yy"
     8176#line 2292 "parser.yy"
    81468177    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    81478178    break;
     
    81508181
    81518182/* Line 1806 of yacc.c  */
    8152 #line 2288 "parser.yy"
     8183#line 2294 "parser.yy"
    81538184    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81548185    break;
     
    81578188
    81588189/* Line 1806 of yacc.c  */
    8159 #line 2293 "parser.yy"
     8190#line 2299 "parser.yy"
    81608191    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81618192    break;
     
    81648195
    81658196/* Line 1806 of yacc.c  */
    8166 #line 2295 "parser.yy"
     8197#line 2301 "parser.yy"
    81678198    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    81688199    break;
     
    81718202
    81728203/* Line 1806 of yacc.c  */
    8173 #line 2297 "parser.yy"
     8204#line 2303 "parser.yy"
    81748205    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81758206    break;
     
    81788209
    81798210/* Line 1806 of yacc.c  */
    8180 #line 2312 "parser.yy"
     8211#line 2318 "parser.yy"
    81818212    { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); }
    81828213    break;
     
    81858216
    81868217/* Line 1806 of yacc.c  */
    8187 #line 2314 "parser.yy"
     8218#line 2320 "parser.yy"
    81888219    { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); }
    81898220    break;
     
    81928223
    81938224/* Line 1806 of yacc.c  */
    8194 #line 2316 "parser.yy"
     8225#line 2322 "parser.yy"
    81958226    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    81968227    break;
     
    81998230
    82008231/* Line 1806 of yacc.c  */
    8201 #line 2321 "parser.yy"
     8232#line 2327 "parser.yy"
    82028233    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    82038234    break;
     
    82068237
    82078238/* Line 1806 of yacc.c  */
    8208 #line 2323 "parser.yy"
     8239#line 2329 "parser.yy"
    82098240    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    82108241    break;
     
    82138244
    82148245/* Line 1806 of yacc.c  */
    8215 #line 2325 "parser.yy"
     8246#line 2331 "parser.yy"
    82168247    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82178248    break;
     
    82208251
    82218252/* Line 1806 of yacc.c  */
    8222 #line 2330 "parser.yy"
     8253#line 2336 "parser.yy"
    82238254    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    82248255    break;
     
    82278258
    82288259/* Line 1806 of yacc.c  */
    8229 #line 2332 "parser.yy"
     8260#line 2338 "parser.yy"
    82308261    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    82318262    break;
     
    82348265
    82358266/* Line 1806 of yacc.c  */
    8236 #line 2334 "parser.yy"
     8267#line 2340 "parser.yy"
    82378268    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82388269    break;
     
    82418272
    82428273/* Line 1806 of yacc.c  */
    8243 #line 2349 "parser.yy"
     8274#line 2355 "parser.yy"
    82448275    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    82458276    break;
     
    82488279
    82498280/* Line 1806 of yacc.c  */
    8250 #line 2352 "parser.yy"
     8281#line 2358 "parser.yy"
    82518282    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    82528283    break;
     
    82558286
    82568287/* Line 1806 of yacc.c  */
    8257 #line 2354 "parser.yy"
     8288#line 2360 "parser.yy"
    82588289    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    82598290    break;
     
    82628293
    82638294/* Line 1806 of yacc.c  */
    8264 #line 2360 "parser.yy"
     8295#line 2366 "parser.yy"
    82658296    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82668297    break;
     
    82698300
    82708301/* Line 1806 of yacc.c  */
    8271 #line 2365 "parser.yy"
     8302#line 2371 "parser.yy"
    82728303    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    82738304    break;
     
    82768307
    82778308/* Line 1806 of yacc.c  */
    8278 #line 2367 "parser.yy"
     8309#line 2373 "parser.yy"
    82798310    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    82808311    break;
     
    82838314
    82848315/* Line 1806 of yacc.c  */
    8285 #line 2369 "parser.yy"
     8316#line 2375 "parser.yy"
    82868317    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    82878318    break;
     
    82908321
    82918322/* Line 1806 of yacc.c  */
    8292 #line 2374 "parser.yy"
     8323#line 2380 "parser.yy"
    82938324    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    82948325    break;
     
    82978328
    82988329/* Line 1806 of yacc.c  */
    8299 #line 2376 "parser.yy"
     8330#line 2382 "parser.yy"
    83008331    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83018332    break;
     
    83048335
    83058336/* Line 1806 of yacc.c  */
    8306 #line 2378 "parser.yy"
     8337#line 2384 "parser.yy"
    83078338    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83088339    break;
     
    83118342
    83128343/* Line 1806 of yacc.c  */
    8313 #line 2380 "parser.yy"
     8344#line 2386 "parser.yy"
    83148345    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83158346    break;
     
    83188349
    83198350/* Line 1806 of yacc.c  */
    8320 #line 2385 "parser.yy"
     8351#line 2391 "parser.yy"
    83218352    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    83228353    break;
     
    83258356
    83268357/* Line 1806 of yacc.c  */
    8327 #line 2387 "parser.yy"
     8358#line 2393 "parser.yy"
    83288359    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    83298360    break;
     
    83328363
    83338364/* Line 1806 of yacc.c  */
    8334 #line 2389 "parser.yy"
     8365#line 2395 "parser.yy"
    83358366    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83368367    break;
     
    83398370
    83408371/* Line 1806 of yacc.c  */
    8341 #line 2399 "parser.yy"
     8372#line 2405 "parser.yy"
    83428373    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83438374    break;
     
    83468377
    83478378/* Line 1806 of yacc.c  */
    8348 #line 2402 "parser.yy"
     8379#line 2408 "parser.yy"
    83498380    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83508381    break;
     
    83538384
    83548385/* Line 1806 of yacc.c  */
    8355 #line 2404 "parser.yy"
     8386#line 2410 "parser.yy"
    83568387    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    83578388    break;
     
    83608391
    83618392/* Line 1806 of yacc.c  */
    8362 #line 2409 "parser.yy"
     8393#line 2415 "parser.yy"
    83638394    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    83648395    break;
     
    83678398
    83688399/* Line 1806 of yacc.c  */
    8369 #line 2411 "parser.yy"
     8400#line 2417 "parser.yy"
    83708401    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    83718402    break;
     
    83748405
    83758406/* Line 1806 of yacc.c  */
    8376 #line 2413 "parser.yy"
     8407#line 2419 "parser.yy"
    83778408    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    83788409    break;
     
    83818412
    83828413/* Line 1806 of yacc.c  */
    8383 #line 2418 "parser.yy"
     8414#line 2424 "parser.yy"
    83848415    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    83858416    break;
     
    83888419
    83898420/* Line 1806 of yacc.c  */
    8390 #line 2420 "parser.yy"
     8421#line 2426 "parser.yy"
    83918422    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83928423    break;
     
    83958426
    83968427/* Line 1806 of yacc.c  */
    8397 #line 2422 "parser.yy"
     8428#line 2428 "parser.yy"
    83988429    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    83998430    break;
     
    84028433
    84038434/* Line 1806 of yacc.c  */
    8404 #line 2424 "parser.yy"
     8435#line 2430 "parser.yy"
    84058436    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84068437    break;
     
    84098440
    84108441/* Line 1806 of yacc.c  */
    8411 #line 2429 "parser.yy"
     8442#line 2435 "parser.yy"
    84128443    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    84138444    break;
     
    84168447
    84178448/* Line 1806 of yacc.c  */
    8418 #line 2431 "parser.yy"
     8449#line 2437 "parser.yy"
    84198450    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    84208451    break;
     
    84238454
    84248455/* Line 1806 of yacc.c  */
    8425 #line 2433 "parser.yy"
     8456#line 2439 "parser.yy"
    84268457    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84278458    break;
     
    84308461
    84318462/* Line 1806 of yacc.c  */
    8432 #line 2464 "parser.yy"
     8463#line 2470 "parser.yy"
    84338464    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84348465    break;
     
    84378468
    84388469/* Line 1806 of yacc.c  */
    8439 #line 2467 "parser.yy"
     8470#line 2473 "parser.yy"
    84408471    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84418472    break;
     
    84448475
    84458476/* Line 1806 of yacc.c  */
    8446 #line 2469 "parser.yy"
     8477#line 2475 "parser.yy"
    84478478    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    84488479    break;
     
    84518482
    84528483/* Line 1806 of yacc.c  */
    8453 #line 2474 "parser.yy"
     8484#line 2480 "parser.yy"
    84548485    {
    84558486                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    84618492
    84628493/* Line 1806 of yacc.c  */
    8463 #line 2479 "parser.yy"
     8494#line 2485 "parser.yy"
    84648495    {
    84658496                        typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) );
     
    84718502
    84728503/* Line 1806 of yacc.c  */
    8473 #line 2487 "parser.yy"
     8504#line 2493 "parser.yy"
    84748505    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    84758506    break;
     
    84788509
    84798510/* Line 1806 of yacc.c  */
    8480 #line 2489 "parser.yy"
     8511#line 2495 "parser.yy"
    84818512    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    84828513    break;
     
    84858516
    84868517/* Line 1806 of yacc.c  */
    8487 #line 2491 "parser.yy"
     8518#line 2497 "parser.yy"
    84888519    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    84898520    break;
     
    84928523
    84938524/* Line 1806 of yacc.c  */
    8494 #line 2496 "parser.yy"
     8525#line 2502 "parser.yy"
    84958526    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    84968527    break;
     
    84998530
    85008531/* Line 1806 of yacc.c  */
    8501 #line 2498 "parser.yy"
     8532#line 2504 "parser.yy"
    85028533    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    85038534    break;
     
    85068537
    85078538/* Line 1806 of yacc.c  */
    8508 #line 2503 "parser.yy"
     8539#line 2509 "parser.yy"
    85098540    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); }
    85108541    break;
     
    85138544
    85148545/* Line 1806 of yacc.c  */
    8515 #line 2505 "parser.yy"
     8546#line 2511 "parser.yy"
    85168547    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    85178548    break;
     
    85208551
    85218552/* Line 1806 of yacc.c  */
    8522 #line 2520 "parser.yy"
     8553#line 2526 "parser.yy"
    85238554    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85248555    break;
     
    85278558
    85288559/* Line 1806 of yacc.c  */
    8529 #line 2522 "parser.yy"
     8560#line 2528 "parser.yy"
    85308561    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    85318562    break;
     
    85348565
    85358566/* Line 1806 of yacc.c  */
    8536 #line 2527 "parser.yy"
     8567#line 2533 "parser.yy"
    85378568    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    85388569    break;
     
    85418572
    85428573/* Line 1806 of yacc.c  */
    8543 #line 2529 "parser.yy"
     8574#line 2535 "parser.yy"
    85448575    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    85458576    break;
     
    85488579
    85498580/* Line 1806 of yacc.c  */
    8550 #line 2531 "parser.yy"
     8581#line 2537 "parser.yy"
    85518582    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    85528583    break;
     
    85558586
    85568587/* Line 1806 of yacc.c  */
    8557 #line 2533 "parser.yy"
     8588#line 2539 "parser.yy"
    85588589    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    85598590    break;
     
    85628593
    85638594/* Line 1806 of yacc.c  */
    8564 #line 2535 "parser.yy"
     8595#line 2541 "parser.yy"
    85658596    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    85668597    break;
     
    85698600
    85708601/* Line 1806 of yacc.c  */
    8571 #line 2541 "parser.yy"
     8602#line 2547 "parser.yy"
    85728603    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    85738604    break;
     
    85768607
    85778608/* Line 1806 of yacc.c  */
    8578 #line 2543 "parser.yy"
     8609#line 2549 "parser.yy"
    85798610    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    85808611    break;
     
    85838614
    85848615/* Line 1806 of yacc.c  */
    8585 #line 2545 "parser.yy"
     8616#line 2551 "parser.yy"
    85868617    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    85878618    break;
     
    85908621
    85918622/* Line 1806 of yacc.c  */
    8592 #line 2550 "parser.yy"
     8623#line 2556 "parser.yy"
    85938624    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    85948625    break;
     
    85978628
    85988629/* Line 1806 of yacc.c  */
    8599 #line 2552 "parser.yy"
     8630#line 2558 "parser.yy"
    86008631    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    86018632    break;
     
    86048635
    86058636/* Line 1806 of yacc.c  */
    8606 #line 2554 "parser.yy"
     8637#line 2560 "parser.yy"
    86078638    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86088639    break;
     
    86118642
    86128643/* Line 1806 of yacc.c  */
    8613 #line 2560 "parser.yy"
     8644#line 2566 "parser.yy"
    86148645    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    86158646    break;
     
    86188649
    86198650/* Line 1806 of yacc.c  */
    8620 #line 2562 "parser.yy"
     8651#line 2568 "parser.yy"
    86218652    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); }
    86228653    break;
     
    86258656
    86268657/* Line 1806 of yacc.c  */
    8627 #line 2568 "parser.yy"
     8658#line 2574 "parser.yy"
    86288659    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); }
    86298660    break;
     
    86328663
    86338664/* Line 1806 of yacc.c  */
    8634 #line 2570 "parser.yy"
     8665#line 2576 "parser.yy"
    86358666    { (yyval.decl) = DeclarationNode::newVarArray( 0 ); }
    86368667    break;
     
    86398670
    86408671/* Line 1806 of yacc.c  */
    8641 #line 2572 "parser.yy"
     8672#line 2578 "parser.yy"
    86428673    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); }
    86438674    break;
     
    86468677
    86478678/* Line 1806 of yacc.c  */
    8648 #line 2574 "parser.yy"
     8679#line 2580 "parser.yy"
    86498680    { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); }
    86508681    break;
     
    86538684
    86548685/* Line 1806 of yacc.c  */
    8655 #line 2589 "parser.yy"
     8686#line 2595 "parser.yy"
    86568687    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    86578688    break;
     
    86608691
    86618692/* Line 1806 of yacc.c  */
    8662 #line 2591 "parser.yy"
     8693#line 2597 "parser.yy"
    86638694    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    86648695    break;
     
    86678698
    86688699/* Line 1806 of yacc.c  */
    8669 #line 2596 "parser.yy"
     8700#line 2602 "parser.yy"
    86708701    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    86718702    break;
     
    86748705
    86758706/* Line 1806 of yacc.c  */
    8676 #line 2598 "parser.yy"
     8707#line 2604 "parser.yy"
    86778708    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    86788709    break;
     
    86818712
    86828713/* Line 1806 of yacc.c  */
    8683 #line 2600 "parser.yy"
     8714#line 2606 "parser.yy"
    86848715    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    86858716    break;
     
    86888719
    86898720/* Line 1806 of yacc.c  */
    8690 #line 2602 "parser.yy"
     8721#line 2608 "parser.yy"
    86918722    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    86928723    break;
     
    86958726
    86968727/* Line 1806 of yacc.c  */
    8697 #line 2604 "parser.yy"
     8728#line 2610 "parser.yy"
    86988729    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    86998730    break;
     
    87028733
    87038734/* Line 1806 of yacc.c  */
    8704 #line 2610 "parser.yy"
     8735#line 2616 "parser.yy"
    87058736    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87068737    break;
     
    87098740
    87108741/* Line 1806 of yacc.c  */
    8711 #line 2612 "parser.yy"
     8742#line 2618 "parser.yy"
    87128743    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    87138744    break;
     
    87168747
    87178748/* Line 1806 of yacc.c  */
    8718 #line 2614 "parser.yy"
     8749#line 2620 "parser.yy"
    87198750    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87208751    break;
     
    87238754
    87248755/* Line 1806 of yacc.c  */
    8725 #line 2619 "parser.yy"
     8756#line 2625 "parser.yy"
    87268757    { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); }
    87278758    break;
     
    87308761
    87318762/* Line 1806 of yacc.c  */
    8732 #line 2621 "parser.yy"
     8763#line 2627 "parser.yy"
    87338764    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    87348765    break;
     
    87378768
    87388769/* Line 1806 of yacc.c  */
    8739 #line 2623 "parser.yy"
     8770#line 2629 "parser.yy"
    87408771    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    87418772    break;
     
    87448775
    87458776/* Line 1806 of yacc.c  */
    8746 #line 2630 "parser.yy"
     8777#line 2636 "parser.yy"
    87478778    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); }
    87488779    break;
     
    87518782
    87528783/* Line 1806 of yacc.c  */
    8753 #line 2641 "parser.yy"
     8784#line 2647 "parser.yy"
    87548785    { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); }
    87558786    break;
     
    87588789
    87598790/* Line 1806 of yacc.c  */
    8760 #line 2644 "parser.yy"
     8791#line 2650 "parser.yy"
    87618792    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    87628793    break;
     
    87658796
    87668797/* Line 1806 of yacc.c  */
    8767 #line 2646 "parser.yy"
     8798#line 2652 "parser.yy"
    87688799    { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); }
    87698800    break;
     
    87728803
    87738804/* Line 1806 of yacc.c  */
    8774 #line 2649 "parser.yy"
     8805#line 2655 "parser.yy"
    87758806    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    87768807    break;
     
    87798810
    87808811/* Line 1806 of yacc.c  */
    8781 #line 2651 "parser.yy"
     8812#line 2657 "parser.yy"
    87828813    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); }
    87838814    break;
     
    87868817
    87878818/* Line 1806 of yacc.c  */
    8788 #line 2653 "parser.yy"
     8819#line 2659 "parser.yy"
    87898820    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); }
    87908821    break;
     
    87938824
    87948825/* Line 1806 of yacc.c  */
    8795 #line 2667 "parser.yy"
     8826#line 2673 "parser.yy"
    87968827    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    87978828    break;
     
    88008831
    88018832/* Line 1806 of yacc.c  */
    8802 #line 2669 "parser.yy"
     8833#line 2675 "parser.yy"
    88038834    { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }
    88048835    break;
     
    88078838
    88088839/* Line 1806 of yacc.c  */
    8809 #line 2674 "parser.yy"
     8840#line 2680 "parser.yy"
    88108841    { (yyval.decl) = DeclarationNode::newPointer( 0 ); }
    88118842    break;
     
    88148845
    88158846/* Line 1806 of yacc.c  */
    8816 #line 2676 "parser.yy"
     8847#line 2682 "parser.yy"
    88178848    { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); }
    88188849    break;
     
    88218852
    88228853/* Line 1806 of yacc.c  */
    8823 #line 2678 "parser.yy"
     8854#line 2684 "parser.yy"
    88248855    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); }
    88258856    break;
     
    88288859
    88298860/* Line 1806 of yacc.c  */
    8830 #line 2680 "parser.yy"
     8861#line 2686 "parser.yy"
    88318862    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); }
    88328863    break;
     
    88358866
    88368867/* Line 1806 of yacc.c  */
    8837 #line 2682 "parser.yy"
     8868#line 2688 "parser.yy"
    88388869    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88398870    break;
     
    88428873
    88438874/* Line 1806 of yacc.c  */
    8844 #line 2688 "parser.yy"
     8875#line 2694 "parser.yy"
    88458876    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    88468877    break;
     
    88498880
    88508881/* Line 1806 of yacc.c  */
    8851 #line 2690 "parser.yy"
     8882#line 2696 "parser.yy"
    88528883    { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); }
    88538884    break;
     
    88568887
    88578888/* Line 1806 of yacc.c  */
    8858 #line 2692 "parser.yy"
     8889#line 2698 "parser.yy"
    88598890    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88608891    break;
     
    88638894
    88648895/* Line 1806 of yacc.c  */
    8865 #line 2697 "parser.yy"
     8896#line 2703 "parser.yy"
    88668897    { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); }
    88678898    break;
     
    88708901
    88718902/* Line 1806 of yacc.c  */
    8872 #line 2699 "parser.yy"
     8903#line 2705 "parser.yy"
    88738904    { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
    88748905    break;
     
    88778908
    88788909/* Line 1806 of yacc.c  */
    8879 #line 2709 "parser.yy"
     8910#line 2715 "parser.yy"
    88808911    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    88818912    break;
     
    88848915
    88858916/* Line 1806 of yacc.c  */
    8886 #line 2719 "parser.yy"
     8917#line 2725 "parser.yy"
    88878918    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    88888919    break;
     
    88918922
    88928923/* Line 1806 of yacc.c  */
    8893 #line 2721 "parser.yy"
     8924#line 2727 "parser.yy"
    88948925    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    88958926    break;
     
    88988929
    88998930/* Line 1806 of yacc.c  */
    8900 #line 2723 "parser.yy"
     8931#line 2729 "parser.yy"
    89018932    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89028933    break;
     
    89058936
    89068937/* Line 1806 of yacc.c  */
    8907 #line 2725 "parser.yy"
     8938#line 2731 "parser.yy"
    89088939    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89098940    break;
     
    89128943
    89138944/* Line 1806 of yacc.c  */
    8914 #line 2727 "parser.yy"
     8945#line 2733 "parser.yy"
    89158946    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    89168947    break;
     
    89198950
    89208951/* Line 1806 of yacc.c  */
    8921 #line 2729 "parser.yy"
     8952#line 2735 "parser.yy"
    89228953    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    89238954    break;
     
    89268957
    89278958/* Line 1806 of yacc.c  */
    8928 #line 2736 "parser.yy"
     8959#line 2742 "parser.yy"
    89298960    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89308961    break;
    89318962
    89328963  case 721:
    8933 
    8934 /* Line 1806 of yacc.c  */
    8935 #line 2738 "parser.yy"
    8936     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    8937     break;
    8938 
    8939   case 722:
    8940 
    8941 /* Line 1806 of yacc.c  */
    8942 #line 2740 "parser.yy"
    8943     { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    8944     break;
    8945 
    8946   case 723:
    8947 
    8948 /* Line 1806 of yacc.c  */
    8949 #line 2742 "parser.yy"
    8950     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    8951     break;
    8952 
    8953   case 724:
    89548964
    89558965/* Line 1806 of yacc.c  */
     
    89588968    break;
    89598969
     8970  case 722:
     8971
     8972/* Line 1806 of yacc.c  */
     8973#line 2746 "parser.yy"
     8974    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     8975    break;
     8976
     8977  case 723:
     8978
     8979/* Line 1806 of yacc.c  */
     8980#line 2748 "parser.yy"
     8981    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
     8982    break;
     8983
     8984  case 724:
     8985
     8986/* Line 1806 of yacc.c  */
     8987#line 2750 "parser.yy"
     8988    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
     8989    break;
     8990
    89608991  case 725:
    89618992
    89628993/* Line 1806 of yacc.c  */
    8963 #line 2747 "parser.yy"
     8994#line 2753 "parser.yy"
    89648995    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    89658996    break;
    89668997
    89678998  case 726:
    8968 
    8969 /* Line 1806 of yacc.c  */
    8970 #line 2749 "parser.yy"
    8971     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    8972     break;
    8973 
    8974   case 727:
    8975 
    8976 /* Line 1806 of yacc.c  */
    8977 #line 2751 "parser.yy"
    8978     { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    8979     break;
    8980 
    8981   case 728:
    8982 
    8983 /* Line 1806 of yacc.c  */
    8984 #line 2753 "parser.yy"
    8985     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
    8986     break;
    8987 
    8988   case 729:
    89898999
    89909000/* Line 1806 of yacc.c  */
     
    89939003    break;
    89949004
     9005  case 727:
     9006
     9007/* Line 1806 of yacc.c  */
     9008#line 2757 "parser.yy"
     9009    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     9010    break;
     9011
     9012  case 728:
     9013
     9014/* Line 1806 of yacc.c  */
     9015#line 2759 "parser.yy"
     9016    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }
     9017    break;
     9018
     9019  case 729:
     9020
     9021/* Line 1806 of yacc.c  */
     9022#line 2761 "parser.yy"
     9023    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
     9024    break;
     9025
    89959026  case 730:
    89969027
    89979028/* Line 1806 of yacc.c  */
    8998 #line 2760 "parser.yy"
     9029#line 2766 "parser.yy"
    89999030    { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); }
    90009031    break;
     
    90039034
    90049035/* Line 1806 of yacc.c  */
    9005 #line 2762 "parser.yy"
     9036#line 2768 "parser.yy"
    90069037    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); }
    90079038    break;
     
    90109041
    90119042/* Line 1806 of yacc.c  */
    9012 #line 2767 "parser.yy"
     9043#line 2773 "parser.yy"
    90139044    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); }
    90149045    break;
     
    90179048
    90189049/* Line 1806 of yacc.c  */
    9019 #line 2769 "parser.yy"
     9050#line 2775 "parser.yy"
    90209051    { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); }
    90219052    break;
     
    90249055
    90259056/* Line 1806 of yacc.c  */
    9026 #line 2796 "parser.yy"
     9057#line 2802 "parser.yy"
    90279058    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); }
    90289059    break;
     
    90319062
    90329063/* Line 1806 of yacc.c  */
    9033 #line 2807 "parser.yy"
     9064#line 2813 "parser.yy"
    90349065    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90359066    break;
     
    90389069
    90399070/* Line 1806 of yacc.c  */
    9040 #line 2809 "parser.yy"
     9071#line 2815 "parser.yy"
    90419072    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90429073    break;
     
    90459076
    90469077/* Line 1806 of yacc.c  */
    9047 #line 2811 "parser.yy"
     9078#line 2817 "parser.yy"
    90489079    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90499080    break;
     
    90529083
    90539084/* Line 1806 of yacc.c  */
    9054 #line 2813 "parser.yy"
     9085#line 2819 "parser.yy"
    90559086    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90569087    break;
     
    90599090
    90609091/* Line 1806 of yacc.c  */
    9061 #line 2815 "parser.yy"
     9092#line 2821 "parser.yy"
    90629093    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    90639094    break;
     
    90669097
    90679098/* Line 1806 of yacc.c  */
    9068 #line 2817 "parser.yy"
     9099#line 2823 "parser.yy"
    90699100    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); }
    90709101    break;
    90719102
    90729103  case 745:
    9073 
    9074 /* Line 1806 of yacc.c  */
    9075 #line 2824 "parser.yy"
    9076     { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    9077     break;
    9078 
    9079   case 746:
    9080 
    9081 /* Line 1806 of yacc.c  */
    9082 #line 2826 "parser.yy"
    9083     { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    9084     break;
    9085 
    9086   case 747:
    9087 
    9088 /* Line 1806 of yacc.c  */
    9089 #line 2828 "parser.yy"
    9090     { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
    9091     break;
    9092 
    9093   case 748:
    90949104
    90959105/* Line 1806 of yacc.c  */
     
    90989108    break;
    90999109
    9100   case 749:
     9110  case 746:
    91019111
    91029112/* Line 1806 of yacc.c  */
     
    91059115    break;
    91069116
    9107   case 750:
     9117  case 747:
    91089118
    91099119/* Line 1806 of yacc.c  */
     
    91129122    break;
    91139123
     9124  case 748:
     9125
     9126/* Line 1806 of yacc.c  */
     9127#line 2836 "parser.yy"
     9128    { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     9129    break;
     9130
     9131  case 749:
     9132
     9133/* Line 1806 of yacc.c  */
     9134#line 2838 "parser.yy"
     9135    { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     9136    break;
     9137
     9138  case 750:
     9139
     9140/* Line 1806 of yacc.c  */
     9141#line 2840 "parser.yy"
     9142    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }
     9143    break;
     9144
    91149145  case 751:
    91159146
    91169147/* Line 1806 of yacc.c  */
    9117 #line 2839 "parser.yy"
     9148#line 2845 "parser.yy"
    91189149    { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); }
    91199150    break;
     
    91229153
    91239154/* Line 1806 of yacc.c  */
    9124 #line 2846 "parser.yy"
     9155#line 2852 "parser.yy"
    91259156    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91269157    break;
     
    91299160
    91309161/* Line 1806 of yacc.c  */
    9131 #line 2848 "parser.yy"
     9162#line 2854 "parser.yy"
    91329163    { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); }
    91339164    break;
     
    91369167
    91379168/* Line 1806 of yacc.c  */
    9138 #line 2872 "parser.yy"
     9169#line 2878 "parser.yy"
    91399170    { (yyval.en) = 0; }
    91409171    break;
     
    91439174
    91449175/* Line 1806 of yacc.c  */
    9145 #line 2874 "parser.yy"
     9176#line 2880 "parser.yy"
    91469177    { (yyval.en) = (yyvsp[(2) - (2)].en); }
    91479178    break;
     
    91509181
    91519182/* Line 1806 of yacc.c  */
    9152 #line 9153 "Parser/parser.cc"
     9183#line 9184 "Parser/parser.cc"
    91539184      default: break;
    91549185    }
     
    93819412
    93829413/* Line 2067 of yacc.c  */
    9383 #line 2877 "parser.yy"
     9414#line 2883 "parser.yy"
    93849415
    93859416// ----end of grammar----
  • src/Parser/parser.yy

    r3a2128f r1f44196  
    199199
    200200%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    201 %type<en> field field_list
    202 %type<tok> field_name
     201%type<en> field field_list field_name fraction_constants
    203202
    204203%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    384383                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    385384        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     385                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    386386        | postfix_expression REALFRACTIONconstant                       // CFA, tuple index
     387                { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_REALFRACTIONconstant( *$2 ) ) ); }
    387388        | postfix_expression ARROW no_attr_identifier
    388389                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    389390        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     391                        { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    390392        | postfix_expression ICR
    391393                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     
    421423field:                                                                                                  // CFA, tuple field selector
    422424        field_name
    423                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
    424425        | REALDECIMALconstant field
    425                 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); }
     426                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); }
    426427        | REALDECIMALconstant '[' push field_list pop ']'
    427                 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); }
     428                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), build_tuple( $4 ) ) ); }
    428429        | field_name '.' field
    429                 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     430                { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    430431        | field_name '.' '[' push field_list pop ']'
    431                 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
     432                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    432433        | field_name ARROW field
    433                 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
     434                { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    434435        | field_name ARROW '[' push field_list pop ']'
    435                 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     436                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    436437        ;
    437438
    438439field_name:
    439440        INTEGERconstant fraction_constants
    440                 { $$ = $1; }
     441                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
    441442        | FLOATINGconstant fraction_constants
    442                 { $$ = $1; }
     443                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    443444        | no_attr_identifier fraction_constants
    444                 { $$ = $1; }
     445                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); }
    445446        ;
    446447
    447448fraction_constants:
    448449        // empty
     450                { $$ = nullptr; }
    449451        | fraction_constants REALFRACTIONconstant
     452                {
     453                        Expression * constant = build_field_name_REALFRACTIONconstant( *$2 );
     454                        $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1,  constant ) ) : new ExpressionNode( constant );
     455                }
    450456        ;
    451457
  • src/ResolvExpr/Alternative.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Alternative.cc -- 
     7// Alternative.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1212// Last Modified On : Sat May 16 23:54:23 2015
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#include "Alternative.h"
     
    2020
    2121namespace ResolvExpr {
    22         Alternative::Alternative() : expr( 0 ) {}
     22        Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {}
    2323
    2424        Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
     
    3535                if ( &other == this ) return *this;
    3636                initialize( other, *this );
     37                return *this;
     38        }
     39
     40        Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) {
     41                other.expr = nullptr;
     42        }
     43
     44        Alternative & Alternative::operator=( Alternative && other ) {
     45                if ( &other == this )  return *this;
     46                delete expr;
     47                cost = other.cost;
     48                cvtCost = other.cvtCost;
     49                expr = other.expr;
     50                env = other.env;
     51                other.expr = nullptr;
    3752                return *this;
    3853        }
     
    5469                        expr->print( os, indent );
    5570                        os << "(types:" << std::endl;
    56                         printAll( expr->get_results(), os, indent + 4 );
    57                         os << ")" << std::endl;
     71                        os << std::string( indent+4, ' ' );
     72                        expr->get_result()->print( os, indent + 4 );
     73                        os << std::endl << ")" << std::endl;
    5874                } else {
    5975                        os << "Null expression!" << std::endl;
  • src/ResolvExpr/Alternative.h

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Alternative.h -- 
     7// Alternative.h --
    88//
    99// Author           : Richard C. Bilson
     
    1212// Last Modified On : Sat May 16 23:54:39 2015
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#ifndef ALTERNATIVE_H
     
    3232                Alternative( const Alternative &other );
    3333                Alternative &operator=( const Alternative &other );
     34                Alternative( Alternative && other );
     35                Alternative &operator=( Alternative && other );
    3436                ~Alternative();
    35  
     37
    3638                void initialize( const Alternative &src, Alternative &dest );
    37  
     39
    3840                void print( std::ostream &os, int indent = 0 ) const;
    39  
     41
    4042                Cost cost;
    4143                Cost cvtCost;
  • src/ResolvExpr/AlternativeFinder.cc

    r3a2128f r1f44196  
    3838#include "SynTree/TypeSubstitution.h"
    3939#include "SymTab/Validate.h"
    40 #include "Tuples/TupleAssignment.h"
    41 #include "Tuples/NameMatcher.h"
     40#include "Tuples/Tuples.h"
     41#include "Tuples/Explode.h"
    4242#include "Common/utility.h"
    4343#include "InitTweak/InitTweak.h"
     44#include "InitTweak/GenInit.h"
    4445#include "ResolveTypeof.h"
    4546
     
    6465        }
    6566
     67        Cost sumCost( const AltList &in ) {
     68                Cost total;
     69                for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) {
     70                        total += i->cost;
     71                }
     72                return total;
     73        }
     74
    6675        namespace {
    6776                void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) {
     
    7685                                out.push_back( i->expr->clone() );
    7786                        }
    78                 }
    79 
    80                 Cost sumCost( const AltList &in ) {
    81                         Cost total;
    82                         for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) {
    83                                 total += i->cost;
    84                         }
    85                         return total;
    8687                }
    8788
     
    101102                                PruneStruct current( candidate );
    102103                                std::string mangleName;
    103                                 for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ) {
    104                                         Type *newType = (*retType)->clone();
     104                                {
     105                                        Type * newType = candidate->expr->get_result()->clone();
    105106                                        candidate->env.apply( newType );
    106                                         mangleName += SymTab::Mangler::mangle( newType );
     107                                        mangleName = SymTab::Mangler::mangle( newType );
    107108                                        delete newType;
    108109                                }
     
    133134                                if ( ! target->second.isAmbiguous ) {
    134135                                        Alternative &alt = *target->second.candidate;
    135                                         for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) {
    136                                                 alt.env.applyFree( *result );
    137                                         }
     136                                        alt.env.applyFree( alt.expr->get_result() );
    138137                                        *out++ = alt;
    139138                                }
    140139                        }
    141 
    142                 }
    143 
    144                 template< typename InputIterator, typename OutputIterator >
    145                 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    146                         AltList alternatives;
    147 
    148                         // select the alternatives that have the minimum parameter cost
    149                         Cost minCost = Cost::infinity;
    150                         for ( AltList::iterator i = begin; i != end; ++i ) {
    151                                 if ( i->cost < minCost ) {
    152                                         minCost = i->cost;
    153                                         i->cost = i->cvtCost;
    154                                         alternatives.clear();
    155                                         alternatives.push_back( *i );
    156                                 } else if ( i->cost == minCost ) {
    157                                         i->cost = i->cvtCost;
    158                                         alternatives.push_back( *i );
    159                                 }
    160                         }
    161                         std::copy( alternatives.begin(), alternatives.end(), out );
    162                 }
    163 
    164                 template< typename InputIterator >
    165                 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
    166                         while ( begin != end ) {
    167                                 result.simpleCombine( (*begin++).env );
    168                         }
    169140                }
    170141
    171142                void renameTypes( Expression *expr ) {
    172                         for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
    173                                 (*i)->accept( global_renamer );
    174                         }
     143                        expr->get_result()->accept( global_renamer );
    175144                }
    176145        }
     
    204173                for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    205174                        if ( adjust ) {
    206                                 adjustExprTypeList( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );
     175                                adjustExprType( i->expr->get_result(), i->env, indexer );
    207176                        }
    208177                }
     
    240209        }
    241210
     211        // std::unordered_map< Expression *, UniqueExpr * > ;
     212
    242213        template< typename StructOrUnionType >
    243         void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) {
     214        void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
     215                // by this point, member must be a name expr
     216                NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member );
     217                const std::string & name = nameExpr->get_name();
    244218                std::list< Declaration* > members;
    245219                aggInst->lookup( name, members );
     
    254228        }
    255229
     230        void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
     231                if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) {
     232                        // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning
     233                        // xxx - this should be improved by memoizing the value of constant exprs
     234                        // during parsing and reusing that information here.
     235                        std::stringstream ss( constantExpr->get_constant()->get_value() );
     236                        int val;
     237                        std::string tmp;
     238                        if ( ss >> val && ! (ss >> tmp) ) {
     239                                if ( val >= 0 && (unsigned int)val < tupleType->size() ) {
     240                                        alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
     241                                } // if
     242                        } // if
     243                } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) {
     244                        // xxx - temporary hack until 0/1 are int constants
     245                        if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) {
     246                                std::stringstream ss( nameExpr->get_name() );
     247                                int val;
     248                                ss >> val;
     249                                alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
     250                        }
     251                } // if
     252        }
     253
    256254        void AlternativeFinder::visit( ApplicationExpr *applicationExpr ) {
    257255                alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) );
     
    259257
    260258        Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) {
    261                 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( alt.expr );
    262                 assert( appExpr );
    263                 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    264                 assert( pointer );
    265                 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    266                 assert( function );
     259                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr );
     260                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     261                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    267262
    268263                Cost convCost( 0, 0, 0 );
     
    270265                std::list< DeclarationWithType* >::iterator formal = formals.begin();
    271266                std::list< Expression* >& actuals = appExpr->get_args();
     267
     268                std::list< Type * > formalTypes;
     269                std::list< Type * >::iterator formalType = formalTypes.end();
     270
    272271                for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
     272
    273273                        PRINT(
    274274                                std::cerr << "actual expression:" << std::endl;
    275275                                (*actualExpr)->print( std::cerr, 8 );
    276276                                std::cerr << "--- results are" << std::endl;
    277                                 printAll( (*actualExpr)->get_results(), std::cerr, 8 );
     277                                (*actualExpr)->get_result()->print( std::cerr, 8 );
    278278                        )
    279279                        std::list< DeclarationWithType* >::iterator startFormal = formal;
    280280                        Cost actualCost;
    281                         for ( std::list< Type* >::iterator actual = (*actualExpr)->get_results().begin(); actual != (*actualExpr)->get_results().end(); ++actual ) {
    282                                 if ( formal == formals.end() ) {
    283                                         if ( function->get_isVarArgs() ) {
    284                                                 convCost += Cost( 1, 0, 0 );
    285                                                 break;
    286                                         } else {
    287                                                 return Cost::infinity;
     281                        std::list< Type * > flatActualTypes;
     282                        flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) );
     283                        for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) {
     284
     285
     286                                // tuple handling code
     287                                if ( formalType == formalTypes.end() ) {
     288                                        // the type of the formal parameter may be a tuple type. To make this easier to work with,
     289                                        // flatten the tuple type and traverse the resulting list of types, incrementing the formal
     290                                        // iterator once its types have been extracted. Once a particular formal parameter's type has
     291                                        // been exhausted load the next formal parameter's type.
     292                                        if ( formal == formals.end() ) {
     293                                                if ( function->get_isVarArgs() ) {
     294                                                        convCost += Cost( 1, 0, 0 );
     295                                                        break;
     296                                                } else {
     297                                                        return Cost::infinity;
     298                                                }
    288299                                        }
     300                                        formalTypes.clear();
     301                                        flatten( (*formal)->get_type(), back_inserter( formalTypes ) );
     302                                        formalType = formalTypes.begin();
     303                                        ++formal;
    289304                                }
     305
    290306                                PRINT(
    291307                                        std::cerr << std::endl << "converting ";
    292                                         (*actual)->print( std::cerr, 8 );
     308                                        (*actualType)->print( std::cerr, 8 );
    293309                                        std::cerr << std::endl << " to ";
    294310                                        (*formal)->get_type()->print( std::cerr, 8 );
    295311                                )
    296                                 Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env );
     312                                Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env );
    297313                                PRINT(
    298314                                        std::cerr << std::endl << "cost is" << newCost << std::endl;
     
    305321                                actualCost += newCost;
    306322
    307                                 convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );
    308 
    309                                 formal++;
     323                                convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 );
     324
     325                                formalType++;
    310326                        }
    311327                        if ( actualCost != Cost( 0, 0, 0 ) ) {
     
    356372        /// Adds type variables to the open variable set and marks their assertions
    357373        void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) {
    358                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     374                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    359375                        unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();
    360376                        for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {
     
    365381        }
    366382
    367         bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) {
     383        /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType,
     384        /// producing expression(s) in out and their total cost in cost.
     385        template< typename AltIterator, typename OutputIterator >
     386        bool instantiateArgument( Type * formalType, Initializer * defaultValue, AltIterator & actualIt, AltIterator actualEnd, OpenVarSet & openVars, TypeEnvironment & resultEnv, AssertionSet & resultNeed, AssertionSet & resultHave, const SymTab::Indexer & indexer, Cost & cost, OutputIterator out ) {
     387                if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) {
     388                        // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType
     389                        TupleExpr * tupleExpr = new TupleExpr();
     390                        for ( Type * type : *tupleType ) {
     391                                if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) {
     392                                        delete tupleExpr;
     393                                        return false;
     394                                }
     395                        }
     396                        tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) );
     397                        *out++ = tupleExpr;
     398                } else if ( actualIt != actualEnd ) {
     399                        // both actualType and formalType are atomic (non-tuple) types - if they unify
     400                        // then accept actual as an argument, otherwise return false (fail to instantiate argument)
     401                        Expression * actual = actualIt->expr;
     402                        Type * actualType = actual->get_result();
     403                        PRINT(
     404                                std::cerr << "formal type is ";
     405                                formalType->print( std::cerr );
     406                                std::cerr << std::endl << "actual type is ";
     407                                actualType->print( std::cerr );
     408                                std::cerr << std::endl;
     409                        )
     410                        if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
     411                                return false;
     412                        }
     413                        // move the expression from the alternative to the output iterator
     414                        *out++ = actual;
     415                        actualIt->expr = nullptr;
     416                        cost += actualIt->cost;
     417                        ++actualIt;
     418                } else {
     419                        // End of actuals - Handle default values
     420                        if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) {
     421                                // so far, only constant expressions are accepted as default values
     422                                if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) {
     423                                        if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) {
     424                                                if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
     425                                                        // xxx - Don't know if this is right
     426                                                        *out++ = cnstexpr->clone();
     427                                                        return true;
     428                                                } // if
     429                                        } // if
     430                                } // if
     431                        } // if
     432                        return false;
     433                } // if
     434                return true;
     435        }
     436
     437        bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) {
    368438                simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv );
    369439                // make sure we don't widen any existing bindings
     
    373443                resultEnv.extractOpenVars( openVars );
    374444
    375                 /*
    376                   Tuples::NameMatcher matcher( formals );
    377                   try {
    378                   matcher.match( actuals );
    379                   } catch ( Tuples::NoMatch &e ) {
    380                   std::cerr << "Alternative doesn't match: " << e.message << std::endl;
    381                   }
    382                 */
    383                 std::list< DeclarationWithType* >::iterator formal = formals.begin();
    384                 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
    385                         for ( std::list< Type* >::iterator actual = actualExpr->expr->get_results().begin(); actual != actualExpr->expr->get_results().end(); ++actual ) {
    386                                 if ( formal == formals.end() ) {
    387                                         return isVarArgs;
    388                                 }
    389                                 PRINT(
    390                                         std::cerr << "formal type is ";
    391                                         (*formal)->get_type()->print( std::cerr );
    392                                         std::cerr << std::endl << "actual type is ";
    393                                         (*actual)->print( std::cerr );
    394                                         std::cerr << std::endl;
    395                                 )
    396                                 if ( ! unify( (*formal)->get_type(), *actual, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    397                                         return false;
    398                                 }
    399                                 formal++;
    400                         }
    401                 }
    402                 // Handling of default values
    403                 while ( formal != formals.end() ) {
    404                         if ( ObjectDecl *od = dynamic_cast<ObjectDecl *>( *formal ) )
    405                                 if ( SingleInit *si = dynamic_cast<SingleInit *>( od->get_init() ))
    406                                         // so far, only constant expressions are accepted as default values
    407                                         if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) )
    408                                                 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) )
    409                                                         if ( unify( (*formal)->get_type(), cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
    410                                                                 // XXX Don't know if this is right
    411                                                                 actuals.push_back( Alternative( cnstexpr->clone(), env, Cost::zero ) );
    412                                                                 formal++;
    413                                                                 if ( formal == formals.end()) break;
    414                                                         }
    415                         return false;
     445                // flatten actuals so that each actual has an atomic (non-tuple) type
     446                AltList exploded;
     447                Tuples::explode( actuals, indexer, back_inserter( exploded ) );
     448
     449                AltList::iterator actualExpr = exploded.begin();
     450                AltList::iterator actualEnd = exploded.end();
     451                for ( DeclarationWithType * formal : formals ) {
     452                        // match flattened actuals with formal parameters - actuals will be grouped to match
     453                        // with formals as appropriate
     454                        Cost cost;
     455                        std::list< Expression * > newExprs;
     456                        ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal );
     457                        if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) {
     458                                deleteAll( newExprs );
     459                                return false;
     460                        }
     461                        // success - produce argument as a new alternative
     462                        assert( newExprs.size() == 1 );
     463                        out.push_back( Alternative( newExprs.front(), resultEnv, cost ) );
     464                }
     465                if ( actualExpr != actualEnd ) {
     466                        // there are still actuals remaining, but we've run out of formal parameters to match against
     467                        // this is okay only if the function is variadic
     468                        if ( ! isVarArgs ) {
     469                                return false;
     470                        }
     471                        out.splice( out.end(), exploded, actualExpr, actualEnd );
    416472                }
    417473                return true;
     
    500556                                //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    501557                                Expression *varExpr = new VariableExpr( candDecl );
    502                                 deleteAll( varExpr->get_results() );
    503                                 varExpr->get_results().clear();
    504                                 varExpr->get_results().push_front( adjType->clone() );
     558                                delete varExpr->get_result();
     559                                varExpr->set_result( adjType->clone() );
    505560                                PRINT(
    506561                                        std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
     
    545600
    546601        template< typename OutputIterator >
    547         void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {
     602        void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) {
    548603                OpenVarSet openVars;
    549604                AssertionSet resultNeed, resultHave;
    550605                TypeEnvironment resultEnv;
    551606                makeUnifiableVars( funcType, openVars, resultNeed );
    552                 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) {
     607                AltList instantiatedActuals; // filled by instantiate function
     608                if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) {
    553609                        ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() );
    554                         Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt ) );
    555                         makeExprList( actualAlt, appExpr->get_args() );
     610                        Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) );
     611                        makeExprList( instantiatedActuals, appExpr->get_args() );
    556612                        PRINT(
    557613                                std::cerr << "need assertions:" << std::endl;
     
    574630                                PointerType pt( Type::Qualifiers(), v.clone() );
    575631                                UntypedExpr *vexpr = untypedExpr->clone();
    576                                 vexpr->get_results().push_front( pt.clone() );
     632                                vexpr->set_result( pt.clone() );
    577633                                alternatives.push_back( Alternative( vexpr, env, Cost()) );
    578634                                return;
     
    587643                combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) );
    588644
    589                 Tuples::TupleAssignSpotter tassign( this );
    590                 if ( tassign.isTupleAssignment( untypedExpr, possibilities ) ) {
    591                         // take care of possible tuple assignments, or discard expression
    592                         return;
    593                 } // else ...
     645                // take care of possible tuple assignments
     646                // if not tuple assignment, assignment is taken care of as a normal function call
     647                Tuples::handleTupleAssignment( *this, untypedExpr, possibilities );
    594648
    595649                AltList candidates;
     
    604658                                // check if the type is pointer to function
    605659                                PointerType *pointer;
    606                                 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {
     660                                if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) {
    607661                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    608662                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    640694                                                // check if the type is pointer to function
    641695                                                PointerType *pointer;
    642                                                 if ( funcOp->expr->get_results().size() == 1
    643                                                         && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) {
     696                                                if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) {
    644697                                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    645698                                                                for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) {
     
    665718
    666719                        PRINT(
    667                                 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( withFunc->expr );
    668                                 assert( appExpr );
    669                                 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    670                                 assert( pointer );
    671                                 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    672                                 assert( function );
     720                                ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr );
     721                                PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     722                                FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    673723                                std::cerr << "Case +++++++++++++" << std::endl;
    674724                                std::cerr << "formals are:" << std::endl;
     
    692742
    693743        bool isLvalue( Expression *expr ) {
    694                 for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) {
    695                         if ( !(*i)->get_isLvalue() ) return false;
    696                 } // for
    697                 return true;
     744                // xxx - recurse into tuples?
     745                return expr->has_result() && expr->get_result()->get_isLvalue();
    698746        }
    699747
     
    709757
    710758        void AlternativeFinder::visit( CastExpr *castExpr ) {
    711                 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) {
    712                         *i = resolveTypeof( *i, indexer );
    713                         SymTab::validateType( *i, &indexer );
    714                         adjustExprType( *i, env, indexer );
    715                 } // for
     759                Type *& toType = castExpr->get_result();
     760                toType = resolveTypeof( toType, indexer );
     761                SymTab::validateType( toType, &indexer );
     762                adjustExprType( toType, env, indexer );
    716763
    717764                AlternativeFinder finder( indexer, env );
     
    727774                        // that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
    728775                        // to.
    729                         int discardedValues = (*i).expr->get_results().size() - castExpr->get_results().size();
     776                        int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size();
    730777                        if ( discardedValues < 0 ) continue;
    731                         std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin();
    732                         std::advance( candidate_end, castExpr->get_results().size() );
     778                        // xxx - may need to go into tuple types and extract relavent types and use unifyList
    733779                        // unification run for side-effects
    734                         unifyList( castExpr->get_results().begin(), castExpr->get_results().end(),
    735                                            (*i).expr->get_results().begin(), candidate_end,
    736                                    i->env, needAssertions, haveAssertions, openVars, indexer );
    737                         Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end,
    738                                                                                   castExpr->get_results().begin(), castExpr->get_results().end(),
    739                                                                                   indexer, i->env );
     780                        unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer );
     781                        Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env );
    740782                        if ( thisCost != Cost::infinity ) {
    741783                                // count one safe conversion for each value that is thrown away
     
    760802
    761803                for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) {
    762                         if ( agg->expr->get_results().size() == 1 ) {
    763                                 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) {
    764                                         addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    765                                 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) {
    766                                         addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    767                                 } // if
     804                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) {
     805                                addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     806                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) {
     807                                addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
     808                        } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) {
     809                                addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() );
    768810                        } // if
    769811                } // for
     
    791833                        renameTypes( alternatives.back().expr );
    792834                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) {
    793                                 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
     835                                NameExpr nameExpr( "" );
     836                                addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
    794837                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) {
    795                                 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" );
     838                                NameExpr nameExpr( "" );
     839                                addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr );
    796840                        } // if
    797841                } // for
     
    894938                        alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) );
    895939                        for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    896                                 alternatives.back().expr->get_results().push_back( (*i)->get_type()->clone() );
     940                                alternatives.back().expr->set_result( (*i)->get_type()->clone() );
    897941                        } // for
    898942                } // if
     
    917961                                                        finder.find( attrExpr->get_expr() );
    918962                                                        for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    919                                                                 if ( choice->expr->get_results().size() == 1 ) {
    920                                                                         resolveAttr(*i, function, choice->expr->get_results().front(), choice->env );
     963                                                                if ( choice->expr->get_result()->size() == 1 ) {
     964                                                                        resolveAttr(*i, function, choice->expr->get_result(), choice->env );
    921965                                                                } // fi
    922966                                                        } // for
     
    9601004                                        AssertionSet needAssertions, haveAssertions;
    9611005                                        Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost );
    962                                         std::list< Type* > commonTypes;
    963                                         if ( unifyList( second->expr->get_results().begin(), second->expr->get_results().end(), third->expr->get_results().begin(), third->expr->get_results().end(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
     1006                                        Type* commonType = nullptr;
     1007                                        if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    9641008                                                ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() );
    965                                                 std::list< Type* >::const_iterator original = second->expr->get_results().begin();
    966                                                 std::list< Type* >::const_iterator commonType = commonTypes.begin();
    967                                                 for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) {
    968                                                         if ( *commonType ) {
    969                                                                 newExpr->get_results().push_back( *commonType );
    970                                                         } else {
    971                                                                 newExpr->get_results().push_back( (*original)->clone() );
    972                                                         } // if
    973                                                 } // for
     1009                                                newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() );
    9741010                                                newAlt.expr = newExpr;
    9751011                                                inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
     
    9991035                        TupleExpr *newExpr = new TupleExpr;
    10001036                        makeExprList( *i, newExpr->get_exprs() );
    1001                         for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) {
    1002                                 for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) {
    1003                                         newExpr->get_results().push_back( (*resultType)->clone() );
    1004                                 } // for
    1005                         } // for
     1037                        newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) );
    10061038
    10071039                        TypeEnvironment compositeEnv;
     
    10241056                }
    10251057        }
     1058
     1059        void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) {
     1060                alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
     1061        }
     1062
     1063        void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) {
     1064                alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );
     1065        }
     1066
     1067        void AlternativeFinder::visit( UniqueExpr *unqExpr ) {
     1068                AlternativeFinder finder( indexer, env );
     1069                finder.findWithAdjustment( unqExpr->get_expr() );
     1070                for ( Alternative & alt : finder.alternatives ) {
     1071                        // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked"
     1072                        UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() );
     1073                        alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) );
     1074                }
     1075        }
     1076
    10261077} // namespace ResolvExpr
    10271078
  • src/ResolvExpr/AlternativeFinder.h

    r3a2128f r1f44196  
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    69           public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
     69                virtual void visit( TupleIndexExpr *tupleExpr );
     70                virtual void visit( TupleAssignExpr *tupleExpr );
     71                virtual void visit( UniqueExpr *unqExpr );
     72                /// Runs a new alternative finder on each element in [begin, end)
     73                /// and writes each alternative finder to out.
    7074                template< typename InputIterator, typename OutputIterator >
    7175                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    7276
    73           private:
    7477                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    75                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name );
     78                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     79                /// Adds alternatives for member expressions where the left side has tuple type
     80                void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
    7681                /// Adds alternatives for offsetof expressions, given the base type and name of the member
    7782                template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
    78                 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave );
     83                bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out );
    7984                template< typename OutputIterator >
    80                 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );
     85                void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out );
    8186                template< typename OutputIterator >
    8287                void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out );
     
    8994
    9095        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
     96
     97        template< typename InputIterator, typename OutputIterator >
     98        void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
     99                AltList alternatives;
     100
     101                // select the alternatives that have the minimum parameter cost
     102                Cost minCost = Cost::infinity;
     103                for ( InputIterator i = begin; i != end; ++i ) {
     104                        if ( i->cost < minCost ) {
     105                                minCost = i->cost;
     106                                i->cost = i->cvtCost;
     107                                alternatives.clear();
     108                                alternatives.push_back( *i );
     109                        } else if ( i->cost == minCost ) {
     110                                i->cost = i->cvtCost;
     111                                alternatives.push_back( *i );
     112                        }
     113                }
     114                std::copy( alternatives.begin(), alternatives.end(), out );
     115        }
     116
     117        Cost sumCost( const AltList &in );
     118
     119        template< typename InputIterator >
     120        void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
     121                while ( begin != end ) {
     122                        result.simpleCombine( (*begin++).env );
     123                }
     124        }
    91125} // namespace ResolvExpr
    92126
  • src/ResolvExpr/AlternativePrinter.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AlternativePrinter.cc -- 
     7// AlternativePrinter.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3333                for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    3434                        os << "Alternative " << count++ << " ==============" << std::endl;
    35                         printAll( i->expr->get_results(), os );
     35                        i->expr->get_result()->print( os );
    3636                        //    i->print( os );
    3737                        os << std::endl;
  • src/ResolvExpr/ConversionCost.cc

    r3a2128f r1f44196  
    240240                        std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
    241241                        std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin();
    242                         while ( srcIt != tupleType->get_types().end() ) {
     242                        while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    243243                                Cost newCost = conversionCost( *srcIt++, *destIt++, indexer, env );
    244244                                if ( newCost == Cost::infinity ) {
  • src/ResolvExpr/FindOpenVars.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FindOpenVars.cc -- 
     7// FindOpenVars.cc --
    88//
    99// Author           : Richard C. Bilson
     
    4747        void FindOpenVars::common_action( Type *type ) {
    4848                if ( nextIsOpen ) {
    49                         for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     49                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    5050                                openVars[ (*i)->get_name() ] = (*i)->get_kind();
    5151                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
     
    5656                        }
    5757                } else {
    58                         for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     58                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    5959                                closedVars[ (*i)->get_name() ] = (*i)->get_kind();
    6060                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
  • src/ResolvExpr/RenameVars.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // RenameVars.cc -- 
     7// RenameVars.cc --
    88//
    99// Author           : Richard C. Bilson
     
    125125                        mapStack.push_front( mapStack.front() );
    126126                        // renames all "forall" type names to `_${level}_${name}'
    127                         for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     127                        for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    128128                                std::ostringstream output;
    129129                                output << "_" << level << "_" << (*i)->get_name();
  • src/ResolvExpr/ResolveTypeof.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ResolveTypeof.cc -- 
     7// ResolveTypeof.cc --
    88//
    99// Author           : Richard C. Bilson
     
    5858                if ( typeofType->get_expr() ) {
    5959                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
    60                         assert( newExpr->get_results().size() > 0 );
    61                         Type *newType;
    62                         if ( newExpr->get_results().size() > 1 ) {
    63                                 TupleType *tupleType = new TupleType( Type::Qualifiers() );
    64                                 cloneAll( newExpr->get_results(), tupleType->get_types() );
    65                                 newType = tupleType;
    66                         } else {
    67                                 newType = newExpr->get_results().front()->clone();
    68                         } // if
     60                        assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
     61                        Type *newType = newExpr->get_result();
    6962                        delete typeofType;
    7063                        return newType;
  • src/ResolvExpr/Resolver.cc

    r3a2128f r1f44196  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
     21#include "typeops.h"
    2122#include "SynTree/Statement.h"
    2223#include "SynTree/Type.h"
     
    6869          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6970          void fallbackInit( ConstructorInit * ctorInit );
    70                 std::list< Type * > functionReturn;
    71                 Type *initContext;
     71
     72                Type * functionReturn = nullptr;
     73                Type *initContext = nullptr;
    7274                bool inEnumDecl = false;
    7375        };
     
    157159                        const TypeEnvironment *newEnv = 0;
    158160                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    159                                 if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
     161                                if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
    160162                                        if ( newExpr ) {
    161163                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    234236                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    235237                functionDecl->set_type( new_type );
    236                 std::list< Type * > oldFunctionReturn = functionReturn;
    237                 functionReturn.clear();
    238                 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
    239                         functionReturn.push_back( (*i)->get_type() );
    240                 } // for
     238                ValueGuard< Type * > oldFunctionReturn( functionReturn );
     239                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    241240                SymTab::Indexer::visit( functionDecl );
    242                 functionReturn = oldFunctionReturn;
    243241        }
    244242
     
    338336        void Resolver::visit( ReturnStmt *returnStmt ) {
    339337                if ( returnStmt->get_expr() ) {
    340                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
    341                         cloneAll( functionReturn, castExpr->get_results() );
     338                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
    342339                        Expression *newExpr = findSingleExpression( castExpr, *this );
    343340                        delete castExpr;
     
    384381                                if ( isCharType( at->get_base() ) ) {
    385382                                        // check if the resolved type is char *
    386                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
     383                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    387384                                                if ( isCharType( pt->get_base() ) ) {
    388385                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    446443                                (*iter)->accept( *this );
    447444                        } // for
     445                } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
     446                        for ( Type * t : *tt ) {
     447                                if ( iter == end ) break;
     448                                initContext = t;
     449                                (*iter++)->accept( *this );
     450                        }
    448451                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    449452                        resolveAggrInit( st->get_baseStruct(), iter, end );
  • src/ResolvExpr/TypeEnvironment.cc

    r3a2128f r1f44196  
    158158        }
    159159
    160         void TypeEnvironment::add( const std::list< TypeDecl* > &tyDecls ) {
    161                 for ( std::list< TypeDecl* >::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) {
     160        void TypeEnvironment::add( const Type::ForallList &tyDecls ) {
     161                for ( Type::ForallList::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) {
    162162                        EqvClass newClass;
    163163                        newClass.vars.insert( (*i)->get_name() );
  • src/ResolvExpr/TypeEnvironment.h

    r3a2128f r1f44196  
    5555                bool lookup( const std::string &var, EqvClass &eqvClass ) const;
    5656                void add( const EqvClass &eqvClass );
    57                 void add( const std::list< TypeDecl* > &tyDecls );
     57                void add( const Type::ForallList &tyDecls );
    5858                template< typename SynTreeClass > int apply( SynTreeClass *&type ) const;
    5959                template< typename SynTreeClass > int applyFree( SynTreeClass *&type ) const;
  • src/ResolvExpr/Unify.cc

    r3a2128f r1f44196  
    597597        }
    598598
     599        // xxx - compute once and store in the FunctionType?
     600        Type * extractResultType( FunctionType * function ) {
     601                if ( function->get_returnVals().size() == 0 ) {
     602                        return new VoidType( Type::Qualifiers() );
     603                } else if ( function->get_returnVals().size() == 1 ) {
     604                        return function->get_returnVals().front()->get_type()->clone();
     605                } else {
     606                        TupleType * tupleType = new TupleType( Type::Qualifiers() );
     607                        for ( DeclarationWithType * decl : function->get_returnVals() ) {
     608                                tupleType->get_types().push_back( decl->get_type()->clone() );
     609                        } // for
     610                        return tupleType;
     611                }
     612        }
    599613} // namespace ResolvExpr
    600614
  • src/ResolvExpr/typeops.h

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // typeops.h -- 
     7// typeops.h --
    88//
    99// Author           : Richard C. Bilson
     
    3030                typedef typename InputIterator::value_type SetType;
    3131                typedef typename std::list< typename SetType::value_type > ListType;
    32  
     32
    3333                if ( begin == end )     {
    3434                        *out++ = ListType();
    3535                        return;
    3636                } // if
    37  
     37
    3838                InputIterator current = begin;
    3939                begin++;
     
    4141                std::list< ListType > recursiveResult;
    4242                combos( begin, end, back_inserter( recursiveResult ) );
    43  
     43
    4444                for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) {
    4545                        for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) {
     
    5252                } // for
    5353        }
    54  
     54
    5555        // in AdjustExprType.cc
    5656        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
     
    144144        }
    145145
     146        /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.
     147        Type * extractResultType( FunctionType * functionType );
     148
    146149        // in CommonType.cc
    147150        Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
     
    152155        // in Occurs.cc
    153156        bool occurs( Type *type, std::string varName, const TypeEnvironment &env );
     157
     158        // flatten tuple type into list of types
     159        template< typename OutputIterator >
     160        void flatten( Type * type, OutputIterator out ) {
     161                if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {
     162                        for ( Type * t : tupleType->get_types() ) {
     163                                flatten( t, out );
     164                        }
     165                } else {
     166                        *out++ = type;
     167                }
     168        }
    154169} // namespace ResolvExpr
    155170
  • src/SymTab/Autogen.cc

    r3a2128f r1f44196  
    116116                // This happens before function pointer type conversion, so need to do it manually here
    117117                VariableExpr * assignVarExpr = new VariableExpr( assignDecl );
    118                 Type *& assignVarExprType = assignVarExpr->get_results().front();
     118                Type * assignVarExprType = assignVarExpr->get_result();
    119119                assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType );
     120                assignVarExpr->set_result( assignVarExprType );
    120121                ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr );
    121122                assignExpr->get_args().push_back( new VariableExpr( dstParam ) );
  • src/SymTab/Indexer.cc

    r3a2128f r1f44196  
    4040
    4141namespace SymTab {
    42         template< typename Container, typename VisitorType >
    43         inline void acceptAllNewScope( Container &container, VisitorType &visitor ) {
     42        template< typename TreeType, typename VisitorType >
     43        inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
    4444                visitor.enterScope();
    45                 acceptAll( container, visitor );
     45                maybeAccept( tree, visitor );
    4646                visitor.leaveScope();
    4747        }
     
    143143                for ( DeclarationWithType * decl : copy ) {
    144144                        if ( FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl ) ) {
    145                                 std::list< DeclarationWithType * > params = function->get_functionType()->get_parameters();
     145                                std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters();
    146146                                assert( ! params.empty() );
    147147                                // use base type of pointer, so that qualifiers on the pointer type aren't considered.
     
    337337
    338338        void Indexer::visit( ApplicationExpr *applicationExpr ) {
    339                 acceptAllNewScope( applicationExpr->get_results(), *this );
     339                acceptNewScope( applicationExpr->get_result(), *this );
    340340                maybeAccept( applicationExpr->get_function(), *this );
    341341                acceptAll( applicationExpr->get_args(), *this );
     
    343343
    344344        void Indexer::visit( UntypedExpr *untypedExpr ) {
    345                 acceptAllNewScope( untypedExpr->get_results(), *this );
     345                acceptNewScope( untypedExpr->get_result(), *this );
    346346                acceptAll( untypedExpr->get_args(), *this );
    347347        }
    348348
    349349        void Indexer::visit( NameExpr *nameExpr ) {
    350                 acceptAllNewScope( nameExpr->get_results(), *this );
     350                acceptNewScope( nameExpr->get_result(), *this );
    351351        }
    352352
    353353        void Indexer::visit( AddressExpr *addressExpr ) {
    354                 acceptAllNewScope( addressExpr->get_results(), *this );
     354                acceptNewScope( addressExpr->get_result(), *this );
    355355                maybeAccept( addressExpr->get_arg(), *this );
    356356        }
    357357
    358358        void Indexer::visit( LabelAddressExpr *labAddressExpr ) {
    359                 acceptAllNewScope( labAddressExpr->get_results(), *this );
     359                acceptNewScope( labAddressExpr->get_result(), *this );
    360360                maybeAccept( labAddressExpr->get_arg(), *this );
    361361        }
    362362
    363363        void Indexer::visit( CastExpr *castExpr ) {
    364                 acceptAllNewScope( castExpr->get_results(), *this );
     364                acceptNewScope( castExpr->get_result(), *this );
    365365                maybeAccept( castExpr->get_arg(), *this );
    366366        }
    367367
    368368        void Indexer::visit( UntypedMemberExpr *memberExpr ) {
    369                 acceptAllNewScope( memberExpr->get_results(), *this );
     369                acceptNewScope( memberExpr->get_result(), *this );
    370370                maybeAccept( memberExpr->get_aggregate(), *this );
    371371        }
    372372
    373373        void Indexer::visit( MemberExpr *memberExpr ) {
    374                 acceptAllNewScope( memberExpr->get_results(), *this );
     374                acceptNewScope( memberExpr->get_result(), *this );
    375375                maybeAccept( memberExpr->get_aggregate(), *this );
    376376        }
    377377
    378378        void Indexer::visit( VariableExpr *variableExpr ) {
    379                 acceptAllNewScope( variableExpr->get_results(), *this );
     379                acceptNewScope( variableExpr->get_result(), *this );
    380380        }
    381381
    382382        void Indexer::visit( ConstantExpr *constantExpr ) {
    383                 acceptAllNewScope( constantExpr->get_results(), *this );
     383                acceptNewScope( constantExpr->get_result(), *this );
    384384                maybeAccept( constantExpr->get_constant(), *this );
    385385        }
    386386
    387387        void Indexer::visit( SizeofExpr *sizeofExpr ) {
    388                 acceptAllNewScope( sizeofExpr->get_results(), *this );
     388                acceptNewScope( sizeofExpr->get_result(), *this );
    389389                if ( sizeofExpr->get_isType() ) {
    390390                        maybeAccept( sizeofExpr->get_type(), *this );
     
    395395
    396396        void Indexer::visit( AlignofExpr *alignofExpr ) {
    397                 acceptAllNewScope( alignofExpr->get_results(), *this );
     397                acceptNewScope( alignofExpr->get_result(), *this );
    398398                if ( alignofExpr->get_isType() ) {
    399399                        maybeAccept( alignofExpr->get_type(), *this );
     
    404404
    405405        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
    406                 acceptAllNewScope( offsetofExpr->get_results(), *this );
     406                acceptNewScope( offsetofExpr->get_result(), *this );
    407407                maybeAccept( offsetofExpr->get_type(), *this );
    408408        }
    409409
    410410        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
    411                 acceptAllNewScope( offsetofExpr->get_results(), *this );
     411                acceptNewScope( offsetofExpr->get_result(), *this );
    412412                maybeAccept( offsetofExpr->get_type(), *this );
    413413                maybeAccept( offsetofExpr->get_member(), *this );
     
    415415
    416416        void Indexer::visit( OffsetPackExpr *offsetPackExpr ) {
    417                 acceptAllNewScope( offsetPackExpr->get_results(), *this );
     417                acceptNewScope( offsetPackExpr->get_result(), *this );
    418418                maybeAccept( offsetPackExpr->get_type(), *this );
    419419        }
    420420
    421421        void Indexer::visit( AttrExpr *attrExpr ) {
    422                 acceptAllNewScope( attrExpr->get_results(), *this );
     422                acceptNewScope( attrExpr->get_result(), *this );
    423423                if ( attrExpr->get_isType() ) {
    424424                        maybeAccept( attrExpr->get_type(), *this );
     
    429429
    430430        void Indexer::visit( LogicalExpr *logicalExpr ) {
    431                 acceptAllNewScope( logicalExpr->get_results(), *this );
     431                acceptNewScope( logicalExpr->get_result(), *this );
    432432                maybeAccept( logicalExpr->get_arg1(), *this );
    433433                maybeAccept( logicalExpr->get_arg2(), *this );
     
    435435
    436436        void Indexer::visit( ConditionalExpr *conditionalExpr ) {
    437                 acceptAllNewScope( conditionalExpr->get_results(), *this );
     437                acceptNewScope( conditionalExpr->get_result(), *this );
    438438                maybeAccept( conditionalExpr->get_arg1(), *this );
    439439                maybeAccept( conditionalExpr->get_arg2(), *this );
     
    442442
    443443        void Indexer::visit( CommaExpr *commaExpr ) {
    444                 acceptAllNewScope( commaExpr->get_results(), *this );
     444                acceptNewScope( commaExpr->get_result(), *this );
    445445                maybeAccept( commaExpr->get_arg1(), *this );
    446446                maybeAccept( commaExpr->get_arg2(), *this );
     
    448448
    449449        void Indexer::visit( TupleExpr *tupleExpr ) {
    450                 acceptAllNewScope( tupleExpr->get_results(), *this );
     450                acceptNewScope( tupleExpr->get_result(), *this );
    451451                acceptAll( tupleExpr->get_exprs(), *this );
    452452        }
    453453
    454         void Indexer::visit( SolvedTupleExpr *tupleExpr ) {
    455                 acceptAllNewScope( tupleExpr->get_results(), *this );
    456                 acceptAll( tupleExpr->get_exprs(), *this );
     454        void Indexer::visit( TupleAssignExpr *tupleExpr ) {
     455                acceptNewScope( tupleExpr->get_result(), *this );
     456                enterScope();
     457                acceptAll( tupleExpr->get_tempDecls(), *this );
     458                acceptAll( tupleExpr->get_assigns(), *this );
     459                leaveScope();
    457460        }
    458461
    459462        void Indexer::visit( TypeExpr *typeExpr ) {
    460                 acceptAllNewScope( typeExpr->get_results(), *this );
     463                acceptNewScope( typeExpr->get_result(), *this );
    461464                maybeAccept( typeExpr->get_type(), *this );
    462465        }
     
    469472
    470473        void Indexer::visit( UntypedValofExpr *valofExpr ) {
    471                 acceptAllNewScope( valofExpr->get_results(), *this );
     474                acceptNewScope( valofExpr->get_result(), *this );
    472475                maybeAccept( valofExpr->get_body(), *this );
    473476        }
  • src/SymTab/Indexer.h

    r3a2128f r1f44196  
    6464                virtual void visit( ConditionalExpr *conditionalExpr );
    6565                virtual void visit( CommaExpr *commaExpr );
    66                 virtual void visit( TupleExpr *tupleExpr );
    67                 virtual void visit( SolvedTupleExpr *tupleExpr );
    6866                virtual void visit( TypeExpr *typeExpr );
    6967                virtual void visit( AsmExpr *asmExpr );
    7068                virtual void visit( UntypedValofExpr *valofExpr );
     69                virtual void visit( TupleExpr *tupleExpr );
     70                virtual void visit( TupleAssignExpr *tupleExpr );
    7171
    7272                virtual void visit( TraitInstType *contextInst );
  • src/SymTab/Mangler.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Mangler.cc -- 
     7// Mangler.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3535                return mangler.get_mangleName();
    3636        }
    37        
     37
    3838        Mangler::Mangler( bool mangleOverridable, bool typeMode )
    3939                : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ), typeMode( typeMode ) {}
    40                
     40
    4141        Mangler::Mangler( const Mangler &rhs ) : mangleName() {
    4242                varNums = rhs.varNums;
     
    115115                        "Ir",   // LongDoubleImaginary
    116116                };
    117  
     117
    118118                printQualifiers( basicType );
    119119                mangleName << btLetter[ basicType->get_kind() ];
     
    253253                // skip if not including qualifiers
    254254                if ( typeMode ) return;
    255                
     255
    256256                if ( ! type->get_forall().empty() ) {
    257257                        std::list< std::string > assertionNames;
    258258                        int tcount = 0, dcount = 0, fcount = 0;
    259259                        mangleName << "A";
    260                         for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     260                        for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    261261                                switch ( (*i)->get_kind() ) {
    262262                                  case TypeDecl::Any:
  • src/SymTab/Validate.cc

    r3a2128f r1f44196  
    2323// - All enumeration constants have type EnumInstType.
    2424//
    25 // - The type "void" never occurs in lists of function parameter or return types; neither do tuple types.  A function
    26 //   taking no arguments has no argument types, and tuples are flattened.
     25// - The type "void" never occurs in lists of function parameter or return types.  A function
     26//   taking no arguments has no argument types.
    2727//
    2828// - No context instances exist; they are all replaced by the set of declarations signified by the context, instantiated
     
    243243                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
    244244        }
    245 
     245        // xxx - shouldn't this be declsToAddBefore?
    246246        template< typename AggDecl >
    247247        void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) {
     
    431431        /// Fix up assertions
    432432        void forallFixer( Type *func ) {
    433                 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
     433                for ( Type::ForallList::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
    434434                        std::list< DeclarationWithType * > toBeDone, nextRound;
    435435                        toBeDone.splice( toBeDone.end(), (*type )->get_assertions() );
  • src/SynTree/AddressExpr.cc

    r3a2128f r1f44196  
    1919
    2020AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
    21         for ( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) {
    22                 get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );
    23         } // for
     21        if ( arg->has_result() ) {
     22                set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) );
     23        }
    2424}
    2525
     
    3535        if ( arg ) {
    3636                os << std::string( indent+2, ' ' );
    37     arg->print( os, indent+2 );
     37                arg->print( os, indent+2 );
    3838        } // if
    3939}
  • src/SynTree/ApplicationExpr.cc

    r3a2128f r1f44196  
    2121#include "TypeSubstitution.h"
    2222#include "Common/utility.h"
    23 
     23#include "ResolvExpr/typeops.h"
    2424
    2525ParamEntry::ParamEntry( const ParamEntry &other ) :
     
    4343
    4444ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
    45         PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() );
    46         assert( pointer );
    47         FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    48         assert( function );
     45        PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
     46        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
    4947
    50         for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
    51                 get_results().push_back( (*i)->get_type()->clone() );
    52         } // for
     48        set_result( ResolvExpr::extractResultType( function ) );
     49
     50        assert( has_result() );
    5351}
    5452
  • src/SynTree/CommaExpr.cc

    r3a2128f r1f44196  
    2323        // to false on all result types. Actually doing this causes some strange things
    2424        // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    25         cloneAll( arg2->get_results(), get_results() );
    26         // for ( Type *& type : get_results() ) {
    27         //      type->set_isLvalue( false );
    28         // }
     25        set_result( maybeClone( arg2->get_result() ) );
     26        // get_type->set_isLvalue( false );
    2927}
    3028
  • src/SynTree/CompoundStmt.cc

    r3a2128f r1f44196  
    2020#include "Expression.h"
    2121#include "Declaration.h"
     22#include "SynTree/VarExprReplacer.h"
    2223
    2324using std::string;
    2425using std::endl;
    25 
    26 class VarExprReplacer : public Visitor {
    27 public:
    28   typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
    29 private:
    30   const DeclMap & declMap;
    31 public:
    32   VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {}
    33 
    34   // replace variable with new node from decl map
    35   virtual void visit( VariableExpr * varExpr ) {
    36     if ( declMap.count( varExpr->get_var() ) ) {
    37       varExpr->set_var( declMap.at( varExpr->get_var() ) );
    38     }
    39   }
    40 };
    41 
    4226
    4327CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) {
     
    4731        cloneAll( other.kids, kids );
    4832
    49   // when cloning a compound statement, we may end up cloning declarations which
    50   // are referred to by VariableExprs throughout the block. Cloning a VariableExpr
    51   // does a shallow copy, so the VariableExpr will end up pointing to the original
    52   // declaration. If the original declaration is deleted, e.g. because the original
    53   // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case,
    54   // find all DeclarationWithType nodes (since a VariableExpr must point to a
    55   // DeclarationWithType) in the original CompoundStmt and map them to the cloned
    56   // node in the new CompoundStmt ('this'), then replace the Declarations referred to
    57   // by each VariableExpr according to the constructed map. Note that only the declarations
    58   // in the current level are collected into the map, because child CompoundStmts will
    59   // recursively execute this routine. There may be more efficient ways of doing
    60   // this.
    61   VarExprReplacer::DeclMap declMap;
    62   std::list< Statement * >::const_iterator origit = other.kids.begin();
    63   for ( Statement * s : kids ) {
    64     assert( origit != other.kids.end() );
    65     if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) {
    66       DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( *origit );
    67       assert( origDeclStmt );
    68       if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) {
    69         DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
    70         assert( origdwt );
    71         declMap[ origdwt ] = dwt;
    72       }
    73     }
    74   }
    75   if ( ! declMap.empty() ) {
    76     VarExprReplacer replacer( declMap );
    77     accept( replacer );
    78   }
     33        // when cloning a compound statement, we may end up cloning declarations which
     34        // are referred to by VariableExprs throughout the block. Cloning a VariableExpr
     35        // does a shallow copy, so the VariableExpr will end up pointing to the original
     36        // declaration. If the original declaration is deleted, e.g. because the original
     37        // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case,
     38        // find all DeclarationWithType nodes (since a VariableExpr must point to a
     39        // DeclarationWithType) in the original CompoundStmt and map them to the cloned
     40        // node in the new CompoundStmt ('this'), then replace the Declarations referred to
     41        // by each VariableExpr according to the constructed map. Note that only the declarations
     42        // in the current level are collected into the map, because child CompoundStmts will
     43        // recursively execute this routine. There may be more efficient ways of doing
     44        // this.
     45        VarExprReplacer::DeclMap declMap;
     46        std::list< Statement * >::const_iterator origit = other.kids.begin();
     47        for ( Statement * s : kids ) {
     48                assert( origit != other.kids.end() );
     49                Statement * origStmt = *origit++;
     50                if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) {
     51                        DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( origStmt );
     52                        assert( origDeclStmt );
     53                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) {
     54                                DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
     55                                assert( origdwt );
     56                                assert( dwt->get_name() == origdwt->get_name() );
     57                                declMap[ origdwt ] = dwt;
     58                        }
     59                }
     60        }
     61        if ( ! declMap.empty() ) {
     62                VarExprReplacer replacer( declMap );
     63                accept( replacer );
     64        }
    7965}
    8066
  • src/SynTree/Expression.cc

    r3a2128f r1f44196  
    3131
    3232
    33 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
    34 
    35 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    36         cloneAll( other.results, results );
     33Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
     34
     35Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    3736}
    3837
     
    4039        delete env;
    4140        delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    42         deleteAll( results );
    43 }
    44 
    45 void Expression::add_result( Type *t ) {
    46         if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) {
    47                 std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) );
    48         } else {
    49                 results.push_back(t);
    50         } // if
     41        delete result;
    5142}
    5243
     
    6859
    6960ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
    70         add_result( constant.get_type()->clone() );
     61        set_result( constant.get_type()->clone() );
    7162}
    7263
     
    8576        assert( var );
    8677        assert( var->get_type() );
    87         add_result( var->get_type()->clone() );
    88         for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
    89                 (*i)->set_isLvalue( true );
    90         } // for
     78        Type * type = var->get_type()->clone();
     79        type->set_isLvalue( true );
     80        set_result( type );
    9181}
    9282
     
    110100SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    111101                Expression( _aname ), expr(expr_), type(0), isType(false) {
    112         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     102        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    113103}
    114104
    115105SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    116106                Expression( _aname ), expr(0), type(type_), isType(true) {
    117         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     107        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    118108}
    119109
     
    141131AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    142132                Expression( _aname ), expr(expr_), type(0), isType(false) {
    143         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     133        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    144134}
    145135
    146136AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    147137                Expression( _aname ), expr(0), type(type_), isType(true) {
    148         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     138        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    149139}
    150140
     
    172162UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
    173163                Expression( _aname ), type(type_), member(member_) {
    174         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     164        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    175165}
    176166
     
    197187OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
    198188                Expression( _aname ), type(type_), member(member_) {
    199         add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     189        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    200190}
    201191
     
    229219
    230220OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    231         add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     221        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    232222}
    233223
     
    284274
    285275CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    286         add_result(toType);
     276        set_result(toType);
    287277}
    288278
    289279CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     280        set_result( new VoidType( Type::Qualifiers() ) );
    290281}
    291282
     
    303294        arg->print(os, indent+2);
    304295        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
    305         if ( results.empty() ) {
    306                 os << std::string( indent+2, ' ' ) << "nothing" << std::endl;
     296        os << std::string( indent+2, ' ' );
     297        if ( result->isVoid() ) {
     298                os << "nothing";
    307299        } else {
    308                 printAll(results, os, indent+2);
     300                result->print( os, indent+2 );
    309301        } // if
    310         Expression::print( os, indent );
    311 }
    312 
    313 UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) :
     302        os << std::endl;
     303        Expression::print( os, indent );
     304}
     305
     306UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) :
    314307                Expression( _aname ), member(_member), aggregate(_aggregate) {}
    315308
    316309UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
    317                 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     310                Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
    318311}
    319312
    320313UntypedMemberExpr::~UntypedMemberExpr() {
    321314        delete aggregate;
     315        delete member;
    322316}
    323317
    324318void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    325         os << "Untyped Member Expression, with field: " << get_member();
     319        os << "Untyped Member Expression, with field: " << std::endl;
     320        os << std::string( indent+2, ' ' );
     321        get_member()->print(os, indent+4);
     322        os << std::string( indent+2, ' ' );
    326323
    327324        Expression *agg = get_aggregate();
    328         os << ", from aggregate: ";
     325        os << "from aggregate: " << std::endl;
    329326        if (agg != 0) {
    330                 os << std::string( indent + 2, ' ' );
    331                 agg->print(os, indent + 2);
     327                os << std::string( indent + 4, ' ' );
     328                agg->print(os, indent + 4);
    332329        }
    333330        os << std::string( indent+2, ' ' );
     
    338335MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    339336                Expression( _aname ), member(_member), aggregate(_aggregate) {
    340         add_result( member->get_type()->clone() );
    341         for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
    342                 (*i)->set_isLvalue( true );
    343         } // for
     337        set_result( member->get_type()->clone() );
     338        get_result()->set_isLvalue( true );
    344339}
    345340
     
    372367}
    373368
    374 
    375 UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function ) {}
     369UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
     370                Expression( _aname ), function(_function), args(_args) {}
    376371
    377372UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    380375}
    381376
    382 UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :
    383                 Expression( _aname ), function(_function), args(_args) {}
    384 
    385377UntypedExpr::~UntypedExpr() {
    386378        delete function;
    387379        deleteAll( args );
    388380}
     381
     382UntypedExpr * UntypedExpr::createDeref( Expression * expr ) {
     383        UntypedExpr * ret = new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ expr } );
     384        if ( Type * type = expr->get_result() ) {
     385                Type * base = InitTweak::getPointerBase( type );
     386                if ( ! base ) {
     387                        std::cerr << type << std::endl;
     388                }
     389                assertf( base, "expected pointer type in dereference\n" );
     390                ret->set_result( maybeClone( base ) );
     391        }
     392        return ret;
     393}
     394
     395UntypedExpr * UntypedExpr::createAssign( Expression * arg1, Expression * arg2 ) {
     396        assert( arg1 && arg2 );
     397        UntypedExpr * ret = new UntypedExpr( new NameExpr( "?=?" ), std::list< Expression * >{ arg1, arg2 } );
     398        if ( arg1->get_result() && arg2->get_result() ) {
     399                // if both expressions are typed, assumes that this assignment is a C bitwise assignment,
     400                // so the result is the type of the RHS
     401                ret->set_result( arg2->get_result()->clone() );
     402        }
     403        return ret;
     404}
     405
    389406
    390407void UntypedExpr::print( std::ostream &os, int indent ) const {
     
    419436LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    420437                Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    421         add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
     438        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    422439}
    423440
     
    454471
    455472void ConditionalExpr::print( std::ostream &os, int indent ) const {
    456         os << std::string( indent, ' ' ) << "Conditional expression on: " << std::endl;
     473        os << "Conditional expression on: " << std::endl;
     474        os << std::string( indent+2, ' ' );
    457475        arg1->print( os, indent+2 );
    458476        os << std::string( indent, ' ' ) << "First alternative:" << std::endl;
     477        os << std::string( indent+2, ' ' );
    459478        arg2->print( os, indent+2 );
    460479        os << std::string( indent, ' ' ) << "Second alternative:" << std::endl;
     480        os << std::string( indent+2, ' ' );
    461481        arg3->print( os, indent+2 );
    462482        os << std::endl;
     
    477497ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    478498        assert( callExpr );
    479         cloneAll( callExpr->get_results(), results );
     499        assert( callExpr->has_result() );
     500        set_result( callExpr->get_result()->clone() );
    480501}
    481502
     
    510531        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    511532        assert( arg );
    512         cloneAll( arg->get_results(), results );
     533        set_result( maybeClone( arg->get_result() ) );
    513534}
    514535
     
    530551
    531552CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    532         add_result( type->clone() );
    533 }
    534 
    535 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     553        assert( type && initializer );
     554        set_result( type->clone() );
     555}
     556
     557CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {}
    536558
    537559CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    542564void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
    543565        os << "Compound Literal Expression: " << std::endl;
    544         if ( type ) type->print( os, indent + 2 );
    545         if ( initializer ) initializer->print( os, indent + 2 );
     566        os << std::string( indent+2, ' ' );
     567        type->print( os, indent + 2 );
     568        os << std::string( indent+2, ' ' );
     569        initializer->print( os, indent + 2 );
    546570}
    547571
     
    557581
    558582RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    559 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
     583RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    560584void RangeExpr::print( std::ostream &os, int indent ) const {
    561         os << std::string( indent, ' ' ) << "Range Expression: ";
     585        os << "Range Expression: ";
    562586        low->print( os, indent );
    563587        os << " ... ";
    564588        high->print( os, indent );
     589}
     590
     591StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
     592        assert( statements );
     593        std::list< Statement * > & body = statements->get_kids();
     594        if ( ! body.empty() ) {
     595                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
     596                        set_result( maybeClone( exprStmt->get_expr()->get_result() ) );
     597                }
     598        }
     599}
     600StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {}
     601StmtExpr::~StmtExpr() {
     602        delete statements;
     603}
     604void StmtExpr::print( std::ostream &os, int indent ) const {
     605        os << "Statement Expression: " << std::endl << std::string( indent, ' ' );
     606        statements->print( os, indent+2 );
     607}
     608
     609
     610long long UniqueExpr::count = 0;
     611UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
     612        assert( expr );
     613        assert( count != -1 );
     614        if ( id == -1 ) id = count++;
     615        if ( expr->get_result() ) {
     616                set_result( expr->get_result()->clone() );
     617        }
     618}
     619UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
     620}
     621UniqueExpr::~UniqueExpr() {
     622        delete expr;
     623        delete object;
     624        delete var;
     625}
     626void UniqueExpr::print( std::ostream &os, int indent ) const {
     627        os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' );
     628        get_expr()->print( os, indent+2 );
     629        if ( get_object() ) {
     630                os << " with decl: ";
     631                get_object()->printShort( os, indent+2 );
     632        }
    565633}
    566634
  • src/SynTree/Expression.h

    r3a2128f r1f44196  
    3232        virtual ~Expression();
    3333
    34         std::list<Type *>& get_results() { return results; }
    35         void add_result( Type *t );
     34        Type *& get_result() { return result; }
     35        void set_result( Type *newValue ) { result = newValue; }
     36        bool has_result() const { return result != nullptr; }
    3637
    3738        TypeSubstitution *get_env() const { return env; }
     
    4748        virtual void print( std::ostream &os, int indent = 0 ) const;
    4849  protected:
    49         std::list<Type *> results;
     50        Type * result;
    5051        TypeSubstitution *env;
    5152        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     
    9899class UntypedExpr : public Expression {
    99100  public:
    100         UntypedExpr( Expression *function, Expression *_aname = nullptr );
     101        UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr );
    101102        UntypedExpr( const UntypedExpr &other );
    102         UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );
    103103        virtual ~UntypedExpr();
    104104
     
    111111        std::list<Expression*>& get_args() { return args; }
    112112
     113        static UntypedExpr * createDeref( Expression * arg );
     114        static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 );
     115
    113116        virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
    114117        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    200203class UntypedMemberExpr : public Expression {
    201204  public:
    202         UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr );
     205        UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr );
    203206        UntypedMemberExpr( const UntypedMemberExpr &other );
    204207        virtual ~UntypedMemberExpr();
    205208
    206         std::string get_member() const { return member; }
    207         void set_member( const std::string &newValue ) { member = newValue; }
     209        Expression * get_member() const { return member; }
     210        void set_member( Expression * newValue ) { member = newValue; }
    208211        Expression *get_aggregate() const { return aggregate; }
    209212        void set_aggregate( Expression *newValue ) { aggregate = newValue; }
     
    214217        virtual void print( std::ostream &os, int indent = 0 ) const;
    215218  private:
    216         std::string member;
     219        Expression *member;
    217220        Expression *aggregate;
    218221};
     
    483486};
    484487
    485 /// TupleExpr represents a tuple expression ( [a, b, c] )
    486 class TupleExpr : public Expression {
    487   public:
    488         TupleExpr( Expression *_aname = nullptr );
    489         TupleExpr( const TupleExpr &other );
    490         virtual ~TupleExpr();
    491 
    492         void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
    493         std::list<Expression*>& get_exprs() { return exprs; }
    494 
    495         virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
    496         virtual void accept( Visitor &v ) { v.visit( this ); }
    497         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    498         virtual void print( std::ostream &os, int indent = 0 ) const;
    499   private:
    500         std::list<Expression*> exprs;
    501 };
    502 
    503 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
    504 class SolvedTupleExpr : public Expression {
    505   public:
    506         SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}
    507         SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );
    508         SolvedTupleExpr( const SolvedTupleExpr &other );
    509         virtual ~SolvedTupleExpr() {}
    510 
    511         std::list<Expression*> &get_exprs() { return exprs; }
    512 
    513         virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
    514         virtual void accept( Visitor &v ) { v.visit( this ); }
    515         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    516         virtual void print( std::ostream &os, int indent = 0 ) const;
    517   private:
    518         std::list<Expression*> exprs;
    519 };
    520 
    521488/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    522489class TypeExpr : public Expression {
     
    618585        CompoundLiteralExpr( Type * type, Initializer * initializer );
    619586        CompoundLiteralExpr( const CompoundLiteralExpr &other );
    620         ~CompoundLiteralExpr();
     587        virtual ~CompoundLiteralExpr();
    621588
    622589        Type * get_type() const { return type; }
     
    670637  private:
    671638        Expression *low, *high;
     639};
     640
     641/// TupleExpr represents a tuple expression ( [a, b, c] )
     642class TupleExpr : public Expression {
     643  public:
     644        TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr );
     645        TupleExpr( const TupleExpr &other );
     646        virtual ~TupleExpr();
     647
     648        void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
     649        std::list<Expression*>& get_exprs() { return exprs; }
     650
     651        virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
     652        virtual void accept( Visitor &v ) { v.visit( this ); }
     653        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     654        virtual void print( std::ostream &os, int indent = 0 ) const;
     655  private:
     656        std::list<Expression*> exprs;
     657};
     658
     659/// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer
     660class TupleIndexExpr : public Expression {
     661  public:
     662        TupleIndexExpr( Expression * tuple, unsigned int index );
     663        TupleIndexExpr( const TupleIndexExpr &other );
     664        virtual ~TupleIndexExpr();
     665
     666        Expression * get_tuple() const { return tuple; }
     667        int get_index() const { return index; }
     668        TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; }
     669        TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; }
     670
     671        virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); }
     672        virtual void accept( Visitor &v ) { v.visit( this ); }
     673        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     674        virtual void print( std::ostream &os, int indent = 0 ) const;
     675  private:
     676        Expression * tuple;
     677        unsigned int index;
     678};
     679
     680/// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer
     681class MemberTupleExpr : public Expression {
     682  public:
     683        MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );
     684        MemberTupleExpr( const MemberTupleExpr &other );
     685        virtual ~MemberTupleExpr();
     686
     687        Expression * get_member() const { return member; }
     688        Expression * get_aggregate() const { return aggregate; }
     689        MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; }
     690        MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; }
     691
     692        virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); }
     693        virtual void accept( Visitor &v ) { v.visit( this ); }
     694        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     695        virtual void print( std::ostream &os, int indent = 0 ) const;
     696  private:
     697        Expression * member;
     698        Expression * aggregate;
     699};
     700
     701/// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression
     702class TupleAssignExpr : public Expression {
     703  public:
     704        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
     705        TupleAssignExpr( const TupleAssignExpr &other );
     706        virtual ~TupleAssignExpr();
     707
     708        std::list< Expression * > & get_assigns() { return assigns; }
     709        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     710
     711        virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); }
     712        virtual void accept( Visitor &v ) { v.visit( this ); }
     713        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     714        virtual void print( std::ostream &os, int indent = 0 ) const;
     715  private:
     716        std::list< Expression * > assigns; // assignment expressions that use tempDecls
     717        std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs
     718};
     719
     720/// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; })
     721class StmtExpr : public Expression {
     722public:
     723        StmtExpr( CompoundStmt *statements );
     724        StmtExpr( const StmtExpr & other );
     725        virtual ~StmtExpr();
     726
     727        CompoundStmt * get_statements() const { return statements; }
     728        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
     729
     730        virtual StmtExpr *clone() const { return new StmtExpr( *this ); }
     731        virtual void accept( Visitor &v ) { v.visit( this ); }
     732        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     733        virtual void print( std::ostream &os, int indent = 0 ) const;
     734private:
     735        CompoundStmt * statements;
     736};
     737
     738class UniqueExpr : public Expression {
     739public:
     740        UniqueExpr( Expression * expr, long long idVal = -1 );
     741        UniqueExpr( const UniqueExpr & other );
     742        ~UniqueExpr();
     743
     744        Expression * get_expr() const { return expr; }
     745        UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
     746
     747        ObjectDecl * get_object() const { return object; }
     748        UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; }
     749
     750        VariableExpr * get_var() const { return var; }
     751        UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; }
     752
     753        int get_id() const { return id; }
     754
     755        virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); }
     756        virtual void accept( Visitor &v ) { v.visit( this ); }
     757        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     758        virtual void print( std::ostream &os, int indent = 0 ) const;
     759private:
     760        Expression * expr;
     761        ObjectDecl * object;
     762        VariableExpr * var;
     763        int id;
     764        static long long count;
    672765};
    673766
  • src/SynTree/Initializer.h

    r3a2128f r1f44196  
    2323
    2424#include <cassert>
     25
     26const std::list<Expression*> noDesignators;
    2527
    2628// Initializer: base class for object initializers (provide default values)
  • src/SynTree/Mutator.cc

    r3a2128f r1f44196  
    178178
    179179Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    180         mutateAll( applicationExpr->get_results(), *this );
     180        applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
    181181        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
    182182        mutateAll( applicationExpr->get_args(), *this );
     
    185185
    186186Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
    187         mutateAll( untypedExpr->get_results(), *this );
     187        untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
    188188        mutateAll( untypedExpr->get_args(), *this );
    189189        return untypedExpr;
     
    191191
    192192Expression *Mutator::mutate( NameExpr *nameExpr ) {
    193         mutateAll( nameExpr->get_results(), *this );
     193        nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
    194194        return nameExpr;
    195195}
    196196
    197197Expression *Mutator::mutate( AddressExpr *addressExpr ) {
    198         mutateAll( addressExpr->get_results(), *this );
     198        addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
    199199        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
    200200        return addressExpr;
     
    202202
    203203Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
    204         mutateAll( labelAddressExpr->get_results(), *this );
     204        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    205205        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    206206        return labelAddressExpr;
     
    208208
    209209Expression *Mutator::mutate( CastExpr *castExpr ) {
    210         mutateAll( castExpr->get_results(), *this );
     210        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    211211        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    212212        return castExpr;
     
    214214
    215215Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    216         mutateAll( memberExpr->get_results(), *this );
     216        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
     217        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
     218        memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
     219        return memberExpr;
     220}
     221
     222Expression *Mutator::mutate( MemberExpr *memberExpr ) {
     223        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
    217224        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    218225        return memberExpr;
    219226}
    220227
    221 Expression *Mutator::mutate( MemberExpr *memberExpr ) {
    222         mutateAll( memberExpr->get_results(), *this );
    223         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
    224         return memberExpr;
    225 }
    226 
    227228Expression *Mutator::mutate( VariableExpr *variableExpr ) {
    228         mutateAll( variableExpr->get_results(), *this );
     229        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
    229230        return variableExpr;
    230231}
    231232
    232233Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
    233         mutateAll( constantExpr->get_results(), *this );
     234        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
    234235//  maybeMutate( constantExpr->get_constant(), *this )
    235236        return constantExpr;
     
    237238
    238239Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
    239         mutateAll( sizeofExpr->get_results(), *this );
     240        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
    240241        if ( sizeofExpr->get_isType() ) {
    241242                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
     
    247248
    248249Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
    249         mutateAll( alignofExpr->get_results(), *this );
     250        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
    250251        if ( alignofExpr->get_isType() ) {
    251252                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
     
    257258
    258259Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
    259         mutateAll( offsetofExpr->get_results(), *this );
     260        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    260261        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    261262        return offsetofExpr;
     
    263264
    264265Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
    265         mutateAll( offsetofExpr->get_results(), *this );
     266        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
    266267        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
    267268        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     
    270271
    271272Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
    272         mutateAll( offsetPackExpr->get_results(), *this );
     273        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
    273274        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
    274275        return offsetPackExpr;
     
    276277
    277278Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    278         mutateAll( attrExpr->get_results(), *this );
     279        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
    279280        if ( attrExpr->get_isType() ) {
    280281                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
     
    286287
    287288Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
    288         mutateAll( logicalExpr->get_results(), *this );
     289        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
    289290        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
    290291        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
     
    293294
    294295Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
    295         mutateAll( conditionalExpr->get_results(), *this );
     296        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
    296297        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
    297298        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
     
    301302
    302303Expression *Mutator::mutate( CommaExpr *commaExpr ) {
    303         mutateAll( commaExpr->get_results(), *this );
     304        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
    304305        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
    305306        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
     
    307308}
    308309
    309 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
    310         mutateAll( tupleExpr->get_results(), *this );
    311         mutateAll( tupleExpr->get_exprs(), *this );
    312         return tupleExpr;
    313 }
    314 
    315 Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {
    316         mutateAll( tupleExpr->get_results(), *this );
    317         mutateAll( tupleExpr->get_exprs(), *this );
    318         return tupleExpr;
    319 }
    320 
    321310Expression *Mutator::mutate( TypeExpr *typeExpr ) {
    322         mutateAll( typeExpr->get_results(), *this );
     311        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
    323312        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
    324313        return typeExpr;
     
    340329
    341330Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
    342         mutateAll( ctorExpr->get_results(), *this );
     331        ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
    343332        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
    344333        return ctorExpr;
     
    346335
    347336Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
    348         mutateAll( compLitExpr->get_results(), *this );
     337        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    349338        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    350339        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
     
    353342
    354343Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    355         mutateAll( valofExpr->get_results(), *this );
     344        valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    356345        return valofExpr;
    357346}
     
    361350        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
    362351        return rangeExpr;
     352}
     353
     354Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
     355        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     356        mutateAll( tupleExpr->get_exprs(), *this );
     357        return tupleExpr;
     358}
     359
     360Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
     361        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     362        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
     363        return tupleExpr;
     364}
     365
     366Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
     367        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
     368        tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
     369        tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );
     370        return tupleExpr;
     371}
     372
     373Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
     374        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
     375        mutateAll( assignExpr->get_tempDecls(), *this );
     376        mutateAll( assignExpr->get_assigns(), *this );
     377        return assignExpr;
     378}
     379
     380Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
     381        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
     382        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
     383        return stmtExpr;
     384}
     385
     386Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
     387        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
     388        uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
     389        return uniqueExpr;
    363390}
    364391
  • src/SynTree/Mutator.h

    r3a2128f r1f44196  
    7171        virtual Expression* mutate( ConditionalExpr *conditionalExpr );
    7272        virtual Expression* mutate( CommaExpr *commaExpr );
    73         virtual Expression* mutate( TupleExpr *tupleExpr );
    74         virtual Expression* mutate( SolvedTupleExpr *tupleExpr );
    7573        virtual Expression* mutate( TypeExpr *typeExpr );
    7674        virtual Expression* mutate( AsmExpr *asmExpr );
     
    8078        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8179        virtual Expression* mutate( RangeExpr *rangeExpr );
     80        virtual Expression* mutate( TupleExpr *tupleExpr );
     81        virtual Expression* mutate( TupleIndexExpr *tupleExpr );
     82        virtual Expression* mutate( MemberTupleExpr *tupleExpr );
     83        virtual Expression* mutate( TupleAssignExpr *assignExpr );
     84        virtual Expression* mutate( StmtExpr * stmtExpr );
     85        virtual Expression* mutate( UniqueExpr * uniqueExpr );
    8286
    8387        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/ReferenceToType.cc

    r3a2128f r1f44196  
    5656        }
    5757} // namespace
     58
     59StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct ) : Parent( tq, baseStruct->get_name() ), baseStruct( baseStruct ) {}
    5860
    5961std::string StructInstType::typeString() const { return "struct"; }
  • src/SynTree/SynTree.h

    r3a2128f r1f44196  
    7676class ConditionalExpr;
    7777class CommaExpr;
    78 class TupleExpr;
    79 class SolvedTupleExpr;
    8078class TypeExpr;
    8179class AsmExpr;
     
    8583class UntypedValofExpr;
    8684class RangeExpr;
     85class TupleExpr;
     86class TupleIndexExpr;
     87class MemberTupleExpr;
     88class TupleAssignExpr;
     89class StmtExpr;
     90class UniqueExpr;
    8791
    8892class Type;
  • src/SynTree/TupleExpr.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleExpr.cc -- 
     7// TupleExpr.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1616#include "Expression.h"
    1717#include "Common/utility.h"
     18#include "Type.h"
     19#include "Declaration.h"
     20#include "Tuples/Tuples.h"
     21#include "VarExprReplacer.h"
    1822
    19 TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
     23TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) {
     24        if ( ! exprs.empty() ) {
     25                if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) {
     26                        set_result( Tuples::makeTupleType( exprs ) );
     27                }
     28        }
    2029}
    2130
     
    2938
    3039void TupleExpr::print( std::ostream &os, int indent ) const {
    31         os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
     40        os << "Tuple:" << std::endl;
    3241        printAll( exprs, os, indent+2 );
    3342        Expression::print( os, indent );
    3443}
    3544
    36 SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
    37         std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
     45TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index )  {
     46        TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() );
     47        assert( type->size() > index );
     48        set_result( (*std::next( type->get_types().begin(), index ))->clone() );
     49        get_result()->set_isLvalue( type->get_isLvalue() );
    3850}
    3951
    40 SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
    41         cloneAll( other.exprs, exprs );
     52TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
    4253}
    4354
    44 void SolvedTupleExpr::print( std::ostream &os, int indent ) const {
    45         os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl;
    46         printAll( exprs, os, indent+2 );
     55TupleIndexExpr::~TupleIndexExpr() {
     56        delete tuple;
     57}
     58
     59void TupleIndexExpr::print( std::ostream &os, int indent ) const {
     60        os << "Tuple Index Expression, with tuple:" << std::endl;
     61        os << std::string( indent+2, ' ' );
     62        tuple->print( os, indent+2 );
     63        os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl;
    4764        Expression::print( os, indent );
    4865}
     66
     67MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
     68        set_result( maybeClone( member->get_result() ) ); // xxx - ???
     69}
     70
     71MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
     72}
     73
     74MemberTupleExpr::~MemberTupleExpr() {
     75        delete member;
     76        delete aggregate;
     77}
     78
     79void MemberTupleExpr::print( std::ostream &os, int indent ) const {
     80        os << "Member Tuple Expression, with aggregate:" << std::endl;
     81        os << std::string( indent+2, ' ' );
     82        aggregate->print( os, indent+2 );
     83        os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
     84        os << std::string( indent+2, ' ' );
     85        member->print( os, indent+2 );
     86        Expression::print( os, indent );
     87}
     88
     89
     90TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) {
     91        set_result( Tuples::makeTupleType( assigns ) );
     92}
     93
     94TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ) {
     95        cloneAll( other.assigns, assigns );
     96        cloneAll( other.tempDecls, tempDecls );
     97
     98        // clone needs to go into assigns and replace tempDecls
     99        VarExprReplacer::DeclMap declMap;
     100        std::list< ObjectDecl * >::const_iterator origit = other.tempDecls.begin();
     101        for ( ObjectDecl * temp : tempDecls ) {
     102                assert( origit != other.tempDecls.end() );
     103                ObjectDecl * origTemp = *origit++;
     104                assert( origTemp );
     105                assert( temp->get_name() == origTemp->get_name() );
     106                declMap[ origTemp ] = temp;
     107        }
     108        if ( ! declMap.empty() ) {
     109                VarExprReplacer replacer( declMap );
     110                for ( Expression * assn : assigns ) {
     111                        assn->accept( replacer );
     112                }
     113        }
     114}
     115
     116TupleAssignExpr::~TupleAssignExpr() {
     117        deleteAll( assigns );
     118        // deleteAll( tempDecls );
     119}
     120
     121void TupleAssignExpr::print( std::ostream &os, int indent ) const {
     122        os << "Tuple Assignment Expression, with temporaries:" << std::endl;
     123        printAll( tempDecls, os, indent+4 );
     124        os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl;
     125        printAll( assigns, os, indent+4 );
     126        Expression::print( os, indent );
     127}
     128
     129
    49130
    50131// Local Variables: //
  • src/SynTree/TupleType.cc

    r3a2128f r1f44196  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TupleType.cc -- 
     7// TupleType.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1717#include "Common/utility.h"
    1818
    19 TupleType::TupleType( const Type::Qualifiers &tq ) : Type( tq ) {
     19TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types ) : Type( tq ), types( types ) {
    2020}
    2121
  • src/SynTree/Type.h

    r3a2128f r1f44196  
    2020#include "Visitor.h"
    2121#include "Mutator.h"
     22#include "Common/utility.h"
    2223
    2324class Type {
     
    2728                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
    2829
     30                Qualifiers &operator&=( const Qualifiers &other );
    2931                Qualifiers &operator+=( const Qualifiers &other );
    3032                Qualifiers &operator-=( const Qualifiers &other );
     
    6365        void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    6466        void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    65         std::list<TypeDecl*>& get_forall() { return forall; }
     67
     68        typedef std::list<TypeDecl *> ForallList;
     69        ForallList& get_forall() { return forall; }
     70
     71        /// How many elemental types are represented by this type
     72        virtual unsigned size() const { return 1; };
     73        virtual bool isVoid() const { return size() == 0; }
    6674
    6775        virtual Type *clone() const = 0;
     
    7179  private:
    7280        Qualifiers tq;
    73         std::list<TypeDecl*> forall;
     81        ForallList forall;
    7482};
    7583
     
    7785  public:
    7886        VoidType( const Type::Qualifiers &tq );
     87
     88        virtual unsigned size() const { return 0; };
    7989
    8090        virtual VoidType *clone() const { return new VoidType( *this ); }
     
    234244  public:
    235245        StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
     246        StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );
    236247        StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    237248
     
    348359class TupleType : public Type {
    349360  public:
    350         TupleType( const Type::Qualifiers &tq );
     361        TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );
    351362        TupleType( const TupleType& );
    352363        virtual ~TupleType();
    353364
     365        typedef std::list<Type*> value_type;
     366        typedef value_type::iterator iterator;
     367
    354368        std::list<Type*>& get_types() { return types; }
     369        virtual unsigned size() const { return types.size(); };
     370
     371        iterator begin() { return types.begin(); }
     372        iterator end() { return types.end(); }
    355373
    356374        virtual TupleType *clone() const { return new TupleType( *this ); }
     
    442460};
    443461
     462inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {
     463        isConst &= other.isConst;
     464        isVolatile &= other.isVolatile;
     465        isRestrict &= other.isRestrict;
     466        isLvalue &= other.isLvalue;
     467        isAtomic &= other.isAtomic;
     468        return *this;
     469}
     470
    444471inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    445472        isConst |= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    r3a2128f r1f44196  
    7272Type *TypeSubstitution::lookup( std::string formalType ) const {
    7373        TypeEnvType::const_iterator i = typeEnv.find( formalType );
    74        
     74
    7575        // break on not in substitution set
    7676        if ( i == typeEnv.end() ) return 0;
    77        
     77
    7878        // attempt to transitively follow TypeInstType links.
    7979        while ( TypeInstType *actualType = dynamic_cast< TypeInstType* >( i->second ) ) {
    8080                const std::string& typeName = actualType->get_name();
    81                
     81
    8282                // break cycles in the transitive follow
    8383                if ( formalType == typeName ) break;
    84                
     84
    8585                // Look for the type this maps to, returning previous mapping if none-such
    8686                i = typeEnv.find( typeName );
    8787                if ( i == typeEnv.end() ) return actualType;
    8888        }
    89        
     89
    9090        // return type from substitution set
    9191        return i->second;
    92        
     92
    9393#if 0
    9494        if ( i == typeEnv.end() ) {
     
    149149        // bind type variables from forall-qualifiers
    150150        if ( freeOnly ) {
    151                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     151                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    152152                        boundVars.insert( (*tyvar )->get_name() );
    153153                } // for
     
    163163        // bind type variables from forall-qualifiers
    164164        if ( freeOnly ) {
    165                 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
     165                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    166166                        boundVars.insert( (*tyvar )->get_name() );
    167167                } // for
  • src/SynTree/Visitor.cc

    r3a2128f r1f44196  
    150150
    151151void Visitor::visit( ApplicationExpr *applicationExpr ) {
    152         acceptAll( applicationExpr->get_results(), *this );
     152        maybeAccept( applicationExpr->get_result(), *this );
    153153        maybeAccept( applicationExpr->get_function(), *this );
    154154        acceptAll( applicationExpr->get_args(), *this );
     
    156156
    157157void Visitor::visit( UntypedExpr *untypedExpr ) {
    158         acceptAll( untypedExpr->get_results(), *this );
     158        maybeAccept( untypedExpr->get_result(), *this );
    159159        acceptAll( untypedExpr->get_args(), *this );
    160160}
    161161
    162162void Visitor::visit( NameExpr *nameExpr ) {
    163         acceptAll( nameExpr->get_results(), *this );
     163        maybeAccept( nameExpr->get_result(), *this );
    164164}
    165165
    166166void Visitor::visit( AddressExpr *addressExpr ) {
    167         acceptAll( addressExpr->get_results(), *this );
     167        maybeAccept( addressExpr->get_result(), *this );
    168168        maybeAccept( addressExpr->get_arg(), *this );
    169169}
    170170
    171171void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    172         acceptAll( labAddressExpr->get_results(), *this );
     172        maybeAccept( labAddressExpr->get_result(), *this );
    173173        maybeAccept( labAddressExpr->get_arg(), *this );
    174174}
    175175
    176176void Visitor::visit( CastExpr *castExpr ) {
    177         acceptAll( castExpr->get_results(), *this );
     177        maybeAccept( castExpr->get_result(), *this );
    178178        maybeAccept( castExpr->get_arg(), *this );
    179179}
    180180
    181181void Visitor::visit( UntypedMemberExpr *memberExpr ) {
    182         acceptAll( memberExpr->get_results(), *this );
     182        maybeAccept( memberExpr->get_result(), *this );
    183183        maybeAccept( memberExpr->get_aggregate(), *this );
     184        maybeAccept( memberExpr->get_member(), *this );
    184185}
    185186
    186187void Visitor::visit( MemberExpr *memberExpr ) {
    187         acceptAll( memberExpr->get_results(), *this );
     188        maybeAccept( memberExpr->get_result(), *this );
    188189        maybeAccept( memberExpr->get_aggregate(), *this );
    189190}
    190191
    191192void Visitor::visit( VariableExpr *variableExpr ) {
    192         acceptAll( variableExpr->get_results(), *this );
     193        maybeAccept( variableExpr->get_result(), *this );
    193194}
    194195
    195196void Visitor::visit( ConstantExpr *constantExpr ) {
    196         acceptAll( constantExpr->get_results(), *this );
     197        maybeAccept( constantExpr->get_result(), *this );
    197198        maybeAccept( constantExpr->get_constant(), *this );
    198199}
    199200
    200201void Visitor::visit( SizeofExpr *sizeofExpr ) {
    201         acceptAll( sizeofExpr->get_results(), *this );
     202        maybeAccept( sizeofExpr->get_result(), *this );
    202203        if ( sizeofExpr->get_isType() ) {
    203204                maybeAccept( sizeofExpr->get_type(), *this );
     
    208209
    209210void Visitor::visit( AlignofExpr *alignofExpr ) {
    210         acceptAll( alignofExpr->get_results(), *this );
     211        maybeAccept( alignofExpr->get_result(), *this );
    211212        if ( alignofExpr->get_isType() ) {
    212213                maybeAccept( alignofExpr->get_type(), *this );
     
    217218
    218219void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
    219         acceptAll( offsetofExpr->get_results(), *this );
     220        maybeAccept( offsetofExpr->get_result(), *this );
    220221        maybeAccept( offsetofExpr->get_type(), *this );
    221222}
    222223
    223224void Visitor::visit( OffsetofExpr *offsetofExpr ) {
    224         acceptAll( offsetofExpr->get_results(), *this );
     225        maybeAccept( offsetofExpr->get_result(), *this );
    225226        maybeAccept( offsetofExpr->get_type(), *this );
    226227        maybeAccept( offsetofExpr->get_member(), *this );
     
    228229
    229230void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
    230         acceptAll( offsetPackExpr->get_results(), *this );
     231        maybeAccept( offsetPackExpr->get_result(), *this );
    231232        maybeAccept( offsetPackExpr->get_type(), *this );
    232233}
    233234
    234235void Visitor::visit( AttrExpr *attrExpr ) {
    235         acceptAll( attrExpr->get_results(), *this );
     236        maybeAccept( attrExpr->get_result(), *this );
    236237        if ( attrExpr->get_isType() ) {
    237238                maybeAccept( attrExpr->get_type(), *this );
     
    242243
    243244void Visitor::visit( LogicalExpr *logicalExpr ) {
    244         acceptAll( logicalExpr->get_results(), *this );
     245        maybeAccept( logicalExpr->get_result(), *this );
    245246        maybeAccept( logicalExpr->get_arg1(), *this );
    246247        maybeAccept( logicalExpr->get_arg2(), *this );
     
    248249
    249250void Visitor::visit( ConditionalExpr *conditionalExpr ) {
    250         acceptAll( conditionalExpr->get_results(), *this );
     251        maybeAccept( conditionalExpr->get_result(), *this );
    251252        maybeAccept( conditionalExpr->get_arg1(), *this );
    252253        maybeAccept( conditionalExpr->get_arg2(), *this );
     
    255256
    256257void Visitor::visit( CommaExpr *commaExpr ) {
    257         acceptAll( commaExpr->get_results(), *this );
     258        maybeAccept( commaExpr->get_result(), *this );
    258259        maybeAccept( commaExpr->get_arg1(), *this );
    259260        maybeAccept( commaExpr->get_arg2(), *this );
    260261}
    261262
    262 void Visitor::visit( TupleExpr *tupleExpr ) {
    263         acceptAll( tupleExpr->get_results(), *this );
    264         acceptAll( tupleExpr->get_exprs(), *this );
    265 }
    266 
    267 void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
    268         acceptAll( tupleExpr->get_results(), *this );
    269         acceptAll( tupleExpr->get_exprs(), *this );
    270 }
    271 
    272263void Visitor::visit( TypeExpr *typeExpr ) {
    273         acceptAll( typeExpr->get_results(), *this );
     264        maybeAccept( typeExpr->get_result(), *this );
    274265        maybeAccept( typeExpr->get_type(), *this );
    275266}
     
    288279
    289280void Visitor::visit( ConstructorExpr * ctorExpr ) {
    290         acceptAll( ctorExpr->get_results(), *this );
     281        maybeAccept( ctorExpr->get_result(), *this );
    291282        maybeAccept( ctorExpr->get_callExpr(), *this );
    292283}
    293284
    294285void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    295         acceptAll( compLitExpr->get_results(), *this );
     286        maybeAccept( compLitExpr->get_result(), *this );
    296287        maybeAccept( compLitExpr->get_type(), *this );
    297288        maybeAccept( compLitExpr->get_initializer(), *this );
     
    299290
    300291void Visitor::visit( UntypedValofExpr *valofExpr ) {
    301         acceptAll( valofExpr->get_results(), *this );
     292        maybeAccept( valofExpr->get_result(), *this );
    302293        maybeAccept( valofExpr->get_body(), *this );
    303294}
     
    306297        maybeAccept( rangeExpr->get_low(), *this );
    307298        maybeAccept( rangeExpr->get_high(), *this );
     299}
     300
     301void Visitor::visit( TupleExpr *tupleExpr ) {
     302        maybeAccept( tupleExpr->get_result(), *this );
     303        acceptAll( tupleExpr->get_exprs(), *this );
     304}
     305
     306void Visitor::visit( TupleIndexExpr *tupleExpr ) {
     307        maybeAccept( tupleExpr->get_result(), *this );
     308        maybeAccept( tupleExpr->get_tuple(), *this );
     309}
     310
     311void Visitor::visit( MemberTupleExpr *tupleExpr ) {
     312        maybeAccept( tupleExpr->get_result(), *this );
     313        maybeAccept( tupleExpr->get_member(), *this );
     314        maybeAccept( tupleExpr->get_aggregate(), *this );
     315}
     316
     317void Visitor::visit( TupleAssignExpr *assignExpr ) {
     318        maybeAccept( assignExpr->get_result(), *this );
     319        acceptAll( assignExpr->get_tempDecls(), *this );
     320        acceptAll( assignExpr->get_assigns(), *this );
     321}
     322
     323void Visitor::visit( StmtExpr *stmtExpr ) {
     324        maybeAccept( stmtExpr->get_result(), *this );
     325        maybeAccept( stmtExpr->get_statements(), *this );
     326}
     327
     328void Visitor::visit( UniqueExpr *uniqueExpr ) {
     329        maybeAccept( uniqueExpr->get_result(), *this );
     330        maybeAccept( uniqueExpr->get_expr(), *this );
    308331}
    309332
  • src/SynTree/Visitor.h

    r3a2128f r1f44196  
    7171        virtual void visit( ConditionalExpr *conditionalExpr );
    7272        virtual void visit( CommaExpr *commaExpr );
    73         virtual void visit( TupleExpr *tupleExpr );
    74         virtual void visit( SolvedTupleExpr *tupleExpr );
    7573        virtual void visit( TypeExpr *typeExpr );
    7674        virtual void visit( AsmExpr *asmExpr );
     
    8078        virtual void visit( UntypedValofExpr *valofExpr );
    8179        virtual void visit( RangeExpr *rangeExpr );
     80        virtual void visit( TupleExpr *tupleExpr );
     81        virtual void visit( TupleIndexExpr *tupleExpr );
     82        virtual void visit( MemberTupleExpr *tupleExpr );
     83        virtual void visit( TupleAssignExpr *assignExpr );
     84        virtual void visit( StmtExpr * stmtExpr );
     85        virtual void visit( UniqueExpr * uniqueExpr );
    8286
    8387        virtual void visit( VoidType *basicType );
  • src/SynTree/module.mk

    r3a2128f r1f44196  
    4949       SynTree/AddStmtVisitor.cc \
    5050       SynTree/TypeSubstitution.cc \
    51        SynTree/Attribute.cc
     51       SynTree/Attribute.cc \
     52       SynTree/VarExprReplacer.cc
    5253
  • src/Tuples/TupleAssignment.cc

    r3a2128f r1f44196  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 15:02:53 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Nov 9 13:48:42 2016
    1313// Update Count     : 2
    1414//
     
    1818#include "ResolvExpr/typeops.h"
    1919#include "SynTree/Expression.h"
    20 #include "TupleAssignment.h"
     20#include "SynTree/Initializer.h"
     21#include "Tuples.h"
     22#include "Explode.h"
    2123#include "Common/SemanticError.h"
     24#include "InitTweak/InitTweak.h"
    2225
    2326#include <functional>
     
    2730#include <cassert>
    2831#include <set>
     32#include <unordered_set>
    2933
    3034namespace Tuples {
    31         TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f )
    32                 : currentFinder(f), matcher(0), hasMatched( false ) {}
    33 
    34         bool TupleAssignSpotter::pointsToTuple( Expression *expr ) {
     35        class TupleAssignSpotter {
     36          public:
     37                // dispatcher for Tuple (multiple and mass) assignment operations
     38                TupleAssignSpotter( ResolvExpr::AlternativeFinder & );
     39                void spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities );
     40
     41          private:
     42                void match();
     43
     44                struct Matcher {
     45                  public:
     46                        Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts );
     47                        virtual ~Matcher() {}
     48                        virtual void match( std::list< Expression * > &out ) = 0;
     49                        ResolvExpr::AltList lhs, rhs;
     50                        TupleAssignSpotter &spotter;
     51                        std::list< ObjectDecl * > tmpDecls;
     52                };
     53
     54                struct MassAssignMatcher : public Matcher {
     55                  public:
     56                        MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts );
     57                        virtual void match( std::list< Expression * > &out );
     58                };
     59
     60                struct MultipleAssignMatcher : public Matcher {
     61                  public:
     62                        MultipleAssignMatcher( TupleAssignSpotter &spot, const ResolvExpr::AltList & alts );
     63                        virtual void match( std::list< Expression * > &out );
     64                };
     65
     66                ResolvExpr::AlternativeFinder &currentFinder;
     67                std::string fname;
     68                std::unique_ptr< Matcher > matcher;
     69        };
     70
     71        /// true if expr is an expression of tuple type, i.e. a tuple expression, tuple variable, or MRV (multiple-return-value) function
     72        bool isTuple( Expression *expr ) {
     73                if ( ! expr ) return false;
     74                assert( expr->has_result() );
     75                return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1;
     76        }
     77
     78        template< typename AltIter >
     79        bool isMultAssign( AltIter begin, AltIter end ) {
     80                // multiple assignment if more than one alternative in the range or if
     81                // the alternative is a tuple
     82                if ( begin == end ) return false;
     83                if ( isTuple( begin->expr ) ) return true;
     84                return ++begin != end;
     85        }
     86
     87        bool pointsToTuple( Expression *expr ) {
    3588                // also check for function returning tuple of reference types
    36                 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(expr) )
    37                         if ( isTuple(addr->get_arg() ) )
    38                                 return true;
     89                if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
     90                        return pointsToTuple( castExpr->get_arg() );
     91                } else if ( AddressExpr *addr = dynamic_cast< AddressExpr * >( expr) ) {
     92                        return isTuple( addr->get_arg() );
     93                }
    3994                return false;
    4095        }
    4196
    42         bool TupleAssignSpotter::isTupleVar( DeclarationWithType *decl ) {
    43                 if ( dynamic_cast<TupleType *>(decl->get_type()) )
    44                         return true;
    45                 return false;
    46         }
    47 
    48         bool TupleAssignSpotter::isTuple( Expression *expr, bool isRight ) {
    49                 // true if `expr' is an expression returning a tuple: tuple, tuple variable or MRV function
    50                 if ( ! expr ) return false;
    51 
    52                 if ( dynamic_cast<TupleExpr *>(expr) )
    53                         return true;
    54                 else if ( VariableExpr *var = dynamic_cast<VariableExpr *>(expr) ) {
    55                         if ( isTupleVar(var->get_var()) )
    56                                 return true;
    57                 }
    58 
    59                 return false;
    60         }
    61 
    62         bool TupleAssignSpotter::match() {
    63                 assert ( matcher != 0 );
    64 
    65                 std::list< Expression * > new_assigns;
    66                 if ( ! matcher->match(new_assigns) )
    67                         return false;
    68 
    69                 if ( new_assigns.empty() ) return false;
    70                 /*return */matcher->solve( new_assigns );
    71                 if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
    72                         // now resolve new assignments
    73                         std::list< Expression * > solved_assigns;
    74                         ResolvExpr::AltList solved_alts;
    75                         assert( currentFinder != 0 );
    76 
    77                         ResolvExpr::AltList current;
    78                         for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
    79                                 //try {
    80                                 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    81                                 finder.findWithAdjustment(*i);
    82                                 // prune expressions that don't coincide with
    83                                 ResolvExpr::AltList alts = finder.get_alternatives();
    84                                 assert( alts.size() == 1 );
    85                                 assert(alts.front().expr != 0 );
    86                                 current.push_back( finder.get_alternatives().front() );
    87                                 solved_assigns.push_back( alts.front().expr->clone() );
    88                                 //solved_assigns.back()->print(std::cerr);
    89                                 /*} catch( ... ) {
    90                                   continue; // no reasonable alternative found
    91                                   }*/
    92                         }
    93                         options.add_option( current );
    94 
    95                         return true;
    96                 } else { // mass assignment
    97                         //if ( new_assigns.empty() ) return false;
    98                         std::list< Expression * > solved_assigns;
    99                         ResolvExpr::AltList solved_alts;
    100                         assert( currentFinder != 0 );
    101 
    102                         ResolvExpr::AltList current;
    103                         if ( optMass.empty() ) {
    104                                 for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
    105                                         optMass.push_back( ResolvExpr::AltList() );
    106                         }
    107                         int cnt = 0;
    108                         for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
    109 
    110                                 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    111                                 finder.findWithAdjustment(*i);
    112                                 ResolvExpr::AltList alts = finder.get_alternatives();
    113                                 assert( alts.size() == 1 );
    114                                 assert(alts.front().expr != 0 );
    115                                 current.push_back( finder.get_alternatives().front() );
    116                                 optMass[cnt].push_back( finder.get_alternatives().front() );
    117                                 solved_assigns.push_back( alts.front().expr->clone() );
    118                         }
    119 
    120                         return true;
    121                 }
    122 
    123                 return false;
    124         }
    125 
    126         bool TupleAssignSpotter::isMVR( Expression *expr ) {
    127                 if ( expr->get_results().size() > 1 ) {
    128                         // MVR processing
    129                         return true;
    130                 }
    131                 return false;
    132         }
    133 
    134         bool TupleAssignSpotter::isTupleAssignment( UntypedExpr * expr, std::list<ResolvExpr::AltList> &possibilities ) {
    135                 if (  NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) {
    136 
    137                         if ( assgnop->get_name() == std::string("?=?") ) {
    138 
    139                                 for ( std::list<ResolvExpr::AltList>::iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
    140                                         assert( ali->size() == 2 );
    141                                         ResolvExpr::AltList::iterator opit = ali->begin();
    142                                         ResolvExpr::Alternative op1 = *opit, op2 = *(++opit);
    143 
    144                                         if ( pointsToTuple(op1.expr) ) { // also handles tuple vars
    145                                                 if ( isTuple( op2.expr, true ) )
    146                                                         matcher = new MultipleAssignMatcher(op1.expr, op2.expr);
    147                                                 else if ( isMVR( op2.expr ) ) {
    148                                                         // handle MVR differently
    149                                                 } else
     97        void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) {
     98                TupleAssignSpotter spotter( currentFinder );
     99                spotter.spot( expr, possibilities );
     100        }
     101
     102        TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder &f )
     103                : currentFinder(f) {}
     104
     105        void TupleAssignSpotter::spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) {
     106                if (  NameExpr *op = dynamic_cast< NameExpr * >(expr->get_function()) ) {
     107                        if ( InitTweak::isCtorDtorAssign( op->get_name() ) ) {
     108                                fname = op->get_name();
     109                                for ( std::list<ResolvExpr::AltList>::const_iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
     110                                        if ( ali->size() == 0 ) continue; // AlternativeFinder will natrually handle this case, if it's legal
     111                                        if ( ali->size() <= 1 && InitTweak::isAssignment( op->get_name() ) ) {
     112                                                // what does it mean if an assignment takes 1 argument? maybe someone defined such a function, in which case AlternativeFinder will naturally handle it
     113                                                continue;
     114                                        }
     115
     116                                        assert( ! ali->empty() );
     117                                        // grab args 2-N and group into a TupleExpr
     118                                        const ResolvExpr::Alternative & alt1 = ali->front();
     119                                        auto begin = std::next(ali->begin(), 1), end = ali->end();
     120                                        if ( pointsToTuple(alt1.expr) ) {
     121                                                if ( isMultAssign( begin, end ) ) {
     122                                                        matcher.reset( new MultipleAssignMatcher( *this, *ali ) );
     123                                                } else {
    150124                                                        // mass assignment
    151                                                         matcher = new MassAssignMatcher(op1.expr, op2.expr);
    152 
    153                                                 std::list< ResolvExpr::AltList > options;
    154                                                 if ( match() )
    155                                                         /*
    156                                                           if ( hasMatched ) {
    157                                                           // throw SemanticError("Ambiguous tuple assignment");
    158                                                           } else {*/
    159                                                         // Matched for the first time
    160                                                         hasMatched = true;
    161                                                 /*} */
    162                                         } /* else if ( isTuple( op2 ) )
    163                                                  throw SemanticError("Inapplicable tuple assignment.");
    164                                           */
    165                                 }
    166 
    167                                 if ( hasMatched ) {
    168                                         if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
    169                                                 //options.print( std::cerr );
    170                                                 std::list< ResolvExpr::AltList >best = options.get_best();
    171                                                 if ( best.size() == 1 ) {
    172                                                         std::list<Expression *> solved_assigns;
    173                                                         for ( ResolvExpr::AltList::iterator i = best.front().begin(); i != best.front().end(); ++i ) {
    174                                                                 solved_assigns.push_back( i->expr );
    175                                                         }
    176                                                         /* assigning cost zero? */
    177                                                         currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MULTIPLE*/), currentFinder->get_environ(), ResolvExpr::Cost() ) );
     125                                                        matcher.reset( new MassAssignMatcher( *this,  *ali ) );
    178126                                                }
    179                                         } else {
    180                                                 assert( ! optMass.empty() );
    181                                                 ResolvExpr::AltList winners;
    182                                                 for ( std::vector< ResolvExpr::AltList >::iterator i = optMass.begin(); i != optMass.end(); ++i )
    183                                                         findMinCostAlt( i->begin(), i->end(), back_inserter(winners) );
    184 
    185                                                 std::list< Expression *> solved_assigns;
    186                                                 for ( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i )
    187                                                         solved_assigns.push_back( i->expr );
    188                                                 currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MASS*/), currentFinder->get_environ(), ResolvExpr::Cost() ) );
     127                                                match();
    189128                                        }
    190129                                }
    191130                        }
    192131                }
    193                 return hasMatched;
    194         }
    195 
    196         void TupleAssignSpotter::Matcher::init( Expression *_lhs, Expression *_rhs ) {
    197                 lhs.clear();
    198                 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(_lhs) )
    199                         if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(addr->get_arg()) )
    200                                 std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(lhs) );
    201 
    202                 rhs.clear();
    203         }
    204 
    205         TupleAssignSpotter::Matcher::Matcher( /*TupleAssignSpotter &spot,*/ Expression *_lhs, Expression *_rhs ) /*: own_spotter(spot) */{
    206                 init(_lhs,_rhs);
    207         }
    208 
    209         TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( Expression *_lhs, Expression *_rhs )/* : own_spotter(spot) */{
    210                 init(_lhs,_rhs);
    211 
    212                 if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(_rhs) )
    213                         std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(rhs) );
    214         }
    215 
    216         UntypedExpr *TupleAssignSpotter::Matcher::createAssgn( Expression *left, Expression *right ) {
    217                 if ( left && right ) {
    218                         std::list< Expression * > args;
    219                         args.push_back(new AddressExpr(left->clone()));  args.push_back(right->clone());
    220                         return new UntypedExpr(new NameExpr("?=?"), args);
    221                 } else
    222                         throw 0; // xxx - diagnose the problem
    223         }
    224 
    225         bool TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) {
    226                 if ( lhs.empty() || (rhs.size() != 1) ) return false;
    227 
    228                 for ( std::list< Expression * >::iterator l = lhs.begin(); l != lhs.end(); l++ ) {
    229                         std::list< Expression * > args;
    230                         args.push_back( new AddressExpr(*l) );
    231                         args.push_back( rhs.front() );
    232                         out.push_back( new UntypedExpr(new NameExpr("?=?"), args) );
    233                 }
    234 
    235                 return true;
    236         }
    237 
    238         bool TupleAssignSpotter::MassAssignMatcher::solve( std::list< Expression * > &assigns ) {
    239                 /*
    240                   std::list< Expression * > solved_assigns;
    241                   ResolvExpr::AltList solved_alts;
    242                   assert( currentFinder != 0 );
    243 
    244                   ResolvExpr::AltList current;
    245                   if ( optMass.empty() ) {
    246                   for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
    247                   optMass.push_back( ResolvExpr::AltList() );
    248                   }
    249                   int cnt = 0;
    250                   for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
    251 
    252                   ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    253                   finder.findWithAdjustment(*i);
    254                   ResolvExpr::AltList alts = finder.get_alternatives();
    255                   assert( alts.size() == 1 );
    256                   assert(alts.front().expr != 0 );
    257                   current.push_back( finder.get_alternatives().front() );
    258                   optMass[cnt].push_back( finder.get_alternatives().front() );
    259                   solved_assigns.push_back( alts.front().expr->clone() );
    260                   }
    261                 */
    262                 return true;
    263         }
    264 
    265         bool TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) {
    266                 // need more complicated matching
     132        }
     133
     134        void TupleAssignSpotter::match() {
     135                assert ( matcher != 0 );
     136
     137                std::list< Expression * > new_assigns;
     138                matcher->match( new_assigns );
     139
     140                if ( new_assigns.empty() ) return;
     141                ResolvExpr::AltList current;
     142                // now resolve new assignments
     143                for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
     144                        ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() );
     145                        try {
     146                                finder.findWithAdjustment(*i);
     147                        } catch (...) {
     148                                return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid
     149                        }
     150                        // prune expressions that don't coincide with
     151                        ResolvExpr::AltList alts = finder.get_alternatives();
     152                        assert( alts.size() == 1 );
     153                        assert( alts.front().expr != 0 );
     154                        current.push_back( alts.front() );
     155                }
     156
     157                // extract expressions from the assignment alternatives to produce a list of assignments that
     158                // together form a single alternative
     159                std::list< Expression *> solved_assigns;
     160                for ( ResolvExpr::Alternative & alt : current ) {
     161                        solved_assigns.push_back( alt.expr->clone() );
     162                }
     163                // xxx - need to do this??
     164                ResolvExpr::TypeEnvironment compositeEnv;
     165                simpleCombineEnvironments( current.begin(), current.end(), compositeEnv );
     166                currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) );
     167        }
     168
     169        TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter) {
     170                assert( ! alts.empty() );
     171                ResolvExpr::Alternative lhsAlt = alts.front();
     172                // peel off the cast that exists on ctor/dtor expressions
     173                bool isCast = false;
     174                if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( lhsAlt.expr ) ) {
     175                        lhsAlt.expr = castExpr->get_arg();
     176                        castExpr->set_arg( nullptr );
     177                        delete castExpr;
     178                        isCast = true;
     179                }
     180
     181                // explode the lhs so that each field of the tuple-valued-expr is assigned.
     182                explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs) );
     183
     184                // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed
     185                if ( isCast ) {
     186                        for ( ResolvExpr::Alternative & alt : lhs ) {
     187                                Expression *& expr = alt.expr;
     188                                Type * castType = expr->get_result()->clone();
     189                                Type * type = InitTweak::getPointerBase( castType );
     190                                assert( type );
     191                                type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
     192                                type->set_isLvalue( true ); // xxx - might not need this
     193                                expr = new CastExpr( expr, castType );
     194                        }
     195                }
     196        }
     197
     198        TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) {
     199                assert( alts.size() == 1 || alts.size() == 2 );
     200                if ( alts.size() == 2 ) {
     201                        rhs.push_back( alts.back() );
     202                }
     203        }
     204
     205        TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) {
     206                // explode the rhs so that each field of the tuple-valued-expr is assigned.
     207                explode( std::next(alts.begin(), 1), alts.end(), spotter.currentFinder.get_indexer(), back_inserter(rhs) );
     208        }
     209
     210        UntypedExpr * createFunc( const std::string &fname, ObjectDecl *left, ObjectDecl *right ) {
     211                assert( left );
     212                std::list< Expression * > args;
     213                args.push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( left ) ) ) );
     214                // args.push_back( new AddressExpr( new VariableExpr( left ) ) );
     215                if ( right ) args.push_back( new VariableExpr( right ) );
     216                return new UntypedExpr( new NameExpr( fname ), args );
     217        }
     218
     219        ObjectDecl * newObject( UniqueName & namer, Expression * expr ) {
     220                assert( expr->has_result() && ! expr->get_result()->isVoid() );
     221                return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );
     222        }
     223
     224        void TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) {
     225                static UniqueName lhsNamer( "__massassign_L" );
     226                static UniqueName rhsNamer( "__massassign_R" );
     227                assert ( ! lhs.empty() && rhs.size() <= 1);
     228
     229                ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr;
     230                for ( ResolvExpr::Alternative & lhsAlt : lhs ) {
     231                        ObjectDecl * ltmp = newObject( lhsNamer, lhsAlt.expr );
     232                        out.push_back( createFunc( spotter.fname, ltmp, rtmp ) );
     233                        tmpDecls.push_back( ltmp );
     234                }
     235                if ( rtmp ) tmpDecls.push_back( rtmp );
     236        }
     237
     238        void TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) {
     239                static UniqueName lhsNamer( "__multassign_L" );
     240                static UniqueName rhsNamer( "__multassign_R" );
     241
     242                // xxx - need more complicated matching?
    267243                if ( lhs.size() == rhs.size() ) {
    268                         zipWith( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), back_inserter(out), TupleAssignSpotter::Matcher::createAssgn );
    269                         return true;
    270                 } //else
    271                 //std::cerr << "The length of (left, right) is: (" << lhs.size() << "," << rhs.size() << ")" << std::endl;*/
    272                 return false;
    273         }
    274 
    275         bool TupleAssignSpotter::MultipleAssignMatcher::solve( std::list< Expression * > &assigns ) {
    276                 /*
    277                   std::list< Expression * > solved_assigns;
    278                   ResolvExpr::AltList solved_alts;
    279                   assert( currentFinder != 0 );
    280 
    281                   ResolvExpr::AltList current;
    282                   for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
    283                   //try {
    284                   ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
    285                   finder.findWithAdjustment(*i);
    286                   // prune expressions that don't coincide with
    287                   ResolvExpr::AltList alts = finder.get_alternatives();
    288                   assert( alts.size() == 1 );
    289                   assert(alts.front().expr != 0 );
    290                   current.push_back( finder.get_alternatives().front() );
    291                   solved_assigns.push_back( alts.front().expr->clone() );
    292                   //solved_assigns.back()->print(std::cerr);
    293                   //} catch( ... ) {
    294                   //continue; // no reasonable alternative found
    295                   //}
    296                   }
    297                   options.add_option( current );
    298                 */
    299 
    300                 return true;
    301         }
    302 
    303         void TupleAssignSpotter::Options::add_option( ResolvExpr::AltList &opt ) {
    304                 using namespace std;
    305 
    306                 options.push_back( opt );
    307                 /*
    308                   vector< Cost > costs;
    309                   costs.reserve( opt.size() );
    310                   transform( opt.begin(), opt.end(), back_inserter(costs), ptr_fun(extract_cost) );
    311                 */
    312                 // transpose matrix
    313                 if ( costMatrix.empty() )
    314                         for ( unsigned int i = 0; i< opt.size(); ++i)
    315                                 costMatrix.push_back( vector<ResolvExpr::Cost>() );
    316 
    317                 int cnt = 0;
    318                 for ( ResolvExpr::AltList::iterator i = opt.begin(); i != opt.end(); ++i, cnt++ )
    319                         costMatrix[cnt].push_back( i->cost );
    320 
    321                 return;
    322         }
    323 
    324         std::list< ResolvExpr::AltList > TupleAssignSpotter::Options::get_best() {
    325                 using namespace std;
    326                 using namespace ResolvExpr;
    327                 list< ResolvExpr::AltList > ret;
    328                 list< multiset<int> > solns;
    329                 for ( vector< vector<Cost> >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
    330                         list<int> current;
    331                         findMinCost( i->begin(), i->end(), back_inserter(current) );
    332                         solns.push_back( multiset<int>(current.begin(), current.end()) );
    333                 }
    334                 // need to combine
    335                 multiset<int> result;
    336                 lift_intersection( solns.begin(), solns.end(), inserter( result, result.begin() ) );
    337                 if ( result.size() != 1 )
    338                         throw SemanticError("Ambiguous tuple expression");
    339                 ret.push_back(get_option( *(result.begin() )));
    340                 return ret;
    341         }
    342 
    343         void TupleAssignSpotter::Options::print( std::ostream &ostr ) {
    344                 using namespace std;
    345 
    346                 for ( vector< vector < ResolvExpr::Cost > >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
    347                         for ( vector < ResolvExpr::Cost >::iterator j = i->begin(); j != i->end(); ++j )
    348                                 ostr << *j << " " ;
    349                         ostr << std::endl;
    350                 } // for
    351                 return;
    352         }
    353 
    354         ResolvExpr::Cost extract_cost( ResolvExpr::Alternative &alt ) {
    355                 return alt.cost;
    356         }
    357 
    358         template< typename InputIterator, typename OutputIterator >
    359         void TupleAssignSpotter::Options::findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    360                 using namespace ResolvExpr;
    361                 std::list<int> alternatives;
    362 
    363                 // select the alternatives that have the minimum parameter cost
    364                 Cost minCost = Cost::infinity;
    365                 unsigned int index = 0;
    366                 for ( InputIterator i = begin; i != end; ++i, index++ ) {
    367                         if ( *i < minCost ) {
    368                                 minCost = *i;
    369                                 alternatives.clear();
    370                                 alternatives.push_back( index );
    371                         } else if ( *i == minCost ) {
    372                                 alternatives.push_back( index );
    373                         }
    374                 }
    375                 std::copy( alternatives.begin(), alternatives.end(), out );
    376         }
    377 
    378         template< class InputIterator, class OutputIterator >
    379         void TupleAssignSpotter::Options::lift_intersection( InputIterator begin, InputIterator end, OutputIterator out ) {
    380                 if ( begin == end ) return;
    381                 InputIterator test = begin;
    382 
    383                 if (++test == end)
    384                         { copy(begin->begin(), begin->end(), out); return; }
    385 
    386 
    387                 std::multiset<int> cur; // InputIterator::value_type::value_type
    388                 copy( begin->begin(), begin->end(), inserter( cur, cur.begin() ) );
    389 
    390                 while ( test != end ) {
    391                         std::multiset<int> temp;
    392                         set_intersection( cur.begin(), cur.end(), test->begin(), test->end(), inserter(temp,temp.begin()) );
    393                         cur.clear();
    394                         copy( temp.begin(), temp.end(), inserter(cur,cur.begin()));
    395                         ++test;
    396                 }
    397 
    398                 copy( cur.begin(), cur.end(), out );
    399                 return;
    400         }
    401 
    402         ResolvExpr::AltList TupleAssignSpotter::Options::get_option( std::list< ResolvExpr::AltList >::size_type index ) {
    403                 if ( index >= options.size() )
    404                         throw 0; // XXX
    405                 std::list< ResolvExpr::AltList >::iterator it = options.begin();
    406                 for ( std::list< ResolvExpr::AltList >::size_type i = 0; i < index; ++i, ++it );
    407                 return *it;
     244                        std::list< ObjectDecl * > ltmp;
     245                        std::list< ObjectDecl * > rtmp;
     246                        std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), []( ResolvExpr::Alternative & alt ){
     247                                return newObject( lhsNamer, alt.expr );
     248                        });
     249                        std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), []( ResolvExpr::Alternative & alt ){
     250                                return newObject( rhsNamer, alt.expr );
     251                        });
     252                        zipWith( ltmp.begin(), ltmp.end(), rtmp.begin(), rtmp.end(), back_inserter(out), [&](ObjectDecl * obj1, ObjectDecl * obj2 ) { return createFunc(spotter.fname, obj1, obj2); } );
     253                        tmpDecls.splice( tmpDecls.end(), ltmp );
     254                        tmpDecls.splice( tmpDecls.end(), rtmp );
     255                }
    408256        }
    409257} // namespace Tuples
  • src/Tuples/module.mk

    r3a2128f r1f44196  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Richard C. Bilson
     
    1616
    1717SRC +=  Tuples/TupleAssignment.cc \
    18         Tuples/NameMatcher.cc
     18        Tuples/TupleExpansion.cc \
     19        Tuples/Explode.cc
  • src/driver/cfa.cc

    r3a2128f r1f44196  
    244244                nargs += 1;
    245245        } // if
     246        args[nargs] = "-I" CFA_INCDIR "/concurrency";
     247        nargs += 1;
    246248        args[nargs] = "-I" CFA_INCDIR "/containers";
    247249        nargs += 1;
  • src/libcfa/Makefile.am

    r3a2128f r1f44196  
    5656CC = ${abs_top_srcdir}/src/driver/cfa
    5757
    58 headers = limits stdlib math iostream fstream iterator rational containers/vector
     58headers = limits stdlib math iostream fstream iterator rational assert containers/vector concurrency/threads
     59runtimehdrs = concurrency
    5960libobjs = ${headers:=.o}
    6061
  • src/libcfa/Makefile.in

    r3a2128f r1f44196  
    9292am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) math.$(OBJEXT) \
    9393        iostream.$(OBJEXT) fstream.$(OBJEXT) iterator.$(OBJEXT) \
    94         rational.$(OBJEXT) containers/vector.$(OBJEXT)
     94        rational.$(OBJEXT) assert.$(OBJEXT) \
     95        containers/vector.$(OBJEXT) concurrency/threads.$(OBJEXT)
    9596am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1)
    9697libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
     
    234235cfalib_DATA = builtins.cf extras.cf prelude.cf
    235236MAINTAINERCLEANFILES = builtins.cf extras.cf ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
    236 headers = limits stdlib math iostream fstream iterator rational containers/vector
     237headers = limits stdlib math iostream fstream iterator rational assert containers/vector concurrency/threads
     238runtimehdrs = concurrency
    237239libobjs = ${headers:=.o}
    238240libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c}
     
    312314containers/vector.$(OBJEXT): containers/$(am__dirstamp) \
    313315        containers/$(DEPDIR)/$(am__dirstamp)
     316concurrency/$(am__dirstamp):
     317        @$(MKDIR_P) concurrency
     318        @: > concurrency/$(am__dirstamp)
     319concurrency/$(DEPDIR)/$(am__dirstamp):
     320        @$(MKDIR_P) concurrency/$(DEPDIR)
     321        @: > concurrency/$(DEPDIR)/$(am__dirstamp)
     322concurrency/threads.$(OBJEXT): concurrency/$(am__dirstamp) \
     323        concurrency/$(DEPDIR)/$(am__dirstamp)
    314324libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES)
    315325        $(AM_V_at)-rm -f libcfa.a
     
    319329mostlyclean-compile:
    320330        -rm -f *.$(OBJEXT)
     331        -rm -f concurrency/threads.$(OBJEXT)
    321332        -rm -f containers/vector.$(OBJEXT)
    322333
     
    324335        -rm -f *.tab.c
    325336
     337@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Po@am__quote@
    326338@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream.Po@am__quote@
    327339@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iostream.Po@am__quote@
     
    332344@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@
    333345@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@
     346@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/threads.Po@am__quote@
    334347@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/vector.Po@am__quote@
    335348
     
    505518        -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
    506519        -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
     520        -rm -f concurrency/$(DEPDIR)/$(am__dirstamp)
     521        -rm -f concurrency/$(am__dirstamp)
    507522        -rm -f containers/$(DEPDIR)/$(am__dirstamp)
    508523        -rm -f containers/$(am__dirstamp)
     
    517532
    518533distclean: distclean-am
    519         -rm -rf ./$(DEPDIR) containers/$(DEPDIR)
     534        -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
    520535        -rm -f Makefile
    521536distclean-am: clean-am distclean-compile distclean-generic \
     
    563578
    564579maintainer-clean: maintainer-clean-am
    565         -rm -rf ./$(DEPDIR) containers/$(DEPDIR)
     580        -rm -rf ./$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
    566581        -rm -f Makefile
    567582maintainer-clean-am: distclean-am maintainer-clean-generic \
  • src/main.cc

    r3a2128f r1f44196  
    4343#include "Common/UnimplementedError.h"
    4444#include "../config.h"
     45#include "Tuples/Tuples.h"
    4546
    4647using namespace std;
     
    236237                OPTPRINT( "tweakInit" )
    237238                InitTweak::genInit( translationUnit );
    238 
     239                OPTPRINT( "expandMemberTuples" );
     240                Tuples::expandMemberTuples( translationUnit );
    239241                if ( libcfap ) {
    240242                        // generate the bodies of cfa library functions
     
    261263                        return 0;
    262264                } // if
     265
     266                OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
     267                Tuples::expandUniqueExpr( translationUnit );
    263268
    264269                OPTPRINT("instantiateGenerics")
     
    277282                OPTPRINT( "box" )
    278283                GenPoly::box( translationUnit );
     284                OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
     285                Tuples::expandTuples( translationUnit );
    279286
    280287                // print tree right before code generation
Note: See TracChangeset for help on using the changeset viewer.