Changeset 3f91792


Ignore:
Timestamp:
Dec 8, 2020, 1:01:05 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8e58264
Parents:
33a129a (diff), c9e0991 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/collection.hfa

    r33a129a r3f91792  
    77
    88inline {
     9        // PUBLIC
     10
    911        void ?{}( Colable & co ) with( co ) {
    1012                next = 0p;
     
    1618        }
    1719
    18         Colable * getNext( Colable & co ) with( co ) {
    19                 return next;
     20        Colable & getNext( Colable & co ) with( co ) {
     21                return *next;
    2022        }
     23
     24        // PRIVATE
    2125
    2226        Colable *& Next( Colable * cp ) {
     
    2428        }
    2529
     30        // wrappers to make Collection have T
    2631        forall( dtype T ) {
    2732                T *& Next( T * n ) {
  • libcfa/src/bits/multi_list.cfa

    r33a129a r3f91792  
    5757
    5858        SeqIter(TaskDL) sqiter;
    59         TaskDL & dl;
     59        TaskDL & dl;                                                                            // iterator index
    6060        TaskSL & sl;
    6161
  • libcfa/src/bits/queue.hfa

    r33a129a r3f91792  
    2828
    2929                T * succ( Queue(T) & q, T * n ) with( q ) {             // pre: *n in *q
    30 #ifdef __CFA_DEBUG__
     30                        #ifdef __CFA_DEBUG__
    3131                        if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n );
    32 #endif // __CFA_DEBUG__
     32                        #endif // __CFA_DEBUG__
    3333                        return (Next( n ) == n) ? 0p : Next( n );
    3434                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q
    3535
    3636                void addHead( Queue(T) & q, T & n ) with( q ) {
    37 #ifdef __CFA_DEBUG__
     37                        #ifdef __CFA_DEBUG__
    3838                        if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n );
    39 #endif // __CFA_DEBUG__
     39                        #endif // __CFA_DEBUG__
    4040                        if ( last ) {
    4141                                Next( &n ) = &head( q );
     
    4343                        } else {
    4444                                root = last = &n;
    45                                 Next( &n ) = &n;                                                        // last node points to itself
     45                                Next( &n ) = &n;                                                // last node points to itself
    4646                        }
    4747                }
    4848
    4949                void addTail( Queue(T) & q, T & n ) with( q ) {
    50 #ifdef __CFA_DEBUG__
     50                        #ifdef __CFA_DEBUG__
    5151                        if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n );
    52 #endif // __CFA_DEBUG__
     52                        #endif // __CFA_DEBUG__
    5353                        if ( last ) Next( last ) = &n;
    5454                        else root = &n;
    5555                        last = &n;
    56                         Next( &n ) = &n;                                                                // last node points to itself
     56                        Next( &n ) = &n;                                                        // last node points to itself
    5757                }
    5858
     
    7878
    7979                void remove( Queue(T) & q, T & n ) with( q ) {  // O(n)
    80 #ifdef __CFA_DEBUG__
     80                        #ifdef __CFA_DEBUG__
    8181                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n );
    82 #endif // __CFA_DEBUG__
     82                        #endif // __CFA_DEBUG__
    8383                        T * prev = 0p;
    8484                        T * curr = (T *)root;
     
    9696                                        break;
    9797                                }
    98 #ifdef __CFA_DEBUG__
    9998                                // not found => error
    100                                 if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
    101 #endif // __CFA_DEBUG__
     99                                #ifdef __CFA_DEBUG__
     100                                if ( curr == last ) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
     101                                #endif // __CFA_DEBUG__
    102102                                prev = curr;
    103103                                curr = Next( curr );
     
    125125                // Node "n" must be in the "from" list.
    126126                void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) {
    127 #ifdef __CFA_DEBUG__
     127                        #ifdef __CFA_DEBUG__
    128128                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n );
    129 #endif // __CFA_DEBUG__
     129                        #endif // __CFA_DEBUG__
    130130                        Queue(T) to;
    131131                        to.root = from.root;                                            // start of "to" list
     
    177177        } // distribution
    178178} // distribution
    179 
    180 // Local Variables: //
    181 // compile-command: "cfa queue.cfa" //
    182 // End: //
  • libcfa/src/bits/queue_example.cfa

    r33a129a r3f91792  
    107107        }
    108108}
    109 
    110 // Local Variables: //
    111 // compile-command: "cfa queue_example.cfa" //
    112 // End: //
  • libcfa/src/bits/sequence.hfa

    r33a129a r3f91792  
    99
    1010inline {
     11        // PUBLIC
     12
    1113        void ?{}( Seqable & sq ) with( sq ) {
    12                 ((Colable &) sq){};
     14                ((Colable &)sq){};
    1315                back = 0p;
    1416        } // post: ! listed()
     
    1820        }
    1921
     22        // PRIVATE
     23
    2024        Seqable *& Back( Seqable * sq ) {
    2125                return sq->back;
    2226        }
     27
     28        // wrappers to make Collection have T
     29        forall( dtype T ) {
     30                T *& Back( T * n ) {
     31                        return (T *)Back( (Seqable *)n );
     32                }
     33        } // distribution
    2334} // distribution
    2435
     
    3445                } // post: empty() & head() == 0 | !empty() & head() in *s
    3546
    36                 T *& Back( T * n ) {
    37                         return (T *)Back( (Seqable *)n );
    38                 }
    39 
    4047                void ?{}( Sequence(T) &, const Sequence(T) & ) = void; // no copy
    4148                Sequence(T) & ?=?( const Sequence(T) & ) = void; // no assignment
    4249
    4350                void ?{}( Sequence(T) & s ) with( s ) {
    44                         ((Collection &) s){};
     51                        ((Collection &)s){};
    4552                }       // post: isEmpty().
    4653
     
    5057                }       // post: empty() & tail() == 0 | !empty() & tail() in *s
    5158
    52                 // Return a pointer to the element after *n, or 0p if there isn't one.
     59                // Return a pointer to the element after *n, or 0p if list empty.
    5360                T * succ( Sequence(T) & s, T * n ) with( s ) {  // pre: *n in *s
    54 #ifdef __CFA_DEBUG__
     61                        #ifdef __CFA_DEBUG__
    5562                        if ( ! listed( n ) ) abort( "(Sequence &)%p.succ( %p ) : Node is not on a list.", &s, n );
    56 #endif // __CFA_DEBUG__
     63                        #endif // __CFA_DEBUG__
    5764                        return Next( n ) == &head( s ) ? 0p : Next( n );
    5865                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s
     
    6067                // Return a pointer to the element before *n, or 0p if there isn't one.
    6168                T * pred( Sequence(T) & s, T * n ) with( s ) {  // pre: *n in *s
    62 #ifdef __CFA_DEBUG__
     69                        #ifdef __CFA_DEBUG__
    6370                        if ( ! listed( n ) ) abort( "(Sequence &)%p.pred( %p ) : Node is not on a list.", &s, n );
    64 #endif // __CFA_DEBUG__
     71                        #endif // __CFA_DEBUG__
    6572                        return n == &head( s ) ? 0p : Back( n );
    6673                }       // post: n == head() & head(n) == 0 | n != head() & *pred(n) in *s
     
    6976                // Insert *n into the sequence before *bef, or at the end if bef == 0.
    7077                void insertBef( Sequence(T) & s, T & n, T & bef ) with( s ) { // pre: !n->listed() & *bef in *s
    71 #ifdef __CFA_DEBUG__
     78                        #ifdef __CFA_DEBUG__
    7279                        if ( listed( &n ) ) abort( "(Sequence &)%p.insertBef( %p, %p ) : Node is already on another list.", &s, n, &bef );
    73 #endif // __CFA_DEBUG__
     80                        #endif // __CFA_DEBUG__
    7481                        if ( &bef == &head( s ) ) {                                     // must change root
    7582                                if ( root ) {
     
    101108                // Insert *n into the sequence after *aft, or at the beginning if aft == 0.
    102109                void insertAft( Sequence(T) & s, T & aft, T & n ) with( s ) {   // pre: !n->listed() & *aft in *s
    103 #ifdef __CFA_DEBUG__
     110                        #ifdef __CFA_DEBUG__
    104111                        if ( listed( &n ) ) abort( "(Sequence &)%p.insertAft( %p, %p ) : Node is already on another list.", &s, &aft, &n );
    105 #endif // __CFA_DEBUG__
     112                        #endif // __CFA_DEBUG__
    106113                        if ( ! &aft ) {                                                         // must change root
    107114                                if ( root ) {
     
    130137                // pre: n->listed() & *n in *s
    131138                void remove( Sequence(T) & s, T & n ) with( s ) { // O(1)
    132 #ifdef __CFA_DEBUG__
     139                        #ifdef __CFA_DEBUG__
    133140                        if ( ! listed( &n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, &n );
    134 #endif // __CFA_DEBUG__
     141                        #endif // __CFA_DEBUG__
    135142                        if ( &n == &head( s ) ) {
    136143                                if ( Next( &head( s ) ) == &head( s ) ) root = 0p;
     
    188195                // Node "n" must be in the "from" list.
    189196                void split( Sequence(T) & s, Sequence(T) & from, T & n ) with( s ) {
    190 #ifdef __CFA_DEBUG__
     197                        #ifdef __CFA_DEBUG__
    191198                        if ( ! listed( &n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, &n );
    192 #endif // __CFA_DEBUG__
     199                        #endif // __CFA_DEBUG__
    193200                        Sequence(T) to;
    194201                        to.root = from.root;                                            // start of "to" list
     
    199206                                Back( &head( from ) ) = Back( &head( to ) ); // fix "from" list
    200207                                Next( Back( &head( to ) ) ) = &head( from );
    201                                 Next( &n ) = &head( to );                                       // fix "to" list
     208                                Next( &n ) = &head( to );                               // fix "to" list
    202209                                Back( &head( to ) ) = &n;
    203210                        } // if
     
    214221                // passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence
    215222                // to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular.
    216                 Sequence(T) * seq;
     223                Sequence(T) * seq;                                                              // FIX ME: cannot be reference
    217224        };
    218225
     
    224231
    225232                void ?{}( SeqIter(T) & si, Sequence(T) & s ) with( si ) {
    226                         ((ColIter &) si){};
     233                        ((ColIter &)si){};
    227234                        seq = &s;
    228235                        curr = &head( s );
     
    230237
    231238                void ?{}( SeqIter(T) & si, Sequence(T) & s, T & start ) with( si ) {
    232                         ((ColIter &) si){};
     239                        ((ColIter &)si){};
    233240                        seq = &s;
    234241                        curr = &start;
     
    255262                inline ColIter;
    256263                // See above for explanation.
    257                 Sequence(T) * seq;
     264                Sequence(T) * seq;                                                              // FIX ME: cannot be reference
    258265        };
    259266
    260267        inline {
    261268                void ?{}( SeqIterRev(T) & si ) with( si ) {     
    262                         ((ColIter &) si){};
     269                        ((ColIter &)si){};
    263270                        seq = 0p;
    264271                } // post: elts = null.
    265272
    266273                void ?{}( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) {   
    267                         ((ColIter &) si){};
     274                        ((ColIter &)si){};
    268275                        seq = &s;
    269276                        curr = &tail( s );
     
    271278
    272279                void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) {
    273                         ((ColIter &) si){};
     280                        ((ColIter &)si){};
    274281                        seq = &s;
    275282                        curr = &start;
     
    291298        } // distribution
    292299} // distribution
    293 
    294 // Local Variables: //
    295 // compile-command: "cfa sequence.hfa" //
    296 // End: //
  • libcfa/src/bits/sequence_example.cfa

    r33a129a r3f91792  
    137137        }
    138138}
    139 
    140 // Local Variables: //
    141 // compile-command: "cfa sequence_example.cfa" //
    142 // End: //
  • libcfa/src/bits/stack.hfa

    r33a129a r3f91792  
    2626
    2727                void addHead( Stack(T) & s, T & n ) with( s ) {
    28 #ifdef __CFA_DEBUG__
     28                        #ifdef __CFA_DEBUG__
    2929                        if ( listed( (Colable &)(n) ) ) abort( "(Stack &)%p.addHead( %p ) : Node is already on another list.", &s, n );
    30 #endif // __CFA_DEBUG__
     30                        #endif // __CFA_DEBUG__
    3131                        Next( &n ) = &head( s ) ? &head( s ) : &n;
    3232                        root = &n;
     
    4444                        T & t = head( s );
    4545                        if ( root ) {
    46                                 root = ( T *)Next(root);
     46                                root = ( T *)Next( root );
    4747                                if ( &head( s ) == &t ) root = 0p;              // only one element ?
    4848                                Next( &t ) = 0p;
     
    9292        } // distribution
    9393} // distribution
    94 
    95 // Local Variables: //
    96 // compile-command: "make install" //
    97 // End: //
  • libcfa/src/bits/stack_example.cfa

    r33a129a r3f91792  
    107107        }
    108108}
    109 
    110 // Local Variables: //
    111 // compile-command: "cfa stack_example.cfa" //
    112 // End: //
  • src/Common/module.mk

    r33a129a r3f91792  
    1818      Common/Assert.cc \
    1919      Common/CodeLocation.h \
     20      Common/CodeLocationTools.hpp \
     21      Common/CodeLocationTools.cpp \
    2022      Common/CompilerError.h \
    2123      Common/Debug.h \
  • src/main.cc

    r33a129a r3f91792  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Dec  1 14:52:00 2020
    13 // Update Count     : 638
     12// Last Modified On : Mon Dec  7 15:29:00 2020
     13// Update Count     : 639
    1414//
    1515
     
    4040#include "CodeTools/ResolvProtoDump.h"      // for dumpAsResolvProto
    4141#include "CodeTools/TrackLoc.h"             // for fillLocations
     42#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
    4243#include "Common/CompilerError.h"           // for CompilerError
    4344#include "Common/Stats.h"
     
    353354                        } // if
    354355
    355                         // TODO: This is a quick fix to get the build working.
    356                         // Get rid of fillLocations or at least make a new-ast version.
    357                         translationUnit = convert( move( transUnit ) );
    358                         CodeTools::fillLocations( translationUnit );
    359                         transUnit = convert( move( translationUnit ) );
     356                        forceFillCodeLocations( transUnit );
    360357
    361358                        PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
Note: See TracChangeset for help on using the changeset viewer.